PdfContentFont class
Font information sufficient to turn Tj/TJ bytes into text and widths.
Honesty about the reach
- with
/ToUnicodepresent, the text comes out right, subsetted Type0 included; - without
/ToUnicode, simple fonts fall back to WinAnsi/latin-1, which gets ordinary Western documents right and any exotic encoding wrong; - without
/ToUnicode, a subsetted Type0 font is undecipherable: the codes are arbitrary glyph indices. In that case the characters come out as�and PdfContentGlyph.mapped isfalse. There is no way around this without reading thecmaptable of the embedded font file, which is out of scope here; /Encodingwith/Differencesis only honored foruniXXXXnames,uXXXXnames with four or more hex digits, and the names of the standard Latin set;- Type3 is not handled: the font's own matrix is ignored and the widths come out wrong.
Constructors
-
PdfContentFont({String? resourceName, String? baseFont, String? subtype, bool composite = false, int codeByteLength = 1, Map<
int, String> ? toUnicode, Map<int, String> ? differences, bool winAnsi = true, int firstChar = 0, List<double> ? widths, Map<int, double> ? cidWidths, double? defaultWidth, double? missingWidth}) - Creates the description of a font.
Properties
- baseFont → String?
-
/BaseFont.final -
cidWidths
→ Map<
int, double> -
Per-CID widths of a composite font (
/W).final - codeByteLength → int
-
How many bytes each code takes up (1 or 2).
final
- composite → bool
-
truefor Type0 (multi-byte codes).final - defaultWidth → double
-
/DWof a composite font, or the guess used when there is no/Widths.final -
differences
→ Map<
int, String> -
Map coming from
/Encoding /Differences, code → text.final - firstChar → int
-
/FirstCharof a simple font.final - hashCode → int
-
The hash code for this object.
no setterinherited
- hasReliableTextMapping → bool
-
truewhen the text mapping is reliable for any code.no setter - missingWidth → double?
-
/MissingWidthof the descriptor, when declared.final - resourceName → String?
-
Resource name on the page (
/F1), when known.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- subtype → String?
-
/Subtype(/Type1,/TrueType,/Type0,/Type3).final -
toUnicode
→ Map<
int, String> -
/ToUnicodemap, code → text.final -
widths
→ List<
double> -
/Widthsof a simple font, in thousandths of an em.final - winAnsi → bool
-
truewhen/Encodingis WinAnsi (or absent, which is the common case).final
Methods
-
decode(
Uint8List bytes) → List< PdfContentGlyph> - Decodes the bytes of a text string into glyphs.
-
decodeText(
Uint8List bytes) → String - Text matching a content string.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
widthOf(
int code) → double -
Width of code
codein thousandths of an em.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Methods
-
decodeUtf16Be(
Uint8List bytes) → String -
Converts UTF-16BE bytes (the format of
/ToUnicodedestinations) into text, respecting surrogate pairs. -
glyphNameToText(
String name) → String? - Translates a glyph name into text.
-
parseToUnicode(
Uint8List bytes) → PdfToUnicodeCMap -
Reads an already decompressed
/ToUnicodeCMap. -
unknown(
[String? resourceName]) → PdfContentFont - Generic font used when the resource could not be resolved.