From 9f4c6345c561bbce98dea9d1d13ab9d086b3929a Mon Sep 17 00:00:00 2001 From: yelouafi Date: Sat, 13 Sep 2014 17:30:42 +0000 Subject: [PATCH] Moved @tag definition to the derived Table constructors --- lib/font/table.coffee | 2 +- lib/font/tables/cmap.coffee | 4 ++++ lib/font/tables/glyf.coffee | 4 ++++ lib/font/tables/head.coffee | 4 ++++ lib/font/tables/hhea.coffee | 4 ++++ lib/font/tables/hmtx.coffee | 4 ++++ lib/font/tables/loca.coffee | 4 ++++ lib/font/tables/maxp.coffee | 4 ++++ lib/font/tables/name.coffee | 4 ++++ lib/font/tables/post.coffee | 4 ++++ lib/font/ttf.coffee | 20 ++++++++++---------- 11 files changed, 47 insertions(+), 11 deletions(-) diff --git a/lib/font/table.coffee b/lib/font/table.coffee index 6f07a7a..98394cb 100644 --- a/lib/font/table.coffee +++ b/lib/font/table.coffee @@ -1,5 +1,5 @@ class Table - constructor: (@file, @tag) -> + constructor: (@file) -> info = @file.directory.tables[@tag] @exists = !!info diff --git a/lib/font/tables/cmap.coffee b/lib/font/tables/cmap.coffee index 7a66f72..25de025 100644 --- a/lib/font/tables/cmap.coffee +++ b/lib/font/tables/cmap.coffee @@ -2,6 +2,10 @@ Table = require '../table' Data = require '../../data' class CmapTable extends Table + constructor: -> + @tag = 'cmap' + super + parse: (data) -> data.pos = @offset diff --git a/lib/font/tables/glyf.coffee b/lib/font/tables/glyf.coffee index 4cf1431..9116c0b 100644 --- a/lib/font/tables/glyf.coffee +++ b/lib/font/tables/glyf.coffee @@ -2,6 +2,10 @@ Table = require '../table' Data = require '../../data' class GlyfTable extends Table + constructor: -> + @tag = 'glyf' + super + parse: (data) -> # We're not going to parse the whole glyf table, just the glyfs we need. See below. @cache = {} diff --git a/lib/font/tables/head.coffee b/lib/font/tables/head.coffee index 6c45b22..0b5d726 100644 --- a/lib/font/tables/head.coffee +++ b/lib/font/tables/head.coffee @@ -2,6 +2,10 @@ Table = require '../table' Data = require '../../data' class HeadTable extends Table + constructor: -> + @tag = 'head' + super + parse: (data) -> data.pos = @offset diff --git a/lib/font/tables/hhea.coffee b/lib/font/tables/hhea.coffee index 2cb3cb5..c824a09 100644 --- a/lib/font/tables/hhea.coffee +++ b/lib/font/tables/hhea.coffee @@ -2,6 +2,10 @@ Table = require '../table' Data = require '../../data' class HheaTable extends Table + constructor: -> + @tag = 'hhea' + super + parse: (data) -> data.pos = @offset diff --git a/lib/font/tables/hmtx.coffee b/lib/font/tables/hmtx.coffee index b40695b..915c524 100644 --- a/lib/font/tables/hmtx.coffee +++ b/lib/font/tables/hmtx.coffee @@ -2,6 +2,10 @@ Table = require '../table' Data = require '../../data' class HmtxTable extends Table + constructor: -> + @tag = 'hmtx' + super + parse: (data) -> data.pos = @offset diff --git a/lib/font/tables/loca.coffee b/lib/font/tables/loca.coffee index 44ac907..6a78e47 100644 --- a/lib/font/tables/loca.coffee +++ b/lib/font/tables/loca.coffee @@ -2,6 +2,10 @@ Table = require '../table' Data = require '../../data' class LocaTable extends Table + constructor: -> + @tag = 'loca' + super + parse: (data) -> data.pos = @offset format = @file.head.indexToLocFormat diff --git a/lib/font/tables/maxp.coffee b/lib/font/tables/maxp.coffee index 4a308da..8b1abc8 100644 --- a/lib/font/tables/maxp.coffee +++ b/lib/font/tables/maxp.coffee @@ -2,6 +2,10 @@ Table = require '../table' Data = require '../../data' class MaxpTable extends Table + constructor: -> + @tag = 'maxp' + super + parse: (data) -> data.pos = @offset diff --git a/lib/font/tables/name.coffee b/lib/font/tables/name.coffee index 4aa7a98..6dbaec2 100644 --- a/lib/font/tables/name.coffee +++ b/lib/font/tables/name.coffee @@ -3,6 +3,10 @@ Data = require '../../data' utils = require '../utils' class NameTable extends Table + constructor: -> + @tag = 'name' + super + parse: (data) -> data.pos = @offset diff --git a/lib/font/tables/post.coffee b/lib/font/tables/post.coffee index d2c496b..2ed5d77 100644 --- a/lib/font/tables/post.coffee +++ b/lib/font/tables/post.coffee @@ -2,6 +2,10 @@ Table = require '../table' Data = require '../../data' class PostTable extends Table + constructor: -> + @tag = 'post' + super + parse: (data) -> data.pos = @offset diff --git a/lib/font/ttf.coffee b/lib/font/ttf.coffee index b92659c..59023b1 100644 --- a/lib/font/ttf.coffee +++ b/lib/font/ttf.coffee @@ -68,16 +68,16 @@ class TTFFont parse: -> @directory = new Directory(@contents) - @head = new HeadTable(this, 'head') - @name = new NameTable(this, 'name') - @cmap = new CmapTable(this, 'cmap') - @hhea = new HheaTable(this, 'hhea') - @maxp = new MaxpTable(this, 'maxp') - @hmtx = new HmtxTable(this, 'hmtx') - @post = new PostTable(this, 'post') - @os2 = new OS2Table(this, 'os2') - @loca = new LocaTable(this, 'loca') - @glyf = new GlyfTable(this, 'glyf') + @head = new HeadTable(this) + @name = new NameTable(this) + @cmap = new CmapTable(this) + @hhea = new HheaTable(this) + @maxp = new MaxpTable(this) + @hmtx = new HmtxTable(this) + @post = new PostTable(this) + @os2 = new OS2Table(this) + @loca = new LocaTable(this) + @glyf = new GlyfTable(this) @ascender = (@os2.exists and @os2.ascender) or @hhea.ascender @decender = (@os2.exists and @os2.decender) or @hhea.decender