Skip to content

Commit

Permalink
打印点阵字符
Browse files Browse the repository at this point in the history
  • Loading branch information
HEYAHONG committed Dec 12, 2024
1 parent ed218c6 commit 5b20a83
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions hbox/gui/tools/dotfontscan/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "hrc.h"
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_GLYPH_H
#include "stdlib.h"
#include "stdio.h"
#include <string>
Expand Down Expand Up @@ -345,6 +346,40 @@ int main(int argc,const char *argv[])
//设置为unicode
FT_Select_Charmap(face, FT_ENCODING_UNICODE);

{
//显示24x24点阵字符
FT_Set_Pixel_Sizes(face,24,24);
for(auto it=char_set.begin();it!=char_set.end();it++)
{
if(0==FT_Load_Glyph(face,FT_Get_Char_Index(face,*it),FT_LOAD_DEFAULT))
{
printf("\r\n");
if(0==FT_Render_Glyph(face->glyph,FT_RENDER_MODE_NORMAL))
{
FT_Bitmap bmp=face->glyph->bitmap;
size_t w=bmp.width;
size_t h=bmp.rows;
printf("char=%08X,whidth=%d,height=%d\r\n",(int)(*it),(int)w,(int)h);
for(size_t i=0;i<h;i++)
{
for(size_t j=0;j<w;j++)
{
if(bmp.buffer[i*w+j]==0)
{
printf(" ");
}
else
{
printf("#");
}
}
printf("\r\n");
}
}
}
}
}



FT_Done_Face(face);
Expand Down

0 comments on commit 5b20a83

Please sign in to comment.