InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
IFontInstance Class Referenceabstract

#include <IFontInstance.h>

Inheritance diagram for IFontInstance:
grRefCountedObj

Public Types

enum  { kNormalOutlines = 0, kHintedOutlines = 1, kVerticalOutlines = 2, kVerticalGlyphs = 4 }
 
enum  FeatureInfoFlags {
  kApplyGlyphSub = 1 << 0, kApplyGlyphPos = 1 << 1, kApplyGlyphSubAndPos = kApplyGlyphSub | kApplyGlyphPos, kRightToLeft = 1<<3,
  kCTFlagsBitMask = 0x0F, kModifyWidthsInPlace = 1 << 5
}
 
enum  { kNoChange = 0, kLigatureApplied = 1<<4, kGlyphDeleted = 1<<5 }
 

Public Member Functions

virtual Text::GlyphID GetGlyphID (UTF32TextChar charCode) const =0
 
virtual void GetGlyphIDs (const WideString &textString, K2Vector< Text::GlyphID > &glyphIDs) const =0
 
virtual void AppendGlyphIDs (const UTF16TextChar *buffer, int32 bufSize, K2Vector< Text::GlyphID > &glyphIDs) const =0
 
virtual int32 FillOutGlyphIDs (PMRealGlyphPoint *glyphPoints, int32 numGlyphs, const UTF16TextChar *textchars, int32 bufSize) const =0
 
virtual Text::GlyphID GetNotDefinedGlyph () const =0
 
virtual PMReal GetGlyphWidth (Text::GlyphID glyphID) const =0
 
virtual void GetWidths (PMRealGlyphPoint *glyphPoints, int32 numGlyphs) const =0
 
virtual PMRect GetGlyphBBox (Text::GlyphID glyphID) const =0
 
virtual void MeasureWText (const UTF16TextChar *text, int32 utf16BufferLength, PMReal &xWidth, PMReal *yHeight=nil) const =0
 
virtual void MeasureWText (const WideString &string, PMReal &xWidth, PMReal *yHeight=nil) const =0
 
virtual void MeasureWText (const PMString &string, PMReal &xWidth, PMReal *yHeight=nil) const =0
 
virtual bool16 HasKerningTable () const =0
 
virtual void GetKerns (PMRealGlyphPoint *glyphPoints, int32 numGlyphs, bool16 vertical=kFalse, const char *scriptTag=nil, const char *langTag=nil) const =0
 
virtual void GetOutlineInfo (IOutlineInfo *callBack, Text::GlyphID glyphID, PMReal xOffset, PMReal yOffset, int32 flags=kNormalOutlines) const =0
 
virtual PMReal GetAscent () const =0
 
virtual PMReal GetDescent () const =0
 
virtual PMReal GetCapHeight () const =0
 
virtual PMReal GetXHeight () const =0
 
virtual PMReal GetEmBoxHeight () const =0
 
virtual void GetICFBoxInsets (PMReal *fromEmTop, PMReal *fromEmBottom) const =0
 
virtual PMReal GetHorizEmBoxDepth () const =0
 
virtual PMReal GetHorizICFBoxDepth () const =0
 
virtual CTFontInst * GetCTFontInst () const =0
 
virtual CTFontDict * GetParentCTFontDict () const =0
 
virtual void GetDesignVector (PMReal *designVec, size_t &designVecLen) const =0
 
virtual size_t GetNumDesignAxes () const =0
 
virtual const PMMatrixGetPMMatrix () const =0
 
virtual IFontMgr::WritingDirection GetWritingDirection () const =0
 
virtual bool16 ApplyFeatures (PMRealGlyphPoint *glyphPoints, size_t &numGlyphPoints, size_t &numGlyphPointsAvail, int32 numFeatures, const char *features, const int32 *choiceIndices, const size_t *featureRanges, char *changeAttrib, FeatureInfoFlags flags, PMReal *penPos=nil, PMReal *caretPositions=nil, const char *scriptTag=nil, const char *langTag=nil) const =0
 
virtual CTFontInstance * GetCTFontInstance () const =0
 
virtual bool16 GermanLocaleDropsLigatures () const =0
 
- Public Member Functions inherited from grRefCountedObj
 grRefCountedObj ()
 
virtual ~grRefCountedObj ()=0
 
virtual void AddRef () const
 
virtual void Release () const
 

