bkdocument
bkfancytext
fzfont
// font 의 height 계산
// First we go over all the characters to find the max descent
// and ascent (space required above and below the base of a
// line of text) and needed image size. There are simpler methods
// to obtain these with FreeType but they are unreliable.
int max_descent = 0, max_ascent = 0;
// 현재 라인에서 남은 공간(space)
// int space_on_line = image_width - margin, lines = 1;
int loadMode = FT_LOAD_DEFAULT;
// if (autohint)
// loadMode |= FT_LOAD_FORCE_AUTOHINT;
for (int i = 0; i < 65535; ++i) {
// Look up the character in the font file.
int char_index = FT_Get_Char_Index(face, i);
// 아스키 0-31까지는 제어문자로 의미가 없다.
if (i < 32)
char_index = 0;
// Render the current glyph.
FT_Load_Glyph(face, char_index, loadMode);
FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL);
// int advance = (face->glyph->metrics.horiAdvance >> 6) + margin;
// if (advance > space_on_line) {
// space_on_line = image_width - margin;
// ++lines; // 라인증가 (metrics 저장을 위한 전체 메모리사이즈를 결정한다.)
// }
// space_on_line -= advance;
int t = face->glyph->bitmap_top;
if (t > max_ascent)
max_ascent = t;
t = face->glyph->bitmap.rows - face->glyph->bitmap_top;
if (t > max_descent)
max_descent = t;
}
댓글