gftools
gftools copied to clipboard
diffenator: use blackrenderer
@simoncozens I see we've got our own cool draw_text
function, https://github.com/googlefonts/gftools/blob/diff2-fuzz/Lib/gftools/diffenator/ft_hb_shape.py#L9-L18. Perhaps it's better if we use blackrenderer so it'll allow us to also gen colr v1 bitmaps?
I've just quickly modified our function so it uses blackrender and there's a few differences we need to consider:

left: blackrenderer, right: ft_hb_shape.draw_text
- for non-color fonts, colors are inverted
-
draw_text
includes the left side bearing but not the right (did you mean intentionally want this?). Blackrenderer includes both sidebearings - blackrenders output array is for RGBA pixels. Ours is just for greyscale
If none of the above are issues to you, I shall proceed and integrate blackrenderer.
Looks good. We will probably have to fix the diff function but I think go for it.
Cool, I'll proceed. Since the diff function uses numpy arrays, it works from the get go
>>> a = np.array([
[[255, 255, 0],[255, 0, 0]],
])
>>> b = np.array([
[[255, 255, 0], [255, 0, 0]]
])
>>> print(img_diff(a,b))
0.0
>>> a = np.array([
[[255, 255, 0],[255, 0, 0]],
])
>>> b = np.array([
[[255, 255, 0], [125, 0, 0]]
])
>>> print(img_diff(a,b))
0.28
This issue is obsolete with the new diffenator2.