Additional Inherited Members

- Protected Attributes inherited from grRefCountedObj
int32 fRefCount
 

Detailed Description

This is a shell over the CoolType API for FontInstances.

Member Enumeration Documentation

anonymous enum

Flags for outline iterators

kHintedOutlines If set, the outlines will be fetched with hints applied at the size specified by the font matrix. If not set, unhinted outlines will be fetched

kVerticalOutlines If set, CoolType will assume that the outlines are being set vertically and the origin will be shifted accordingly. This will approximate postscript's vmode=1 and will shift the outlines left and down

kVerticalGlyphs If set, the glyphs are assumed to be vertical glyphs but no wmode adjustment will be done. When set, the outlines for ATC font glyphs whose baseline is adjusted vertically will be adjusted horizontally instead. kVerticalOutlines and kVerticalGlyphs are mutually exclusive so both flags must not be set.

anonymous enum

Change attribute flags

See Also
ApplyOTFeatures changeAttrib

FeatureInfoFlags

See Also
ApplyFeatures
Enumerator
kApplyGlyphSub 

Apply 'GSUB' lookups for feature tags.

kApplyGlyphPos 

Apply 'GPOS' lookups for feature tags.

kApplyGlyphSubAndPos 

Apply 'GSUB' and 'GPOS' lookups for feature tags.

kRightToLeft 

This flag is not used by ApplyFeatures. Indicates the directionality of the glyph run. If this flag is set, then the glyphpoint array is for a right-to-left run of text; otherwise, it is for a left-to-right run of text. In either case, the glyphpoints are ordered in the reading order.

Member Function Documentation

virtual void IFontInstance::AppendGlyphIDs (const UTF16TextChar * buffer,
int32 bufSize,
K2Vector< Text::GlyphID > & glyphIDs 
) const
pure virtual

For a buffer of utf16 chars get the glyphIDs.

Parameters
bufferIN Unicode values to get glyphids from.
bufSizenumber of utf16 values in the string (not characters).
glyphIDsOUT glyphIDs
virtual bool16 IFontInstance::ApplyFeatures (PMRealGlyphPointglyphPoints,
size_t & numGlyphPoints,
size_t & numGlyphPointsAvail,
int32 numFeatures,
const char * features,
const int32 * choiceIndices,
const size_t * featureRanges,
char * changeAttrib,
FeatureInfoFlags flags,
PMRealpenPos = nil,
PMRealcaretPositions = nil,
const char * scriptTag = nil,
const char * langTag = nil 
) const
pure virtual

Applies features for a set of glyphs. In OpenType fonts, the order in which features are applied depends on the order of lookups in the 'GSUB' and 'GPOS' tables in the font, and not on the order in the features array of this API.

The featureRanges array, if non-NULL, must contain numFeatures*2 elements. Each feature specified in the features array will correspond, in order, to a range in the featureRanges array. A range is represented by two consecutive longs: the starting and ending indexes, respectively, into the glyphPoints array (which starts at index 0). A client need not bother "clamping" a range e.g. if there are 3 glyphPoints, then the range -1 .. 4 will be regarded as 0 .. 2.

Parameters
glyphPointsPointer to an array of PMRealGlyphPoint's with 'numGlyphPoints' valid entries and 'numGlyphPointsAvail' available entries (to allow room for possible expansion with 'GSUB'). The valid entries must have their glyphID's initialized but the x and y positions needn't be initialized.

If expansion occurs, and the number of glyphPoints needed is greater than numGlyphPointsAvail, then the function will set numGlyphPointsAvail to that number and return false (the client can then re-size the array and call again); otherwise it will return true and set 'numGlyphPoints' to the actual valid number of glyphPoints if this increases or decreases with 'GSUB'.

If glyph positioning is requested (kApplyGlyphPos or kApplyGlyphSubAndPos), The xPosition and yPosition fields of the glyphPoints will be set to the deltas from the glyphs' default positions were no positioning features applied. So if the requested positioning layout features e.g. "kern" didn't affect the glyphs, the xPosition and yPositions would all be set to 0 on return.

The position of the glyphPoints is expressed in a coordinate system with the x axis horizontal, increasing in the direction of the run of text (i.e. increasing toward the right if rightToLeft is kFalse, increasing toward the left if rightToLeft is kTrue). The y axis is vertical, increasing from top to bottom.

