5 #define FONTFACE "/home/ali/.fonts/monaco.ttf"
8 #define MAXDOTS (1 << 10)
10 static FT_Library library
;
12 static int rows
, cols
;
16 FT_Init_FreeType(&library
);
17 FT_New_Face(library
, FONTFACE
, 0, &face
);
18 FT_Set_Char_Size(face
, 0, FONTSIZE
<< 6, DPI
, DPI
);
19 rows
= face
->size
->metrics
.height
>> 6;
20 cols
= face
->size
->metrics
.max_advance
>> 6;
23 unsigned char *font_bitmap(int c
, int bold
)
25 static unsigned char bits
[MAXDOTS
];
28 if (FT_Load_Char(face
, c
, FT_LOAD_RENDER
))
31 int FT_GlyphSlot_Own_Bitmap(FT_GlyphSlot
);
32 FT_GlyphSlot_Own_Bitmap(face
->glyph
);
33 FT_Bitmap_Embolden(library
, &face
->glyph
->bitmap
, 32, 32);
35 sr
= rows
+ (face
->size
->metrics
.descender
>> 6) -
36 (face
->glyph
->metrics
.horiBearingY
>> 6);
37 sc
= face
->glyph
->metrics
.horiBearingX
>> 6;
38 er
= sr
+ face
->glyph
->bitmap
.rows
;
39 ec
= sc
+ face
->glyph
->bitmap
.width
;
40 memset(bits
, 0, sr
* cols
);
41 for (i
= sr
; i
< er
; i
++) {
42 unsigned char *rowaddr
= face
->glyph
->bitmap
.buffer
+
43 (i
- sr
) * face
->glyph
->bitmap
.pitch
;
44 memset(&bits
[i
* cols
], 0, sc
);
45 memcpy(&bits
[i
* cols
+ sc
], rowaddr
, ec
- sc
);
46 memset(&bits
[i
* cols
+ ec
], 0, cols
- ec
);
48 memset(&bits
[er
* cols
], 0, (rows
- er
) * cols
);