summaryrefslogtreecommitdiff
path: root/src/base/ftcolor.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/base/ftcolor.c')
-rw-r--r--src/base/ftcolor.c131
1 files changed, 130 insertions, 1 deletions
diff --git a/src/base/ftcolor.c b/src/base/ftcolor.c
index 0edf379b4..d769c9627 100644
--- a/src/base/ftcolor.c
+++ b/src/base/ftcolor.c
@@ -36,7 +36,7 @@
{
if ( !face )
return FT_THROW( Invalid_Face_Handle );
- if ( !apalette_data)
+ if ( !apalette_data )
return FT_THROW( Invalid_Argument );
if ( FT_IS_SFNT( face ) )
@@ -91,6 +91,57 @@
/* documentation is in ftcolor.h */
FT_EXPORT_DEF( FT_Error )
+ FT_Palette_Set( FT_Face face,
+ FT_Int index,
+ FT_Color* palette )
+ {
+ TT_Face ttface;
+ FT_UShort i;
+
+
+ if ( !face || !FT_IS_SFNT( face ) )
+ return FT_THROW( Invalid_Face_Handle );
+
+ if ( !palette || index >= 0 )
+ return FT_THROW( Invalid_Argument );
+
+ ttface = (TT_Face)face;
+
+ for ( i = 0; i < ttface->palette_data.num_palette_entries; i++ )
+ ttface->palette[i] = palette[i];
+ ttface->palette_index = index;
+
+ return FT_Err_Ok;
+ }
+
+
+ /* documentation is in ftcolor.h */
+
+ FT_EXPORT_DEF( FT_Error )
+ FT_Palette_Get( FT_Face face,
+ FT_Int *anindex,
+ FT_Color* *apalette )
+ {
+ TT_Face ttface;
+
+
+ if ( !face || !FT_IS_SFNT( face ) )
+ return FT_THROW( Invalid_Face_Handle );
+
+ ttface = (TT_Face)face;
+
+ if ( anindex )
+ *anindex = ttface->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 )
{
@@ -111,6 +162,44 @@
return FT_Err_Ok;
}
+
+ /* documentation is in ftcolor.h */
+
+ FT_EXPORT_DEF( FT_Error )
+ FT_Palette_Get_Foreground_Color( FT_Face face,
+ FT_Color* aforeground_color )
+ {
+ TT_Face ttface;
+
+ FT_Color white = { 0xFF, 0xFF, 0xFF, 0xFF };
+ FT_Color black = { 0x00, 0x00, 0x00, 0xFF };
+
+
+ if ( !face || !FT_IS_SFNT( face ) )
+ return FT_THROW( Invalid_Face_Handle );
+
+ if ( !aforeground_color )
+ return FT_THROW( Invalid_Argument );
+
+ ttface = (TT_Face)face;
+
+ if ( ttface->have_foreground_color )
+ *aforeground_color = ttface->foreground_color;
+ else if ( ttface->palette_index < 0 )
+ *aforeground_color = black;
+ else
+ {
+ if ( ttface->palette_data.palette_flags &&
+ ( ttface->palette_data.palette_flags[ttface->palette_index] &
+ FT_PALETTE_FOR_DARK_BACKGROUND ) )
+ *aforeground_color = white;
+ else
+ *aforeground_color = black;
+ }
+
+ return FT_Err_Ok;
+ }
+
#else /* !TT_CONFIG_OPTION_COLOR_LAYERS */
FT_EXPORT_DEF( FT_Error )
@@ -140,6 +229,34 @@
FT_EXPORT_DEF( FT_Error )
+ FT_Palette_Set( FT_Face face,
+ FT_Int index,
+ FT_Color* palette )
+ {
+ FT_UNUSED( face );
+ FT_UNUSED( index );
+ FT_UNUSED( palette );
+
+
+ return FT_THROW( Unimplemented_Feature );
+ }
+
+
+ FT_EXPORT_DEF( FT_Error )
+ FT_Palette_Get( FT_Face face,
+ FT_Int *anindex,
+ FT_Color* *apalette )
+ {
+ FT_UNUSED( face );
+ FT_UNUSED( anindex );
+ 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 )
{
@@ -150,6 +267,18 @@
return FT_THROW( Unimplemented_Feature );
}
+
+ FT_EXPORT_DEF( FT_Error )
+ FT_Palette_Get_Foreground_Color( FT_Face face,
+ FT_Color* aforeground_color )
+ {
+ FT_UNUSED( face );
+ FT_UNUSED( aforeground_color );
+
+
+ return FT_THROW( Unimplemented_Feature );
+ }
+
#endif /* !TT_CONFIG_OPTION_COLOR_LAYERS */