用freetype2显示ascii-art中文
来源:互联网 发布:网络装备诈骗能报警吗 编辑:程序博客网 时间:2024/04/30 17:09
#include <ft2build.h>
#include FT_FREETYPE_H
int main(int argc, char **argv){
int psize;
FT_Library library;
FT_Face face;
unsigned int ucode;
FT_UInt glyph_index;
int row, pixel;
if(argc != 4){
return 10;
}
ucode = strtol(argv[2], NULL, 16);
psize = strtol(argv[3], NULL, 10);
printf("unicode +%X size %d/n", ucode, psize);
if(FT_Init_FreeType(&library)
|| FT_New_Face(library,
argv[1],
0,
&face)
|| FT_Set_Pixel_Sizes(face,
psize,
0)){
return 1;
}
glyph_index = FT_Get_Char_Index(face, ucode);
if(glyph_index == 0){
return 2;
}
if(FT_Load_Glyph(face,
glyph_index,
FT_LOAD_DEFAULT)){
return 3;
}
if(FT_Render_Glyph(face->glyph,
FT_RENDER_MODE_MONO)){
return 4;
}
printf("bitmap_left=%d/n"
"bitmap_top=%d/n"
"bitmap.rows=%d/n"
"bitmap.width=%d/n"
"bitmap.pitch=%d/n"
"bitmap.pixel_mode=%d/n",
face->glyph->bitmap_left,
face->glyph->bitmap_top,
face->glyph->bitmap.rows,
face->glyph->bitmap.width,
face->glyph->bitmap.pitch,
face->glyph->bitmap.pixel_mode);
printf("/n/n");
for(row = 0;
row < (face->glyph->bitmap.rows - face->glyph->bitmap_top);
++row){
for(pixel = 0; pixel < face->glyph->bitmap.width; ++pixel){
printf("_");
}
printf("/n");
}
for(row = 0; row < face->glyph->bitmap.rows; ++row){
for(pixel = 0; pixel < face->glyph->bitmap_left; ++pixel)
printf("_");
for(pixel = 0; pixel < face->glyph->bitmap.width; ++pixel){
printf("%c", (face->glyph->bitmap.buffer
[row * face->glyph->bitmap.pitch +
pixel/8] & (0xC0 >> (pixel % 8)))?'O':'_');
}
printf("/n");
}
return 0;
}
转自 http://www.cublog.cn/u/8057/showart_335549.html
- 用freetype2显示ascii-art中文
- 用freetype2显示ascii-art中文
- 用freetype2显示ascii-art中文
- FreeType2中文手册
- FreeType2中文手册
- ASCII Art—使用纯文本来显示图像:综述
- 中文ascii转为中文显示问题
- ascii tool - Ascii Art Studio
- 图像的ASCII码显示v1—ASCII art--just for fun
- 图像的ASCII码显示v1—ASCII art--just for fun
- Drawing with ASCII art
- [BZOJ3635] [NEERC2006] ASCII Art
- ASCII Art Studio
- Pictures of Ascii Art
- OGREFont的研究与OGRE的中文显示(二) freetype2攻略
- Python中文显示问题:Non-ASCII character
- freetype2
- FreeType2
- oracle中的一个表空间文件被删除
- SEO常识
- curl介绍
- cglib的小例子
- 奇妙的Base64编码
- 用freetype2显示ascii-art中文
- java 链表的实现
- Iterator遍历和 List遍历有什么不同
- Base64简介
- 学习opencv之01
- hibernate脏数据检查
- RPC4Django的使用详解-服务端
- [数据结构]Stack
- MySql 的操作日志