@@ -156,10 +156,15 @@ static void font_post_init(int font_number)
156156 font.Metrics .RealHeight = font.Metrics .NominalHeight ;
157157 font.Metrics .VExtent = std::make_pair (0 , font.Metrics .RealHeight - 1 );
158158 }
159- // Use either nominal or real pixel height to define font's logical height
159+ // Use either nominal, real pixel height or a user-provided value to define font's logical height
160160 // and default linespacing; logical height = nominal height is compatible with the old games
161- font.Metrics .CompatHeight = (font.Info .Flags & FFLG_REPORTNOMINALHEIGHT) != 0 ?
162- font.Metrics .NominalHeight : font.Metrics .RealHeight ;
161+ font.Metrics .CustomHeight = font.Info .CustomHeight ;
162+ if ((font.Info .Flags & FFLG_LOGICALNOMINALHEIGHT) != 0 )
163+ font.Metrics .LogicalHeight = font.Metrics .NominalHeight ;
164+ else if ((font.Info .Flags & FFLG_LOGICALCUSTOMHEIGHT) != 0 )
165+ font.Metrics .LogicalHeight = font.Metrics .CustomHeight ;
166+ else
167+ font.Metrics .LogicalHeight = font.Metrics .RealHeight ;
163168
164169 if (font.Info .Outline != FONT_OUTLINE_AUTO)
165170 {
@@ -182,7 +187,7 @@ static void font_post_init(int font_number)
182187 {
183188 // Calculate default linespacing from the font height + outline thickness.
184189 font.Info .Flags |= FFLG_DEFLINESPACING;
185- font.LineSpacingCalc = font.Metrics .CompatHeight + 2 * font.Info .AutoOutlineThickness ;
190+ font.LineSpacingCalc = font.Metrics .LogicalHeight + 2 * font.Info .AutoOutlineThickness ;
186191 }
187192 }
188193
@@ -368,7 +373,7 @@ int get_font_height(int font_number)
368373{
369374 if (!assert_font_number (font_number))
370375 return 0 ;
371- return fonts[font_number].Metrics .CompatHeight ;
376+ return fonts[font_number].Metrics .LogicalHeight ;
372377}
373378
374379// Returns a max value between the chosen font height (this may be a compat height,
@@ -377,15 +382,15 @@ static int get_font_height_with_outline(int font_number, bool surf_height = fals
377382{
378383 const int self_height = surf_height ?
379384 fonts[font_number].Metrics .ExtentHeight () :
380- fonts[font_number].Metrics .CompatHeight ;
385+ fonts[font_number].Metrics .LogicalHeight ;
381386 const int outline = fonts[font_number].Info .Outline ;
382387 if (outline < 0 || static_cast <uint32_t >(outline) >= fonts.size ())
383388 { // FONT_OUTLINE_AUTO or FONT_OUTLINE_NONE
384389 return self_height + 2 * fonts[font_number].Info .AutoOutlineThickness ;
385390 }
386391 const int outline_height = surf_height ?
387392 fonts[outline].Metrics .ExtentHeight () :
388- fonts[outline].Metrics .CompatHeight ;
393+ fonts[outline].Metrics .LogicalHeight ;
389394 return std::max (self_height, outline_height);
390395}
391396
@@ -396,6 +401,13 @@ int get_font_height_outlined(int font_number)
396401 return get_font_height_with_outline (font_number);
397402}
398403
404+ int get_font_real_height (int font_number)
405+ {
406+ if (!assert_font_number (font_number))
407+ return 0 ;
408+ return fonts[font_number].Metrics .RealHeight ;
409+ }
410+
399411int get_font_surface_height (int font_number)
400412{
401413 if (!assert_font_number (font_number))
0 commit comments