libsswf: sswf::TagFont Class Reference

# sswf::TagFont Class Reference

Define a system or embedded font. More...

`#include <libsswf.h>`

Inheritance diagram for sswf::TagFont:

List of all members.

## Public Types
enum | font_em_size_t { FONT_EM_SMALL = 0, FONT_EM_LARGE = 1 }
enum | font_language_t { FONT_LANGUAGE_UNKNOWN = -1, FONT_LANGUAGE_LOCALE = 0, FONT_LANGUAGE_LATIN = 1, FONT_LANGUAGE_JAPANESE = 2, FONT_LANGUAGE_KOREAN = 3, FONT_LANGUAGE_SIMPLIFIED_CHINESE = 4, FONT_LANGUAGE_TRADITIONAL_CHINESE = 5, FONT_LANGUAGE_max = 6 }
| Language definition for a font. More...
enum | font_thickness_t { FONT_THICKNESS_UNKNOWN = -1, FONT_THICKNESS_THIN = 0, FONT_THICKNESS_MEDIUM = 1, FONT_THICKNESS_THICK = 2, FONT_THICKNESS_max = 3 }
| Defines the thickness of the font. More...
enum | font_type_t { FONT_TYPE_BEST = 0, FONT_TYPE_ASCII, FONT_TYPE_UNICODE, FONT_TYPE_SHIFTJIS }
| The list of font types. More...
## Public Member Functions
ErrorManager::error_code_t | AddGlyph (sswf_ucs4_t name, const TagBase *ref, long advance=LONG_MIN)
| Add a glyph to an embedded font.
void | AddKern (sswf_ucs4_t code0, sswf_ucs4_t code1, long advance)
| Add a special kern between two glyphs.
long | DefaultAscent (void) const
| Returns the default ascent.
long | DefaultDescent (void) const
| Returns the default descent.
long | DefaultLeadingHeight (void) const
| Returns the default leading height.
bool | FindGlyph (font_info_t &info, bool mark_empty_in_use=false) const
| Retrieve the information (advance, etc.) of the specified glyph.
const char * | FontName (void) const
| Gets the name of the font.
ErrorManager::error_code_t | GlyphInfo (font_info_t &info) const
| Retrieve the information (advance, etc.) of the specified glyph.
bool | HasGlyph (void) const
| Check whether the font has glyphs.
virtual ErrorManager::error_code_t | Save (Data &data)
| Save the TagFont in the specified Data buffer.
void | SetBold (bool bold)
| Mark the font as representing a bold style.
void | SetCopyright (const char *copyright)
| Defines a copyright or license for the font.
void | SetDefaultAdvance (long advance)
| Set the default advance.
void | SetDisplayName (const char *display_name)
| Defines the display name of the font.
void | SetEMSize (font_em_size_t font_em_size)
| Define the size of the EM square of the font.
void | SetItalic (bool italic)
| Mark the font as representing an italic style.
void | SetLanguage (font_language_t language)
| Set the language corresponding to this font.
void | SetLayout (long ascent, long descent, long leading_height)
| Set the font layout.
void | SetName (const char *font_name)
| Defines the name of the font.
void | SetSmallText (bool small_text=true)
| Mark the font as being a small text font.
void | SetSpaceAdvance (long advance)
| Set the width of the regular space glyph.
void | SetThickness (font_thickness_t thickness)
| Define the thickness of the font.
void | SetType (font_type_t type)
| Set the type of font.
void | SetUsedByEditText (bool used=true)
| Defines whether the font is used by a TagEditText box.
ErrorManager::error_code_t | SetUsedGlyphs (const sswf_ucs4_t *used_glyphs, bool mark_empty_in_use=false)
| Set which glyphs are used.
ErrorManager::error_code_t | SetUsedGlyphs (const char *used_glyphs, bool mark_empty_in_use=false)
| Set which glyphs are used.
void | SetWide (bool wide)
| Mark the font as a Unicode font.
| TagFont (TagBase *parent)
| Initializes the font object.
virtual swf_type_t | TypeFlags (void) const
| The flags defining a font.
## Static Public Member Functions
static const char * | LanguageToString (font_language_t language)
| Transform a language index to the corresponding name.
static font_language_t | StringToLanguage (const char *language)
| Defines the language number from its name.
## Private Member Functions
virtual ErrorManager::error_code_t | ParseTag (swf_tag_t tag, const Data &data)
| Parse data from a file into a TagFont tag.
virtual ErrorManager::error_code_t | PreSave (void)
| Prepare the font for saving.
virtual ErrorManager::error_code_t | PreSave2ndPass (void)
| Finilize the font preparations for saving.
## Private Attributes
long | f_ascent
bool | f_bold
char * | f_copyright
unsigned long | f_count
long | f_default_advance
bool | f_define_font2
long | f_descent
char * | f_display_name
font_em_size_t | f_font_em_size
char * | f_font_name
Vectors | f_glyphs
bool | f_has_layout
bool | f_has_wide_char
bool | f_has_wide_offsets
bool | f_italic
Vectors | f_kerns
font_language_t | f_language
long | f_leading_height
unsigned long * | f_offsets
long | f_offsets_max
Data | f_save_glyphs
bool | f_small_text
long | f_space_advance
font_thickness_t | f_thickness
font_type_t | f_type
bool | f_used_by_edit_text
bool | f_wide
## Static Private Attributes
static const char * | g_font_language_name [FONT_LANGUAGE_max]
## Classes
struct | font_glyph_t
| Structure used to represent a glyph. More...
struct | font_info_t
| Structure used to handle one glyph information. More...
struct | font_kern_t
| Structure used to define one kern entry. More...

