Font Embedding
Closed: 12/12/2008
The problem
In Flash Player 10, there are two different ways to embed fonts: DefineFont3 and DefineFont4. The original Flash TextField can only be used with DefineFont3 fonts. The new Vellum components can only be used with DefineFont4.
Since Halo components use UITextField, a subclass of TextField, they will only be compatible with DefineFont3. The Gumbo components use Vellum, so they will only be compatible with DefineFont4. Since many Flex 4 projects will use a mix of Halo and Gumbo components, this would lead to two problems:
- The same font would need to be embedded twice in each application--once using DefineFont3 and once using DefineFont4. This will lead to bloated SWFs.
- Developers would have to carefully craft their CSS to ensure that the DefineFont3 version of a font is applied to Halo components and the DefineFont4 version is applied to Gumbo components. This would require a great deal of manual work, and would be highly error-prone, since mismatches could not be detected at compile time.
Possible solutions
- Ask the Flash Player team to make TextField support DefineFont4 fonts in their next version. This is apparently about 3 months of work and is likely to be a non-starter given the limited resources on the Player team.
- Drop Vellum from the Gumbo components. This is a non-starter.
- Add support to both the compiler and the framework to try to automatically use the right version of an embedded font in Halo and Gumbo components. This could conceivably solve the usability issue, but would not solve the SWF bloat issue, and would likely involve a lot of fairly fragile hack work.
- Create a version of TextField that's based on Vellum.
Proposal
We should pursue option (4)--creating a version of TextField that's based on Vellum. Options (1) and (2) are non-starters, and option (3) would take a non-trivial amount of time, be a major hack, and not solve the bloat problem.
Specifically, we would:
- Create a component that is API-compatible with TextField, and preserves as much rendering fidelity as possible, but uses Vellum under the hood.
- By default, the Halo components in Flex 4 would use this new Vellum-based TextField component in place of the built-in Flash Player TextField.
- By default, Flex 4 would embed fonts using DefineFont4. Developers would have to explicitly set CFF to false when embedding a font in order to embed it using DefineFont3 (for example, if they wanted to explicitly use a component based on the original TextField).
- A compiler switch would be provided that would make the Halo components use the original TextField by default. If this switch is on, then the compiler would also automatically switch to using DefineFont3 for embedding fonts. Developers would have to explicitly set CFF to true when embedding a font in order to embed it using DefineFont4.
This work has been roughly estimated at about 2 months of work, and according to Matt is still on the SDK schedule.