![]() | InDesign SDK 20.5 |
Public Member Functions | |
| SnpInsertGlyph () | |
| virtual | ~SnpInsertGlyph () |
| ErrorCode | InsertGlyph (InDesign::TextRange &textRange, IPMFont *font, const Text::GlyphID glyph) |
| IPMFont * | QueryFont (const InDesign::TextRange &textRange, PMString &fontFamilyName, PMString &fontStyleName) |
| const UTF32TextChar | GlyphToCharacter (IPMFont *font, const Text::GlyphID glyph, UTF32TextChar *userAreaChar=nil) |
| const OpenTypeFeatureList | GetOpenTypeFeatureList (IPMFont *font, const Text::GlyphID glyph) |
| ICommand * | CreateInsertAltGlyphCmd (const InDesign::TextRange &textRange, IPMFont *font, const OpenTypeFeatureList &featureList) |
| ICommand * | CreateInsertSpecialGlyphCmd (const InDesign::TextRange &textRange, IPMFont *font, const Text::GlyphID glyph) |
This snippet allows you to insert a glyph by its glyph ID. What is special about this snippet is that it will adapt to glyphs with various special OpenType features, or even if the glyph is just a regular Unicode(TM) character. This snippet will try to find the Unicode character value for the specified glyph, and if it finds the Unicode value, then it will insert that character into the text model, along with necessary text attributes such as OpenType attributes. However, if the character does not have a Unicode character value, a placeholder character is inserted into the text model with an appropriate text attribute.
This snippet code contains code that is useful for situations where you have Unicode characters with alternate forms. This is common in OpenType fonts.
For example, the OpenType font Kozuma Mincho Pro - Regular contains 22 different glyph forms of the the NABE character (commonly used in the Japanese surname "Watanabe"). From the top row, left to right:

Note that many of these glyphs have the same Unicode character value. Therefore, if you simply inserted these characters by their Unicode character values, you may not get the glyph you want. One key difference between these glyphs is their CID (Character ID), or GlyphID. This snippet shows how to insert these different characters by their GlyphID.
NOTE: Due to a shortcoming in the IGlyphUtils interface, some glyphs that have multiple forms but with the same values (e.g. U+9089 with 'aalt' in the list above has 19 different forms), this sample will end up placing a placeholder character (either kTextChar_SpecialGlyph or kTextChar_NonRomanSpecialGlyph) into the text model with a kTextAttrSpecialGlyphBoss attribute.
| inline |
Constructor.
| inlinevirtual |
Destructor.
| ICommand * SnpInsertGlyph::CreateInsertAltGlyphCmd | ( | const InDesign::TextRange & | textRange, |
| IPMFont * | font, | ||
| const OpenTypeFeatureList & | featureList | ||
| ) |
Insert an alternate form of a glyph. This is used when the glyph has a corresponding Unicode codepoint.
| textRange | IN The text range where the special glyph is to be inserted. |
| font | IN The font associated with the glyph. |
| featureList | IN The OpenType feature tags list to apply to the character |
| ICommand * SnpInsertGlyph::CreateInsertSpecialGlyphCmd | ( | const InDesign::TextRange & | textRange, |
| IPMFont * | font, | ||
| const Text::GlyphID | glyph | ||
| ) |
Create a command to insert a special form of a glyph. This is used when the glyph has no corresponding Unicode codepoint.
| textRange | IN The text range where the special glyph is to be inserted. |
| font | IN The font associated with the glyph. |
| glyph | IN The glyph to insert. The font attribute kCharStringNames is automatically determined. |
| const OpenTypeFeatureList SnpInsertGlyph::GetOpenTypeFeatureList | ( | IPMFont * | font, |
| const Text::GlyphID | glyph | ||
| ) |
Get the open type feature list applied to the glyph.
| font | IN The font associated with the glyph. |
| glyph | IN The glyph to examine. |
| const UTF32TextChar SnpInsertGlyph::GlyphToCharacter | ( | IPMFont * | font, |
| const Text::GlyphID | glyph, | ||
| UTF32TextChar * | userAreaChar = nil | ||
| ) |
Convert a glyph to a Unicode character. Also try to find if the glyph is in the Unicode private use area (PUA).
| font | IN The font associated with the glyph. |
| glyph | IN The glyph to examine. |
| userAreaChar | IN/OUT Pass in a non-nil UTF32TextChar in case the glyph is in the PUA. If it is in the PUA, the value will be something other than kTextChar_Null. |
| ErrorCode SnpInsertGlyph::InsertGlyph | ( | InDesign::TextRange & | textRange, |
| IPMFont * | font, | ||
| const Text::GlyphID | glyph | ||
| ) |
Insert a specific glyph by its glyph ID. Note that the Unicode character that corresponds to a specific glyph ID will vary with fonts.
This method will handle any of these cases:
| textRange | IN The text model and text range at which you want to insert the glyph. |
| font | IN The font associated with the glyph. Together with the glyph ID, you can identify a character. |
| glyph | IN The glyph ID to insert. Note that glyph IDs are specific to fonts, so you must make sure the desired glyphID does exist in the font. Note that the glyph may not have an associated Unicode character code with it, and that a single Unicode characters may have multiple glyphs that correspond to it (e.g. alternate glyphs in OpenType fonts). |
| IPMFont * SnpInsertGlyph::QueryFont | ( | const InDesign::TextRange & | textRange, |
| PMString & | fontFamilyName, | ||
| PMString & | fontStyleName | ||
| ) |