From 27974c42f956886ec810e2b6130b1ccb11858b59 Mon Sep 17 00:00:00 2001 From: Fabian Giesen Date: Mon, 8 Dec 2014 19:43:27 -0800 Subject: [PATCH] stb_truetype: Negative size = pixels for EM square. --- stb_truetype.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/stb_truetype.h b/stb_truetype.h index 9a1715b..cc0173d 100644 --- a/stb_truetype.h +++ b/stb_truetype.h @@ -2318,8 +2318,7 @@ int stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontdata, int f k=0; for (i=0; i < num_ranges; ++i) { float fh = ranges[i].font_size; - //float scale = fh > 0 ? stbtt_ScaleForPixelHeight(&info, fh) : stbtt_ScaleForPointSize(&info, fh); - float scale = stbtt_ScaleForPixelHeight(&info, fh); + float scale = fh > 0 ? stbtt_ScaleForPixelHeight(&info, fh) : stbtt_ScaleForMappingEmToPixels(&info, -fh); for (j=0; j < ranges[i].num_chars_in_range; ++j) { int x0,y0,x1,y1; stbtt_GetCodepointBitmapBoxSubpixel(&info, ranges[i].first_unicode_char_in_range + j, @@ -2338,8 +2337,7 @@ int stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontdata, int f k = 0; for (i=0; i < num_ranges; ++i) { float fh = ranges[i].font_size; - //float scale = fh > 0 ? stbtt_ScaleForPixelHeight(&info, fh) : stbtt_ScaleForPointSize(&info, fh); - float scale = stbtt_ScaleForPixelHeight(&info, fh); + float scale = fh > 0 ? stbtt_ScaleForPixelHeight(&info, fh) : stbtt_ScaleForMappingEmToPixels(&info, -fh); for (j=0; j < ranges[i].num_chars_in_range; ++j) { stbrp_rect *r = &rects[k]; if (r->was_packed) {