... |
... |
@@ -45,6 +45,12 @@ FT_BEGIN_HEADER |
45
|
45
|
* @description:
|
46
|
46
|
* The functions described here allow access and manipulation of color
|
47
|
47
|
* palette entries in OpenType's 'CPAL' tables.
|
|
48
|
+ *
|
|
49
|
+ * FreeType maintains a 'working palette' (together with a corresponding
|
|
50
|
+ * 'working palette index'), which can be set either to a palette stored
|
|
51
|
+ * in the font (function @FT_Palette_Select) or to a user-defined palette
|
|
52
|
+ * (function @FT_Palette_Set). For user-defined palettes, the working
|
|
53
|
+ * palette index is negative, and positive otherwise.
|
48
|
54
|
*/
|
49
|
55
|
|
50
|
56
|
|
... |
... |
@@ -218,18 +224,13 @@ FT_BEGIN_HEADER |
218
|
224
|
* FT_Palette_Select
|
219
|
225
|
*
|
220
|
226
|
* @description:
|
221
|
|
- * This function has two purposes.
|
222
|
|
- *
|
223
|
|
- * (1) It activates a palette for rendering color glyphs, and
|
224
|
|
- *
|
225
|
|
- * (2) it retrieves all (unmodified) color entries of this palette. This
|
226
|
|
- * function returns a read-write array, which means that a calling
|
227
|
|
- * application can modify the palette entries on demand.
|
|
227
|
+ * This function copies a palette entry in the font's 'CPAL' table into a
|
|
228
|
+ * 'working palette', which is a read-write array managed by FreeType.
|
|
229
|
+ * It also sets the 'working palette index' to the index value given as
|
|
230
|
+ * an argument.
|
228
|
231
|
*
|
229
|
|
- * A corollary of (2) is that calling the function, then modifying some
|
230
|
|
- * values, then calling the function again with the same arguments resets
|
231
|
|
- * all color entries to the original 'CPAL' values; all user modifications
|
232
|
|
- * are lost.
|
|
232
|
+ * The current working palette and palette index can be retrieved with
|
|
233
|
+ * @FT_Palette_Get.
|
233
|
234
|
*
|
234
|
235
|
* @input:
|
235
|
236
|
* face ::
|
... |
... |
@@ -240,10 +241,10 @@ FT_BEGIN_HEADER |
240
|
241
|
*
|
241
|
242
|
* @output:
|
242
|
243
|
* apalette ::
|
243
|
|
- * An array of color entries for a palette with index `palette_index`,
|
244
|
|
- * having `num_palette_entries` elements (as found in the
|
245
|
|
- * `FT_Palette_Data` structure). If `apalette` is set to `NULL`, no
|
246
|
|
- * array gets returned (and no color entries can be modified).
|
|
244
|
+ * A pointer to the 'working palette', which is an array of color
|
|
245
|
+ * entries for a palette with index `palette_index`, having
|
|
246
|
+ * `num_palette_entries` elements (as found in the `FT_Palette_Data`
|
|
247
|
+ * structure). If `apalette` is set to `NULL`, no array gets returned.
|
247
|
248
|
*
|
248
|
249
|
* In case the font doesn't support color palettes, `NULL` is returned.
|
249
|
250
|
*
|
... |
... |
@@ -266,6 +267,92 @@ FT_BEGIN_HEADER |
266
|
267
|
FT_Color* *apalette );
|
267
|
268
|
|
268
|
269
|
|
|
270
|
+ /**************************************************************************
|
|
271
|
+ *
|
|
272
|
+ * @function:
|
|
273
|
+ * FT_Palette_Set
|
|
274
|
+ *
|
|
275
|
+ * @description:
|
|
276
|
+ * Set FreeType's 'working palette' and 'working palette index' to the
|
|
277
|
+ * given arguments. Use this function if you want to provide a
|
|
278
|
+ * user-defined palette, not being part of the font's 'CPAL' table.
|
|
279
|
+ *
|
|
280
|
+ * The current working palette and palette index can be retrieved with
|
|
281
|
+ * @FT_Palette_Get.
|
|
282
|
+ *
|
|
283
|
+ * @input:
|
|
284
|
+ * face ::
|
|
285
|
+ * The source face handle.
|
|
286
|
+ *
|
|
287
|
+ * palette_index ::
|
|
288
|
+ * A palette index, which must be an arbitrary, negative integer (since
|
|
289
|
+ * positive values are reserved for indices from the 'CPAL' table).
|
|
290
|
+ * FreeType sets the 'working palette index' to this value.
|
|
291
|
+ *
|
|
292
|
+ * palette ::
|
|
293
|
+ * A pointer to an array of color entries, having `num_palette_entries`
|
|
294
|
+ * elements (as found in the `FT_Palette_Data` structure). FreeType
|
|
295
|
+ * copies this array into its 'working palette'.
|
|
296
|
+ *
|
|
297
|
+ * @return:
|
|
298
|
+ * FreeType error code. 0~means success.
|
|
299
|
+ *
|
|
300
|
+ * @note:
|
|
301
|
+ * This function always returns an error if the config macro
|
|
302
|
+ * `TT_CONFIG_OPTION_COLOR_LAYERS` is not defined in `ftoption.h`.
|
|
303
|
+ *
|
|
304
|
+ * @since:
|
|
305
|
+ * 2.12
|
|
306
|
+ */
|
|
307
|
+ FT_EXPORT( FT_Error )
|
|
308
|
+ FT_Palette_Set( FT_Face face,
|
|
309
|
+ FT_Int index,
|
|
310
|
+ FT_Color* palette );
|
|
311
|
+
|
|
312
|
+
|
|
313
|
+ /**************************************************************************
|
|
314
|
+ *
|
|
315
|
+ * @function:
|
|
316
|
+ * FT_Palette_Get
|
|
317
|
+ *
|
|
318
|
+ * @description:
|
|
319
|
+ * Get FreeType's 'working palette' and 'working palette index'.
|
|
320
|
+ *
|
|
321
|
+ * The working palette and palette index can be set with @FT_Palette_Set.
|
|
322
|
+ *
|
|
323
|
+ * @input:
|
|
324
|
+ * face ::
|
|
325
|
+ * The source face handle.
|
|
326
|
+ *
|
|
327
|
+ * @output:
|
|
328
|
+ * anindex ::
|
|
329
|
+ * The 'working palette index'. If the value is zero or positive, the
|
|
330
|
+ * working palette represents an entry from the font's 'CPAL' table
|
|
331
|
+ * (with the given index). Otherwise it is a user-defined palette. If
|
|
332
|
+ * `anindex` is set to `NULL`, no value gets returned.
|
|
333
|
+ *
|
|
334
|
+ * apalette ::
|
|
335
|
+ * A pointer to the 'working palette', which is an array of color
|
|
336
|
+ * entries for a palette having `num_palette_entries` elements (as
|
|
337
|
+ * found in the `FT_Palette_Data` structure). If `apalette` is set to
|
|
338
|
+ * `NULL`, no array gets returned.
|
|
339
|
+ *
|
|
340
|
+ * @return:
|
|
341
|
+ * FreeType error code. 0~means success.
|
|
342
|
+ *
|
|
343
|
+ * @note:
|
|
344
|
+ * This function always returns an error if the config macro
|
|
345
|
+ * `TT_CONFIG_OPTION_COLOR_LAYERS` is not defined in `ftoption.h`.
|
|
346
|
+ *
|
|
347
|
+ * @since:
|
|
348
|
+ * 2.12
|
|
349
|
+ */
|
|
350
|
+ FT_EXPORT( FT_Error )
|
|
351
|
+ FT_Palette_Get( FT_Face face,
|
|
352
|
+ FT_Int *anindex,
|
|
353
|
+ FT_Color* *apalette );
|
|
354
|
+
|
|
355
|
+
|
269
|
356
|
/**************************************************************************
|
270
|
357
|
*
|
271
|
358
|
* @function:
|
... |
... |
@@ -286,11 +373,9 @@ FT_BEGIN_HEADER |
286
|
373
|
* FreeType error code. 0~means success.
|
287
|
374
|
*
|
288
|
375
|
* @note:
|
289
|
|
- * If this function isn't called, the text foreground color is set to
|
290
|
|
- * white opaque (BGRA value 0xFFFFFFFF) if
|
291
|
|
- * @FT_PALETTE_FOR_DARK_BACKGROUND is present for the current palette,
|
292
|
|
- * and black opaque (BGRA value 0x000000FF) otherwise, including the case
|
293
|
|
- * that no palette types are available in the 'CPAL' table.
|
|
376
|
+ * See function @FT_Palette_Get_Foreground_Color for details on what
|
|
377
|
+ * foreground color is used if `FT_Palette_Set_Foreground_Color` is not
|
|
378
|
+ * called.
|
294
|
379
|
*
|
295
|
380
|
* This function always returns an error if the config macro
|
296
|
381
|
* `TT_CONFIG_OPTION_COLOR_LAYERS` is not defined in `ftoption.h`.
|
... |
... |
@@ -303,6 +388,53 @@ FT_BEGIN_HEADER |
303
|
388
|
FT_Color foreground_color );
|
304
|
389
|
|
305
|
390
|
|
|
391
|
+ /**************************************************************************
|
|
392
|
+ *
|
|
393
|
+ * @function:
|
|
394
|
+ * FT_Palette_Get_Foreground_Color
|
|
395
|
+ *
|
|
396
|
+ * @description:
|
|
397
|
+ * Get the 'text foreground color' as set by a previous call to
|
|
398
|
+ * @FT_Palette_Set_Foreground_Color.
|
|
399
|
+ *
|
|
400
|
+ * @input:
|
|
401
|
+ * face ::
|
|
402
|
+ * The source face handle.
|
|
403
|
+ *
|
|
404
|
+ * @output:
|
|
405
|
+ * aforeground_color ::
|
|
406
|
+ * The text foreground color.
|
|
407
|
+ *
|
|
408
|
+ * @return:
|
|
409
|
+ * FreeType error code. 0~means success.
|
|
410
|
+ *
|
|
411
|
+ * @note:
|
|
412
|
+ * The returned color is as follows.
|
|
413
|
+ *
|
|
414
|
+ * * If a foreground color was set with @FT_Palette_Get_Foreground_Color,
|
|
415
|
+ * return this value.
|
|
416
|
+ *
|
|
417
|
+ * * Otherwise, return black opaque (BGRA value 0x000000FF) if the
|
|
418
|
+ * 'working palette' is a user-defined palette.
|
|
419
|
+ *
|
|
420
|
+ * * Otherwise, return white opaque (BGRA value 0xFFFFFFFF) if
|
|
421
|
+ * @FT_PALETTE_FOR_DARK_BACKGROUND is present for the current palette.
|
|
422
|
+ *
|
|
423
|
+ * * Otherwise, return black opaque (BGRA value 0x000000FF). This
|
|
424
|
+ * includes the case that no palette types are available in the 'CPAL'
|
|
425
|
+ * table.
|
|
426
|
+ *
|
|
427
|
+ * This function always returns an error if the config macro
|
|
428
|
+ * `TT_CONFIG_OPTION_COLOR_LAYERS` is not defined in `ftoption.h`.
|
|
429
|
+ *
|
|
430
|
+ * @since:
|
|
431
|
+ * 2.12
|
|
432
|
+ */
|
|
433
|
+ FT_EXPORT( FT_Error )
|
|
434
|
+ FT_Palette_Get_Foreground_Color( FT_Face face,
|
|
435
|
+ FT_Color* aforeground_color );
|
|
436
|
+
|
|
437
|
+
|
306
|
438
|
/**************************************************************************
|
307
|
439
|
*
|
308
|
440
|
* @section:
|