Various minor color fixes. * include/freetype/config/ftheader.h (FT_COLOR_H): New macro. * include/freetype/internal/ftobjs.h (FT_Colr_Internal): Change type of `load_flags' to `FT_Int32'. * include/freetype/internal/sfnt.h (TT_Load_Colr_Layer_Func): Change type of `idx' to `FT_UInt'. (TT_Blend_Colr_Func): Change type of `color_index' to `FT_UInt'. * src/base/ftobjs.c (FT_Render_Glyph_Internal): Change type of `load_flags' to `FT_Int32'. * src/sfnt/ttcolr.c (find_base_glyph_record, tt_face_load_colr_layers): Change type of `glyph_id' to `FT_UInt'. (tt_face_find_color, tt_face_colr_blend_layer): Change type of `color_index' to `FT_UInt'. Fix signedness and type issues. * src/sfnt/ttcolr.h: Updated.
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 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392
diff --git a/ChangeLog b/ChangeLog
index 1d46029..3d8fc5c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,27 @@
+2018-05-30 Werner Lemberg <wl@gnu.org>
+
+ Various minor color fixes.
+
+ * include/freetype/config/ftheader.h (FT_COLOR_H): New macro.
+
+ * include/freetype/internal/ftobjs.h (FT_Colr_Internal): Change
+ type of `load_flags' to `FT_Int32'.
+
+ * include/freetype/internal/sfnt.h (TT_Load_Colr_Layer_Func): Change
+ type of `idx' to `FT_UInt'.
+ (TT_Blend_Colr_Func): Change type of `color_index' to `FT_UInt'.
+
+ * src/base/ftobjs.c (FT_Render_Glyph_Internal): Change type of
+ `load_flags' to `FT_Int32'.
+
+ * src/sfnt/ttcolr.c (find_base_glyph_record,
+ tt_face_load_colr_layers): Change type of `glyph_id' to `FT_UInt'.
+ (tt_face_find_color, tt_face_colr_blend_layer): Change type of
+ `color_index' to `FT_UInt'.
+ Fix signedness and type issues.
+
+ * src/sfnt/ttcolr.h: Updated.
+
2018-05-25 Nikhil Ramakrishnan <ramakrishnan.nikhil@gmail.com>
[docmaker] Fix missing `Defined in (...)' under Windows/Cygwin.
diff --git a/include/freetype/config/ftheader.h b/include/freetype/config/ftheader.h
index 702f77c..13e5de7 100644
--- a/include/freetype/config/ftheader.h
+++ b/include/freetype/config/ftheader.h
@@ -760,6 +760,18 @@
#define FT_ADVANCES_H <freetype/ftadvanc.h>
+ /*************************************************************************
+ *
+ * @macro:
+ * FT_COLOR_H
+ *
+ * @description:
+ * A macro used in #include statements to name the file containing the
+ * FreeType~2 API which handles the OpenType CPAL table.
+ */
+#define FT_COLOR_H <freetype/ftcolor.h>
+
+
/* */
/* These header files don't need to be included by the user. */
diff --git a/include/freetype/freetype.h b/include/freetype/freetype.h
index 4151b06..322680a 100644
--- a/include/freetype/freetype.h
+++ b/include/freetype/freetype.h
@@ -1226,8 +1226,8 @@ FT_BEGIN_HEADER
/* tricky fonts; they are hard-coded in file `ttobjs.c'. */
/* */
/* FT_FACE_FLAG_COLOR :: */
- /* [Since 2.5.1] The face has color glyph tables. To access color */
- /* glyphs use @FT_LOAD_COLOR. */
+ /* [Since 2.5.1] The face has color glyph tables. See */
+ /* @FT_LOAD_COLOR for more information. */
/* */
/* FT_FACE_FLAG_VARIATION :: */
/* [Since 2.9] Set if the current face (or named instance) has been */
@@ -2959,11 +2959,24 @@ FT_BEGIN_HEADER
* Disable the auto-hinter. See also the note below.
*
* FT_LOAD_COLOR ::
+ * Load colored glyphs. There are slight differences depending on the
+ * font format.
+ *
* [Since 2.5] Load embedded color bitmap images. The resulting color
- * bitmaps, if available, will have the @FT_PIXEL_MODE_BGRA format.
- * If the flag is not set and color bitmaps are found, they are
- * converted to 256-level gray bitmaps transparently, using the
- * @FT_PIXEL_MODE_GRAY format.
+ * bitmaps, if available, will have the @FT_PIXEL_MODE_BGRA format,
+ * with pre-multiplied color channels. If the flag is not set and
+ * color bitmaps are found, they are converted to 256-level gray
+ * bitmaps, using the @FT_PIXEL_MODE_GRAY format.
+ *
+ * [Since 2.10] If the glyph index contains an entry in the face's
+ * `COLR' table with a `CPAL' palette table (as defined in the
+ * OpenType specification), make @FT_Render_Glyph provide a default
+ * blending of the color glyph layers associated with the glyph index,
+ * using the same bitmap format as embedded color bitmap images. This
+ * is mainly for convenience; for full control of color layers use
+ * @FT_Get_GlyphLayers and FreeType's color functions like
+ * @FT_Palette_Select instead of setting FT_LOAD_COLOR for rendering
+ * so that the client application can handle blending by itself.
*
* FT_LOAD_COMPUTE_METRICS ::
* [Since 2.6.1] Compute glyph metrics from the glyph data, without
@@ -3272,6 +3285,14 @@ FT_BEGIN_HEADER
/* a bitmap. See @FT_Render_Mode for a list of */
/* possible values. */
/* */
+ /* If @FT_RENDER_MODE_NORMAL is used, the flag */
+ /* @FT_LOAD_COLOR can be additionally set to make the */
+ /* function provide a default blending of colored */
+ /* glyph layers associated with the current glyph slot */
+ /* (provided the font contains such layers) instead of */
+ /* rendering the glyph slot's outline. See */
+ /* @FT_LOAD_COLOR for more information. */
+ /* */
/* <Return> */
/* FreeType error code. 0~means success. */
/* */
@@ -4073,7 +4094,7 @@ FT_BEGIN_HEADER
* to this information.
*
* @FT_Render_Glyph, however, handles colored glyph layers
- * automatically.
+ * automatically if the @FT_LOAD_COLOR flag is passed to it.
*/
FT_EXPORT( FT_Error )
FT_Get_GlyphLayers( FT_GlyphSlot glyph,
diff --git a/include/freetype/ftcolor.h b/include/freetype/ftcolor.h
index 91183b8..4a2e11d 100644
--- a/include/freetype/ftcolor.h
+++ b/include/freetype/ftcolor.h
@@ -74,7 +74,7 @@ FT_BEGIN_HEADER
* Alpha value, giving the red, green, and blue color's opacity.
*
* @since:
- * 2.10.0
+ * 2.10
*/
typedef struct FT_Color_
{
@@ -114,7 +114,7 @@ FT_BEGIN_HEADER
* `TT_CONFIG_OPTION_COLOR_LAYERS' is not defined in `ftoption.h'.
*
* @since:
- * 2.10.0
+ * 2.10
*/
FT_EXPORT( FT_Error )
FT_Palette_Get_Size( FT_Face face,
@@ -153,7 +153,7 @@ FT_BEGIN_HEADER
* `TT_CONFIG_OPTION_COLOR_LAYERS' is not defined in `ftoption.h'.
*
* @since:
- * 2.10.0
+ * 2.10
*/
FT_EXPORT( FT_Error )
FT_Palette_Get_Names( FT_Face face,
@@ -184,7 +184,7 @@ FT_BEGIN_HEADER
* @FT_Palette_Get_Size.
*
* @since:
- * 2.10.0
+ * 2.10
*/
#define FT_PALETTE_USABLE_WITH_LIGHT_BACKGROUND 0x01
#define FT_PALETTE_USABLE_WITH_DARK_BACKGROUND 0x02
@@ -220,7 +220,7 @@ FT_BEGIN_HEADER
* `TT_CONFIG_OPTION_COLOR_LAYERS' is not defined in `ftoption.h'.
*
* @since:
- * 2.10.0
+ * 2.10
*/
FT_EXPORT( FT_Error )
FT_Palette_Get_Types( FT_Face face,
@@ -263,7 +263,7 @@ FT_BEGIN_HEADER
* `TT_CONFIG_OPTION_COLOR_LAYERS' is not defined in `ftoption.h'.
*
* @since:
- * 2.10.0
+ * 2.10
*/
FT_EXPORT( FT_Error )
FT_Palette_Get_Entry_Names( FT_Face face,
@@ -316,7 +316,7 @@ FT_BEGIN_HEADER
* `TT_CONFIG_OPTION_COLOR_LAYERS' is not defined in `ftoption.h'.
*
* @since:
- * 2.10.0
+ * 2.10
*/
FT_EXPORT( FT_Error )
FT_Palette_Select( FT_Face face,
@@ -348,7 +348,7 @@ FT_BEGIN_HEADER
* `TT_CONFIG_OPTION_COLOR_LAYERS' is not defined in `ftoption.h'.
*
* @since:
- * 2.10.0
+ * 2.10
*/
FT_EXPORT( FT_Error )
FT_Palette_Set_Foreground_COlor( FT_Face face,
diff --git a/include/freetype/internal/ftobjs.h b/include/freetype/internal/ftobjs.h
index 77f5dc4..b49c78d 100644
--- a/include/freetype/internal/ftobjs.h
+++ b/include/freetype/internal/ftobjs.h
@@ -388,7 +388,7 @@ FT_BEGIN_HEADER
{
FT_Glyph_Layer layers;
FT_UShort num_layers;
- FT_Int load_flags;
+ FT_Int32 load_flags;
} FT_Colr_InternalRec, *FT_Colr_Internal;
diff --git a/include/freetype/internal/sfnt.h b/include/freetype/internal/sfnt.h
index d28b682..dceb897 100644
--- a/include/freetype/internal/sfnt.h
+++ b/include/freetype/internal/sfnt.h
@@ -453,7 +453,7 @@ FT_BEGIN_HEADER
/* */
typedef FT_Error
(*TT_Load_Colr_Layer_Func)( TT_Face face,
- FT_Int idx,
+ FT_UInt idx,
FT_Glyph_Layer *layers,
FT_UShort* num_layers );
@@ -485,7 +485,7 @@ FT_BEGIN_HEADER
/* */
typedef FT_Error
(*TT_Blend_Colr_Func)( TT_Face face,
- FT_Int color_index,
+ FT_UInt color_index,
FT_GlyphSlot base_glyph,
FT_GlyphSlot new_glyph );
diff --git a/src/base/ftobjs.c b/src/base/ftobjs.c
index 2cd0c92..4770007 100644
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -4541,7 +4541,7 @@
idx < slot->internal->color_layers->num_layers;
idx++ )
{
- FT_Int load_flags;
+ FT_Int32 load_flags;
load_flags = slot->internal->color_layers->load_flags
diff --git a/src/sfnt/ttcolr.c b/src/sfnt/ttcolr.c
index 24d350e..395c8c9 100644
--- a/src/sfnt/ttcolr.c
+++ b/src/sfnt/ttcolr.c
@@ -256,7 +256,7 @@
static FT_Bool
find_base_glyph_record( FT_Byte* base_glyph_begin,
FT_Int num_base_glyph,
- FT_UShort glyph_id,
+ FT_UInt glyph_id,
BaseGlyphRecord* record )
{
FT_Int min = 0;
@@ -291,7 +291,7 @@
FT_LOCAL_DEF( FT_Error )
tt_face_load_colr_layers( TT_Face face,
- FT_Int glyph_id,
+ FT_UInt glyph_id,
FT_Glyph_Layer *ret_layers,
FT_UShort* ret_num_layers )
{
@@ -360,12 +360,12 @@
static FT_Bool
- tt_face_find_color( TT_Face face,
- FT_UShort color_index,
- FT_Byte* blue,
- FT_Byte* green,
- FT_Byte* red,
- FT_Byte* alpha )
+ 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;
@@ -378,7 +378,7 @@
if ( color_index >= cpal->num_palettes_entries )
return 0;
- p = cpal->color_indices + palette_index * sizeof ( FT_UShort );
+ p = cpal->color_indices + palette_index * (int)sizeof ( FT_UShort );
color_offset = FT_NEXT_USHORT( p );
@@ -395,7 +395,7 @@
FT_LOCAL_DEF( FT_Error )
tt_face_colr_blend_layer( TT_Face face,
- FT_Int color_index,
+ FT_UInt color_index,
FT_GlyphSlot dstSlot,
FT_GlyphSlot srcSlot )
{
@@ -404,7 +404,7 @@
FT_UInt x, y;
FT_Byte b, g, r, alpha;
- FT_Long size;
+ FT_ULong size;
FT_Byte* src;
FT_Byte* dst;
@@ -419,10 +419,10 @@
dstSlot->bitmap.width = srcSlot->bitmap.width;
dstSlot->bitmap.rows = srcSlot->bitmap.rows;
dstSlot->bitmap.pixel_mode = FT_PIXEL_MODE_BGRA;
- dstSlot->bitmap.pitch = dstSlot->bitmap.width * 4;
+ dstSlot->bitmap.pitch = (int)dstSlot->bitmap.width * 4;
dstSlot->bitmap.num_grays = 256;
- size = dstSlot->bitmap.rows * dstSlot->bitmap.pitch;
+ size = dstSlot->bitmap.rows * (unsigned int)dstSlot->bitmap.pitch;
error = ft_glyphslot_alloc_bitmap( dstSlot, size );
if ( error )
@@ -451,8 +451,8 @@
{
FT_Memory memory = face->root.memory;
- FT_UInt width = x_max - x_min;
- FT_UInt rows = y_max - y_min;
+ FT_UInt width = (FT_UInt)( x_max - x_min );
+ FT_UInt rows = (FT_UInt)( y_max - y_min );
FT_UInt pitch = width * 4;
FT_Byte* buf;
@@ -466,7 +466,7 @@
p = dstSlot->bitmap.buffer;
q = buf +
- pitch * ( y_max - dstSlot->bitmap_top ) +
+ (int)pitch * ( y_max - dstSlot->bitmap_top ) +
4 * ( dstSlot->bitmap_left - x_min );
for ( y = 0; y < dstSlot->bitmap.rows; y++ )
@@ -484,7 +484,7 @@
dstSlot->bitmap.width = width;
dstSlot->bitmap.rows = rows;
- dstSlot->bitmap.pitch = pitch;
+ dstSlot->bitmap.pitch = (int)pitch;
dstSlot->internal->flags |= FT_GLYPH_OWN_BITMAP;
dstSlot->format = FT_GLYPH_FORMAT_BITMAP;
@@ -528,10 +528,10 @@
int ba = dst[4 * x + 3];
- dst[4 * x + 0] = bb * ba2 / 255 + fb;
- dst[4 * x + 1] = bg * ba2 / 255 + fg;
- dst[4 * x + 2] = br * ba2 / 255 + fr;
- dst[4 * x + 3] = ba * ba2 / 255 + fa;
+ dst[4 * x + 0] = (FT_Byte)( bb * ba2 / 255 + fb );
+ dst[4 * x + 1] = (FT_Byte)( bg * ba2 / 255 + fg );
+ dst[4 * x + 2] = (FT_Byte)( br * ba2 / 255 + fr );
+ dst[4 * x + 3] = (FT_Byte)( ba * ba2 / 255 + fa );
}
src += srcSlot->bitmap.pitch;
diff --git a/src/sfnt/ttcolr.h b/src/sfnt/ttcolr.h
index 1c58153..bd33f69 100644
--- a/src/sfnt/ttcolr.h
+++ b/src/sfnt/ttcolr.h
@@ -38,13 +38,13 @@ FT_BEGIN_HEADER
FT_LOCAL( FT_Error )
tt_face_load_colr_layers( TT_Face face,
- FT_Int glyph_id,
+ FT_UInt glyph_id,
FT_Glyph_Layer *ret_layers,
FT_UShort* ret_num_layers );
FT_LOCAL( FT_Error )
tt_face_colr_blend_layer( TT_Face face,
- FT_Int color_index,
+ FT_UInt color_index,
FT_GlyphSlot dstSlot,
FT_GlyphSlot srcSlot );