Finish CPAL/COLR support (4/4). * src/sfnt/ttcolr.c (tt_face_find_color): Removed. (tt_face_colr_blend_layer): Use `face->palette' instead of calling `tt_face_find_color'. Use and set text foreground color.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116
diff --git a/ChangeLog b/ChangeLog
index c12b068..d054628 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
2018-06-12 Werner Lemberg <wl@gnu.org>
+ Finish CPAL/COLR support (4/4).
+
+ * src/sfnt/ttcolr.c (tt_face_find_color): Removed.
+ (tt_face_colr_blend_layer): Use `face->palette' instead of calling
+ `tt_face_find_color'.
+ Use and set text foreground color.
+
+2018-06-12 Werner Lemberg <wl@gnu.org>
+
Finish CPAL/COLR support (3/4).
* src/base/ftcolor.c: Include FT_INTERNAL_SFNT_H.
diff --git a/src/sfnt/ttcolr.c b/src/sfnt/ttcolr.c
index 9783b70..5efdc10 100644
--- a/src/sfnt/ttcolr.c
+++ b/src/sfnt/ttcolr.c
@@ -438,40 +438,6 @@
}
- static FT_Bool
- tt_face_find_color( TT_Face face,
- FT_UInt color_index,
- FT_Byte* blue,
- FT_Byte* green,
- FT_Byte* red,
- FT_Byte* alpha )
- {
- ColrCpal* colr_and_cpal = (ColrCpal *)face->colr_and_cpal;
- Cpal* cpal = &colr_and_cpal->cpal;
-
- FT_Int palette_index = 0;
- FT_Byte* p;
- FT_Int color_offset;
-
-
- if ( color_index >= face->palette_data.num_palette_entries )
- return 0;
-
- p = cpal->color_indices + palette_index * (int)sizeof ( FT_UShort );
-
- color_offset = FT_NEXT_USHORT( p );
-
- p = cpal->colors + color_offset + COLOR_SIZE * color_index;
-
- *blue = FT_NEXT_BYTE( p );
- *green = FT_NEXT_BYTE( p );
- *red = FT_NEXT_BYTE( p );
- *alpha = FT_NEXT_BYTE( p );
-
- return 1;
- }
-
-
FT_LOCAL_DEF( FT_Error )
tt_face_palette_set( TT_Face face,
FT_UInt palette_index )
@@ -607,16 +573,43 @@
}
}
- /* Default assignments to pacify compiler. */
- r = g = b = 0;
- alpha = 255;
-
- if ( color_index != 0xFFFF )
- tt_face_find_color( face, color_index, &b, &g, &r, &alpha );
+ if ( color_index == 0xFFFF )
+ {
+ if ( face->have_foreground_color )
+ {
+ b = face->foreground_color.blue;
+ g = face->foreground_color.green;
+ r = face->foreground_color.red;
+ alpha = face->foreground_color.alpha;
+ }
+ else
+ {
+ if ( face->palette_data.palette_types &&
+ ( face->palette_data.palette_types[face->palette_index] &
+ FT_PALETTE_USABLE_WITH_DARK_BACKGROUND ) )
+ {
+ /* white opaque */
+ b = 0xFF;
+ g = 0xFF;
+ r = 0xFF;
+ alpha = 0xFF;
+ }
+ else
+ {
+ /* black opaque */
+ b = 0x00;
+ g = 0x00;
+ r = 0x00;
+ alpha = 0xFF;
+ }
+ }
+ }
else
{
- /* TODO. foreground color from argument? */
- /* Add public FT_Render_Glyph_Color() with color value? */
+ b = face->palette[color_index].blue;
+ g = face->palette[color_index].green;
+ r = face->palette[color_index].red;
+ alpha = face->palette[color_index].alpha;
}
/* XXX Convert if srcSlot.bitmap is not grey? */