## Detailed Description

This tag is used to define a font.

Embedded fonts include definitions for each glyph as required.

System fonts just define the name of the system font.

See also:
  sswf::TagShape

  SWF Alexis' Reference—Define Font

  SWF Alexis' Reference—Define Font2

  SWF Alexis' Reference—Define Font3

  SWF Alexis' Reference—Define Font Info

  SWF Alexis' Reference—Define Font Info2

  SWF Alexis' Reference—Define Font Name

  SWF Alexis' Reference—Define Font Align Zones

  SWF Alexis' Reference—Define Shape

  SWF Alexis' Reference—swf_tag

## Member Enumeration Documentation

enum sswf::TagFont::font_em_size_t

Enumerator:

  FONT_EM_SMALL |
  FONT_EM_LARGE |

enum sswf::TagFont::font_language_t

Before version 6, many strange things appeared in Flash including a language definition for a font. There is really no need for it. Just use Unicode.

Enumerator:

  FONT_LANGUAGE_UNKNOWN | This value is used to mark a font as not having a language. This is the default value for a font.
  FONT_LANGUAGE_LOCALE | This value is used so the player uses the current locale. I'm not too sure what this was for. How can a font be defined by a changing locale?
  FONT_LANGUAGE_LATIN | Latin-1 languages. This value was for fonts representing the Latin-1 character set. (code page 0x00 in Unicode.)
  FONT_LANGUAGE_JAPANESE | Japanese language. This value was for fonts representing a set of Japanese glyphs.
  FONT_LANGUAGE_KOREAN | Korean language. This value was for fonts representing a set of Korean glyphs.
  FONT_LANGUAGE_SIMPLIFIED_CHINESE | Chinese language. This value was for fonts representing a set of simplified Chinese glyphs.
  FONT_LANGUAGE_TRADITIONAL_CHINESE | Chinese language. This value was for fonts representing a set of traditional Chinese glyphs.
  FONT_LANGUAGE_max | This represents the largest possible language code. This can be used as a limit boundary.

enum sswf::TagFont::font_thickness_t

The Flash player will by default determine the thickness of a font using a lookup table. If the font isn't found in that table, then it uses the thickness defined in the SWF file.

Enumerator:

  FONT_THICKNESS_UNKNOWN | The default: the thickness is not specified. The thickness is a feature of the fonts since SWF version 8. By default the thickness is not specified.
  FONT_THICKNESS_THIN | Defines the thickness of the font as thin. This is a thin font. This means thinner than normal (light).
  FONT_THICKNESS_MEDIUM | Defines the thickness of the font as medium. This is a medium font. This means a mostly normal font.
  FONT_THICKNESS_THICK | Defines the thickness of the font as thick. This is a thick font. This means thicker than normal (bold).
  FONT_THICKNESS_max |

enum sswf::TagFont::font_type_t

This enumeration defines the different types of fonts available.

Enumerator:

  FONT_TYPE_BEST | Selects the best type which can be used. Use this type to let the font choose what it wants to make it all work properly.
  FONT_TYPE_ASCII | Select the type ASCII. This type represents a font with at most 256 characters.
  FONT_TYPE_UNICODE | Select the type UNICODE. This type represents any font in all languages. It supports 65536 characters all together. The character numbers are defined by the Unicode consortium: http://www.unicode.org This is the prefered type since version 6.
  FONT_TYPE_SHIFTJIS | Select the type SHIFTJIS. This type represents Japanese. I'm not too sure how this was used. Now, Japanese as well as Chinese, Korean, and any other language character set is defined using Unicode.

## Constructor & Destructor Documentation

TagFont::TagFont | ( | TagBase * | parent | ) |

This function sets the font object to defaults.

By default a font has no name, no display name, no copyrigth, no predefined language, no type, no specific style, no glyph, etc.

Parameters:

  `[in]` | parent | The TagHeader where the TagFont is included.

References DefaultAscent(), DefaultDescent(), DefaultLeadingHeight(), f_ascent, f_bold, f_copyright, f_count, f_default_advance, f_define_font2, f_descent, f_display_name, f_font_em_size, f_font_name, f_has_layout, f_has_wide_char, f_has_wide_offsets, f_italic, f_language, f_leading_height, f_offsets, f_offsets_max, f_small_text, f_space_advance, f_thickness, f_type, f_used_by_edit_text, f_wide, FONT_EM_SMALL, FONT_LANGUAGE_UNKNOWN, FONT_THICKNESS_UNKNOWN, and FONT_TYPE_BEST.

