Table of contents
File: Import.php line 47
Tags
since: 2011-05-23
category: Library
author: Nicola Asuni info@tecnick.com
copyright: 2011-2026 Nicola Asuni - Tecnick.com LTD
license: https://www.gnu.org/copyleft/lesser.html GNU-LGPL v3 (see LICENSE)
phpstan-import-type: TFontData from Load
SuppressWarnings: (“PHPMD.ExcessiveClassComplexity”)
__construct() : mixed: Import the specified font and create output files.
getFontMetrics() : TFontData: Get all the extracted font metrics
getFontName() : string: Get the output font name
linkedFileName() : string: Returns the name of the symbolic link that linked mode creates for a font program.
Methods
__construct()
File: Import.php line 115
public __construct(string $file[, string $output_path = '' ][, string|FontType $type = '' ][, string $encoding = '' ][, int $flags = 32 ][, int $platform_id = 3 ][, int $encoding_id = 1 ][, bool $linked = false ][, File|null $fileHelper = null ]) : mixed
Parameters
- $file : string: Font file to process
- $output_path : string = ‘’: Output path for generated font files (must be writeable by the web server). Leave empty for the default font folder.
- $type : string|FontType = ‘’: Font type (or FontType enum case). Leave empty for autodetect mode. Valid values are: Core (AFM - Adobe Font Metrics) TrueTypeUnicode TrueType Type1 CID0JP (CID-0 Japanese) CID0KR (CID-0 Korean) CID0CS (CID-0 Chinese Simplified) CID0CT (CID-0 Chinese Traditional)
- $encoding : string = ‘’: Name of the encoding table to use. Leave empty for default mode. Omit this parameter for TrueType Unicode and symbolic fonts like Symbol or ZapfDingBats.
- $flags : int = 32: Unsigned 32-bit integer containing flags specifying various characteristics of the font as described in “PDF32000:2008 - 9.8.2 Font Descriptor Flags”: +1 for fixed width font +4 for symbol or +32 for non-symbol +64 for italic Note: Fixed and Italic mode are generally autodetected, so you have to set it to 32 = non-symbolic font (default) or 4 = symbolic font.
- $platform_id : int = 3: Platform ID for CMAP table to extract. For a Unicode font for Windows this value should be 3, for Macintosh should be 1.
- $encoding_id : int = 1: Encoding ID for CMAP table to extract. For a Unicode font for Windows this value should be 1, for Macintosh should be 0. When Platform ID is 3, legal values for Encoding ID are: 0 = Symbol, 1 = Unicode, 2 = ShiftJIS, 3 = PRC, 4 = Big5, 5 = Wansung, 6 = Johab, 7 = Reserved, 8 = Reserved, 9 = Reserved, 10 = UCS-4.
- $linked : bool = false: If true, links the font file to system font instead of copying the font data (not transportable). This option is unsupported for Type1 fonts.
- $fileHelper : File|null = null: Optional file helper for font loading.
Tags
- throws: Exception in case of error
- throws: Exception in case of error
getFontMetrics()
File: Import.php line 292
public getFontMetrics() : TFontData
Return values
getFontName()
File: Import.php line 300
public getFontName() : string
Return values
linkedFileName()
File: Import.php line 262
public static linkedFileName(string $fileName, string $inputFile) : string
The extension of the input file is carried over, reduced to lowercase alphanumeric characters: it ends up both on the filesystem and, unescaped, inside the hand-built JSON of the definition file.
Shared by Import, which removes this artifact when the import fails, and TrueType, which creates it.
Parameters
- $fileName : string: Sanitized font name stem.
- $inputFile : string: Path of the input font file.
Return values
string