Parameters
numGlyphPointsnumber of glyphs in glyphPoints
numGlyphPointsAvailglyphPoints allocated in glyphPoints variable
numFeaturesnumber of features in features variable
featuresfeatures to apply to glyphs
choiceIndicesarray of choice for features. count is the same as numFeatures. use -1 for features without choice
featureRangeslength of size_t is 2*numFeatures. size_t pair indicates the range of glyphs to apply the feature to. 0,0 would apply only to the first glyph. One pair for each feature in the features array. This array is optional and may be NULL
changeAttribArray of flags. This array of bytes must be as long as 'numStrikes' if present. Set to NULL if functionality not needed. The array will be filled in with bitflags that will indicate what changes occurred in the* original* strike list. This may not match the resulting list but is intended to indicate what has changed to aid in cursor positioning, for instance.
flags@seeFeatureInfoFlags
penPosIf this optional parameter is non-NULL and glyph positioning is requested (kApplyGlyphPos or kApplyGlyphSubAndPos in the featureInfo's flags field), then this parameter must point to an array of 2 elements.

On successful return, these elements (which needn't be initialized by the client) will be set to the x and y deltas, respectively, from the point to which the pen advances after the last resulting glyphPoint's default pen displacement. If glyph positioning is not requested, this parameter is not read and may be set to NULL

Parameters
caretPositionsThe glyphs' positions for rasterizing will be maintained in the 'glyphPoints' array, but if the client wants precise caret positioning it must maintain its own parallel array for caret positions. Conceptually, before applying layout features, these two arrays coincide.

If this parameter is non-NULL and glyph positioning is requested, (kApplyGlyphPos or kApplyGlyphSubAndPos in the featureInfo's flags field) then this parameter must point to an array of (n + 1) entries, where n is the input value of 'numGlyphPointsAvail'. On successful return, these entries (which needn't be initialized by the client) will be set to the increments in caret positions that resulted from applying the features.

If the writing direction of the font instance is left to right, the caret increments in the x direction are returned. If the writing direction is top to bottom, the caret increments in the y direction are returned.

The initial m entries (where m is the output value of 'numGlyphPoints') will correspond to the caret positions just before each of the glyphs in the resulting 'glyphPoints' array, and the next entry will correspond to the caret position just after the last glyph in the resulting 'glyphPoints' array. Caret positions within a ligature glyph are not provided.

Parameters
scriptTag4-character OpenType script tag. The 'script' and 'language' parameters identify the language system to be used. If 'script' is NULL, a language system in the font based on the font's writing script is used; the 'language' parameter is ignored. 'script' and 'language' are ignored for non-OpenType fonts.
langTag4-character OpenType language tag. See 'script' parameter above.
Returns
kFalse if there was an error
virtual int32 IFontInstance::FillOutGlyphIDs (PMRealGlyphPointglyphPoints,
int32 numGlyphs,
const UTF16TextChar * textchars,
int32 bufSize 
) const
pure virtual

For a buffer of utf16 chars get the glyphIDs.

Parameters
glyphPointsOUT resulting glyphs are stored here.
numGlyphsIN number of glyphPoints available in the buffer.
textcharsIN Unicode values to get glyphids from.
bufSizenumber of utf16 values in the string (not characters).
Returns
the number of glyphIDs written.
virtual bool16 IFontInstance::GermanLocaleDropsLigatures () const
pure virtual

GermanLocaleDropsLigatures In some earlier versions of Adobe OpenType fonts, the German locale would not do ligatures. However, earlier versions of InDesign would do ligatures because the locale was not considered. After passing in the locale, we want to continue to do ligatures anyway in the fonts with this behavior.

Returns
true if the font supports ligatures with LATN, DefaultLanguage, but not LATN, GERMAN
virtual PMReal IFontInstance::GetAscent () const
pure virtual

Get the font instance's ascent. Height of the lower case 'd'.

virtual PMReal IFontInstance::GetCapHeight () const
pure virtual

Height of a capital 'X' if outline of X is available. Otherwise, bbox height.

virtual CTFontInst* IFontInstance::GetCTFontInst () const
pure virtual

Returns CTFontInst pointer for this font instance

virtual CTFontInstance* IFontInstance::GetCTFontInstance () const
pure virtual

Private: GetCTFontInstance returns the underlying opaque font instance object.

Returns
the opaque underlying font instance.
virtual PMReal IFontInstance::GetDescent () const
pure virtual

Get the font's descent. Bottom of the lower case 'p'.

virtual void IFontInstance::GetDesignVector (PMRealdesignVec,
size_t & designVecLen 
) const
pure virtual

Returns design axes vector and length in case of variable font. 'designVec' must be an allocated array that is at least of length kCTMaxDesignElements. If designVec passed nil then, only designVecLen gets populated.

Parameters
designVecpass memory allocated array of RMReal, which gets populated by API.
designVecLenpopulated by API to get number of design axes.
virtual PMReal IFontInstance::GetEmBoxHeight () const
pure virtual

Returns height of em-box. In CJK fonts, this is the height of the ideographic embox, which is usually equal to the pointsize, unless the font uses a scaled embox.

In vertical font instances, this "height" is actually the width of the embox, since ideographs are drawn upright in the vertical line of text.

The font's embox is based on the left, top, right, and bottom edges (in horizontal writing mode) of the ideographic em-box of the font. This value will be defined for every font (including non-CJK fonts, where it can be used to em-box-align these fonts alongside CJK fonts).

The ideographic em-box of a font, also referred to as an ideographic font's design space, defines a standard monospaced escapement around the glyphs of the font, for both horizontal and vertical writing modes. This will be an em high and an em wide unless the vendor explicitly indicates otherwise in the font. The OpenType specification strongly recommends against this being other than an em wide, but there are legitimate reasons for having it be other than an em high: some fonts used in Japanese newspaper layout, for example, have a vertically compressed ideographic em-box.

See the 'ideo' Baseline tag in the OpenType tag registry for more information.

Returns
height of em-box
virtual PMRect IFontInstance::GetGlyphBBox (Text::GlyphID glyphID) const
pure virtual

Get bounding box for glyphid.

Parameters
glyphIDglyphid to get bbox for
Returns
bounding box of glyph
virtual Text::GlyphID IFontInstance::GetGlyphID (UTF32TextChar charCode) const
pure virtual

For a Unicode value get the glyphID.

Parameters
charCodeIN Unicode value to get glyphids from
Returns
glyphID for Unicode
virtual void IFontInstance::GetGlyphIDs (const WideStringtextString,
K2Vector< Text::GlyphID > & glyphIDs 
) const
pure virtual

For a widestring get the glyphIDs.

Parameters
textStringIN Unicode values to get glyphids from
glyphIDsOUT glyphIDs
virtual PMReal IFontInstance::GetGlyphWidth (Text::GlyphID glyphID) const
pure virtual

Returns the default pen displacement

The default pen displacement is sometimes called escapement or advance width. This is a simple lookup function and does not take into account things like kerning. Note that the writing direction for 'this' will effect the values returned for this function. If the writing direction is kWD_LeftToRight, the horizontal advance width is returned. If the writing direction is kWD_TopToBottom, the vertical advance height is returned. This means that if the font instance contains a rotated matrix the width returned is 0, i.e., rotated matrices are not handled by this function and a debug alert message is displayed in this case. If the font instance contains a rotated matrix then the GetWidths() function should be called.

Parameters
glyphIDglyphid to get width for
Returns
width of glyph
virtual PMReal IFontInstance::GetHorizEmBoxDepth () const
pure virtual

Returns the distance from the Roman baseline to the em-box bottom for the horizontal writing mode. This is used to calculate roman baseline offset for both horizontal and vertical text, since InDesign draws vertical text and horizontal text from the same location (the pen location is at the roman baseline).

Returns
horizontal em-box depth
virtual PMReal IFontInstance::GetHorizICFBoxDepth () const
pure virtual

Returns the distance from the Roman baseline to the ICF box bottom for the horizontal writing mode. This is used to calculate roman baseline offset for both horizontal and vertical text, since InDesign draws vertical text and horizontal text from the same location (the pen location is at the roman baseline).

Returns
horizontal ICF box depth
virtual void IFontInstance::GetICFBoxInsets (PMRealfromEmTop,
PMRealfromEmBottom 
) const
pure virtual

Calculate inset of Ideographic Character Face (ICF) box from embox. In vertical font instances, this is the left inset and right inset.

The ICF box is the maximum bounding box of the ideographic portion of a CJK font, usually centered within the em-box. Note that this value is defined also for non-CJK fonts.

The ICF box is used to size character grids to approximate the ink boundaries of each character and of the outsides of a full-justified frame.

See the 'icfb' and 'icft' Baseline tags in the OpenType tag registry for more information.

Parameters
fromEmTopdistance of ICF top from embox top
fromEmBottomdistance of ICF bottom from embox bottom
virtual void IFontInstance::GetKerns (PMRealGlyphPointglyphPoints,
int32 numGlyphs,
bool16 vertical = kFalse,
const char * scriptTag = nil,
const char * langTag = nil 
) const
pure virtual

Get kerning values for glyphids.

Parameters
glyphPointscontains glyphs to get kern values for and puts results in x and y fields
numGlyphsnumber of glyphs in glyphPoints
verticalvertical or horizontal kerning? (ie "kern" or "vkrn" opentype feature?)
scriptTagscript tag
langTaglanguage tag
virtual Text::GlyphID IFontInstance::GetNotDefinedGlyph () const
pure virtual

Glyph id for undefined glyph.

Returns
undefined glyph identifier
virtual size_t IFontInstance::GetNumDesignAxes () const
pure virtual

Returns number of design axes in case of variable font.

Returns
number of design axis in font.
virtual void IFontInstance::GetOutlineInfo (IOutlineInfocallBack,
Text::GlyphID glyphID,
PMReal xOffset,
PMReal yOffset,
int32 flags = kNormalOutlines 
) const
pure virtual

Allows the caller to get path information about a specific Glyph. IOutlineInfo is a call back class. The various methods of IOutlineInfo are called for each segment of the character path.

Parameters
callBackcallback class
glyphIDglyph for which path info is obtained
xOffsetx offset
yOffsety offset
flagsoutline iterator
virtual CTFontDict* IFontInstance::GetParentCTFontDict () const
pure virtual

Returns CTFontDict pointer for this font instance

virtual const PMMatrix& IFontInstance::GetPMMatrix () const
pure virtual

Returns PMMatrix for this font instance

virtual void IFontInstance::GetWidths (PMRealGlyphPointglyphPoints,
int32 numGlyphs 
) const
pure virtual

Returns the default pen displacements for one or more glyphs

This function is a multiple glyph version of GetGlyphWidth with the important exception that font instances that contain rotated matrices are handled correctly, i.e., the PMRealGlyphPoint's xPosition and yPosition fields are set to the x and y components, respectively, of either the horizontal advance (if the writing direction is kWD_LeftToRight) or the vertical advance (if the writing direction is kWD_TopToBottom) of each glyph. It is a simple lookup function and does not take into account things like kerning.

Parameters
glyphPointscontains glyphs to get width values for and puts results in x and y fields
numGlyphsnumber of glyphs in glyphPoints
virtual IFontMgr::WritingDirection IFontInstance::GetWritingDirection () const
pure virtual

Get WritingDirection for this font instance

virtual PMReal IFontInstance::GetXHeight () const
pure virtual

Height of small 'x' if outline of x is available. Otherwise 2/3 of bbox height.

virtual bool16 IFontInstance::HasKerningTable () const
pure virtual

Returns whether font instance has kerning table. This is not an OpenType specific call. This call will return true if the font has kerning whether it is OpenType or not.

Returns
kTrue if font instance has kerning table
virtual void IFontInstance::MeasureWText (const UTF16TextChar * text,
int32 utf16BufferLength,
PMRealxWidth,
PMRealyHeight = nil 
) const
pure virtual

Measure text using this font instance. Finds width and maximum height.

Parameters
textUnicode values to find dimensions of.
utf16BufferLengthLength of Unicode text.
xWidthOUT width of Unicode values.
yWidthOUT maximum height of Unicode values.
virtual void IFontInstance::MeasureWText (const WideStringstring,
PMRealxWidth,
PMRealyHeight = nil 
) const
pure virtual

Measure text using this font instance. Finds width and maximum height.

Parameters
stringUnicode values to find dimensions of.
xWidthOUT width of Unicode values.
yWidthOUT maximum height of Unicode values.
virtual void IFontInstance::MeasureWText (const PMStringstring,
PMRealxWidth,
PMRealyHeight = nil 
) const
pure virtual

Measure text using this font instance. Finds width and maximum height.

Parameters
stringUnicode values to find dimensions of.
xWidthOUT width of Unicode values.
yWidthOUT maximum height of Unicode values.