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.

@cmyr cmyr force-pushed the split-kern-by-script branch from da37594 to d4160af Compare March 13, 2024 21:12
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 force-pushed the kern-lookup-type branch from 83c0668 to 69cff1d Compare March 14, 2024 14:22
@cmyr cmyr force-pushed the split-kern-by-script branch from b687af6 to e1e743d Compare March 14, 2024 17:01
@cmyr cmyr mentioned this pull request Mar 14, 2024
@cmyr cmyr force-pushed the kern-lookup-type branch from 69cff1d to 1ea4260 Compare March 14, 2024 18:33
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 🕵️

cmyr added 2 commits March 15, 2024 12:03
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 force-pushed the kern-lookup-type branch from 1ea4260 to d5e8245 Compare March 15, 2024 16:06
@cmyr cmyr force-pushed the kern-lookup-type branch from d5e8245 to ff58bec Compare March 15, 2024 16:07
@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