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

Font constants crate? #1182

Open
simoncozens opened this issue Oct 9, 2024 · 10 comments
Open

Font constants crate? #1182

simoncozens opened this issue Oct 9, 2024 · 10 comments

Comments

@simoncozens
Copy link
Contributor

One thing I have noticed in the Python font ecosystem is endless duplication of core constants; various packages have their own lists of:

  • Valid language/script/feature tags
  • Conversions between usWeightClass/usWidthClass values and fvar values
  • Which scripts go through the Indic or USE shapers
  • Well-known names for various weight instances
  • Unicode range / codepage bit definitions
  • Registered axis tags

and so on. Would there be any interest in hosting a crate in this repo with a common set of font-related constants?

@rsheeter
Copy link
Collaborator

rsheeter commented Oct 9, 2024

Makes sense to me. I have questions about whether it should be one crate, several crates, if some of it belongs in font-types, if some of it belongs in harfruzz (what shaper), etc.

@cmyr
Copy link
Member

cmyr commented Oct 17, 2024

We've discussed this sort of thing in the past, and I think it's a good idea. I would make it an additional crate in this repo, and called something like... font-common or similar?

We want to avoid adding much to font-types because it has some unsafe and requires additional review, so I think a new #[forbid(unsafe_code)] crate would be the best approach.

@cmyr
Copy link
Member

cmyr commented Oct 21, 2024

@rsheeter does this sound reasonable?

@rsheeter
Copy link
Collaborator

Broadly yes. Needs a norse name of course. Is it possible to enumerate what we currently believe would go into this crate and what we think might consume it? It would also be nice to capture where current python and/or Rust definitions live. For example, fontc has a port of the python codepage range code @ https://github.com/googlefonts/fontc/blob/ab35d44b16267fa97c12c110bdc1b5dc53a01166/fontbe/src/os2.rs#L341. Presumably that should use the new library once it exists.

@rsheeter
Copy link
Collaborator

@simoncozens
Copy link
Contributor Author

Is it possible to enumerate what we currently believe would go into this crate

I made a list above. :-)

what we think might consume it?

The immediate motivation for this issue is fontspector (fontbakery port), but I imagine fontc and fea-rs also have collections of magical data. Python constants are scattered around opentypespec-py, fontbakery.constants, ufo2ft.constants, fontTools.agl, fontTools.ttLib.standardGlyphOrder, gftools.constants, gftools.util.styles`...

https://cleasby-vigfusson-dictionary.vercel.app/word/kunnasta perhaps?

Sounds gud, ya. I wanted fróðleikr just to see what cargo would do with utf8 crate names.

@rsheeter
Copy link
Collaborator

I made a list above. :-)

If that's the list all good, I wasn't sure if that was just quick examples or all the examples we currently have.

to see what cargo would do with utf8 crate names

I am very curious about that too. Lots of wonderful options if it works. Might be a bit gnarly to see in source code haha.

@simoncozens
Copy link
Contributor Author

warning: the name `fróðleikr` contains non-ASCII characters
Non-ASCII crate names are not supported by Rust.

Boo hiss.

@drott
Copy link
Contributor

drott commented Nov 6, 2024

From a Chromium and Skia perspective, there's a bit of per crate overhead involved in depending on additional crates, getting them through review and rolling them. Are we expected to need the constants in skrifa, read-fonts soon? In that case, I would prefer to keep them in an existing crate. I'd rather not set up a new crate import for a set of constants.

@simoncozens
Copy link
Contributor Author

We don't need to use them in skrifa/read-fonts. We could just have the create for use only in fontc and other tools.

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

No branches or pull requests

4 participants