|
|
@@ -193,15 +193,17 @@ int fons__tt_buildGlyphBitmap(FONSttFontImpl *font, int glyph, float size, float |
|
|
|
{ |
|
|
|
FT_Error ftError; |
|
|
|
FT_GlyphSlot ftGlyph; |
|
|
|
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))); |
|
|
|
if (ftError) return 0; |
|
|
|
ftError = FT_Load_Glyph(font->font, glyph, FT_LOAD_RENDER); |
|
|
|
if (ftError) return 0; |
|
|
|
ftError = FT_Get_Advance(font->font, glyph, FT_LOAD_NO_SCALE, (FT_Fixed*)advance); |
|
|
|
ftError = FT_Get_Advance(font->font, glyph, FT_LOAD_NO_SCALE, &advFixed); |
|
|
|
if (ftError) return 0; |
|
|
|
ftGlyph = font->font->glyph; |
|
|
|
*advance = (int)advFixed; |
|
|
|
*lsb = (int)ftGlyph->metrics.horiBearingX; |
|
|
|
*x0 = ftGlyph->bitmap_left; |
|
|
|
*x1 = *x0 + ftGlyph->bitmap.width; |
|
|
@@ -360,7 +362,6 @@ struct FONSglyph |
|
|
|
}; |
|
|
|
typedef struct FONSglyph FONSglyph; |
|
|
|
|
|
|
|
|
|
|
|
struct FONSfont |
|
|
|
{ |
|
|
|
FONSttFontImpl font; |
|
|
@@ -761,11 +762,10 @@ static FONSstate* fons__getState(FONScontext* stash) |
|
|
|
return &stash->states[stash->nstates-1]; |
|
|
|
} |
|
|
|
|
|
|
|
int fonsAddFallbackFont(FONScontext* stash,int base,int fallback) |
|
|
|
int fonsAddFallbackFont(FONScontext* stash, int base, int fallback) |
|
|
|
{ |
|
|
|
FONSfont* baseFont = stash->fonts[base]; |
|
|
|
if (baseFont->nfallbacks < FONS_MAX_FALLBACKS) |
|
|
|
{ |
|
|
|
if (baseFont->nfallbacks < FONS_MAX_FALLBACKS) { |
|
|
|
baseFont->fallbacks[baseFont->nfallbacks++] = fallback; |
|
|
|
return 1; |
|
|
|
} |
|
|
@@ -1058,15 +1058,12 @@ static FONSglyph* fons__getGlyph(FONScontext* stash, FONSfont* font, unsigned in |
|
|
|
// Could not find glyph, create it. |
|
|
|
scale = fons__tt_getPixelHeightScale(&font->font, size); |
|
|
|
g = fons__tt_getGlyphIndex(&font->font, codepoint); |
|
|
|
//If tofu glyph fallback to other fonts |
|
|
|
if(g == 0) |
|
|
|
{ |
|
|
|
for (i=0; i<font->nfallbacks; ++i) |
|
|
|
{ |
|
|
|
glyph = fons__getGlyph(stash,stash->fonts[font->fallbacks[i]],codepoint,isize,iblur); |
|
|
|
if(glyph->index != 0) |
|
|
|
{ |
|
|
|
return glyph; |
|
|
|
// Try to find the glyph in fallback fonts. |
|
|
|
if (g == 0) { |
|
|
|
for (i = 0; i < font->nfallbacks; ++i) { |
|
|
|
FONSglyph* fallbackGlyph = fons__getGlyph(stash, stash->fonts[font->fallbacks[i]], codepoint, isize, iblur); |
|
|
|
if (fallbackGlyph != NULL && fallbackGlyph->index != 0) { |
|
|
|
return fallbackGlyph; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|