fontgoggles icon indicating copy to clipboard operation
fontgoggles copied to clipboard

Some glyphs fails to render in COLRv1 variable font which renders fine in Chrome

Open yarmola opened this issue 2 years ago • 8 comments

A sample VF built with FontLab using latest varLib and Nabla sources fails to render certain glyphs in the latest FG. Same font renders fine in Chrome.

Font is attached ("A" is modified as a marker).

It is possible that font has its own issues (we continue testing it), but I think it may actually be an issue in FG rendering, as COLRv1 is relatively new tech.

Nabla-VF.ttf.zip

FG (with the original Nabla and modified/problematic version):

Screenshot 2022-09-18 at 18 22 32

Same modified font in Chrome:

Screenshot 2022-09-18 at 18 21 56

yarmola avatar Sep 18 '22 15:09 yarmola

Thanks for reporting! It's a good old ZeroDivisionError :)

https://github.com/BlackFoundryCom/black-renderer/blob/main/Lib/blackrenderer/font.py#L459-L469

I'lve opened an issue in blackrenderer: https://github.com/BlackFoundryCom/black-renderer/issues/113

justvanrossum avatar Sep 18 '22 16:09 justvanrossum

(Most likely because the points of a linear gradient are simply overlapping.)

justvanrossum avatar Sep 18 '22 16:09 justvanrossum

Btw. the fonttools subsetter stumbles over the the CPAL table, which is format 1. Not sure if the font is faulty or fonttools buggy.

justvanrossum avatar Sep 18 '22 16:09 justvanrossum

the fonttools subsetter stumbles over the the CPAL table

Will check that, thanks! That happens with the original or modified font?

yarmola avatar Sep 18 '22 17:09 yarmola

Will check that, thanks! That happens with the original or modified font?

The modified font, the original has a format 0 CPAL table.

justvanrossum avatar Sep 18 '22 17:09 justvanrossum

Some investigation:

I checked how B (gid 13) is built and found that the original font has one of the gradients made like this:

Screenshot 2022-09-18 at 21 01 15

If I read COLRv1 spec correctly, that makes zero-length gradient line, which is technically wrong:

If either point p₁ or p₂ is the same as point p₀, the gradient is ill-formed and must not be rendered.

I think that we have 1) problem in the source Nabla font 2) same problem but packed differently in the converted font 3) issue in the renderer which should be more tolerant to such cases.

yarmola avatar Sep 18 '22 18:09 yarmola

I've fixed the ZeroDivisionError in the meantime (https://github.com/BlackFoundryCom/black-renderer/pull/114), but I need to investigate the zero-length gradient (https://github.com/justvanrossum/nabla/issues/41).

justvanrossum avatar Sep 18 '22 18:09 justvanrossum

That's the first gradient "shape" in B, easy to spot.

yarmola avatar Sep 18 '22 18:09 yarmola

This should be fixed in FontGoggle 1.7.0: https://github.com/justvanrossum/fontgoggles/releases

justvanrossum avatar Nov 22 '22 10:11 justvanrossum