[color] Fix alpha channel value and adjust spaces
This commit is contained in:
parent
00e94ce24e
commit
687f679b80
@ -131,14 +131,14 @@ colr_cpal_rendering (hb_face_t *face, cairo_font_face_t *cairo_face)
|
||||
for (unsigned int pallet = 0; pallet < pallet_count; ++pallet) {
|
||||
char output_path[255];
|
||||
|
||||
unsigned int num_colors = hb_ot_color_get_palette_colors (face, pallet, 0, nullptr, nullptr);
|
||||
if (!num_colors)
|
||||
continue;
|
||||
unsigned int num_colors = hb_ot_color_get_palette_colors (face, pallet, 0, nullptr, nullptr);
|
||||
if (!num_colors)
|
||||
continue;
|
||||
|
||||
hb_ot_color_t *colors = (hb_ot_color_t*) calloc (num_colors, sizeof (hb_ot_color_t));
|
||||
hb_ot_color_get_palette_colors (face, pallet, 0, &num_colors, colors);
|
||||
if (num_colors)
|
||||
{
|
||||
hb_ot_color_t *colors = (hb_ot_color_t*) calloc (num_colors, sizeof (hb_ot_color_t));
|
||||
hb_ot_color_get_palette_colors (face, pallet, 0, &num_colors, colors);
|
||||
if (num_colors)
|
||||
{
|
||||
// If we have more than one pallet, use a better namin
|
||||
if (pallet_count == 1)
|
||||
sprintf (output_path, "out/colr-%d.svg", gid);
|
||||
@ -153,13 +153,13 @@ colr_cpal_rendering (hb_face_t *face, cairo_font_face_t *cairo_face)
|
||||
for (unsigned int layer = 0; layer < num_layers; ++layer)
|
||||
{
|
||||
uint32_t color = 0xFF;
|
||||
if (color_indices[layer] != 0xFFFF)
|
||||
if (color_indices[layer] != 0xFFFF)
|
||||
color = colors[color_indices[layer]];
|
||||
int alpha = hb_ot_color_get_alpha (color);
|
||||
int r = hb_ot_color_get_red (color);
|
||||
int g = hb_ot_color_get_green (color);
|
||||
int b = hb_ot_color_get_blue (color);
|
||||
cairo_set_source_rgba (cr, r / 255., g / 255., b / 255., alpha);
|
||||
cairo_set_source_rgba (cr,
|
||||
hb_ot_color_get_red (color) / 255.,
|
||||
hb_ot_color_get_green (color) / 255.,
|
||||
hb_ot_color_get_blue (color) / 255.,
|
||||
hb_ot_color_get_alpha (color) / 255.);
|
||||
|
||||
cairo_glyph_t glyph;
|
||||
glyph.index = layer_gids[layer];
|
||||
@ -170,8 +170,8 @@ colr_cpal_rendering (hb_face_t *face, cairo_font_face_t *cairo_face)
|
||||
|
||||
cairo_surface_destroy (surface);
|
||||
cairo_destroy (cr);
|
||||
}
|
||||
free (colors);
|
||||
}
|
||||
free (colors);
|
||||
}
|
||||
}
|
||||
|
||||
@ -281,12 +281,12 @@ main (int argc, char **argv)
|
||||
FT_New_Face (library, argv[1], 0, &ftface);
|
||||
cairo_face = cairo_ft_font_face_create_for_ft_face (ftface, 0);
|
||||
}
|
||||
colr_cpal_rendering (face, cairo_face);
|
||||
|
||||
unsigned int num_glyphs = hb_face_get_glyph_count (face);
|
||||
unsigned int upem = hb_face_get_upem (face);
|
||||
colr_cpal_rendering (face, cairo_face);
|
||||
dump_glyphs (cairo_face, upem, num_glyphs);
|
||||
|
||||
|
||||
hb_font_destroy (font);
|
||||
hb_face_destroy (face);
|
||||
hb_blob_destroy (blob);
|
||||
|
@ -58,7 +58,7 @@ hb_buffer_serialize_list_formats (void)
|
||||
* @str is a valid buffer serialization format, use
|
||||
* hb_buffer_serialize_list_formats() to get the list of supported formats.
|
||||
*
|
||||
* Return value:
|
||||
* Return value:
|
||||
* The parsed #hb_buffer_serialize_format_t.
|
||||
*
|
||||
* Since: 0.9.7
|
||||
@ -319,7 +319,7 @@ _hb_buffer_serialize_glyphs_text (hb_buffer_t *buffer,
|
||||
* ## json
|
||||
* TODO.
|
||||
*
|
||||
* Return value:
|
||||
* Return value:
|
||||
* The number of serialized items.
|
||||
*
|
||||
* Since: 0.9.7
|
||||
@ -425,14 +425,14 @@ parse_int (const char *pp, const char *end, int32_t *pv)
|
||||
* hb_buffer_deserialize_glyphs:
|
||||
* @buffer: an #hb_buffer_t buffer.
|
||||
* @buf: (array length=buf_len):
|
||||
* @buf_len:
|
||||
* @buf_len:
|
||||
* @end_ptr: (out):
|
||||
* @font:
|
||||
* @format:
|
||||
* @font:
|
||||
* @format:
|
||||
*
|
||||
*
|
||||
*
|
||||
* Return value:
|
||||
*
|
||||
* Return value:
|
||||
*
|
||||
* Since: 0.9.7
|
||||
**/
|
||||
|
@ -99,7 +99,7 @@ hb_ot_color_get_palette_count (hb_face_t *face)
|
||||
* the result is 0xFFFF. The implementation does not check whether
|
||||
* the returned palette name id is actually in @face's `name` table.
|
||||
*
|
||||
* Since: REPLACEME
|
||||
* Since: DONTREPLACEME
|
||||
*/
|
||||
unsigned int
|
||||
hb_ot_color_get_palette_name_id (hb_face_t *face, unsigned int palette)
|
||||
@ -118,7 +118,7 @@ hb_ot_color_get_palette_name_id (hb_face_t *face, unsigned int palette)
|
||||
* or if @palette is not between 0 and hb_ot_color_get_palette_count(),
|
||||
* the result is #HB_OT_COLOR_PALETTE_FLAG_DEFAULT.
|
||||
*
|
||||
* Since: REPLACEME
|
||||
* Since: DONTREPLACEME
|
||||
*/
|
||||
hb_ot_color_palette_flags_t
|
||||
hb_ot_color_get_palette_flags (hb_face_t *face, unsigned int palette)
|
||||
@ -158,10 +158,10 @@ hb_ot_color_get_palette_flags (hb_face_t *face, unsigned int palette)
|
||||
*/
|
||||
unsigned int
|
||||
hb_ot_color_get_palette_colors (hb_face_t *face,
|
||||
unsigned int palette, /* default=0 */
|
||||
unsigned int palette, /* default=0 */
|
||||
unsigned int start_offset,
|
||||
unsigned int *count /* IN/OUT */,
|
||||
hb_ot_color_t *colors /* OUT */)
|
||||
unsigned int *count /* IN/OUT */,
|
||||
hb_ot_color_t *colors /* OUT */)
|
||||
{
|
||||
const OT::CPAL& cpal = _get_cpal(face);
|
||||
if (unlikely (palette >= cpal.get_palette_count ()))
|
||||
|
Loading…
Reference in New Issue
Block a user