32 |
gotError(error); |
gotError(error); |
33 |
|
|
34 |
if((error = FT_Set_Pixel_Sizes(face, 0, pixsize))) gotError(error); |
if((error = FT_Set_Pixel_Sizes(face, 0, pixsize))) gotError(error); |
35 |
|
|
36 |
|
// scale line height to unity |
37 |
|
this->scale = 1.0 / (face->size->metrics.height >> 6); |
38 |
} |
} |
39 |
|
|
40 |
FTFont::~FTFont() { |
FTFont::~FTFont() { |
49 |
FT_GlyphSlot slot = face->glyph; |
FT_GlyphSlot slot = face->glyph; |
50 |
FT_Bitmap *bitmap = &(slot->bitmap); |
FT_Bitmap *bitmap = &(slot->bitmap); |
51 |
|
|
52 |
float ps = this->pixsize; |
float ps = this->scale; |
53 |
|
|
54 |
return Glyph(GlyphInfo( |
return Glyph(GlyphInfo( |
55 |
-slot->bitmap_top / ps, slot->bitmap_left / ps, |
-slot->bitmap_top * ps, slot->bitmap_left * ps, |
56 |
bitmap->width / ps, bitmap->rows / ps, |
bitmap->width * ps, bitmap->rows * ps, |
57 |
(slot->advance.x >> 6) / ps, |
(slot->advance.x >> 6) * ps, |
58 |
1/ps, |
scale, |
59 |
bitmap->width, bitmap->rows |
bitmap->width, bitmap->rows |
60 |
), |
), |
61 |
Raster<Mosaic::Format::Alpha>(bitmap->width, bitmap->rows, |
Raster<Mosaic::Format::Alpha>(bitmap->width, bitmap->rows, |
65 |
|
|
66 |
} |
} |
67 |
|
|
68 |
int FTFont::getLineHeight() { |
float FTFont::getLineHeight() { |
69 |
return (face->size->metrics.height >> 6) / (float)pixsize; |
return (face->size->metrics.height >> 6) * scale; |
70 |
} |
} |
71 |
int FTFont::getLineOffset() { |
float FTFont::getLineOffset() { |
72 |
return (face->size->metrics.ascender >> 6) / (float)pixsize; |
return (face->size->metrics.ascender >> 6) * scale; |
73 |
} |
} |
74 |
|
|
75 |
|
|