mirror of
https://github.com/harfbuzz/harfbuzz.git
synced 2025-04-13 08:42:59 +00:00
[COLR] Use palette 0 if palette index out of range
Fixes https://github.com/harfbuzz/harfbuzz/issues/5112
This commit is contained in:
parent
41e14f7029
commit
575e70b063
3 changed files with 18 additions and 2 deletions
|
@ -95,7 +95,8 @@ public:
|
|||
font (font_),
|
||||
palette (
|
||||
#ifndef HB_NO_COLOR
|
||||
font->face->table.CPAL->get_palette_colors (palette_)
|
||||
// https://github.com/harfbuzz/harfbuzz/issues/5112
|
||||
font->face->table.CPAL->get_palette_colors (palette_ < font->face->table.CPAL->get_palette_count () ? palette_ : 0)
|
||||
#endif
|
||||
),
|
||||
foreground (foreground_),
|
||||
|
|
|
@ -203,7 +203,11 @@ extern "C" fn _hb_fontations_get_glyph_extents(
|
|||
|
||||
let glyph_id = GlyphId::new(glyph);
|
||||
let x_extents = x_glyph_metrics.bounds(glyph_id);
|
||||
let y_extents = if x_size == y_size { x_extents } else { y_glyph_metrics.bounds(glyph_id) };
|
||||
let y_extents = if x_size == y_size {
|
||||
x_extents
|
||||
} else {
|
||||
y_glyph_metrics.bounds(glyph_id)
|
||||
};
|
||||
let (Some(x_extents), Some(y_extents)) = (x_extents, y_extents) else {
|
||||
return false as hb_bool_t;
|
||||
};
|
||||
|
@ -703,6 +707,12 @@ extern "C" fn _hb_fontations_paint_glyph(
|
|||
let num_entries: usize = cpal.num_palette_entries().into();
|
||||
let color_records = cpal.color_records_array();
|
||||
let start_index = cpal.color_record_indices().get(palette_index as usize);
|
||||
let start_index = if start_index.is_some() {
|
||||
start_index
|
||||
} else {
|
||||
// https://github.com/harfbuzz/harfbuzz/issues/5112
|
||||
cpal.color_record_indices().get(0 as usize)
|
||||
};
|
||||
|
||||
if let (Some(Ok(color_records)), Some(start_index)) = (color_records, start_index) {
|
||||
let start_index: usize = start_index.get().into();
|
||||
|
|
|
@ -491,6 +491,11 @@ hb_ft_paint_glyph_colr (hb_font_t *font,
|
|||
|
||||
(void) FT_Palette_Data_Get(ft_face, &palette_data);
|
||||
(void) FT_Palette_Select(ft_face, palette_index, &palette);
|
||||
if (!palette)
|
||||
{
|
||||
// https://github.com/harfbuzz/harfbuzz/issues/5112
|
||||
(void) FT_Palette_Select(ft_face, 0, &palette);
|
||||
}
|
||||
|
||||
auto palette_array = hb_array ((const FT_Color *) palette,
|
||||
palette ? palette_data.num_palette_entries : 0);
|
||||
|
|
Loading…
Add table
Reference in a new issue