## Member Function Documentation

ErrorManager::error_code_t TagFont::AddGlyph | ( | sswf_ucs4_t | name,
|  | const TagBase * | ref,
|  | long | advance = `LONG_MIN` |
| ) |  |  |

This function adds the ref shape as the character defined with the code defined in the name parameter.

If you want to use the normal advance for a character, set the advance paramter to LONG_MIN. Wider or smaller characters need to use a specific value here.

Parameters:

  `[in]` | name | The name (unicode number) of the glyph
  `[in]` | ref | The corresponding shape
  `[in]` | advance | The number of twips to the next character

Returns:
  An error code or ErrorManager::ERROR_CODE_NONE

References sswf::ErrorManager::ERROR_CODE_GLYPH_DEFINED_TWICE, sswf::ErrorManager::ERROR_CODE_MISSING_SHAPE, sswf::ErrorManager::ERROR_CODE_NONE, sswf::TagFont::font_glyph_t::f_advance, sswf::TagFont::font_info_t::f_glyph, f_glyphs, sswf::TagFont::font_glyph_t::f_in_use, sswf::TagFont::font_info_t::f_index, sswf::TagFont::font_glyph_t::f_name, sswf::TagFont::font_info_t::f_position, sswf::TagFont::font_glyph_t::f_shape, FindGlyph(), sswf::Vectors::Insert(), sswf::MemoryManager::MemAttach(), sswf::TagBase::Name(), sswf::TagBase::OnError(), and SSWF_FONT_SPACE_INDEX.

void TagFont::AddKern | ( | sswf_ucs4_t | code0,
|  | sswf_ucs4_t | code1,
|  | long | advance |
| ) |  |  |

Defines two glyphs and the space to add when they are encountered in that specific order in a word.

For instance, a capital W followed by a lower case I need to be closer to each others than what the default advance of the W character implies.

This advance is added to the normal advance (cumulative) this it often ends up being negative.

Todo:
  We would need to make sure that all kerns are distinct.

Parameters:

  `[in]` | code0 | The first glyph
  `[in]` | code1 | The second glyph
  `[in]` | advance | The advance to add when these two glyphs are found in a string

References sswf::TagFont::font_kern_t::f_advance, sswf::TagFont::font_kern_t::f_code, f_kerns, sswf::MemoryManager::MemAttach(), and sswf::Vectors::Set().

long TagFont::DefaultAscent | ( | void |  | ) | const

This function returns the value representing the default ascent for an SWF font. It is recommanded to use that value for your font ascent if possible.

Returns:
  The default ascent.

Referenced by DefaultDescent(), PreSave2ndPass(), and TagFont().

long TagFont::DefaultDescent | ( | void |  | ) | const

This function returns the value representing the default descent for an SWF font. It is recommanded to use that value for your font descent if possible.

Returns:
  The default descent.

References DefaultAscent().

Referenced by PreSave2ndPass(), and TagFont().

long TagFont::DefaultLeadingHeight | ( | void |  | ) | const

This function returns the value representing the default leading height for an SWF font. It is recommanded that you use that value for your own fonts if possible.

Returns:
  The default leading height

Referenced by PreSave2ndPass(), and TagFont().

bool TagFont::FindGlyph | ( | font_info_t & | info,
|  | bool | mark_empty_in_use = `false` |
| ) |  |  | const

For this function, define info.f_glyph with the glyph Unicode number you want to retrieve. Call the function, and if the glyph exists, the information for that glyph will be saved in the other fields of the structure.

The glyph is searched with a binary search so it is fast.

When the fonction does not find the glyph, it is not considered an error. It returns the structure with f_index set to the location where the glyph defined in f_glyph can be inserted (this is used internally whenever a new glyph is added to the TagFont.)

Parameters:

  `[in,out]` | info | A glyph information structure with its f_glyph properly defined; returned with the other glyph information
  `[in]` | mark_empty_in_use | Whether to mark empty glyphs in use or not

Returns:
  true when the glyph was found

See also:
  sswf::TagFont::GlyphInfo(font_info_t& info) const

References sswf::Vectors::Count(), sswf::TagFont::font_info_t::f_advance, sswf::TagFont::font_glyph_t::f_advance, f_default_advance, sswf::TagFont::font_info_t::f_glyph, f_glyphs, sswf::TagFont::font_glyph_t::f_in_use, sswf::TagFont::font_glyph_t::f_index, sswf::TagFont::font_info_t::f_index, sswf::TagFont::font_info_t::f_is_empty, sswf::TagFont::font_glyph_t::f_name, sswf::TagFont::font_info_t::f_position, sswf::TagFont::font_info_t::f_saved_index, sswf::TagFont::font_glyph_t::f_shape, f_space_advance, sswf::Vectors::Get(), sswf::TagShape::IsEmpty(), and SSWF_FONT_SPACE_INDEX.

