emscripten-ports / FreeType

6 stars 6 forks source link

Emscripten's FreeType fails to open NotoColorEmoji with "unknown file format" #3

Open albertvaka opened 3 years ago

albertvaka commented 3 years ago

Google Noto is a family of free fonts. Within it, NotoColorEmoji contains all emojis, but no regular characters. It can be downloaded from the official site: https://www.google.com/get/noto/

Emscripten's port of FreeType fails to read NotoColorEmoji, but the same code works compiled natively.

Test program:

#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_ERRORS_H
int main() {
    FT_Library ft;
    FT_Face ftface;
    FT_Error fterr;
    fterr = FT_Init_FreeType(&ft);
    if (fterr) {
        printf("FT_Init_FreeType: %s\n", GetErrorString(fterr));
        return;
    }
    fterr = FT_New_Face(ft, "data/NotoColorEmoji.ttf", 0, &ftface);
    if (fterr) {
        printf("FT_New_Face: %s\n", GetErrorString(fterr));
        return;
    }
}

Output:

FT_New_Face: unknown file format
HinTak commented 2 years ago

It is just that 2.6 is very old and before support for colour fonts (which emoji's are).

albertvaka commented 2 years ago

According to https://freetype.org/ "color embedded bitmaps" are supported since 2.5, though.

HinTak commented 2 years ago

Hmm, somehow my reply didn't make it - anyway, there are 4 colour font formats in total, one from each of Apple, Microsoft, Google, and Adobe + Mozilla . FreeType 2.5 was likely the first version when one of the four first appeared! As far as I know the last one was still being improved as of 2.12 .

HinTak commented 2 years ago

There are 4 different colour font formats - one from each of Microsoft, apple, Google, Mozilla/Adobe. Freetype 2.5 was likely the beginning of it. Support for the last one is still being improved as of 2.12 - I filed/posted some related issue to the last one recently with the freetype devel, only a week or two ago.

HinTak commented 2 years ago

I thought I commented elsewhere - see also https://github.com/rougier/freetype-py/issues/154 - some of the colour font formats requires libpng . It is an optional dependency of freetype: without it, a few font formats don't work.