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

set lookupflag and mark filtering set for kerning lookups #733

Merged
merged 3 commits into from
Mar 15, 2024

Conversation

cmyr
Copy link
Member

@cmyr cmyr commented Mar 13, 2024

This adds a PendingLookup type so that we can compute and store the lookup flag and the mark filtering sets when we generate the kerning lookups.

based on #731, which should go in first.

Cargo.toml Outdated
@@ -52,3 +51,6 @@ members = [
"layout-normalizer",
]

[patch.crates-io]
Copy link
Contributor

Choose a reason for hiding this comment

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

Presumably we should move to unpatched deps before merge.

.as_ref()
.map(write_fonts::dump_table)
.transpose()
.expect("if this doesn't compile we will already panic when we try to add it to the context");
Copy link
Contributor

Choose a reason for hiding this comment

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

Not quite sure I follow. This seems like it should return an Error and if that causes a downstream panic that's a bug?

Copy link
Member Author

Choose a reason for hiding this comment

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

what this comment is saying is that if we panic here (because GSUB fails to pack) it's a case where we are already going to panic, because the way contexts work we unwrap this when we save it to the context.

pub const COMMON_SCRIPT: UnicodeShortName =
unsafe { UnicodeShortName::from_bytes_unchecked(*b"Zyyy") };
pub const INHERITED_SCRIPT: UnicodeShortName =
unsafe { UnicodeShortName::from_bytes_unchecked(*b"Zinh") };
Copy link
Contributor

Choose a reason for hiding this comment

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

Having just gone through considerable delay as a result of unsafe I would very much like to avoid the unsafe.

Perhaps a function with a static OnceCell hidden inside would suffice?

Copy link
Member Author

@cmyr cmyr Mar 14, 2024

Choose a reason for hiding this comment

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

Do we anticipate trying to get fontc into google3 in the near future? I've opened unicode-org/icu4x#4691 to add a safe const constructor for tinystr, which will let us remove this; in the meantime the safety of these blocks is trivially verifiable. A function feels bad, but if this is an issue I can always just declare them as needed where they're used.

Copy link
Contributor

Choose a reason for hiding this comment

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

If this is temporary it's fine to file an issue for it and submit. I wouldn't expect to put fontc in google3 soon.

Copy link
Contributor

@rsheeter rsheeter left a comment

Choose a reason for hiding this comment

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

The Rust largely LGTM. I think @anthrotype better have a look before we merge as he has greater understanding of the nuances of the Python.

@cmyr cmyr mentioned this pull request Mar 14, 2024
Base automatically changed from split-kern-by-script to main March 14, 2024 19:22
@@ -585,7 +619,8 @@ fn debug_ordered_lookups(

/// All the state needed for splitting kern pairs by script & writing direction
struct KernSplitContext {
gdef: Option<HashMap<GlyphId, GlyphClassDef>>,
/// map of all mark glyphs; bool indicates if mark is spacing
Copy link
Member

Choose a reason for hiding this comment

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

the MarkSpacing enum is not actually a "bool" though, is it? Should it be? maybe you changed it to enum and the comment is stale

Copy link
Member Author

Choose a reason for hiding this comment

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

your deduction is correct 🕵️

This will let us pre-compute and store the lookupflags and any mark
filtering set.
This also adds tests that we are generating the expected lookups & flags
for mark & non-mark kerning lookups.
@cmyr cmyr added this pull request to the merge queue Mar 15, 2024
Merged via the queue into main with commit 9466281 Mar 15, 2024
10 checks passed
@cmyr cmyr deleted the kern-lookup-type branch March 15, 2024 16:15
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