mirror of
https://github.com/harfbuzz/harfbuzz.git
synced 2025-04-13 08:42:59 +00:00
[fontations] Render nothing if palette index out of range
Matches ot. Ft crashes currently.
This commit is contained in:
parent
cd45a7f531
commit
ad9fa13d23
1 changed files with 10 additions and 5 deletions
|
@ -375,17 +375,22 @@ impl HbColorPainter<'_> {
|
|||
}
|
||||
|
||||
fn lookup_color(&self, color_index: u16, alpha: f32) -> hb_color_t {
|
||||
if color_index == 0xFFFF {
|
||||
// Apply alpha to foreground color
|
||||
return ((self.foreground & 0xFFFFFF00)
|
||||
| (((self.foreground & 0xFF) as f32 * alpha).round() as u32))
|
||||
as hb_color_t;
|
||||
}
|
||||
|
||||
let c = self.color_records.get(color_index as usize);
|
||||
if let Some(c) = c.filter(|_| color_index != 0xFFFF) {
|
||||
if c.is_some() {
|
||||
let c = c.unwrap();
|
||||
(((c.blue as u32) << 24)
|
||||
| ((c.green as u32) << 16)
|
||||
| ((c.red as u32) << 8)
|
||||
| ((c.alpha as f32 * alpha).round() as u32)) as hb_color_t
|
||||
} else {
|
||||
// Apply alpha to foreground color
|
||||
((self.foreground & 0xFFFFFF00)
|
||||
| (((self.foreground & 0xFF) as f32 * alpha).round() as u32))
|
||||
as hb_color_t
|
||||
0 as hb_color_t
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue