Interface Font

  • All Superinterfaces:
    java.io.Serializable
    All Known Implementing Classes:
    Base14Font, FontImpl, MemoryFont, ResourceFont

    public interface Font
    extends java.io.Serializable
    The basic interface for all public font interaction.

    This class provides the basic functionality common to all Fonts.

    Metrics

    Metrics are expressed in a metric space, which is related to the em space by the matrix (1/ux 0, 0, 1/uy), where ux is the units per em in the X direction and uy is the units per em in the Y direction. Those two quantities can be retrieved by the getUnitsPerEmX() and getUnitsPerEmY() methods. The values ux and uy may or may not be related to any data in the font; they are only guaranteed to be compatible with the values returned by methods that retrieve metrics. In other words, if x is an horizontal metric returned by some method, only the value x / ux is meaningful, and the specific values x and ux may change from one execution to the next (ux is constant for the life of a Font object).

    Very often (but not always), the font metrics stored in the font are expressed in the metric space (or conversely, the metric space is selected to be the space in which the raw font data is expressed). Returning metrics in the metric space, instead of in the em space, allows the conversion to the em space to be performed less often (e.g. only after metrics such as the advance width have been cumulated). Another benefit is that the conversion to em space is often followed by a conversion to some kind of user space (e.g. scaling by the point size, or expressing the result in some other units than points); those further conversions can be combined with the metric to em space conversion, resulting in less computations.

    Glyphs

    A font contains a number of glyphs, which are identified by their gids. Gids are by construction in the range [0, numGlyphs-1[. The glyph with gid 0 has a special meaning: it is the .notdef glyph, which is used, e.g. when a font contains no glyph for a given character.

    Synchronization

    Implementations of this interface are synchronized as needed, so that users can use a Font in multiple threads without synchronization on their side.

    Handling of symbolic fonts

    A symbolic font is an OpenType font (without or without OpenType tables) which does not have Unicode cmap, but has a Microsoft/Symbol cmap. The fonts Wingdings, Webdings, and Symbol that are provided by Microsoft are symbolic fonts. The symbol cmaps, typically maps the code points 0xF0 yz

    AFE behaves as if those fonts had a Unicode cmap. If 0xF0 yz is mapped in the symbolic cmap, then both U+F0 yz and U+00 yz are mapped in the Unicode cmap. The purpose of this double mapping is to approximate the behavior of GDI and applications such as Word.

    The first set of mappings, from U+F0 yz , are rather innocuous, as those code points are Private Use Area, and have very little semantic. The second set of mappings, from U+00 yz , are very problematic, because the the semantic of the source characters is typically not applicable. This is particulary true for the glyphs mapped from U+0000 .. U+001F and U+0080 .. U+009F (because those characters have the semantic of control character) and the glyph mapped from U+00AD SOFT HYPHEN (which is a Cf character that is not normally rendered). Other strange behavior can occur in bidi processing and line breaking processing. To help clients avoid those problems, the isSymbolic() method returns true for symbolic fonts.