ot-svg svg-hooks cannot be disabled when font have alternatives
Windows version: Windows 11 22H2 (Build 22621.1702)
FreeType version: 2.13.0-1 (on MSYS2, UCRT64)
When using FreeType to open and render Noto Color Emojis, FreeType insists on using SVG, even when svg-hooks are unset and COLR is available.
Font file: NotoColorEmoji-Regular.ttf
Example code:
#include <ft2build.h>
#include FT_FREETYPE_H
#include FT_TRUETYPE_TABLES_H
#include FT_MODULE_H
#include FT_OTSVG_H
int main()
{
FT_Library lib;
FT_Face face;
FT_Error err;
FT_ULong len;
SVG_RendererHooks hooks = {
NULL,
NULL,
NULL,
NULL
};
FT_Init_FreeType(&lib);
// try to disable SVG hooks by setting it to NULL
FT_Property_Set(lib, "ot-svg", "svg-hooks", &hooks);
if ( (err = FT_New_Face(lib, "NotoColorEmoji-Regular.ttf", 0, &face)) )
{
printf("FT_New_Face(): %d\n",err);
return -1;
}
printf("font has color: %d\n", FT_HAS_COLOR(face));
printf("Bitmap strides: %d\n", face->num_fixed_sizes);
len = 0;
if ( (err = FT_Load_Sfnt_Table(face, FT_MAKE_TAG('C', 'B', 'D', 'T'), 0, NULL, &len)) )
{
if ( err == FT_Err_Table_Missing )
{
printf("NO CBDT\n");
}
else
{
printf("FT_Load_Sfnt_Table(CBDT): %ld\n", err);
return -1;
}
}
else
{
printf("CBDT: %d\n", len);
}
len = 0;
if ( (err = FT_Load_Sfnt_Table(face, FT_MAKE_TAG('C', 'O', 'L', 'R'), 0, NULL, &len)) )
{
if ( err == FT_Err_Table_Missing )
{
printf("NO COLR\n");
}
else
{
printf("FT_Load_Sfnt_Table(COLR): %ld\n", err);
return -1;
}
}
else
{
printf("COLR: %d\n", len);
}
if ( (err = FT_Set_Pixel_Sizes(face, 0, 20)) )
{
printf("FT_Set_Pixel_Sizes(): %d\n",err);
return -1;
}
if ( (err = FT_Load_Char(face, 0x2744, FT_LOAD_DEFAULT | FT_LOAD_COLOR | FT_LOAD_RENDER) ) )
{
printf("FT_Load_Char(): %d\n", err);
return -1;
}
printf("Height %d\n", face->glyph->metrics.height / 64);
return 0;
}
This produces the following result:
font has color: 1
Bitmap strides: 0
NO CBDT
COLR: 1095153
FT_Load_Char(): 158
FreeType didn't load the bitmap strides, but detects COLR. However, when rendering, it tries to use svg-hooks and fails.