Skip to content

Commit

Permalink
set extra glyph scale factor from freetype font metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
李政 committed Jul 10, 2018
1 parent 6fa3b3d commit fec13a0
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/fontstash.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,7 @@ struct FONSfont
float ascender;
float descender;
float lineh;
float scaleFactor;
FONSglyph* glyphs;
int cglyphs;
int nglyphs;
Expand Down Expand Up @@ -938,6 +939,11 @@ int fonsAddFontMem(FONScontext* stash, const char* name, unsigned char* data, in
font->ascender = (float)ascent / (float)fh;
font->descender = (float)descent / (float)fh;
font->lineh = (float)(fh + lineGap) / (float)fh;
#ifdef FONS_USE_FREETYPE
font->scaleFactor = (float)(font->font.font->height) / (float)(font->font.font->units_per_EM);
#else
font->scaleFactor = 1.0f;
#endif

return idx;

Expand Down Expand Up @@ -1042,7 +1048,7 @@ static FONSglyph* fons__getGlyph(FONScontext* stash, FONSfont* font, unsigned in
float scale;
FONSglyph* glyph = NULL;
unsigned int h;
float size = isize/10.0f;
float size = isize/10.0f * font->scaleFactor;
int pad, added;
unsigned char* bdst;
unsigned char* dst;
Expand Down

0 comments on commit fec13a0

Please sign in to comment.