Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

COLR/CPAL requirement for glyph ID 1 #346

Closed
khaledhosny opened this issue Jan 24, 2020 · 9 comments
Closed

COLR/CPAL requirement for glyph ID 1 #346

khaledhosny opened this issue Jan 24, 2020 · 9 comments

Comments

@khaledhosny
Copy link

Fonts using COLR and CPAL tables must implement glyph ID 1 as the .null glyph.

The spec has the text above with no explanation why this is needed.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

@bungeman
Copy link

bungeman commented Mar 4, 2020

It appears that in DirectWrite's current implementation (tested on Microsoft Windows Version 10.0.18363.657) when using a font with CFF outlines and COLR/CPAL the IDWriteColorGlyphRunEnumerator will always state that glyph ID 1 needs to be drawn first for all color glyph runs, as if every layer record started with an implicit gID of 1 (I haven't checked what the implicit paletteIndex is, I think it was either black or current color, though it may have been the paletteIndex of the actual first entry). This has come up in https://bugs.chromium.org/p/skia/issues/detail?id=9981 (call TranslateColorGlyphRun to get IDWriteColorGlyphRunEnumerator then MoveNext and GetCurrentRun to get the DWRITE_COLOR_GLYPH_RUN which has a DWRITE_GLYPH_RUN which always seems to want to draw glyph 1 the first time around).

I think this text may just be the result of this bug? I'll try to put together a simple reproducer if I can. Hopefully if this is fixed this text can be removed. If not, I'd be very interested in knowing why glyph ID 1 is being drawn under all color CFF glyphs and how that is supposed to work.

@khaledhosny
Copy link
Author

Great finding, thanks. This then wouldn't be the only case where the COLR spec is modeled after the Windows implementation, another one would be #250.

@PeterCon
Copy link
Collaborator

PeterCon commented Sep 4, 2020

I contacted the relevant developer at Microsoft asking him to provide input in this discussion. I had in mind for him to respond here, but instead he responded to me email with the following info:

The DWrite implementation used to try to combine multiple glyphs of the same color in the same glyph run, in order to reduce the total number of glyph runs rendered. When doing so, it might need to insert white space between non-consecutive glyphs to preserve spacing, and glyph ID 1 was used for this purpose. The requirement that glyph ID 1 be blank was written into the spec to allow for this implementation detail.

This changed a while back, but there are still systems out there that use the older implementation.

@behdad
Copy link

behdad commented Sep 7, 2020

The DWrite implementation used to try to combine multiple glyphs of the same color in the same glyph run, in order to reduce the total number of glyph runs rendered. When doing so, it might need to insert white space between non-consecutive glyphs to preserve spacing, and glyph ID 1 was used for this purpose. The requirement that glyph ID 1 be blank was written into the spec to allow for this implementation detail.

That's exactly why specs should not be written by whoever makes an implementation....

@PeterCon
Copy link
Collaborator

PeterCon commented Sep 7, 2020

The ask in this issue was for information, which has been provided. If there isn't any proposal for revision of the spec, it can be closed.

(One possibility might be to change the across-the-board requirement to a compatibility note; e.g., "Some early Windows implementations require...")

If there's no further discussion in the next few days, I'll close this.

@khaledhosny
Copy link
Author

khaledhosny commented Sep 7, 2020

I know at least 4 non-MS implementations that do not check for this requirement, nor do they need any special handling of GID 1, so my suggestion is to change the spec and make it a note that old MS implementation had this requirement.

@PeterCon
Copy link
Collaborator

PeterCon commented Sep 7, 2020

I know at least 4 non-MS implementations that do not check for this requirement, no do they need any special handling of GID 1

I know that Apple's implementation ignore this. I'll ping Microsoft with a draft revision to that effect, noting the situation in other implementations.

@PeterCon
Copy link
Collaborator

PeterCon commented Sep 7, 2020

Draft revision:

Fonts using COLR and CPAL tables must implement glyph ID 1 as the .null glyph. If the COLR table is present in a font but no CPAL table exists, then the COLR table will not be supported for this font.

Note: Some early Windows implementations of the 'COLR' table require glyph ID 1 to be the .null glyph.

@PeterCon
Copy link
Collaborator

PeterCon commented Sep 8, 2020

Reviewed by MS: they have no concerns with the proposed change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants