Skip to content

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

Merged
merged 2 commits into from
Dec 7, 2017

Conversation

jrmuizel
Copy link
Collaborator

@jrmuizel jrmuizel commented Nov 28, 2017

This fixes #2051


This change is Reviewable

@bors-servo
Copy link
Contributor

☔ The latest upstream changes (presumably #2121) made this pull request unmergeable. Please resolve the merge conflicts.

@glennw
Copy link
Member

glennw commented Nov 29, 2017

Looks like CI failures on Windows at least?

@bors-servo
Copy link
Contributor

☔ The latest upstream changes (presumably #2120) made this pull request unmergeable. Please resolve the merge conflicts.

@jrmuizel jrmuizel force-pushed the font-data branch 3 times, most recently from 52d09ae to 9517fe9 Compare November 30, 2017 21:06
@jrmuizel
Copy link
Collaborator Author

I just realized this ends up writing out a new font every time it's used

@jrmuizel jrmuizel force-pushed the font-data branch 2 times, most recently from c04fb74 to 0cc1218 Compare December 5, 2017 15:02
@glennw
Copy link
Member

glennw commented Dec 5, 2017

@jrmuizel Is this ready for review now?

@jrmuizel
Copy link
Collaborator Author

jrmuizel commented Dec 5, 2017

Yes.

fn calc_table_checksum<D: Read>(mut data: D) -> u32 {
let mut sum: u32 = 0;
loop {
if let Ok(x) = data.read_u32::<BigEndian>() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

while let Ok(x) = ... {...}

}

fn max_pow_2_less_than(a: u16) -> u16
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: opening bracket

while (x << (shift + 1)) < a {
shift += 1;
}
return shift;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: return

offset += 4 * 3;
offset += 4 * 4 * (count as u32);
for tag in tags.iter() {
if tag == 0x43464620 { // 'CFF '
Copy link
Member

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

@@ -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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: formatting

handle: &NativeFontHandle,
parent: &mut yaml_rust::yaml::Hash,
path_opt: &mut Option<PathBuf>) {
let path = if let &mut Some(ref path) = path_opt {
Copy link
Member

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

}

impl ResourceGenerator {
fn next_rsrc_paths(&mut self, base: &str, ext: &str, ) -> (PathBuf, PathBuf) {
Copy link
Member

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
@glennw
Copy link
Member

glennw commented Dec 7, 2017

I'm just going to assume that the code in cgfont_to_data makes sense. I guess it's based on some existing code? If so, it's probably worth adding a comment in the code referencing where it's ported from.

@bors-servo r+

@bors-servo
Copy link
Contributor

📌 Commit 7bd05c0 has been approved by glennw

bors-servo pushed a commit that referenced this pull request Dec 7, 2017
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 -->
@bors-servo
Copy link
Contributor

⌛ Testing commit 7bd05c0 with merge f6d91e0...

@bors-servo
Copy link
Contributor

☀️ Test successful - status-appveyor, status-travis
Approved by: glennw
Pushing f6d91e0 to master...

@bors-servo bors-servo merged commit 7bd05c0 into servo:master Dec 7, 2017
bors-servo pushed a commit that referenced this pull request Dec 7, 2017
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 -->
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.

Implement NativeFontHandle writing on Mac
4 participants