php-font-lib
php-font-lib copied to clipboard
Add support for other `cmap` formats (only format 4 is supported)
https://github.com/google/fonts/tree/master/apache/droidsansjapanese
My code:
$fontFile=\FontLib\Font::load("DroidSansJapanese.ttf");
$fontFile->parse();
$fontFile->setSubset("DroidSansJapanese");
$fontFile->reduce();
$fontFile->open($tmp, FontLib\BinaryStream::modeWrite);
$fontFile->encode(array("OS/2"));
$fontFile->close();
50MB stack trace, didn't include it all:
Invalid argument supplied for foreach()
Array
(
[0] => Array
(
[file] => /mnt/autofs/ExportVHosts/adrese.kakao.ro/PHPFontLib/src/FontLib/Table/Type/cmap.php
[line] => 129
[function] => {closure}
[args] => Array
(
[0] => 2
[1] => Invalid argument supplied for foreach()
[2] => /mnt/autofs/ExportVHosts/adrese.kakao.ro/PHPFontLib/src/FontLib/Table/Type/cmap.php
[3] => 129
[4] => Array
(
I think you might need to set error reporting to E_STRICT (or -1).
This issue is related to cmap
version used in this font. Its format is 12, while the lib only supports the version 4 (see the spec), section "Format 12: Segmented coverage". The code is here : https://github.com/PhenX/php-font-lib/blob/master/src/FontLib/Table/Type/cmap.php#L56
Note: formats 2, 4, and 12 are currently supported. I'll look to implement other formats as samples are provided that use them.
Tracking general TrueType support in #123.