Referenced by AddGlyph(), sswf::TagText::DefineText(), sswf::TagEditText::PreSave(), and SetUsedGlyphs().

const char * TagFont::FontName | ( | void |  | ) | const

This function returns the current name of the font.

Returns:
  The name of the font.

References f_font_name.

Referenced by sswf::TagText::DefineText(), and sswf::TagEditText::PreSave().

ErrorManager::error_code_t TagFont::GlyphInfo | ( | font_info_t & | info | ) | const

For this function, define info.f_index with the glyph information you want to retrieve. Call the function, and if the glyph exists, the information for that glyph will be saved in the other fields of the structure.

It is an error to put a glyph index larger than the number of glyphs available.

Note that the index represents the index in the array of glyphs, not the glyph Unicode number. Use the FindGlyph() function instead to find a glyph using its glyph Unicode number.

Parameters:

  `[in,out]` | info | A glyph information structure with it's f_index properly defined; returned with the other glyph information

Returns:
  An error code or ErrorManager::ERROR_CODE_NONE

See also:
  sswf::TagFont::FindGlyph(font_info_t& info, bool mark_empty_in_use) const

References sswf::Vectors::Count(), sswf::ErrorManager::ERROR_CODE_INVALID_GLYPH, sswf::ErrorManager::ERROR_CODE_NONE, sswf::TagFont::font_info_t::f_advance, sswf::TagFont::font_glyph_t::f_advance, f_default_advance, sswf::TagFont::font_info_t::f_glyph, f_glyphs, sswf::TagFont::font_glyph_t::f_index, sswf::TagFont::font_info_t::f_index, sswf::TagFont::font_info_t::f_is_empty, sswf::TagFont::font_glyph_t::f_name, sswf::TagFont::font_info_t::f_saved_index, sswf::TagFont::font_glyph_t::f_shape, sswf::Vectors::Get(), sswf::TagShape::IsEmpty(), and sswf::TagBase::OnError().

Referenced by sswf::TagText::Save().

bool TagFont::HasGlyph | ( | void |  | ) | const

This function returns true if the font defins one or more glyphs. This can be used to know whether the font is an embedded or a ssytem font.

Returns:
  true when the font has glyphs

References sswf::Vectors::Count(), and f_glyphs.

Referenced by sswf::TagEditText::PreSave().

const char * TagFont::LanguageToString | ( | font_language_t | language | ) | `[static]`

This function transform a language index in a corresponding string.

Parameters:

  `[in]` | language | The language index to convert to a string.

Returns:
  A constant string with the language name or "invalid".

References FONT_LANGUAGE_max, and g_font_language_name.

ErrorManager::error_code_t TagFont::ParseTag | ( | swf_tag_t | tag,
|  | const Data & | data |
| ) |  |  | `[private, virtual]`

This function reads the data saved in a Font tag.

The function supports the following tags:

            SWF_TAG_DEFINE_FONT
            SWF_TAG_DEFINE_FONT2
            SWF_TAG_DEFINE_FONT3
            SWF_TAG_DEFINE_FONT_INFO
            SWF_TAG_DEFINE_FONT_INFO2
            SWF_TAG_DEFINE_FONT_ALIGN_ZONES
            SWF_TAG_DEFINE_FONT_NAME

When saving such a font, the TagFont object will automatically select the required tag to save the data.

Parameters:

  `[in]` | tag | The tag that generated this call
  `[in]` | data | The Data buffer from the Flash file being loaded

Returns:
  An error if one occurs, or ErrorManager::ERROR_CODE_NONE

Implements sswf::TagBase.

References sswf::Vectors::Count(), sswf::ErrorManager::ERROR_CODE_NONE, sswf::ErrorManager::ERROR_CODE_UNSUPPORTED_ZONE_COUNT, f_bold, f_copyright, f_display_name, f_font_name, f_glyphs, f_has_wide_char, f_italic, f_language, f_small_text, f_thickness, f_type, FONT_TYPE_ASCII, FONT_TYPE_BEST, FONT_TYPE_SHIFTJIS, FONT_TYPE_UNICODE, sswf::Vectors::Get(), sswf::Data::GetBits(), sswf::Data::GetByte(), sswf::Data::GetShort(), sswf::Data::GetString(), sswf::TagBase::SWF_TAG_DEFINE_FONT, sswf::TagBase::SWF_TAG_DEFINE_FONT2, sswf::TagBase::SWF_TAG_DEFINE_FONT3, sswf::TagBase::SWF_TAG_DEFINE_FONT_ALIGN_ZONES, sswf::TagBase::SWF_TAG_DEFINE_FONT_INFO, sswf::TagBase::SWF_TAG_DEFINE_FONT_INFO2, and sswf::TagBase::SWF_TAG_DEFINE_FONT_NAME.

ErrorManager::error_code_t TagFont::PreSave | ( | void |  | ) | `[private, virtual]`

This function ensures that the font will properly be saved (as obtimized as possible.)

