From 911b7edf17a8332e99dd6f4aa1b3d6f301541f0b Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Mon, 14 Jun 2021 01:39:18 -0400 Subject: [PATCH] Revert "Fixes the issue that font size is inconsistent." This reverts commit 69e1a47511781abdc2cd14d9d43c625bb588f25a. Only reverts fontstash.h, not the whole commit. --- src/fontstash.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/fontstash.h b/src/fontstash.h index 6e141a2..6232669 100644 --- a/src/fontstash.h +++ b/src/fontstash.h @@ -194,7 +194,7 @@ void fons__tt_getFontVMetrics(FONSttFontImpl *font, int *ascent, int *descent, i float fons__tt_getPixelHeightScale(FONSttFontImpl *font, float size) { - return size / font->font->units_per_EM; + return size / (font->font->ascender - font->font->descender); } int fons__tt_getGlyphIndex(FONSttFontImpl *font, int codepoint) @@ -210,7 +210,7 @@ int fons__tt_buildGlyphBitmap(FONSttFontImpl *font, int glyph, float size, float FT_Fixed advFixed; FONS_NOTUSED(scale); - ftError = FT_Set_Pixel_Sizes(font->font, 0, size); + ftError = FT_Set_Pixel_Sizes(font->font, 0, (FT_UInt)(size * (float)font->font->units_per_EM / (float)(font->font->ascender - font->font->descender))); if (ftError) return 0; ftError = FT_Load_Glyph(font->font, glyph, FT_LOAD_RENDER | FT_LOAD_FORCE_AUTOHINT | FT_LOAD_TARGET_LIGHT); if (ftError) return 0; @@ -300,7 +300,7 @@ void fons__tt_getFontVMetrics(FONSttFontImpl *font, int *ascent, int *descent, i float fons__tt_getPixelHeightScale(FONSttFontImpl *font, float size) { - return stbtt_ScaleForMappingEmToPixels(&font->font, size); + return stbtt_ScaleForPixelHeight(&font->font, size); } int fons__tt_getGlyphIndex(FONSttFontImpl *font, int codepoint)