X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fgfxfont.c;h=dda20db34049101b4d9e2bd993b15a02714b1887;hp=5004e18359b02a90f3201107b885a0586fe9ab8e;hb=219ea5ad983fc389d894c967528b451ea321b8c6;hpb=b27d77f8a6343e60e2d3ae2c22a8096a6357a927 diff --git a/lib/gfxfont.c b/lib/gfxfont.c index 5004e18..dda20db 100644 --- a/lib/gfxfont.c +++ b/lib/gfxfont.c @@ -539,6 +539,7 @@ ttf_t* gfxfont_to_ttf(gfxfont_t*font) ttf->glyphs = rfx_calloc(num_glyphs*sizeof(ttfglyph_t)); double scale = 1.0; int max_unicode = font->max_unicode; + int remap_pos=0; for(t=0;tnum_glyphs;t++) { gfxglyph_t*src = &font->glyphs[t]; ttfglyph_t*dest = &ttf->glyphs[t+offset]; @@ -592,28 +593,35 @@ ttf_t* gfxfont_to_ttf(gfxfont_t*font) } dest->advance = src->advance*scale; - if(src->unicode > max_unicode) - max_unicode = src->unicode; + + int u = font->glyphs[t].unicode; + if(u<32 || (u>=0xe000 && u<0xf900)) { + u = 0xe000 + remap_pos++; + } + if(u > max_unicode) + max_unicode = u; } ttf->unicode_size = max_unicode+1; ttf->unicode = rfx_calloc(sizeof(unicode_t)*ttf->unicode_size); - int remap_pos=0; + remap_pos=0; for(t=0;tnum_glyphs;t++) { gfxglyph_t*src = &font->glyphs[t]; int u = font->glyphs[t].unicode; if(u<32 || (u>=0xe000 && u<0xf900)) { u = 0xe000 + remap_pos++; } - if(u>=0) + if(u>=0 && uunicode_size) ttf->unicode[u] = t+offset; } int u; - for(u=0;umax_unicode;u++) { - int g = font->unicode2glyph[u]; - if(u<32 || (u>=0xe000 && u<0xf900)) - continue; - if(g>=0 && !ttf->unicode[u]) { - ttf->unicode[u] = g+offset; + if(font->unicode2glyph) { + for(u=0;uunicode_size;u++) { + int g = font->unicode2glyph[u]; + if(u<32 || (u>=0xe000 && u<0xf900)) + continue; + if(g>=0 && !ttf->unicode[u]) { + ttf->unicode[u] = g+offset; + } } } ttf->ascent = font->ascent;