The main action of this function is to clear the in use flag of all the glyphs to false. This means no glyphs will be saved in that font. The next step is for the other tags to mark exactly which glyphs are necessary for them. For instance, an edit text box could ask for all capital letters (A-Z) and another ask for digits (0-9).

In order to complete the preparations before the Save() function is called, the PreSave2ndPass() will be called. That's at that time that the font can determine the index of each glyph since now it knows which glyph will be saved in the final font.

Returns:
  An error code or ErrorManager::ERROR_CODE_NONE

Reimplemented from sswf::TagBase.

References sswf::Vectors::Count(), sswf::ErrorManager::ERROR_CODE_NONE, f_copyright, f_display_name, f_font_em_size, f_font_name, f_glyphs, f_kerns, f_language, f_small_text, f_used_by_edit_text, FONT_EM_LARGE, FONT_LANGUAGE_LOCALE, FONT_LANGUAGE_UNKNOWN, sswf::Vectors::Get(), and sswf::TagBase::MinimumVersion().

ErrorManager::error_code_t TagFont::PreSave2ndPass | ( | void |  | ) | `[private, virtual]`

This function is called after all the other objects PreSave() was called giving them a chance to define which of the embedded glyphs they use.

At this point we also know whether the font must be defined with a DefineFont2 and using Unicode (wide) characters.

Returns:
  An error code or ErrorManager::ERROR_CODE_NONE

Reimplemented from sswf::TagBase.

References sswf::Data::Align(), sswf::assert(), sswf::Data::ByteSize(), sswf::Vectors::Count(), DefaultAscent(), DefaultDescent(), DefaultLeadingHeight(), sswf::Data::Empty(), sswf::ErrorManager::ERROR_CODE_NONE, f_ascent, f_count, f_define_font2, f_descent, f_font_em_size, f_glyphs, f_has_layout, f_has_wide_char, f_has_wide_offsets, sswf::TagFont::font_glyph_t::f_in_use, sswf::TagFont::font_glyph_t::f_index, f_kerns, f_leading_height, sswf::TagFont::font_glyph_t::f_name, f_offsets, f_offsets_max, f_save_glyphs, sswf::TagFont::font_glyph_t::f_shape, f_used_by_edit_text, f_wide, FONT_EM_LARGE, sswf::Vectors::Get(), sswf::TagShape::HasBounds(), sswf::MemoryManager::MemAlloc(), sswf::MemoryManager::MemClean(), sswf::TagBase::MinimumVersion(), sswf::swap_int(), sswf::swap_short(), and sswf::TagBase::Version().

ErrorManager::error_code_t TagFont::Save | ( | Data & | data | ) | `[virtual]`

This function saves the font in the specified Data buffer.

It will save the glyphs in the DefineFont or DefineFont2 tag. And some extraneous information in a DefineFontInfo or DefineFontInfo2 tag. And it saves the name and license in a DefineFontName tag.

To save the glyphs, the TagFont calls the sswf::TagShape::SaveWithoutStyles(Data& data) function.

Parameters:

  `[in]` | data | The Data buffer where the font tags are saved

Returns:
  An error code or ErrorManager::ERROR_CODE_NONE

See also:
  sswf::TagShape::SaveWithoutStyles(Data& data)

Implements sswf::TagBase.

References sswf::Data::Align(), sswf::Data::Append(), sswf::TagShape::Bounds(), sswf::Data::ByteSize(), sswf::Vectors::Count(), sswf::Data::Empty(), sswf::ErrorManager::ERROR_CODE_INVALID_EM_SQUARE, sswf::ErrorManager::ERROR_CODE_NAME_TOO_LONG, sswf::ErrorManager::ERROR_CODE_NONE, sswf::TagFont::font_kern_t::f_advance, sswf::TagFont::font_glyph_t::f_advance, f_ascent, f_bold, sswf::TagFont::font_kern_t::f_code, f_copyright, f_count, f_default_advance, f_define_font2, f_descent, f_display_name, f_font_em_size, f_font_name, f_glyphs, f_has_layout, f_has_wide_char, f_has_wide_offsets, sswf::TagFont::font_glyph_t::f_in_use, f_italic, f_kerns, f_language, f_leading_height, sswf::TagFont::font_glyph_t::f_name, f_offsets, f_save_glyphs, sswf::TagFont::font_glyph_t::f_shape, f_small_text, f_thickness, f_type, FONT_EM_LARGE, FONT_LANGUAGE_LOCALE, FONT_LANGUAGE_UNKNOWN, FONT_THICKNESS_MEDIUM, FONT_THICKNESS_UNKNOWN, FONT_TYPE_ASCII, FONT_TYPE_BEST, FONT_TYPE_SHIFTJIS, FONT_TYPE_UNICODE, sswf::Vectors::Get(), sswf::TagShape::HasAlignZone(), sswf::TagBase::OnError(), sswf::Data::PutByte(), sswf::Data::PutShort(), sswf::SRectangle::Save(), sswf::TagShape::SaveAlignZone(), sswf::TagBaseID::SaveID(), sswf::TagBase::SaveTag(), sswf::TagBase::SWF_TAG_DEFINE_FONT, sswf::TagBase::SWF_TAG_DEFINE_FONT2, sswf::TagBase::SWF_TAG_DEFINE_FONT3, sswf::TagBase::SWF_TAG_DEFINE_FONT_ALIGN_ZONES, sswf::TagBase::SWF_TAG_DEFINE_FONT_INFO, sswf::TagBase::SWF_TAG_DEFINE_FONT_INFO2, sswf::TagBase::SWF_TAG_DEFINE_FONT_NAME, sswf::TagBase::Version(), sswf::Data::Write(), and sswf::Data::WriteBits().

