2018-06-10 09:12:24 +02:00
|
|
|
/****************************************************************************
|
|
|
|
*
|
|
|
|
* ftcolor.c
|
|
|
|
*
|
|
|
|
* FreeType's glyph color management (body).
|
|
|
|
*
|
2021-01-17 07:18:48 +01:00
|
|
|
* Copyright (C) 2018-2021 by
|
2018-06-10 09:12:24 +02:00
|
|
|
* David Turner, Robert Wilhelm, and Werner Lemberg.
|
|
|
|
*
|
|
|
|
* This file is part of the FreeType project, and may only be used,
|
|
|
|
* modified, and distributed under the terms of the FreeType project
|
|
|
|
* license, LICENSE.TXT. By continuing to use, modify, or distribute
|
|
|
|
* this file you indicate that you have read the license and
|
|
|
|
* understand and accept it fully.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
2020-06-08 13:31:55 +02:00
|
|
|
#include <freetype/internal/ftdebug.h>
|
|
|
|
#include <freetype/internal/sfnt.h>
|
|
|
|
#include <freetype/internal/tttypes.h>
|
|
|
|
#include <freetype/ftcolor.h>
|
2018-06-10 09:12:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
#ifdef TT_CONFIG_OPTION_COLOR_LAYERS
|
|
|
|
|
|
|
|
static
|
2018-06-10 21:37:15 +02:00
|
|
|
const FT_Palette_Data null_palette_data = { 0, NULL, NULL, 0, NULL };
|
2018-06-10 09:12:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* documentation is in ftcolor.h */
|
|
|
|
|
|
|
|
FT_EXPORT_DEF( FT_Error )
|
2018-06-10 21:37:15 +02:00
|
|
|
FT_Palette_Data_Get( FT_Face face,
|
|
|
|
FT_Palette_Data *apalette_data )
|
2018-06-10 09:12:24 +02:00
|
|
|
{
|
|
|
|
if ( !face )
|
|
|
|
return FT_THROW( Invalid_Face_Handle );
|
2018-06-10 21:37:15 +02:00
|
|
|
if ( !apalette_data)
|
2018-06-10 09:12:24 +02:00
|
|
|
return FT_THROW( Invalid_Argument );
|
|
|
|
|
|
|
|
if ( FT_IS_SFNT( face ) )
|
2018-06-10 21:37:15 +02:00
|
|
|
*apalette_data = ( (TT_Face)face )->palette_data;
|
2018-06-10 09:12:24 +02:00
|
|
|
else
|
2018-06-10 21:37:15 +02:00
|
|
|
*apalette_data = null_palette_data;
|
2018-06-10 09:12:24 +02:00
|
|
|
|
|
|
|
return FT_Err_Ok;
|
|
|
|
}
|
|
|
|
|
2018-06-12 06:02:59 +02:00
|
|
|
|
|
|
|
/* documentation is in ftcolor.h */
|
|
|
|
|
|
|
|
FT_EXPORT_DEF( FT_Error )
|
|
|
|
FT_Palette_Select( FT_Face face,
|
|
|
|
FT_UShort palette_index,
|
|
|
|
FT_Color* *apalette )
|
|
|
|
{
|
|
|
|
FT_Error error;
|
|
|
|
|
|
|
|
TT_Face ttface;
|
|
|
|
SFNT_Service sfnt;
|
|
|
|
|
|
|
|
|
|
|
|
if ( !face )
|
|
|
|
return FT_THROW( Invalid_Face_Handle );
|
|
|
|
|
|
|
|
if ( !FT_IS_SFNT( face ) )
|
|
|
|
{
|
|
|
|
if ( apalette )
|
|
|
|
*apalette = NULL;
|
|
|
|
|
|
|
|
return FT_Err_Ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
ttface = (TT_Face)face;
|
|
|
|
sfnt = (SFNT_Service)ttface->sfnt;
|
|
|
|
|
|
|
|
error = sfnt->set_palette( ttface, palette_index );
|
|
|
|
if ( error )
|
|
|
|
return error;
|
|
|
|
|
|
|
|
ttface->palette_index = palette_index;
|
|
|
|
|
|
|
|
if ( apalette )
|
|
|
|
*apalette = ttface->palette;
|
|
|
|
|
|
|
|
return FT_Err_Ok;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* documentation is in ftcolor.h */
|
|
|
|
|
|
|
|
FT_EXPORT_DEF( FT_Error )
|
|
|
|
FT_Palette_Set_Foreground_Color( FT_Face face,
|
|
|
|
FT_Color foreground_color )
|
|
|
|
{
|
|
|
|
TT_Face ttface;
|
|
|
|
|
|
|
|
|
|
|
|
if ( !face )
|
|
|
|
return FT_THROW( Invalid_Face_Handle );
|
|
|
|
|
|
|
|
if ( !FT_IS_SFNT( face ) )
|
|
|
|
return FT_Err_Ok;
|
|
|
|
|
|
|
|
ttface = (TT_Face)face;
|
|
|
|
|
|
|
|
ttface->foreground_color = foreground_color;
|
|
|
|
ttface->have_foreground_color = 1;
|
|
|
|
|
|
|
|
return FT_Err_Ok;
|
|
|
|
}
|
|
|
|
|
2018-06-10 09:12:24 +02:00
|
|
|
#else /* !TT_CONFIG_OPTION_COLOR_LAYERS */
|
|
|
|
|
|
|
|
FT_EXPORT_DEF( FT_Error )
|
2018-06-10 21:37:15 +02:00
|
|
|
FT_Palette_Data_Get( FT_Face face,
|
|
|
|
FT_Palette_Data *apalette_data )
|
2018-06-10 09:12:24 +02:00
|
|
|
{
|
|
|
|
FT_UNUSED( face );
|
2018-06-23 17:25:58 +02:00
|
|
|
FT_UNUSED( apalette_data );
|
2018-06-10 09:12:24 +02:00
|
|
|
|
|
|
|
|
|
|
|
return FT_THROW( Unimplemented_Feature );
|
|
|
|
}
|
|
|
|
|
2018-06-12 06:02:59 +02:00
|
|
|
|
|
|
|
FT_EXPORT_DEF( FT_Error )
|
|
|
|
FT_Palette_Select( FT_Face face,
|
|
|
|
FT_UShort palette_index,
|
|
|
|
FT_Color* *apalette )
|
|
|
|
{
|
|
|
|
FT_UNUSED( face );
|
|
|
|
FT_UNUSED( palette_index );
|
|
|
|
FT_UNUSED( apalette );
|
|
|
|
|
|
|
|
|
|
|
|
return FT_THROW( Unimplemented_Feature );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
FT_EXPORT_DEF( FT_Error )
|
|
|
|
FT_Palette_Set_Foreground_Color( FT_Face face,
|
|
|
|
FT_Color foreground_color )
|
|
|
|
{
|
|
|
|
FT_UNUSED( face );
|
|
|
|
FT_UNUSED( foreground_color );
|
2018-07-05 23:13:35 +02:00
|
|
|
|
|
|
|
|
|
|
|
return FT_THROW( Unimplemented_Feature );
|
2018-06-12 06:02:59 +02:00
|
|
|
}
|
|
|
|
|
2018-06-10 09:12:24 +02:00
|
|
|
#endif /* !TT_CONFIG_OPTION_COLOR_LAYERS */
|
|
|
|
|
|
|
|
|
|
|
|
/* END */
|