FontContext
in package
FinalYes
Carries font metadata needed to render custom (non-standard) fonts in form field appearance streams.
When passed to AppearanceGenerator methods, the generator will:
- Use hex-encoded glyph IDs instead of literal text strings
- Wire the font reference into the FormXObject's /Resources
Build via PdfWriter after calling addCompositeFont() / addOpenTypeFont():
$fontCtx = new FontContext(
fontRef: new PdfReference($type0Font->objectNumber),
unicodeToGid: $parsedData->fullUnicodeToGid,
);
Table of Contents
Properties
- $fontRef : PdfReference
- $unicodeToGid : array<string|int, mixed>
Methods
- __construct() : mixed
- textToHex() : string
- Convert a UTF-8 string to hex-encoded 2-byte glyph ID sequence.
Properties
$fontRef read-only
public
PdfReference
$fontRef
$unicodeToGid read-only
public
array<string|int, mixed>
$unicodeToGid
Methods
__construct()
public
__construct(PdfReference $fontRef, array<int, int> $unicodeToGid) : mixed
Parameters
- $fontRef : PdfReference
-
Indirect reference to the registered font object
- $unicodeToGid : array<int, int>
-
Unicode codepoint → glyph ID mapping
textToHex()
Convert a UTF-8 string to hex-encoded 2-byte glyph ID sequence.
public
textToHex(string $text) : string
Parameters
- $text : string