XPS keeps text exactly as laid out: each Glyphs element names a font in
the package, a size and a starting point, and may give every glyph’s index and
position. The Unicode text is kept alongside, for searching and copying.
Glyphs attributes
| Attribute | Meaning |
|---|---|
FontUri | Required: the font part. A #n fragment picks a face in a TrueType collection. |
FontRenderingEmSize | Required: the em size in page units (1/96 inch), so 16 is 12 points. |
OriginX, OriginY | Required: the baseline origin of the first glyph. |
UnicodeString | The text. A value starting with { must begin with {}, which is removed. At least one of UnicodeString and Indices is required. |
Indices | Glyph indices, advances and offsets: see below. |
BidiLevel | 0 to 61: even for left-to-right, odd for right-to-left runs. |
IsSideways | true: glyphs are turned for vertical text. |
StyleSimulations | None, ItalicSimulation, BoldSimulation, BoldItalicSimulation: synthesised styles for fonts that lack them. |
CaretStops | Where a caret may stop within clusters, as a string of hex digits (bits). |
DeviceFontName | A printer font to use instead, if the device has it. |
Fill | A brush for the glyphs. |
Glyphs also take the shared attributes (RenderTransform,
Clip, Opacity, OpacityMask, Name,
FixedPage.NavigateUri, xml:lang).
The Indices syntax
A list of glyph mappings separated by ;, one per glyph, matched in order
with the characters of UnicodeString:
GlyphMapping = [ "(" ClusterCodeUnitCount [ ":" ClusterGlyphCount ] ")" ] [ GlyphIndex ]
[ "," AdvanceWidth [ "," uOffset [ "," vOffset ] ] ]
| Part | Meaning |
|---|---|
| Cluster | How many UTF-16 code units and how many glyphs belong together, for ligatures and combining marks; default 1:1. |
| GlyphIndex | The glyph number in the font; if missing, found from the character through the font’s cmap. |
| AdvanceWidth | How far to move after the glyph, in hundredths of the em size; if missing, the font’s own advance. |
| uOffset, vOffset | Shift of the glyph along and across the baseline, in hundredths of the em size. |
Example: Indices=";;,50;(2:1)213" — the first two characters use
default glyphs and advances, the third has an advance of half an em, and the next two
characters form one glyph, 213 (a ligature).
Fonts and obfuscation
Fonts are TrueType or OpenType files (and collections) stored as parts, often
subset to the glyphs used. A font may be stored plainly
(application/vnd.ms-opentype) or obfuscated
(application/vnd.ms-package.obfuscated-opentype, extension
.odttf), which stops it being copied out as an installable file. Fonts
whose licence allows only preview and print embedding must be obfuscated and linked
from the FixedDocument with the restricted-font relationship, and the
document may then not be edited; editable and no-subsetting fonts must be obfuscated
too, and restricted-licence fonts may not be embedded at all.
To deobfuscate, the last segment of the part name, without its extension, must be
a GUID written without braces, such as
/Resources/Fonts/6B8C2D91-1F0A-4E3B-9C5D-7E2F0A1B3C4D.odttf (the
recommended extensions are .odttf, and .odttc for
collections):
- Take the 32 hexadecimal digits of the GUID in the order written, ignoring the hyphens, and turn each pair into a byte: a 16-byte key, key[0] to key[15].
- For i from 0 to 15: XOR font byte i and font byte i + 16 with key[15 − i].
- The rest of the file is unchanged. Obfuscating is the same operation.
Only the first 32 bytes, the font’s table directory start, are changed, so the font cannot be loaded until it is undone.
Images and colour profiles
| Format | Content type | Notes |
|---|---|---|
| JPEG | image/jpeg | ITU-T T.81 data; JFIF and the Exif APP1 marker are supported, ICC profiles in APP2. |
| PNG | image/png | Conforming to the PNG specification, with a table of the ancillary chunks consumers support. |
| TIFF | image/tiff | Baseline TIFF 6.0 with some extensions, including CMYK, extra (alpha) samples and JPEG compression. |
| HD Photo (Windows Media Photo) | image/vnd.ms-photo | Later standardised as JPEG XR. |
| ICC profile | application/vnd.ms-color.iccprofile | Used by ContextColor and ColorConvertedBitmap. |
Images are painted only through ImageBrush; XPS has no image element.
A usable profile associated through ColorConvertedBitmap overrides one
embedded in the image; otherwise a usable embedded profile is used.
Sources
- ECMA-388 – Open XML Paper Specification, first edition (2009): §12 the
Glyphselement andIndicessyntax, §9.1.7 font parts, embedding rights and obfuscation, §9.1.5 image parts, §15.3.7 image colour profiles, annex D content types