gnu.java.awt.font.opentype

Class CharGlyphMap


public abstract class CharGlyphMap
extends Object

A mapping from Unicode codepoints to glyphs. This mapping does not perform any re-ordering or decomposition, so it is not everything that is needed to support Unicode.

This class manages the cmap table of OpenType and TrueType fonts.

See Also:
the cmap part of Adobe’ OpenType Specification, the cmap section of Apple’s TrueType Reference Manual

Method Summary

static CharGlyphMap
forTable(ByteBuffer buf)
Reads a CharGlyphMap from an OpenType or TrueType cmap table.
abstract int
getGlyph(int ucs4)
Determines the glyph index for a given Unicode codepoint.

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Method Details

forTable

public static CharGlyphMap forTable(ByteBuffer buf)
Reads a CharGlyphMap from an OpenType or TrueType cmap table. The current implementation works as follows:

  1. If the font has a type 4 cmap for the Unicode platform (encoding 0, 1, 2, 3 or 4), or a type 4 cmap for the Microsoft platform (encodings 1 or 10), that table is used to map Unicode codepoints to glyphs. Most recent fonts, both for Macintosh and Windows, should provide such a table.
  2. Otherwise, if the font has any type 0 cmap for the Macintosh platform, a Unicode-to-glyph mapping is synthesized from certain type 0 cmaps. The current implementation collects mappings from Roman, Icelandic, Turkish, Croatian, Romanian, Eastern European, Cyrillic, Greek, Hebrew, Arabic and Farsi cmaps.
Parameters:
buf - a buffer whose position is right at the start of the entire cmap table, and whose limit is at its end.
Returns:
a concrete subclass of CharGlyphMap that performs the mapping.

getGlyph

public abstract int getGlyph(int ucs4)
Determines the glyph index for a given Unicode codepoint. Users should be aware that the character-to-glyph mapping not not everything that is needed for full Unicode support. For example, the cmap table is not able to synthesize accented glyphs from the canonical decomposition sequence, even if the font would contain a glyph for the composed form.
Parameters:
ucs4 - the Unicode codepoint in UCS-4 encoding. Surrogates (U+D800 to U+DFFF) cannot be passed, they must be mapped to UCS-4 first.
Returns:
the glyph index, or 0 if the font does not contain a glyph for this codepoint.

CharGlyphMap.java -- Manages the 'cmap' table of TrueType fonts Copyright (C) 2006 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.