Skip to content

Commit

Permalink
OTS: Add GSUB table support.
Browse files Browse the repository at this point in the history
- Added src/gsub.{cc,h} for supporting GSUB table.
- Many fonts don't arrange script and feature tags in alphabetical order and
it might not be a security issue so no longer treat it as an error.

BUG=27131
TEST=http://code.google.com/p/ots/wiki/HowToTestOts (Verified with ~4000 TrueType/OpenType fonts) 
TEST=Confirmed that chrome can render the W3C font tests[1] for TTF font linking of Complex scripts(Khmer and Devanagari) as expected by hand.

[1] http://www.w3.org/International/tests/tests-html-css/list-fonts
  • Loading branch information
[email protected] committed Mar 18, 2011
1 parent 6d918d9 commit d52d77a
Show file tree
Hide file tree
Showing 11 changed files with 755 additions and 8 deletions.
2 changes: 2 additions & 0 deletions ots-common.gypi
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
'src/glyf.h',
'src/gpos.cc',
'src/gpos.h',
'src/gsub.cc',
'src/gsub.h',
'src/hdmx.cc',
'src/hdmx.h',
'src/head.cc',
Expand Down
10 changes: 8 additions & 2 deletions src/gdef.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <limits>
#include <vector>

#include "gpos.h"
#include "gsub.h"
#include "layout.h"
#include "maxp.h"

Expand Down Expand Up @@ -238,7 +240,7 @@ bool ParseMarkGlyphSetsDefTable(ots::OpenTypeFile *file, const uint8_t *data,
} // namespace

#define DROP_THIS_TABLE \
do { delete file->gdef; file->gdef = 0; } while (0)
do { file->gdef->data = 0; file->gdef->length = 0; } while (0)

namespace ots {

Expand Down Expand Up @@ -367,7 +369,11 @@ bool ots_gdef_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
}

bool ots_gdef_should_serialise(OpenTypeFile *file) {
return file->gdef != NULL;
const bool needed_tables_dropped =
(file->gsub && file->gsub->data == NULL) ||
(file->gpos && file->gpos->data == NULL);
return file->gdef != NULL && file->gdef->data != NULL &&
!needed_tables_dropped;
}

bool ots_gdef_serialise(OTSStream *out, OpenTypeFile *file) {
Expand Down
10 changes: 8 additions & 2 deletions src/gpos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
#include <limits>
#include <vector>

#include "gdef.h"
#include "gsub.h"
#include "layout.h"
#include "maxp.h"

Expand Down Expand Up @@ -665,7 +667,7 @@ bool ParseExtensionPositioning(const ots::OpenTypeFile *file,
} // namespace

#define DROP_THIS_TABLE \
do { delete file->gpos; file->gpos = 0; } while (0)
do { file->gpos->data = 0; file->gpos->length = 0; } while (0)

namespace ots {

Expand Down Expand Up @@ -784,7 +786,11 @@ bool ots_gpos_parse(OpenTypeFile *file, const uint8_t *data, size_t length) {
}

bool ots_gpos_should_serialise(OpenTypeFile *file) {
return file->gpos != NULL;
const bool needed_tables_dropped =
(file->gdef && file->gdef->data == NULL) ||
(file->gsub && file->gsub->data == NULL);
return file->gpos != NULL && file->gpos->data != NULL &&
!needed_tables_dropped;
}

bool ots_gpos_serialise(OTSStream *out, OpenTypeFile *file) {
Expand Down
1 change: 1 addition & 0 deletions src/gpos.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ struct OpenTypeGPOS {
length(0) {
}

// Number of lookups in GPOS table
uint16_t num_lookups;

const uint8_t *data;
Expand Down
Loading

0 comments on commit d52d77a

Please sign in to comment.