Skip to content
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

Avoid crash on null family name #128

Merged
merged 16 commits into from
Mar 2, 2017
Merged

Conversation

springmeyer
Copy link
Contributor

@springmeyer springmeyer commented Nov 23, 2016

Proposed solution for #124. Also addresses #123 and #125

/cc @xrwang @scothis

Copy link
Contributor

@mikemorris mikemorris left a comment

Choose a reason for hiding this comment

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

This looks good with minor changes to avoid creating a glyph PBF when only a style_name exists, which I don't think makes much sense.

It looks like test/bin.test.js may need to be updated, as it appears to be erroring trying to read the invalid test fixture you added (picking it up in https://github.com/mapbox/node-fontnik/blob/master/bin/font-inspect#L29)

src/glyphs.cpp Outdated

std::vector<int> points_vec(points.begin(), points.end());
if (ft_face->family_name || ft_face->style_name) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Handling a case where only ft_face->style_name exists doesn't really make sense IMHO, we'd end up saving glyphs for fonts just named Regular or Bold

src/glyphs.cpp Outdated
} else if (ft_face->family_name) {
baton->faces.emplace_back(ft_face->family_name, std::move(points_vec));
} else {

Copy link
Contributor

Choose a reason for hiding this comment

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

Empty else statement, per comment above handling only style_name doesn't make much sense.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agree, fixed in 90ab6e8

src/glyphs.cpp Outdated
num_faces = ft_face->num_faces;
}

if (ft_face->family_name || ft_face->style_name) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should drop || ft_face->style_name here, as the else fallback will return an error if only style_name is present.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

agree, fixed in 90ab6e8

@springmeyer
Copy link
Contributor Author

This is ready to go and green on travis, except that OS X machines are down right now due to some travis problem.

src/glyphs.cpp Outdated
throw std::runtime_error("control is null");
}
if (!to) {
throw std::runtime_error("control is null");
Copy link
Contributor

Choose a reason for hiding this comment

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

to is null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch. I just removed however (3e2915a) since these are uneeded.

@mikemorris
Copy link
Contributor

This looks ready to merge and tag a release with the minor nit of the error for invalid to. Are the changes in dc87e1e pulled from somewhere upstream, and under what circumstances would the outline funcs crash? If user->ring.pop_back(); invalidates prev, I'm unclear why this would have ever worked...

@springmeyer
Copy link
Contributor Author

This looks ready to merge and tag a release with the minor nit of the error for invalid to.

Agreed.

Are the changes in dc87e1e pulled from somewhere upstream, and under what circumstances would the outline funcs crash? If user->ring.pop_back(); invalidates prev, I'm unclear why this would have ever worked...

This worked because in the currently deployed code (and in master and this previous to a2c47a1) the Point prev was a copy making pop_back() not dangerous. But we really should be taking a reference for efficiency, and therefore dc87e1e fixes the momentary bug introduced in a2c47a1.

@springmeyer
Copy link
Contributor Author

springmeyer commented Nov 29, 2016

Next action on this:

  • merge
  • tag, release
  • test in fontmachine and downstream to ensure things look good

@springmeyer
Copy link
Contributor Author

Note: I'm not able to move on the next actions above for lack of bandwidth. /cc for help on pushing this through @jakepruitt @lbud @tmcw (folks who i can see have worked on the downstream fontmachine).

@springmeyer
Copy link
Contributor Author

Back to this. Merging now and will work on getting this into a release and published next.

@springmeyer springmeyer merged commit 3142641 into master Mar 2, 2017
@springmeyer springmeyer deleted the avoid-crash-on-null-family-name branch March 2, 2017 21:10
@springmeyer
Copy link
Contributor Author

v0.5.0 release is now tagged and published with all these fixes, and including the refactoring work by @ChrisLoer 🙏.

test in fontmachine and downstream to ensure things look good

Looking good at mapbox/fontmachine#15

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.

3 participants