Hello Matthias
I've attached a patch to implement the new font - glyphs logic.
I tested it in quite simple cases for all four situations, so real life usage
may find some bugs, just let me know.
Regards
Huub
> Date: Wed, 21 May 2008 20:23:11 +0200
> From: [EMAIL PROTECTED]
> To: swftools-common@nongnu.org
> Subject: Re: [Swftools-common] partial font embedding not working
>
> On Wed, May 21, 2008 at 07:53:37PM +0200, Huub Schaeks <[EMAIL PROTECTED]>
> wrote:
> > How about this logic:
> >
> > If a glyphs parameter is specified then
> > if the parameter is 'all' then the whole font is included
> > else only the specified glyphs are included
> > else
> > if an .edittext is found then all glyphs are included
> > else include only the glyphs that are used by .text or .textshape
>
> Sounds good to me!
>
> Especially since .edittext fields don't always display user input,
> they might also be used as dynamic text fields- so respecting the glyphs
> parameter even for fonts used in an .edittext makes sense.
>
> Greetings
>
> Matthias
>
>
>
>
_________________________________________________________________
De leukste online filmpjes vind je op MSN Video!
http://video.msn.com/video.aspx?mkt=nl-nl
diff -ur -x'*.o' ../cvs/swftools/lib/modules/swftext.c ./lib/modules/swftext.c
--- ../cvs/swftools/lib/modules/swftext.c 2008-05-23 18:52:04.570873000 +0200
+++ ./lib/modules/swftext.c 2008-05-23 20:34:18.492881000 +0200
@@ -801,6 +801,7 @@
f->use->is_reduced = 0;
f->use->used_glyphs = 0;
f->use->chars = (int*)rfx_calloc(sizeof(f->use->chars[0]) * f->numchars);
+ f->use->glyphs_specified = 0;
return 0;
}
diff -ur -x'*.o' ../cvs/swftools/lib/rfxswf.h ./lib/rfxswf.h
--- ../cvs/swftools/lib/rfxswf.h 2008-04-08 07:09:56.569894000 +0200
+++ ./lib/rfxswf.h 2008-05-23 20:34:19.642898000 +0200
@@ -501,6 +501,7 @@
{ int* chars;
char is_reduced;
int used_glyphs;
+ int glyphs_specified;
} FONTUSAGE;
#define FONT_STYLE_BOLD 1
diff -ur -x'*.o' ../cvs/swftools/src/swfc.c ./src/swfc.c
--- ../cvs/swftools/src/swfc.c 2008-05-23 18:52:05.290884000 +0200
+++ ./src/swfc.c 2008-05-24 11:50:38.537568000 +0200
@@ -979,7 +979,7 @@
swf_FoldSprite(tag);
if(stack[stackpos].scalegrid.xmin | stack[stackpos].scalegrid.ymin |
- stack[stackpos].scalegrid.xmax | stack[stackpos].scalegrid.ymax)
+ stack[stackpos].scalegrid.xmax | stack[stackpos].scalegrid.ymax)
{
tag = swf_InsertTag(tag, ST_DEFINESCALINGGRID);
swf_SetU16(tag, stack[stackpos].id);
@@ -1546,7 +1546,7 @@
swf_FontCreateLayout(font);
}
font->id = id;
- swf_FontReduce_swfc(font);
+ swf_FontReduce_swfc(font);
tag = swf_InsertTag(tag, ST_DEFINEFONT2);
swf_FontSetDefine2(tag, font);
tag = swf_InsertTag(tag, ST_EXPORTASSETS);
@@ -2427,7 +2427,7 @@
v = parseRawTwip(lastpos);
}
*p = save;
- if(ex == '+')
+ if(ex == '+')
val += v;
else if(ex == '-')
val -= v;
@@ -3028,7 +3028,7 @@
{
char*name = lu(args, "name");
char*value = lu(args, "value");
-
+
if(!defines_initialized) {
dictionary_init(&defines);
mem_init(&define_values);
@@ -4289,6 +4289,7 @@
map_t args;
char* fontfile;
int nr = -1;
+ U8* glyphs_to_include;
msg("<verbose> analyse Command: %s (line %d)", command, line);
for(t=0;t<sizeof(arguments)/sizeof(arguments[0]);t++)
@@ -4318,8 +4319,26 @@
font = (SWFFONT*)malloc(sizeof(SWFFONT));
memset(font, 0, sizeof(SWFFONT));
}
- swf_FontUseUTF8(font, lu(&args, "glyphs"));
- swf_FontPrepareForEditText(font);
+ else
+ {
+ swf_FontPrepareForEditText(font);
+ glyphs_to_include = lu(&args, "glyphs");
+ if (!strcmp(glyphs_to_include, "all"))
+ {
+ swf_FontUseAll(font);
+ font->use->glyphs_specified = 1;
+ }
+ else
+ {
+ if (strcmp (glyphs_to_include, ""))
+ {
+ swf_FontUseUTF8(font, glyphs_to_include);
+ font->use->glyphs_specified = 1;
+ }
+ else
+ swf_FontInitUsage(font);
+ }
+ }
dictionary_put2(&fonts, name, font);
}
else
@@ -4328,10 +4347,16 @@
if (!font)
syntaxerror("font %s is not known in line %d", lu(&args, "font"), line);
else
- if (!strcmp(command, "edittext"))
- swf_FontUseAll(font);
- else
- swf_FontUseUTF8(font, lu(&args, "text"));
+ if (font->use && !font->use->glyphs_specified)
+ {
+ if (!strcmp(command, "edittext"))
+ {
+ swf_FontUseAll(font);
+ font->use->glyphs_specified = 1;
+ }
+ else
+ swf_FontUseUTF8(font, lu(&args, "text"));
+ }
}
map_clear(&args);
return;