Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for other cmap formats (only format 4 is supported) #40

Open
oxygen opened this issue Feb 7, 2016 · 3 comments
Open

Add support for other cmap formats (only format 4 is supported) #40

oxygen opened this issue Feb 7, 2016 · 3 comments

Comments

@oxygen
Copy link

oxygen commented Feb 7, 2016

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
                        (

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/30615912-add-support-for-other-cmap-formats-only-format-4-is-supported?utm_campaign=plugin&utm_content=tracker%2F317728&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F317728&utm_medium=issues&utm_source=github).
@oxygen
Copy link
Author

oxygen commented Feb 7, 2016

I think you might need to set error reporting to E_STRICT (or -1).

@PhenX
Copy link
Member

PhenX commented Feb 13, 2016

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

@PhenX PhenX changed the title DroidSansJapanese.ttf - Invalid argument supplied for foreach() Add support for other cmap formats (only format 4 is supported) Feb 14, 2016
chumanfu added a commit to chumanfu/php-font-lib that referenced this issue Sep 5, 2017
PhenX added a commit that referenced this issue Sep 13, 2017
Implement form 12 cmap. Issue #40
@bsweeney
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants