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

Rename Stretch, Style, Weight to have Font prefix #211

Merged

Conversation

waywardmonkeys
Copy link
Contributor

This brings them into line with how they're used in parley::style as well as closer to how they're named in CSS where these properties are font-stretch (since renamed to font-width), font-style, and font-weight.

This is a precursor to extracting this code into a separate crate for styling text.

@waywardmonkeys
Copy link
Contributor Author

I'm sort of mixed on this, but:

  • If we extract these to a separate crate (Experiment: styled_text crate #209), then we'll have to agree on a common name for them.
  • We already have 2 names for them within these 2 crates and it gets annoying.
  • Masonry does a re-export of parley::fontique::Weight as TextWeight, but then goes on to use TextWeight, FontWeight (from parley::style) in doc comments, and also Weight, all in the same code.

So it would be nice to have a single name for these.

In this PR, I chose Font* because of the mapping to what the CSS Fonts specifications use.

@waywardmonkeys waywardmonkeys force-pushed the rename-fontique-attributes branch from f27a037 to 16e9600 Compare December 9, 2024 03:01
@waywardmonkeys waywardmonkeys requested a review from dfrg December 9, 2024 03:01
@waywardmonkeys
Copy link
Contributor Author

linebender/xilem#778 shows why having a single name in Parley and Fontique will be good (and why that name should be FontWeight and not Weight).

Copy link
Collaborator

@dfrg dfrg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this PR, I chose Font* because of the mapping to what the CSS Fonts specifications use.

Sgtm. I think we should generally try to mirror CSS naming moving forward.

@waywardmonkeys
Copy link
Contributor Author

Sgtm. I think we should generally try to mirror CSS naming moving forward.

In a subsequent PR, I will suggest renaming FontStretch to FontWidth and see how we all feel about that.

This brings them into line with how they're used in `parley::style`
as well as closer to how they're named in CSS where these properties
are `font-stretch` (since renamed to `font-width`), `font-style`,
and `font-weight`.

This is a precursor to extracting this code into a separate crate
for styling text.
@waywardmonkeys waywardmonkeys force-pushed the rename-fontique-attributes branch from 16e9600 to 2501041 Compare December 9, 2024 05:06
@waywardmonkeys waywardmonkeys added this pull request to the merge queue Dec 9, 2024
Merged via the queue into linebender:main with commit ffea1e6 Dec 9, 2024
20 checks passed
@waywardmonkeys waywardmonkeys deleted the rename-fontique-attributes branch December 9, 2024 05:13
waywardmonkeys added a commit to waywardmonkeys/parley that referenced this pull request Dec 9, 2024
This exposes `from_fontconfig` functions on `FontStretch`, `FontStyle`,
and `FontWeight` rather than only defining them locally within the
fontconfig code.

This is in preparation for a change similar to linebender#211 where these types
and others get pulled into a shared vocabulary crate and this sort
of constructor helper would be useful to others.
waywardmonkeys added a commit to waywardmonkeys/parley that referenced this pull request Dec 9, 2024
This exposes `from_fontconfig` functions on `FontStretch`, `FontStyle`,
and `FontWeight` rather than only defining them locally within the
fontconfig code.

This is in preparation for a change similar to linebender#211 where these types
and others get pulled into a shared vocabulary crate and this sort
of constructor helper would be useful to others.
waywardmonkeys added a commit to waywardmonkeys/parley that referenced this pull request Dec 9, 2024
This can be used in the future as part of FFI work, but for now,
the `Contiguous` trait is used to provide a `MAX_VALUE` used by
`GenericFamilyMap`.

This is a backport of part of linebender#211 where the separation between
`GenericFamily` and `GenericFamilyMap` has grown to span crates.
waywardmonkeys added a commit to waywardmonkeys/parley that referenced this pull request Dec 9, 2024
This can be used in the future as part of FFI work, but for now,
the `Contiguous` trait is used to provide a `MAX_VALUE` used by
`GenericFamilyMap`.

This is a backport of part of linebender#211 where the separation between
`GenericFamily` and `GenericFamilyMap` has grown to span crates.

The testing here borrows from (copies) what is done for similar
testing of `bytemuck` traits in the `color` crate.
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

Successfully merging this pull request may close these issues.

3 participants