A movie can embed fonts as glyph outlines, and holds text in two ways: static text, which is a list of glyphs placed by the authoring tool, and text fields, which hold characters and are laid out by the player. In a CWS movie, as in every SWF 6 and later movie, the strings are UTF-8 and the character codes in font tables are 16 bits wide, not bytes in the system code page.
DefineFont (10)
| Type | Name | Description |
|---|---|---|
| UI16 | FontID | The character ID |
| UI16 × nGlyphs | OffsetTable | The offset of each glyph from the start of this table; nGlyphs is the first offset ÷ 2 |
| SHAPE × nGlyphs | GlyphShapeTable | The outlines |
SWF 1. Only outlines: the character codes, name and style come from a DefineFontInfo for the same FontID.
Glyph outlines
Each glyph is a SHAPE: no style lists, fill style 1 implied, no lines. Glyphs are drawn in an EM square of 1,024 units (DefineFont, DefineFont2), or 20,480 in DefineFont3, which has 20 times the resolution. An empty glyph, such as a space, can have no bytes: its offset equals the next one.
DefineFontInfo (13)
| Type | Name | Description |
|---|---|---|
| UI16 | FontID | The DefineFont this describes |
| UI8 | FontNameLen | The length of the name in bytes |
| UI8 × FontNameLen | FontName | The font’s name |
| UB[2] | FontFlagsReserved | 0 |
| UB[1] | FontFlagsSmallText | SWF 7 (0x20) |
| UB[1] | FontFlagsShiftJIS | (0x10) |
| UB[1] | FontFlagsANSI | (0x08) |
| UB[1] | FontFlagsItalic | (0x04) |
| UB[1] | FontFlagsBold | (0x02) |
| UB[1] | FontFlagsWideCodes | Codes are UI16 (0x01) |
| UI8 or UI16 × nGlyphs | CodeTable | The character code of each glyph, in glyph order |
DefineFontInfo2 (62)
SWF 6. DefineFontInfo with a UI8 LanguageCode after the flags, and WideCodes always 1. Language codes: 0 none, 1 Latin, 2 Japanese, 3 Korean, 4 Simplified Chinese, 5 Traditional Chinese.
DefineFont2 (48)
| Type | Name | Description |
|---|---|---|
| UI16 | FontID | The character ID |
| UB[1] | FontFlagsHasLayout | Layout fields follow (0x80) |
| UB[1] | FontFlagsShiftJIS | (0x40) |
| UB[1] | FontFlagsSmallText | (0x20) |
| UB[1] | FontFlagsANSI | (0x10) |
| UB[1] | FontFlagsWideOffsets | Offsets are UI32 (0x08) |
| UB[1] | FontFlagsWideCodes | Codes are UI16; always 1 from SWF 6 (0x04) |
| UB[1] | FontFlagsItalic | (0x02) |
| UB[1] | FontFlagsBold | (0x01) |
| UI8 | LanguageCode | As in DefineFontInfo2 |
| UI8 | FontNameLen | The length of the name |
| UI8 × FontNameLen | FontName | The name |
| UI16 | NumGlyphs | The number of glyphs |
| UI16 or UI32 × NumGlyphs | OffsetTable | Glyph offsets from the start of this table |
| UI16 or UI32 | CodeTableOffset | The offset of CodeTable, from the same place |
| SHAPE × NumGlyphs | GlyphShapeTable | The outlines |
| UI16 × NumGlyphs | CodeTable | The character code of each glyph |
| SI16 | FontAscent | If HasLayout |
| SI16 | FontDescent | If HasLayout |
| SI16 | FontLeading | If HasLayout |
| SI16 × NumGlyphs | FontAdvanceTable | If HasLayout: each glyph’s advance |
| RECT × NumGlyphs | FontBoundsTable | If HasLayout: each glyph’s bounds |
| UI16 | KerningCount | If HasLayout |
| KERNINGRECORD × KerningCount | FontKerningTable | If HasLayout: UI16 FontKerningCode1, UI16 FontKerningCode2, SI16 FontKerningAdjustment |
SWF 3. Codes in the kerning records are UI8 when WideCodes is 0, which an SWF 6 or later movie does not use.
DefineFont3 (75)
SWF 8. The same layout as DefineFont2, with the glyphs at 20 times the resolution, in an EM square of 20,480 units, and UI16 codes. It goes with DefineFontAlignZones for the FlashType renderer.
DefineFont4 (91)
| Type | Name | Description |
|---|---|---|
| UI16 | FontID | The character ID |
| UB[5] | FontFlagsReserved | 0 |
| UB[1] | FontFlagsHasFontData | FontData follows |
| UB[1] | FontFlagsItalic | |
| UB[1] | FontFlagsBold | |
| STRING | FontName | The name |
| bytes | FontData | An OpenType font with CFF outlines, to the end of the tag |
SWF 10. Used by the Text Layout Framework (flash.text.engine), not by
the older text tags.
DefineFontAlignZones (73)
| Type | Name | Description |
|---|---|---|
| UI16 | FontID | A DefineFont3 |
| UB[2] | CSMTableHint | 0 thin, 1 medium, 2 thick |
| UB[6] | Reserved | 0 |
| ZONERECORD × glyphs | ZoneTable | One a glyph: UI8 NumZoneData (2), then NumZoneData × (FLOAT16 AlignmentCoordinate, FLOAT16 Range), then UB[6] Reserved, UB[1] ZoneMaskY, UB[1] ZoneMaskX |
SWF 8. Alignment zones for the FlashType renderer.
CSMTextSettings (74)
| Type | Name | Description |
|---|---|---|
| UI16 | TextID | A DefineText or DefineEditText |
| UB[2] | UseFlashType | 0 normal, 1 advanced anti-aliasing |
| UB[3] | GridFit | 0 none, 1 pixel, 2 sub-pixel |
| UB[3] | Reserved | 0 |
| FLOAT | Thickness | |
| FLOAT | Sharpness | |
| UI8 | Reserved | 0 |
SWF 8.
DefineFontName (88)
| Type | Name | Description |
|---|---|---|
| UI16 | FontID | The font |
| STRING | FontName | Its full name |
| STRING | FontCopyright | Its copyright notice |
SWF 9.
DefineText (11)
| Type | Name | Description |
|---|---|---|
| UI16 | CharacterID | The character ID |
| RECT | TextBounds | The bounds |
| MATRIX | TextMatrix | Applied to the text |
| UI8 | GlyphBits | Bits in each glyph index |
| UI8 | AdvanceBits | Bits in each advance |
| TEXTRECORD[] | TextRecords | The text |
| UI8 | EndOfRecordsFlag | 0 |
SWF 1. Static text with RGB colours.
DefineText2 (33)
SWF 3. The same as DefineText, with RGBA text colours.
TEXTRECORD
| Type | Name | Description |
|---|---|---|
| UB[1] | TextRecordType | 1 |
| UB[3] | StyleFlagsReserved | 0 |
| UB[1] | StyleFlagsHasFont | FontID and TextHeight follow |
| UB[1] | StyleFlagsHasColor | TextColor follows |
| UB[1] | StyleFlagsHasYOffset | YOffset follows |
| UB[1] | StyleFlagsHasXOffset | XOffset follows |
| UI16 | FontID | If HasFont |
| RGB or RGBA | TextColor | If HasColor: RGB in DefineText, RGBA in DefineText2 |
| SI16 | XOffset | If HasXOffset, in twips |
| SI16 | YOffset | If HasYOffset, in twips |
| UI16 | TextHeight | If HasFont, in twips |
| UI8 | GlyphCount | The glyphs in this record |
| GLYPHENTRY × GlyphCount | GlyphEntries | Each UB[GlyphBits] GlyphIndex, SB[AdvanceBits] GlyphAdvance; padded to a byte after the last |
Glyph indexes point into the font’s glyph table, not to character codes: static text does not hold its characters, which come from the font’s code table. Glyph i is drawn at the current x, scaled by TextHeight ÷ 1,024 (÷ 20,480 for DefineFont3), and x then moves on by its advance.
DefineEditText (37)
| Type | Name | Description |
|---|---|---|
| UI16 | CharacterID | The character ID |
| RECT | Bounds | The field’s rectangle |
| UB[1] × 8 | first flags byte | HasText 0x80, WordWrap 0x40, Multiline 0x20, Password 0x10, ReadOnly 0x08, HasTextColor 0x04, HasMaxLength 0x02, HasFont 0x01 |
| UB[1] × 8 | second flags byte | HasFontClass 0x80 (SWF 9), AutoSize 0x40 (SWF 6), HasLayout 0x20, NoSelect 0x10, Border 0x08, WasStatic 0x04 (SWF 8), HTML 0x02, UseOutlines 0x01 |
| UI16 | FontID | If HasFont |
| STRING | FontClass | If HasFontClass: an ActionScript 3 font class |
| UI16 | FontHeight | If HasFont, in twips |
| RGBA | TextColor | If HasTextColor |
| UI16 | MaxLength | If HasMaxLength |
| UI8 | Align | If HasLayout: 0 left, 1 right, 2 centre, 3 justify |
| UI16 | LeftMargin | If HasLayout, in twips |
| UI16 | RightMargin | If HasLayout |
| UI16 | Indent | If HasLayout |
| SI16 | Leading | If HasLayout |
| STRING | VariableName | The variable the text is bound to (ActionScript 1 and 2) |
| STRING | InitialText | If HasText; Flash’s subset of HTML if HTML is set |
SWF 4. A dynamic or input text field. With UseOutlines the player draws it with the font’s embedded glyphs; otherwise with a device font.