What is Indices attribute in Glyphs tag in the XPs document
The XPS specification says Glyphs tag is used for displaying the text, and it has a attribute called Indices which holds a encoded string.
Is this tag mandatory?
Does this string directly maps to the text in the Glyphs tag ?
If yes how is this string generated ?
Is it UTF16 representation of the text?
-Parag
Indices Attribute The <Glyphs> element MAY have an Indices attribute. The glyph specifications within the Indices attribute are OPTIONAL. The GlyphIndex portion of the Indices attribute MAY be used to specify a series of glyphs, complex character-to-glyph cluster mappings, or a combination of both. The Indices attribute MAY also include glyph placement information.
Within the Indices attribute, each glyph specification is separated by a semicolon. The Indices attribute MUST adhere to the glyph specification syntax as follows:
GlyphIndices = *1GlyphMapping *( ";" *1GlyphMapping )
GlyphMapping = *1([ClusterMapping] GlyphIndex) [GlyphMetrics]
ClusterMapping = "(" ClusterCodeUnitCount [":" ClusterGlyphCount] ")" ClusterCodeUnitCount = 1*DIGIT
ClusterGlyphCount = 1*DIGIT
GlyphIndex = *DIGIT
GlyphMetrics = "," *1AdvanceWidth ["," *1uOffset ["," vOffset]]
AdvanceWidth = ["+"] RealNum
uOffset = ["+" | "-"] RealNum
vOffset = ["+" | "-"] RealNum
RealNum = ((1*DIGIT ["." 1*DIGIT]) | ("." 1*DIGIT)) [Exponent]
Exponent = *1( ("E"|"e") ("+"|"-") 1*DIGIT )
The sum of the code unit counts for all the GlyphMapping entries in the Indices attribute MUST NOT exceed the number of UTF-16 code units in the UnicodeString attribute if the UnicodeString attribute is specified and does not contain an empty value (“” or “{}”). If a ClusterMapping is not specified within a GlyphMapping entry, the code unit count is 1. If the Indices attribute specifies a GlyphIndex that does not exist in the font, the consumer MUST generate an error. If the Indices attribute is specified, the values provided MUST be used in preference to values determined from the UnicodeString attribute alone.
GlyphIndex:
Index of the glyph (16-bit) in the physical font. The entry MAY be empty, in which case the glyph index is determined by looking up the UTF-16 code unit in the font character map table. If there is not a one-to-one mapping between code units and the glyph indices, this entry MUST be specified. In cases where character-to-glyph mappings are not one-to-one, a cluster mapping specification precedes the glyph index (further described below).
AdvanceWidth:
Advance width indicating placement for the subsequent glyph, relative to the origin of the current glyph. Measured in direction of advance as defined by the IsSideways and BidiLevel attributes. Base glyphs generally have a non-zero advance width and combining glyphs have a zero advance width. Advance width is measured in hundredths of the font em size. The default value is defined in the horizontal metrics font table (hmtx) if the IsSideways attribute is specified as false or the vertical metrics font table (vmtx) if the IsSideways attribute is specified as true. Advance width is a real number with units specified in hundredths of an em. So that rounding errors do not accumulate, the advance MUST be calculated as the exact unrounded origin of the subsequent glyph minus the sum of the calculated (that is, rounded) advance widths of the preceding glyphs. The advance MUST be 0 or greater. The right-to-left writing direction can be specified using the BidiLevel attribute.
uOffset, vOffset:
Offset in the effective coordinate space relative to glyph origin to move this glyph (x offset for uOffset and –y offset for vOffset. The sign of vOffset is reversed from the direction of the y axis. A positive vOffset value shifts the glyph by a negative y offset and vice versa.). Used to attach marks to base characters. The value is added to the nominal glyph origin calculated using the advance width to generate the actual origin for the glyph. The setting of the IsSideways attribute does not change the interpretation of uOffset and vOffset. Measured in hundredths of the font em size. The default offset values are 0.0,0.0. uOffset and vOffset are real numbers. Base glyphs generally have a glyph offset of 0.0,0.0. Combining glyphs generally have an offset that places them correctly on top of the nearest preceding base glyph. For left-to-right text, a positive uOffset value points to the right; for right-to-left text, a positive uOffset value points to the left.
Using indices to specify advance width:
The following Indices attribute specifies that the seventh glyph in the Unicode string has an advance width of 40: Indices = ";;;;;;,40"