Font constructor
Implementation
Font(Map<String, dynamic> options) {
this.options = FontOption(options);
this.options.tables = options["tables"] ?? {};
if (!options["empty"]) {
// Check that we've provided the minimum set of names.
// checkArgument(options.familyName, 'When creating a new Font object, familyName is required.');
// checkArgument(options.styleName, 'When creating a new Font object, styleName is required.');
// checkArgument(options.unitsPerEm, 'When creating a new Font object, unitsPerEm is required.');
// checkArgument(options.ascender, 'When creating a new Font object, ascender is required.');
// checkArgument(options.descender <= 0, 'When creating a new Font object, negative descender value is required.');
// OS X will complain if the names are empty, so we put a single space everywhere by default.
this.names = {
"fontFamily": {"en": options["familyName"] ?? ' '},
"fontSubfamily": {"en": options["styleName"] ?? ' '},
"fullName": {"en": options["fullName"] ?? options["familyName"] + ' ' + options["styleName"]},
// postScriptName may not contain any whitespace
"postScriptName": {"en": options["postScriptName"] ?? (options["familyName"] + options["styleName"]).replaceAll(RegExp("\s"), '')},
"designer": {"en": options["designer"] ?? ' '},
"designerURL": {"en": options["designerURL"] ?? ' '},
"manufacturer": {"en": options["manufacturer"] ?? ' '},
"manufacturerURL": {"en": options["manufacturerURL"] ?? ' '},
"license": {"en": options["license"] ?? ' '},
"licenseURL": {"en": options["licenseURL"] ?? ' '},
"version": {"en": options["version"] ?? 'Version 0.1'},
"description": {"en": options["description"] ?? ' '},
"copyright": {"en": options["copyright"] ?? ' '},
"trademark": {"en": options["trademark"] ?? ' '}
};
this.unitsPerEm = options["unitsPerEm"] ?? 1000;
this.ascender = options["ascender"];
this.descender = options["descender"];
this.createdTimestamp = options["createdTimestamp"];
Map<String, dynamic> _os2 = {
"usWeightClass": options["weightClass"] ?? this.usWeightClasses.MEDIUM,
"usWidthClass": options["widthClass"] ?? this.usWidthClasses.MEDIUM,
"fsSelection": options["fsSelection"] ?? this.fsSelectionValues.REGULAR,
};
_os2.addAll(this.options.tables["os2"]);
Map<String, dynamic> _tables = {
"os2": _os2
};
this.options.tables.addAll(_tables);
this.tables = this.options.tables;
}
this.glyphs = GlyphSet(this, options["glyphs"] ?? []);
this.encoding = new DefaultEncoding(this);
this.position = new Position(this);
// this.substitution = new Substitution(this);
// needed for low memory mode only.
this._push = null;
this._hmtxTableData = {};
}