@@ -72,7 +72,12 @@ class Font
7272 const auto scale = face->size ->metrics .y_scale ;
7373 yMin = FT_FLOOR (FT_MulFix (face->bbox .yMin , scale));
7474 yMax = FT_CEIL (FT_MulFix (face->bbox .yMax , scale));
75- height = FT_CEIL (FT_MulFix (face->height , scale));
75+ // height = FT_CEIL(FT_MulFix(face->height, scale));
76+ height = std::lround (static_cast <float >(face->size ->metrics .height ) / static_cast <float >(1 << 6 ));
77+ // height = std::lround(FT_MulFix(face->height, scale) / static_cast<float>(1 << 6));
78+ ascent = FT_CEIL (FT_MulFix (face->ascender , scale));
79+ // ascent = std::lround(FT_MulFix(face->ascender, scale) / static_cast<float>(1 << 6));
80+ descent = FT_FLOOR (FT_MulFix (face->descender , scale));
7681 }
7782 else
7883 {
@@ -96,6 +101,10 @@ class Font
96101 yMin = 0 ;
97102 yMax = face->available_sizes [ptsize].height ;
98103 height = face->available_sizes [ptsize].height ;
104+
105+ // TODO: correct values
106+ ascent = 0 ;
107+ descent = 0 ;
99108 }
100109
101110 /* Initialize the font face style */
@@ -116,6 +125,8 @@ class Font
116125 glyph_italics *= height;
117126
118127 totalHeight = yMax - yMin;
128+
129+
119130 }
120131
121132 ~Font ()
@@ -233,7 +244,14 @@ class Font
233244 std::cout << " face->bbox.yMin " << FT_FLOOR (FT_MulFix (face->bbox .yMin , scale)) << " \n " ;
234245 std::cout << " face->ascender " << FT_CEIL (FT_MulFix (face->ascender , scale)) << " \n " ;
235246 std::cout << " face->descender " << FT_FLOOR (FT_MulFix (face->descender , scale)) << " \n " ;
236- std::cout << " face->height " << FT_CEIL (FT_MulFix (face->height , scale)) << " \n " ;
247+ std::cout << " face->height " << FT_CEIL (FT_MulFix (face->height , scale)) << " \n " ; // distance between lines
248+ std::cout << " face->height f " << static_cast <float >(FT_MulFix (face->height , scale)) / static_cast <float >(1 << 6 ) << " \n " ;
249+ std::cout << " face->size->metrics.height " << FT_CEIL (face->size ->metrics .height ) << " \n " ;
250+
251+ std::cout << " metrics.height " << static_cast <float >(face->size ->metrics .height ) / static_cast <float >(1 << 6 ) << " \n " ; // as in SFML getLineSpacing
252+ std::cout << " metrics.ascender " << static_cast <float >(face->size ->metrics .ascender ) / static_cast <float >(1 << 6 ) << " \n " ;
253+ std::cout << " metrics.descender " << static_cast <float >(face->size ->metrics .descender ) / static_cast <float >(1 << 6 ) << " \n " ;
254+ std::cout << " a " << static_cast <float >(FT_MulFix (face->ascender , scale)) / static_cast <float >(1 << 6 ) << " \n " ;
237255
238256 FT_UInt gindex;
239257 FT_ULong charcode = FT_Get_First_Char (face, &gindex);
@@ -285,6 +303,8 @@ class Font
285303 int height;
286304 int yMax;
287305 int yMin;
306+ int ascent;
307+ int descent;
288308 int totalHeight = 0 ;
289309
290310 /* For non-scalable formats, we must remember which font index size */
0 commit comments