|
|
@@ -102,8 +102,8 @@ int fonsExpandAtlas(FONScontext* s, int width, int height); |
|
|
|
int fonsResetAtlas(FONScontext* stash, int width, int height); |
|
|
|
|
|
|
|
// Add fonts |
|
|
|
int fonsAddFont(FONScontext* s, const char* name, const char* path); |
|
|
|
int fonsAddFontMem(FONScontext* s, const char* name, unsigned char* data, int ndata, int freeData); |
|
|
|
int fonsAddFont(FONScontext* s, const char* name, const char* path, int fontIndex); |
|
|
|
int fonsAddFontMem(FONScontext* s, const char* name, unsigned char* data, int ndata, int freeData, int fontIndex); |
|
|
|
int fonsGetFontByName(FONScontext* s, const char* name); |
|
|
|
|
|
|
|
// State handling |
|
|
@@ -175,13 +175,13 @@ int fons__tt_done(FONScontext *context) |
|
|
|
return ftError == 0; |
|
|
|
} |
|
|
|
|
|
|
|
int fons__tt_loadFont(FONScontext *context, FONSttFontImpl *font, unsigned char *data, int dataSize) |
|
|
|
int fons__tt_loadFont(FONScontext *context, FONSttFontImpl *font, unsigned char *data, int dataSize, int fontIndex) |
|
|
|
{ |
|
|
|
FT_Error ftError; |
|
|
|
FONS_NOTUSED(context); |
|
|
|
|
|
|
|
//font->font.userdata = stash; |
|
|
|
ftError = FT_New_Memory_Face(ftLibrary, (const FT_Byte*)data, dataSize, 0, &font->font); |
|
|
|
ftError = FT_New_Memory_Face(ftLibrary, (const FT_Byte*)data, dataSize, fontIndex, &font->font); |
|
|
|
return ftError == 0; |
|
|
|
} |
|
|
|
|
|
|
@@ -278,13 +278,18 @@ int fons__tt_done(FONScontext *context) |
|
|
|
return 1; |
|
|
|
} |
|
|
|
|
|
|
|
int fons__tt_loadFont(FONScontext *context, FONSttFontImpl *font, unsigned char *data, int dataSize) |
|
|
|
int fons__tt_loadFont(FONScontext *context, FONSttFontImpl *font, unsigned char *data, int dataSize, int fontIndex) |
|
|
|
{ |
|
|
|
int stbError; |
|
|
|
int offset, stbError; |
|
|
|
FONS_NOTUSED(dataSize); |
|
|
|
|
|
|
|
font->font.userdata = context; |
|
|
|
stbError = stbtt_InitFont(&font->font, data, 0); |
|
|
|
offset = stbtt_GetFontOffsetForIndex(data, fontIndex); |
|
|
|
if (offset == -1) { |
|
|
|
stbError = 0; |
|
|
|
} else { |
|
|
|
stbError = stbtt_InitFont(&font->font, data, offset); |
|
|
|
} |
|
|
|
return stbError; |
|
|
|
} |
|
|
|
|
|
|
@@ -890,7 +895,7 @@ error: |
|
|
|
return FONS_INVALID; |
|
|
|
} |
|
|
|
|
|
|
|
int fonsAddFont(FONScontext* stash, const char* name, const char* path) |
|
|
|
int fonsAddFont(FONScontext* stash, const char* name, const char* path, int fontIndex) |
|
|
|
{ |
|
|
|
FILE* fp = 0; |
|
|
|
int dataSize = 0; |
|
|
@@ -910,7 +915,7 @@ int fonsAddFont(FONScontext* stash, const char* name, const char* path) |
|
|
|
fp = 0; |
|
|
|
if (readed != dataSize) goto error; |
|
|
|
|
|
|
|
return fonsAddFontMem(stash, name, data, dataSize, 1); |
|
|
|
return fonsAddFontMem(stash, name, data, dataSize, 1, fontIndex); |
|
|
|
|
|
|
|
error: |
|
|
|
if (data) free(data); |
|
|
@@ -918,7 +923,7 @@ error: |
|
|
|
return FONS_INVALID; |
|
|
|
} |
|
|
|
|
|
|
|
int fonsAddFontMem(FONScontext* stash, const char* name, unsigned char* data, int dataSize, int freeData) |
|
|
|
int fonsAddFontMem(FONScontext* stash, const char* name, unsigned char* data, int dataSize, int freeData, int fontIndex) |
|
|
|
{ |
|
|
|
int i, ascent, descent, fh, lineGap; |
|
|
|
FONSfont* font; |
|
|
@@ -943,7 +948,7 @@ int fonsAddFontMem(FONScontext* stash, const char* name, unsigned char* data, in |
|
|
|
|
|
|
|
// Init font |
|
|
|
stash->nscratch = 0; |
|
|
|
if (!fons__tt_loadFont(stash, &font->font, data, dataSize)) goto error; |
|
|
|
if (!fons__tt_loadFont(stash, &font->font, data, dataSize, fontIndex)) goto error; |
|
|
|
|
|
|
|
// Store normalized line height. The real line height is got |
|
|
|
// by multiplying the lineh by font size. |
|
|
|