Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
8298974: Add ftcolor.c to imported freetype sources
Backport-of: 05f9e7676ea457cd5ef44acca9a1706b5dd0d093
- Loading branch information
1 parent
5021a07
commit 9b89523
Showing
1 changed file
with
156 additions
and
0 deletions.
There are no files selected for viewing
156 changes: 156 additions & 0 deletions
156
src/java.desktop/share/native/libfreetype/src/base/ftcolor.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,156 @@ | ||
/**************************************************************************** | ||
* | ||
* ftcolor.c | ||
* | ||
* FreeType's glyph color management (body). | ||
* | ||
* Copyright (C) 2018-2022 by | ||
* 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. | ||
* | ||
*/ | ||
|
||
|
||
#include <freetype/internal/ftdebug.h> | ||
#include <freetype/internal/sfnt.h> | ||
#include <freetype/internal/tttypes.h> | ||
#include <freetype/ftcolor.h> | ||
|
||
|
||
#ifdef TT_CONFIG_OPTION_COLOR_LAYERS | ||
|
||
static | ||
const FT_Palette_Data null_palette_data = { 0, NULL, NULL, 0, NULL }; | ||
|
||
|
||
/* documentation is in ftcolor.h */ | ||
|
||
FT_EXPORT_DEF( FT_Error ) | ||
FT_Palette_Data_Get( FT_Face face, | ||
FT_Palette_Data *apalette_data ) | ||
{ | ||
if ( !face ) | ||
return FT_THROW( Invalid_Face_Handle ); | ||
if ( !apalette_data) | ||
return FT_THROW( Invalid_Argument ); | ||
|
||
if ( FT_IS_SFNT( face ) ) | ||
*apalette_data = ( (TT_Face)face )->palette_data; | ||
else | ||
*apalette_data = null_palette_data; | ||
|
||
return FT_Err_Ok; | ||
} | ||
|
||
|
||
/* 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; | ||
} | ||
|
||
#else /* !TT_CONFIG_OPTION_COLOR_LAYERS */ | ||
|
||
FT_EXPORT_DEF( FT_Error ) | ||
FT_Palette_Data_Get( FT_Face face, | ||
FT_Palette_Data *apalette_data ) | ||
{ | ||
FT_UNUSED( face ); | ||
FT_UNUSED( apalette_data ); | ||
|
||
|
||
return FT_THROW( Unimplemented_Feature ); | ||
} | ||
|
||
|
||
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 ); | ||
|
||
|
||
return FT_THROW( Unimplemented_Feature ); | ||
} | ||
|
||
#endif /* !TT_CONFIG_OPTION_COLOR_LAYERS */ | ||
|
||
|
||
/* END */ |
9b89523
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review
Issues