[fontations] Fix color-line extend fetching

This fixes the last bug I know.
This commit is contained in:
Behdad Esfahbod 2025-03-06 14:48:51 -07:00
parent fc8334d96b
commit 77a319daa6
5 changed files with 13 additions and 15 deletions

View file

@ -25,8 +25,6 @@ dependencies = [
[[package]]
name = "font-types"
version = "0.8.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d868ec188a98bb014c606072edd47e52e7ab7297db943b0b28503121e1d037bd"
dependencies = [
"bytemuck",
]
@ -60,8 +58,6 @@ dependencies = [
[[package]]
name = "read-fonts"
version = "0.27.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f004ee5c610b8beb5f33273246893ac6258ec22185a6eb8ee132bccdb904cdaa"
dependencies = [
"bytemuck",
"font-types",
@ -70,8 +66,6 @@ dependencies = [
[[package]]
name = "skrifa"
version = "0.28.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "16e7936ca3627fdb516e97aca3c8ab5103f94ae32fe5ce80a0a02edcbacb7b53"
dependencies = [
"bytemuck",
"read-fonts",

View file

@ -3,8 +3,8 @@ name = "harfbuzz_fontations"
edition = "2021"
[dependencies]
read-fonts = "0.27.2"
skrifa = "0.28.1"
read-fonts = { path = "/home/behdad/fontations/read-fonts" }
skrifa = { path = "/home/behdad/fontations/skrifa" }
[lib]
name = "harfbuzz_fontations"

View file

@ -333,15 +333,14 @@ impl HbColorPainter {
}
}
fn make_color_line(&mut self, color_stops: &ColorLineData) -> hb_color_line_t {
fn make_color_line(&mut self, color_line: &ColorLineData) -> hb_color_line_t {
let mut cl = unsafe { std::mem::zeroed::<hb_color_line_t>() };
cl.data = self as *mut HbColorPainter as *mut ::std::os::raw::c_void;
cl.get_color_stops = Some(_hb_fontations_get_color_stops);
cl.get_color_stops_user_data =
color_stops as *const ColorLineData as *mut ::std::os::raw::c_void;
color_line as *const ColorLineData as *mut ::std::os::raw::c_void;
cl.get_extend = Some(_hb_fontations_get_extend);
cl.get_extend_user_data =
color_stops as *const ColorLineData as *mut ::std::os::raw::c_void;
cl.get_extend_user_data = color_line as *const ColorLineData as *mut ::std::os::raw::c_void;
cl
}
}
@ -384,10 +383,10 @@ extern "C" fn _hb_fontations_get_color_stops(
}
extern "C" fn _hb_fontations_get_extend(
_color_line: *mut hb_color_line_t,
color_line_data: *mut ::std::os::raw::c_void,
_user_data: *mut ::std::os::raw::c_void,
_color_line_data: *mut ::std::os::raw::c_void,
user_data: *mut ::std::os::raw::c_void,
) -> hb_paint_extend_t {
let color_line_data = unsafe { &*(color_line_data as *const ColorLineData) };
let color_line_data = unsafe { &*(user_data as *const ColorLineData) };
color_line_data.extend as hb_paint_extend_t // They are the same
}

View file

@ -294,6 +294,8 @@ _hb_cairo_get_color_stops (hb_cairo_context_t *c,
}
hb_color_line_get_color_stops (color_line, 0, &len, *stops);
for (unsigned i = 0; i < len; i++)
{
printf ("stop at %g\n", (*stops)[i].offset);
if ((*stops)[i].is_foreground)
{
#ifdef HAVE_CAIRO_USER_SCALED_FONT_GET_FOREGROUND_SOURCE
@ -306,6 +308,7 @@ _hb_cairo_get_color_stops (hb_cairo_context_t *c,
#endif
(*stops)[i].color = HB_COLOR (0, 0, 0, hb_color_get_alpha ((*stops)[i].color));
}
}
*count = len;
return true;
@ -341,6 +344,7 @@ _hb_cairo_paint_linear_gradient (hb_cairo_context_t *c,
pattern = cairo_pattern_create_linear ((double) xxx0, (double) yyy0, (double) xxx1, (double) yyy1);
cairo_pattern_set_extend (pattern, hb_cairo_extend (hb_color_line_get_extend (color_line)));
printf("extend %d\n", hb_color_line_get_extend (color_line));
for (unsigned int i = 0; i < len; i++)
{
double r, g, b, a;

View file

@ -321,6 +321,7 @@ hb_cairo_paint_linear_gradient (hb_paint_funcs_t *pfuncs HB_UNUSED,
{
hb_cairo_context_t *c = (hb_cairo_context_t *) paint_data;
printf ("linear gradient %f %f %f %f %f %f\n", x0, y0, x1, y1, x2, y2);
_hb_cairo_paint_linear_gradient (c, color_line, x0, y0, x1, y1, x2, y2);
}