gftools icon indicating copy to clipboard operation
gftools copied to clipboard

diffenator: use blackrenderer

Open m4rc1e opened this issue 2 years ago • 2 comments

@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:

Screenshot 2022-08-02 at 16 58 31

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.

m4rc1e avatar Aug 02 '22 16:08 m4rc1e

Looks good. We will probably have to fix the diff function but I think go for it.

simoncozens avatar Aug 02 '22 16:08 simoncozens

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

m4rc1e avatar Aug 03 '22 10:08 m4rc1e

This issue is obsolete with the new diffenator2.

simoncozens avatar Nov 28 '22 07:11 simoncozens