void TagFont::SetBold | ( | bool | bold | ) |

Set this flag if your font represents a bold version of the font. If you want to use a system font, use this flag so the bold version of the font is used.

Parameters:

  `[in]` | bold | true if the font is bold

References f_bold.

void TagFont::SetCopyright | ( | const char * | copyright | ) |

This function defines a copyright string to save along the font. This can include any information such as how the font can be used.

Parameters:

  `[in]` | copyright | The copyright or license for the embedded font

References f_copyright, sswf::MemoryManager::MemFree(), and sswf::MemoryManager::StrDup().

void TagFont::SetDefaultAdvance | ( | long | advance | ) |

This function can be used to define the default advance of a glyph. This is useful to avoid having to define the advance parameter each time a new glyph is added.

By default this value is set to zero: not advance.

Parameters:

  `[in]` | advance | The amount to advance to go where the next glyph should be rendered

References f_default_advance.

void TagFont::SetDisplayName | ( | const char * | display_name | ) |

This function can be used to define the display name of the font opposed to the exact system name.

For instance, a font can be called "ArialBld" and the display name would then be "Arial Bold"

Parameters:

  `[in]` | display_name | The name of the font as we want to show it to an end user

References f_display_name, sswf::MemoryManager::MemFree(), and sswf::MemoryManager::StrDup().

void TagFont::SetEMSize | ( | font_em_size_t | font_em_size | ) |

This function is used to define the size of the EM square used to draw the glyphs. This could be done automatically by checking the size of the glyphs, but that's not done yet and it would not automatically work in all cases.

The EM square can be small or large:

            FONT_EM_SMALL
            FONT_EM_LARGE

Parameters:

  `[in]` | font_em_size | The new size of the EM square

References f_font_em_size.

void TagFont::SetItalic | ( | bool | italic | ) |

Set this flag if your font represents an italic version of the font. If you want to use a system font, use this flag so the italic version of the font is used.

Parameters:

  `[in]` | italic | true if the font is italic

References f_italic.

void TagFont::SetLanguage | ( | font_language_t | language | ) |

This function sets the language corresponding to this font. This is not very useful since version 6 since all fonts use Unicode which include all possible languages today (and tomorrow once we have Klingon in Unicode.)

You can use the TagFont::StringToLanguage(const char *language) to transform a string to a language code as required by this function.

The available languages are defined here:

            FONT_LANGUAGE_UNKNOWN
            FONT_LANGUAGE_LOCALE
            FONT_LANGUAGE_LATIN
            FONT_LANGUAGE_JAPANESE
            FONT_LANGUAGE_KOREAN
            FONT_LANGUAGE_SIMPLIFIED_CHINESE
            FONT_LANGUAGE_TRADITIONAL_CHINESE

Unknown is used to mark a font as language-less.

Parameters:

  `[in]` | language | The language code

See also:
  sswf::TagFont::StringToLanguage(const char *language)

References f_language, FONT_LANGUAGE_max, and FONT_LANGUAGE_UNKNOWN.

void TagFont::SetLayout | ( | long | ascent,
|  | long | descent,
|  | long | leading_height |
| ) |  |  |

This function sets the ascent, descent and leading height of the font.

The ascent represents the distance from the base to the top of the font.

The descent represents the distance from the base to the bottom of the font.

The leading height is added the ascent and the descent to move to the next of text. The default is zero assuming that the ascent and descent include enough space to separate two lines of text.

Parameters:

  `[in]` | ascent | The ascent of the font.
  `[in]` | descent | The descent of the font.
  `[in]` | leading_height | The leading height of the font.

References f_ascent, f_descent, and f_leading_height.

void TagFont::SetName | ( | const char * | font_name | ) |

This function defines the name of the font.

A font name starting with an underscore is taken as a "direct font name" and requires V6.x. The currently supported names are:

            _sans
            _serif
            _typewriter
            5F E3 82 B4 E3 82 B7 E3 83 83 E3 82 AF (Gothic&mdash;Japanese)
            5F E7 AD 89 E5 B9 85 (Tohaba, Gothic Mono&mdash;Japanese)
            5F E6 98 8E E6 9C 9D (Mincho&mdash;Japanese)

We use that mechanism rather than checking for special names so additional names added by Macromedia/Adobe are automatically supported.

This function overwrites the previous name if one existed.

