-
Notifications
You must be signed in to change notification settings - Fork 72
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
Add codepoints_iter() methods for cmap Subtable4/Subtable12 #174
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[package] | ||
name = "ttf-parser" | ||
version = "0.24.1" | ||
version = "0.25.0" | ||
authors = ["Yevhenii Reizner <[email protected]>"] | ||
keywords = ["ttf", "truetype", "opentype"] | ||
categories = ["parser-implementations"] | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -65,13 +65,16 @@ impl<'a> Subtable12<'a> { | |
u16::try_from(id).ok().map(GlyphId) | ||
} | ||
|
||
/// Iterate over each codepoint defined in this table. | ||
pub fn codepoints_iter(&'a self) -> impl Iterator<Item = u32> + 'a { | ||
self.groups | ||
.into_iter() | ||
.flat_map(|group| group.start_char_code..=group.end_char_code) | ||
} | ||
|
||
/// Calls `f` for each codepoint defined in this table. | ||
pub fn codepoints(&self, mut f: impl FnMut(u32)) { | ||
for group in self.groups { | ||
for code_point in group.start_char_code..=group.end_char_code { | ||
f(code_point); | ||
} | ||
} | ||
pub fn codepoints(&self, f: impl FnMut(u32)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This function name doesn't seam clear to me. Wouldn't something with "map" or "for_each" in the name be more explanatory? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is the question directed at me? |
||
self.codepoints_iter().for_each(f) | ||
} | ||
} | ||
|
||
|
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.
Please don't change the version number in PRs. Just the other changes will do and we can set the version as appropriate during the release process.