-
Notifications
You must be signed in to change notification settings - Fork 296
Support serializing NativeFontHandle on macOS #2122
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
Conversation
☔ The latest upstream changes (presumably #2121) made this pull request unmergeable. Please resolve the merge conflicts. |
Looks like CI failures on Windows at least? |
☔ The latest upstream changes (presumably #2120) made this pull request unmergeable. Please resolve the merge conflicts. |
52d09ae
to
9517fe9
Compare
I just realized this ends up writing out a new font every time it's used |
c04fb74
to
0cc1218
Compare
@jrmuizel Is this ready for review now? |
Yes. |
wrench/src/cgfont_to_data.rs
Outdated
fn calc_table_checksum<D: Read>(mut data: D) -> u32 { | ||
let mut sum: u32 = 0; | ||
loop { | ||
if let Ok(x) = data.read_u32::<BigEndian>() { |
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.
while let Ok(x) = ... {...}
wrench/src/cgfont_to_data.rs
Outdated
} | ||
|
||
fn max_pow_2_less_than(a: u16) -> u16 | ||
{ |
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.
nit: opening bracket
wrench/src/cgfont_to_data.rs
Outdated
while (x << (shift + 1)) < a { | ||
shift += 1; | ||
} | ||
return shift; |
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.
nit: return
wrench/src/cgfont_to_data.rs
Outdated
offset += 4 * 3; | ||
offset += 4 * 4 * (count as u32); | ||
for tag in tags.iter() { | ||
if tag == 0x43464620 { // 'CFF ' |
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.
nit: could be const
thing for clarity
wrench/src/yaml_frame_writer.rs
Outdated
@@ -217,25 +217,49 @@ fn write_sc(parent: &mut Table, sc: &StackingContext, properties: &SceneProperti | |||
} | |||
|
|||
#[cfg(target_os = "windows")] | |||
fn native_font_handle_to_yaml(handle: &NativeFontHandle, parent: &mut yaml_rust::yaml::Hash) { | |||
fn native_font_handle_to_yaml(_rsrc: &mut ResourceGenerator, | |||
handle: &NativeFontHandle, |
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.
nit: formatting
wrench/src/yaml_frame_writer.rs
Outdated
handle: &NativeFontHandle, | ||
parent: &mut yaml_rust::yaml::Hash, | ||
path_opt: &mut Option<PathBuf>) { | ||
let path = if let &mut Some(ref path) = path_opt { |
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.
nit: use match *path_opt
wrench/src/yaml_frame_writer.rs
Outdated
} | ||
|
||
impl ResourceGenerator { | ||
fn next_rsrc_paths(&mut self, base: &str, ext: &str, ) -> (PathBuf, PathBuf) { |
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.
nit: trailing comma?
This cleans up things a little and will make it easier for us to generate files for native fonts because we won't have multiple mutable borrows on YamlFrameWriter.
This ups the core-graphics dependency and adds the ability to convert a CGFont into a font file. The code is based on the code in https://searchfox.org/mozilla-central/rev/7a8c667bdd2a4a32746c9862356e199627c0896d/gfx/2d/ScaledFontMac.cpp#255 We also switch to CFNumber::from to avoid breakage with the latest core-foundation
I'm just going to assume that the code in @bors-servo r+ |
📌 Commit 7bd05c0 has been approved by |
Support serializing NativeFontHandle on macOS This fixes #2051 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/2122) <!-- Reviewable:end -->
☀️ Test successful - status-appveyor, status-travis |
Force corefoundation 0.4.6 or higher since we use CFNumber::from whic… …h didn't exist in 0.4.4 The use of CFNumber::from was added in #2122 and caused downstream gecko bustage since gecko is still using 0.4.4 in its Cargo.lock file. This change will force gecko to update to 0.4.6. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/webrender/2190) <!-- Reviewable:end -->
This fixes #2051
This change is