Parameters:

  `[in]` | font_name | The new name of the font.

References f_font_name, sswf::MemoryManager::MemFree(), and sswf::MemoryManager::StrDup().

void TagFont::SetSmallText | ( | bool | small_text = `true` | ) |

Set this flag to true as a hint to the Flash Player that the font will be used to draw small text.

Parameters:

  `[in]` | small_text | true to mark the font as used for small text

References f_small_text.

void TagFont::SetSpaceAdvance | ( | long | advance | ) |

This function can be used to define the width of the space glyph. This is the glyph with Unicde number 0x20 (32). That glyph is never included in the final font.

Parameters:

  `[in]` | advance | The size of one space character

References f_space_advance.

void TagFont::SetThickness | ( | font_thickness_t | thickness | ) |

This value is set to Unknown by default meaning that the thickness is not specified.

It can be set to Thin, Medium or Thick:

            FONT_THICKNESS_THIN
            FONT_THICKNESS_MEDIUM
            FONT_THICKNESS_THICK

The thickness will not be saved in the font if the EM square is not also marked as large and all glyphs got an align zone defined.

Parameters:

  `[in]` | thickness | The new thickness

See also:
  TagFont::SetEMSize(font_em_size_t font_em_size)

References f_thickness.

void TagFont::SetType | ( | font_type_t | type | ) |

The type of font to use with the TagFont.

This applies to SWF version 5 and earlier. Since version 6, the font type is automatically Unicode, which encompass all the other possible fonts.

The available types are:

            TagFont::FONT_TYPE_BEST
            TagFont::FONT_TYPE_ASCII
            TagFont::FONT_TYPE_UNICODE
            TagFont::FONT_TYPE_SHIFTJIS

Parameters:

  `[in]` | type | The font type.

References f_type.

void TagFont::SetUsedByEditText | ( | bool | used = `true` | ) |

A TagEditText cannot use a DefineFont. Thus it is important to know whether the font will be used by an Edit Text box. At times it is not possible to infer such a thing until the movie runs. For this reason, this flag is included to force the font to be saved in DefineFont2 or DefineFont3.

Parameters:

  `[in]` | used | True if the font is used in a TagEditText

References f_used_by_edit_text.

Referenced by sswf::TagEditText::PreSave().

ErrorManager::error_code_t TagFont::SetUsedGlyphs | ( | const sswf_ucs4_t * | used_glyphs,
|  | bool | mark_empty_in_use = `false` |
| ) |  |  |

This function can be used to define the glyphs that other tags use.

This is the official function which accepts a Unicode string as input.

The special strings "*" and NULL can be used in the used_glyphs parameter to mark all the glyphs in used at once.

The string can otherwise be defined with a range defined by two glyphs separated by a dash (-). For instance, to include all the ASCII upper case characters, one can use "A-Z". Several ranges can be included in the same string and the dash (-) can be included at the very beginning or the end of the string to be included as a glyph in use. The code accepts ranges which are written backward; so "9-0" is taken as "0-9".

Parameters:

  `[in]` | used_glyphs | A string representing the glyphs in use or NULL
  `[in]` | mark_empty_in_use | Whether empty glyphs should be marked in use

Returns:
  An error code or ErrorManager::ERROR_CODE_NONE

See also:
  TagFont::SetUsedGlyphs(const char *used_glyphs, bool mark_empty_in_use)

References sswf::Vectors::Count(), sswf::ErrorManager::ERROR_CODE_NO_SUCH_GLYPH, sswf::ErrorManager::ERROR_CODE_NONE, f_font_name, sswf::TagFont::font_info_t::f_glyph, f_glyphs, FindGlyph(), sswf::Vectors::Get(), sswf::TagBase::OnError(), and sswf::wcname().

ErrorManager::error_code_t TagFont::SetUsedGlyphs | ( | const char * | used_glyphs,
|  | bool | mark_empty_in_use = `false` |
| ) |  |  |

This function can be used to define the glyphs that other tags use.

Parameters:

  `[in]` | used_glyphs | A string representing the glyphs in use or NULL
  `[in]` | mark_empty_in_use | Whether empty glyphs should be marked in use

Returns:
  An error code or ErrorManager::ERROR_CODE_NONE

See also:
  TagFont::SetUsedGlyphs(const sswf_ucs4_t *used_glyphs, bool mark_empty_in_use)

References sswf::mbtowc().

Referenced by sswf::TagEditText::PreSave().

void TagFont::SetWide | ( | bool | wide | ) |

This flag is ignored in SWF version 6 and over. In that case, all fonts must be defined an Unicode (wide).

Otherwise, use this flag to mark whether you want to use the 256 glyphs font or the 65536 glyphs font.

Parameters:

  `[in]` | wide | true to make the font Unicode

References f_wide.

TagFont::font_language_t TagFont::StringToLanguage | ( | const char * | language | ) | `[static]`

This function searches for a language by name and return the corresponding language code.

            LOCALE
            LATIN
            JAPANESE
            KOREAN
            SIMPLIFIED_CHINESE
            TRADITIONAL_CHINESE

