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

C++ Tables (font and cmap) in wrong order #29

Open
GoogleCodeExporter opened this issue Mar 19, 2015 · 1 comment
Open

C++ Tables (font and cmap) in wrong order #29

GoogleCodeExporter opened this issue Mar 19, 2015 · 1 comment

Comments

@GoogleCodeExporter
Copy link

OTS santizer rejected fonts serialized by C++ library because wrong order of 
font tables. And because of wrong ordered cmap tables.

This font could not be loaded in web browser (except IE) after I changed 
comparator classes it started to work.

Jan Hruby

Original issue reported on code.google.com by jhruby....@gmail.com on 28 Jan 2013 at 6:44

@GoogleCodeExporter
Copy link
Author

I ran into this problem as well. This bug is especially problematic because it 
generates fonts that will be rejected by the OTS sanitizer 
(<https://code.google.com/p/ots/source/browse/trunk/src/ots.cc#425>), which is 
used by a bunch of browsers to determine whether or not to allow a font.

I think the problem is that the comparator in header.cc 
<https://code.google.com/p/sfntly/source/browse/trunk/cpp/src/sfntly/table/heade
r.cc?r=89#63> causes the headers to be sorted in reverse order:

bool HeaderComparatorByTag::operator() (const HeaderPtr lhs,
                                        const HeaderPtr rhs) {
  return lhs->tag_ > rhs->tag_;
}

Switching the ">" to a "<" fixes the problem. Note that this is probably a 
mis-port of the 
com.google.typography.font.sfntly.table.Header.COMPARATOR_BY_TAG 
<https://code.google.com/p/sfntly/source/browse/trunk/java/src/com/google/typogr
aphy/font/sfntly/table/Header.java?r=104#53>, which sorts like:

  public static final Comparator<Header> COMPARATOR_BY_TAG = new Comparator<Header>() {
    @Override
    public int compare(Header h1, Header h2) {
      return h1.tag - h2.tag;
    } 

Original comment by mprud...@gmail.com on 22 Dec 2013 at 3:06

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant