-
Notifications
You must be signed in to change notification settings - Fork 13
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
Drop quotes from names parsed from fea earlier so we detect empty ones correctly #1194
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so I'm still slightly confused about where the is_empty
check is, but if I'm understanding the intent of this patch correctly, I think that the cleanest fix is to replace the string()
method on the NameSpec
type in token_tree::typed
with something like,
pub(crate) fn string(&self) -> &str {
self.find_token(Kind::String)
.unwrap()
.text
.trim_matches('"')
}
(although honestly just doing it inline in resolve_name_spec
seems fine too.)
...and then since the actual bug is with something ending up in the binary, the best way to test this would be to add a new case in fea-rs/test-data/compile-tests
; there's a readme there that explains this process but it's easy.
BUT if part of the complication here is that there is some filtering happening outside of fea-rs then that won't work, and in that case we should figure out if fea-rs should be doing this filtering or not.
I've left a few little comments on the PR as written, for informational purposes.
(i'm not marking this approved yet because I want to understand where the filtering you mention is happening first)
fea-rs/src/compile/compile_ctx.rs
Outdated
vec!["", "duck"], | ||
vec![ | ||
parse_name_spec("3 1 0x409 \"\"").string, | ||
parse_name_spec("3 1 0x409 \"duck\"").string | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trivia, but fwiw you don't need the vec
here you can just have these be arrays..
fea-rs/src/token_tree/typed.rs
Outdated
@@ -89,7 +89,7 @@ macro_rules! ast_node { | |||
#[derive(Clone, Debug)] | |||
#[allow(missing_docs)] | |||
pub struct $typ { | |||
inner: Node, | |||
pub(crate) inner: Node, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we generate a node()
method you can call, so this shouldn't be necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was to enable construction of a test value, not reading, but perhaps that will be unnecessary once revised
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice okay ya I do think this is much cleaner. Thanks!
Parsing NameSpec from fea retains the double quotes, dropping them only when generating final
name
records. That causes fontc to produce unwanted empty name records because it filters using is_empty. Naive solution: drop the quotes earlier so is_empty works as expected.Makes
name
identical forpython resources/scripts/ttx_diff.py 'https://github.com/marcologous/hanken-grotesk#sources/HankenGrotesk.glyphs'
.