[sfnt/CPAL] Return early if user requested currently-set palette
Before, we were loading a palette (again and again) even if the same was requested. Even if the font only had one palette... For a font like NotoColorEmoji that has over 5000 colors in its palette, this was dominating the COLRv1 loading times for HarfBuzz (and I believe all other clients) because they have to set the palette to get access to the colors. * src/base/ftcolor.c (FT_Palette_Select): Check the current palette.
This commit is contained in:
parent
b1f4785087
commit
d0c905c62a
|
@ -56,9 +56,7 @@
|
|||
FT_Color* *apalette )
|
||||
{
|
||||
FT_Error error;
|
||||
|
||||
TT_Face ttface;
|
||||
SFNT_Service sfnt;
|
||||
TT_Face ttface = (TT_Face)face;
|
||||
|
||||
|
||||
if ( !face )
|
||||
|
@ -72,14 +70,17 @@
|
|||
return FT_Err_Ok;
|
||||
}
|
||||
|
||||
ttface = (TT_Face)face;
|
||||
sfnt = (SFNT_Service)ttface->sfnt;
|
||||
if ( palette_index != ttface->palette_index )
|
||||
{
|
||||
SFNT_Service sfnt = (SFNT_Service)ttface->sfnt;
|
||||
|
||||
error = sfnt->set_palette( ttface, palette_index );
|
||||
if ( error )
|
||||
return error;
|
||||
|
||||
ttface->palette_index = palette_index;
|
||||
error = sfnt->set_palette( ttface, palette_index );
|
||||
if ( error )
|
||||
return error;
|
||||
|
||||
ttface->palette_index = palette_index;
|
||||
}
|
||||
|
||||
if ( apalette )
|
||||
*apalette = ttface->palette;
|
||||
|
|
Loading…
Reference in New Issue