Parameters:

  `[in]` | language | The name of the language this font is for

References FONT_LANGUAGE_LOCALE, FONT_LANGUAGE_max, FONT_LANGUAGE_UNKNOWN, and g_font_language_name.

TagBase::swf_type_t TagFont::TypeFlags | ( | void |  | ) | const`[virtual]`

A font is a definition and it has an identifier.

Returns:
  SWF_TYPE_DEFINE and SWF_TYPE_HAS_ID

Implements sswf::TagBase.

References SWF_TYPE_DEFINE, and SWF_TYPE_HAS_ID.

## Member Data Documentation

long sswf::TagFont::f_ascent`[private]`

Referenced by PreSave2ndPass(), Save(), SetLayout(), and TagFont().

bool sswf::TagFont::f_bold`[private]`

Referenced by ParseTag(), Save(), SetBold(), and TagFont().

char* sswf::TagFont::f_copyright`[private]`

Referenced by ParseTag(), PreSave(), Save(), SetCopyright(), and TagFont().

unsigned long sswf::TagFont::f_count`[private]`

Referenced by PreSave2ndPass(), Save(), and TagFont().

long sswf::TagFont::f_default_advance`[private]`

Referenced by FindGlyph(), GlyphInfo(), Save(), SetDefaultAdvance(), and TagFont().

bool sswf::TagFont::f_define_font2`[private]`

Referenced by PreSave2ndPass(), Save(), and TagFont().

long sswf::TagFont::f_descent`[private]`

Referenced by PreSave2ndPass(), Save(), SetLayout(), and TagFont().

char* sswf::TagFont::f_display_name`[private]`

Referenced by ParseTag(), PreSave(), Save(), SetDisplayName(), and TagFont().

font_em_size_t sswf::TagFont::f_font_em_size`[private]`

Referenced by PreSave(), PreSave2ndPass(), Save(), SetEMSize(), and TagFont().

char* sswf::TagFont::f_font_name`[private]`

Referenced by FontName(), ParseTag(), PreSave(), Save(), SetName(), SetUsedGlyphs(), and TagFont().

Vectors sswf::TagFont::f_glyphs`[private]`

Referenced by AddGlyph(), FindGlyph(), GlyphInfo(), HasGlyph(), ParseTag(), PreSave(), PreSave2ndPass(), Save(), and SetUsedGlyphs().

bool sswf::TagFont::f_has_layout`[private]`

Referenced by PreSave2ndPass(), Save(), and TagFont().

bool sswf::TagFont::f_has_wide_char`[private]`

Referenced by ParseTag(), PreSave2ndPass(), Save(), and TagFont().

bool sswf::TagFont::f_has_wide_offsets`[private]`

Referenced by PreSave2ndPass(), Save(), and TagFont().

bool sswf::TagFont::f_italic`[private]`

Referenced by ParseTag(), Save(), SetItalic(), and TagFont().

Vectors sswf::TagFont::f_kerns`[private]`

Referenced by AddKern(), PreSave(), PreSave2ndPass(), and Save().

font_language_t sswf::TagFont::f_language`[private]`

Referenced by ParseTag(), PreSave(), Save(), SetLanguage(), and TagFont().

long sswf::TagFont::f_leading_height`[private]`

Referenced by PreSave2ndPass(), Save(), SetLayout(), and TagFont().

unsigned long* sswf::TagFont::f_offsets`[private]`

Referenced by PreSave2ndPass(), Save(), and TagFont().

long sswf::TagFont::f_offsets_max`[private]`

Referenced by PreSave2ndPass(), and TagFont().

Data sswf::TagFont::f_save_glyphs`[private]`

Referenced by PreSave2ndPass(), and Save().

bool sswf::TagFont::f_small_text`[private]`

Referenced by ParseTag(), PreSave(), Save(), SetSmallText(), and TagFont().

long sswf::TagFont::f_space_advance`[private]`

Referenced by FindGlyph(), SetSpaceAdvance(), and TagFont().

font_thickness_t sswf::TagFont::f_thickness`[private]`

Referenced by ParseTag(), Save(), SetThickness(), and TagFont().

font_type_t sswf::TagFont::f_type`[private]`

Referenced by ParseTag(), Save(), SetType(), and TagFont().

bool sswf::TagFont::f_used_by_edit_text`[private]`

Referenced by PreSave(), PreSave2ndPass(), SetUsedByEditText(), and TagFont().

bool sswf::TagFont::f_wide`[private]`

Referenced by PreSave2ndPass(), SetWide(), and TagFont().

const char * TagFont::g_font_language_name`[static, private]`

Initial value:

     {
            "LOCALE",
            "LATIN",
            "JAPANESE",
            "KOREAN",
            "SIMPLIFIED_CHINESE",
            "TRADITIONAL_CHINESE"
    }

Referenced by LanguageToString(), and StringToLanguage().

The documentation for this class was generated from the following files:

- libsswf.h
- libsswf_tag_font.c++