X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fmodules%2Fswftext.c;h=194ec72eb4b54591460f27c9585288ba1e5ac418;hb=e584fab17969f34332c92f7bf67ca2926668e197;hp=912e8fa441257be86f024a2254f2418aa15bda20;hpb=275179c87d277416cfcc0d7a346ed60c4545ba31;p=swftools.git diff --git a/lib/modules/swftext.c b/lib/modules/swftext.c index 912e8fa..194ec72 100644 --- a/lib/modules/swftext.c +++ b/lib/modules/swftext.c @@ -373,28 +373,6 @@ int swf_FontExtract_DefineFont2(int id, SWFFONT * font, TAG * tag) return font->id; } -static float F16toFloat(U16 x) -{ - TAG t; - t.data = (void*)&x; - t.readBit = 0; - t.pos = 0; - t.len = 2; - return swf_GetF16(&t); -} - -static float floatToF16(float f) -{ - U16 u = 0; - TAG t; - t.data = (void*)&u; - t.len = 0; - t.memsize = 2; - t.writeBit = 0; - swf_SetF16(&t, f); - return u; -} - int swf_FontExtract_DefineFontAlignZones(int id, SWFFONT * font, TAG * tag) { U16 fid; @@ -875,6 +853,7 @@ int swf_FontInitUsage(SWFFONT * f) } f->use = (FONTUSAGE*)rfx_alloc(sizeof(FONTUSAGE)); f->use->is_reduced = 0; + f->use->smallest_size = 0xffff; f->use->used_glyphs = 0; f->use->chars = (int*)rfx_calloc(sizeof(f->use->chars[0]) * f->numchars); f->use->glyphs_specified = 0; @@ -895,13 +874,13 @@ int swf_FontUse(SWFFONT * f, U8 * s) return -1; while (*s) { if(*s < f->maxascii && f->ascii2glyph[*s]>=0) - swf_FontUseGlyph(f, f->ascii2glyph[*s]); + swf_FontUseGlyph(f, f->ascii2glyph[*s], /*FIXME*/0xffff); s++; } return 0; } -int swf_FontUseUTF8(SWFFONT * f, U8 * s) +int swf_FontUseUTF8(SWFFONT * f, U8 * s, U16 size) { if( (!s)) return -1; @@ -910,7 +889,7 @@ int swf_FontUseUTF8(SWFFONT * f, U8 * s) { ascii = readUTF8char(&s); if(ascii < f->maxascii && f->ascii2glyph[ascii]>=0) - swf_FontUseGlyph(f, f->ascii2glyph[ascii]); + swf_FontUseGlyph(f, f->ascii2glyph[ascii], size); } return 0; } @@ -927,7 +906,7 @@ int swf_FontUseAll(SWFFONT* f) return 0; } -int swf_FontUseGlyph(SWFFONT * f, int glyph) +int swf_FontUseGlyph(SWFFONT * f, int glyph, U16 size) { if (!f->use) swf_FontInitUsage(f); @@ -936,6 +915,8 @@ int swf_FontUseGlyph(SWFFONT * f, int glyph) if(!f->use->chars[glyph]) f->use->used_glyphs++; f->use->chars[glyph] = 1; + if(size && size < f->use->smallest_size) + f->use->smallest_size = size; return 0; } @@ -1103,27 +1084,6 @@ int swf_FontSetDefine2(TAG * tag, SWFFONT * f) return 0; } -void swf_FontSetAlignZones(TAG*t, SWFFONT *f) -{ - swf_SetU16(t, f->id); - swf_SetU8(t, f->alignzone_flags); - int i; - for(i=0;inumchars;i++) { - ALIGNZONE*a = &f->alignzones[i]; - U8 flags = 0; - if((a->x & a->dx)!=0xffff) - flags |= 1; - if((a->y & a->dy)!=0xffff) - flags |= 2; - swf_SetU8(t, 2); - if(flags&1) swf_SetU16(t, a->x); else swf_SetU16(t, 0); - if(flags&2) swf_SetU16(t, a->y); else swf_SetU16(t, 0); - if((flags&1) && a->dx!=0xffff) swf_SetU16(t, a->dx); else swf_SetU16(t, 0); - if((flags&2) && a->dy!=0xffff) swf_SetU16(t, a->dy); else swf_SetU16(t, 0); - swf_SetU8(t, flags); - } -} - void swf_FontAddLayout(SWFFONT * f, int ascent, int descent, int leading) { f->layout = (SWFLAYOUT *) rfx_alloc(sizeof(SWFLAYOUT)); @@ -1608,46 +1568,6 @@ void swf_FontCreateLayout(SWFFONT * f) } } -#define FONTALIGN_THIN -#define FONTALIGN_MEDIUM -#define FONTALIGN_THICK - -void swf_FontCreateAlignZones(SWFFONT * f) -{ - if(f->alignzones) - return; - - f->alignzones = (ALIGNZONE*)rfx_calloc(sizeof(ALIGNZONE)*f->numchars); - f->alignzone_flags = 0; // thin - - if(!f->layout) { - int t; - for(t=0;tnumchars;t++) { - // just align the baseline - f->alignzones[t].x = 0xffff; - f->alignzones[t].y = 0; - f->alignzones[t].dx = 0xffff; - f->alignzones[t].dy = 0xffff;//floatToF16(460.80 / 1024.0); - } - } else { - int t; - for(t=0;tnumchars;t++) { - // just align the baseline - f->alignzones[t].x = 0xffff; - f->alignzones[t].y = 0; - f->alignzones[t].dx = 0xffff; - f->alignzones[t].dy = 0xffff;//floatToF16(460.80 / 1024.0); - } - } - -/* - "-^_~\xad\xaf+`\xac\xb7\xf7" //chars for which to detect one y value - "#=:;\xb1" //chars for which to detect two y values - "\"\xa8" //chars for which to detect two x values -*/ -} - - void swf_DrawText(drawer_t * draw, SWFFONT * font, int size, const char *text) { U8 *s = (U8 *) text; @@ -2082,4 +2002,3 @@ char*data = swf_SaveSWF(&swf, filename); swf_FreeTags(&swf); } -