swftools-common
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Swftools-common] DefineFontInfo/DefineFont2 fontname format


From: INADA Naoki
Subject: [Swftools-common] DefineFontInfo/DefineFont2 fontname format
Date: Wed, 21 May 2008 21:02:19 +0900
User-agent: Thunderbird 2.0.0.14 (Windows/20080421)

Hi all.

DefineFont2/3 tag and DefineFontInfo tag has fontname property as string with 
length.
Following is from Alex's reference.

        unsigned char           f_font2_name_length;
        unsigned char           f_font2_name[f_font2_name_length];

SWF File Format Specification says f_font2_name is not null terminated.
But the Spec is wrong and f_font2_name is null terminated according to
Flex User forum (http://www.adobeforums.com/webx?13@@.59b53b2d/3 )

Following patch adds null terminator to fontname.

Index: lib/modules/swftext.c
===================================================================
RCS file: /sources/swftools/swftools/lib/modules/swftext.c,v
retrieving revision 1.82
diff -u -8 -r1.82 swftext.c
--- lib/modules/swftext.c       26 Mar 2008 12:59:46 -0000      1.82
+++ lib/modules/swftext.c       21 May 2008 07:53:49 -0000
@@ -937,21 +937,23 @@
        flags |= 32;            // unicode
     if (f->encoding & FONT_ENCODING_SHIFTJIS)
        flags |= 64;            // shiftjis

     swf_SetU8(tag, flags);
     swf_SetU8(tag, 0);         //reserved flags
     if (f->name) {
        /* font name */
-       swf_SetU8(tag, strlen((const char*)f->name));
-       swf_SetBlock(tag, f->name, strlen((const char*)f->name));
+       size_t len = strlen((const char*)f->name) + 1;
+       swf_SetU8(tag, len);
+       swf_SetBlock(tag, f->name, len);
     } else {
        /* font name (="") */
-       swf_SetU8(tag, 0);
+       swf_SetU8(tag, 1);
+       swf_SetBlock(tag, NULL, 1);
     }
     /* number of glyphs */
     swf_SetU16(tag, f->numchars);
     /* font offset table */
     pos = tag->len;
     for (t = 0; t <= f->numchars; t++) {
        if (flags & 8)
            swf_SetU32(tag, /* fontoffset */ 0);        /*placeholder */





reply via email to

[Prev in Thread] Current Thread [Next in Thread]