-
Notifications
You must be signed in to change notification settings - Fork 4
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
new check: arabic_spacing_symbols #2
new check: arabic_spacing_symbols #2
Conversation
@simoncozens, I have been working on porting this check and I am still wrapping my head around the Rust language and the way failure conditions are handled. I'm not sure I did the right thing here, so I would appreciate if you could take a look at my implementation and let me know if I did something incorrectly. I'm specially confused about the |
@simoncozens, please also configure this repo so that I become able to request code-reviews from you. |
I'll try to find a nice way to rewrite this (I'm kind of OOO today), but |
5d37eb3
to
2849571
Compare
I haven't addressed the error handling yet, but I have just fixed the conflicts by git-rebasing the branch and updating the code to the latest API. |
note: this now includes the commit from PR #5 as well |
@simoncozens, I've just pushed a few additional commits I've been working on. I am now handling the error conditions and emitting ERROR status code. The code feels too verbose. And maybe I am not yet writing good rust code, but this is the result of my initial attempts to understand how error handling works in rust. One of the next steps, I think, would be to make check functions return What do you think? Please take a look at my updated implementation and let me know how can I further improve it. |
And there's still a Also, I think that if we make checks return return |
6eecb60
to
5ab978a
Compare
@simoncozens, I've updated the code to return But I'm still unhappy about the code-style in my check implementation. I'd love to have a video call with you to get some guidance on better rust coding style. |
We can have a call next week. But note that you can turn an |
Unicode has a few spacing symbols representing Arabic dots and other marks, but they are purposefully not classified as marks. Many fonts mistakenly classify them as marks, making them unsuitable for their original purpose as stand-alone symbols to used in pedagogical contexts discussing Arabic consonantal marks. com.google.fonts/check/arabic_spacing_symbols Added to Universal profile. (Ported from fonttools/fontbakery#4295)
5ab978a
to
dd4af2c
Compare
Ok, I've just updated the PR again to the latest API, now using the check macro. This is now broken though, because I don't know how to properly handle this: pub fn glyph_class_def(&self) -> Option<Result<ClassDef<'a>, ReadError>>``` |
well... I also tried using let cmap = f.get_cmap()
.map_err(|_| CheckError::Error("Font lacks a cmap table".to_string()))?;
let gdef = f.get_gdef()
.map_err(|_| CheckError::Error("Font lacks a gdef table".to_string()))?;
let class_def = gdef.glyph_class_def().ok_or("No class_def found")
.map_err(|e| CheckError::Error(format!("Some classDef error: {}", e)))?;
for codepoint in ARABIC_SPACING_SYMBOLS {
let gid = cmap.map_codepoint(codepoint);
if gid.is_some() && class_def.get(gid.ok_or("Failed to read gid")?) == 3
{
problems.push(Status::fail("gdef-mark", &format!(
"U+{:04X} is defined in GDEF as a mark (class 3).", codepoint)));
}
} |
}; | ||
|
||
for codepoint in ARABIC_SPACING_SYMBOLS { | ||
let gid = cmap.map_codepoint(codepoint); | ||
if gid.is_some() | ||
// && class_def.get(gid.ok_or("Failed to read gid")?) == 3 |
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.
oh boy... it will take me some time to get used to this! LOL
Thanks for the tips, @simoncozens !
Check that Arabic spacing symbols U+FBB2–FBC1 aren't classified as marks.
Unicode has a few spacing symbols representing Arabic dots and other marks, but they are purposefully not classified as marks.
Many fonts mistakenly classify them as marks, making them unsuitable for their original purpose as stand-alone symbols to used in pedagogical contexts discussing Arabic consonantal marks.
(Ported from fonttools/fontbakery#4295)