mirror of
https://github.com/memononen/nanovg
synced 2026-09-26 16:19:07 +03:00
Merge pull request #558 from olliwang/font
Fixes the issue that font size is inconsistent.
This commit is contained in:
commit
b2337d9ead
2 changed files with 1931 additions and 169 deletions
|
|
@ -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->ascender - font->font->descender);
|
||||
return size / font->font->units_per_EM;
|
||||
}
|
||||
|
||||
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, (FT_UInt)(size * (float)font->font->units_per_EM / (float)(font->font->ascender - font->font->descender)));
|
||||
ftError = FT_Set_Pixel_Sizes(font->font, 0, size);
|
||||
if (ftError) return 0;
|
||||
ftError = FT_Load_Glyph(font->font, glyph, FT_LOAD_RENDER | FT_LOAD_FORCE_AUTOHINT);
|
||||
if (ftError) return 0;
|
||||
|
|
@ -295,7 +295,7 @@ void fons__tt_getFontVMetrics(FONSttFontImpl *font, int *ascent, int *descent, i
|
|||
|
||||
float fons__tt_getPixelHeightScale(FONSttFontImpl *font, float size)
|
||||
{
|
||||
return stbtt_ScaleForPixelHeight(&font->font, size);
|
||||
return stbtt_ScaleForMappingEmToPixels(&font->font, size);
|
||||
}
|
||||
|
||||
int fons__tt_getGlyphIndex(FONSttFontImpl *font, int codepoint)
|
||||
|
|
|
|||
2094
src/stb_truetype.h
2094
src/stb_truetype.h
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue