ttfunk 1.2.2 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/examples/metrics.rb +1 -2
- data/lib/ttfunk/directory.rb +2 -3
- data/lib/ttfunk/resource_file.rb +1 -1
- data/lib/ttfunk/subset/base.rb +13 -13
- data/lib/ttfunk/subset/mac_roman.rb +3 -2
- data/lib/ttfunk/subset/unicode.rb +1 -1
- data/lib/ttfunk/subset/unicode_8bit.rb +1 -1
- data/lib/ttfunk/subset/windows_1252.rb +3 -2
- data/lib/ttfunk/subset.rb +4 -4
- data/lib/ttfunk/subset_collection.rb +1 -1
- data/lib/ttfunk/table/cmap/format00.rb +4 -4
- data/lib/ttfunk/table/cmap/format06.rb +2 -2
- data/lib/ttfunk/table/cmap/format10.rb +2 -2
- data/lib/ttfunk/table/cmap/format12.rb +3 -3
- data/lib/ttfunk/table/cmap/subtable.rb +6 -6
- data/lib/ttfunk/table/cmap.rb +1 -1
- data/lib/ttfunk/table/glyf/compound.rb +1 -1
- data/lib/ttfunk/table/glyf/simple.rb +1 -1
- data/lib/ttfunk/table/glyf.rb +3 -3
- data/lib/ttfunk/table/head.rb +1 -1
- data/lib/ttfunk/table/hhea.rb +1 -1
- data/lib/ttfunk/table/hmtx.rb +1 -1
- data/lib/ttfunk/table/kern/format0.rb +2 -3
- data/lib/ttfunk/table/kern.rb +2 -2
- data/lib/ttfunk/table/loca.rb +1 -1
- data/lib/ttfunk/table/maxp.rb +1 -1
- data/lib/ttfunk/table/name.rb +3 -3
- data/lib/ttfunk/table/os2.rb +1 -1
- data/lib/ttfunk/table/post/format20.rb +1 -1
- data/lib/ttfunk/table/post.rb +19 -16
- data/lib/ttfunk/table/simple.rb +1 -1
- data/lib/ttfunk/table.rb +1 -1
- data/lib/ttfunk.rb +14 -14
- metadata +2 -3
- data/lib/ttfunk/table/post/format25.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 177f0f3efc15ab66c0ea79eb2487cf99c490ba6c
|
4
|
+
data.tar.gz: 7626c05ec3d7e39f747ad0d057ad9b7deef0953a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cc35b7fecf4001efabab23ddbac642f852506ed574c9d2a1ebcb54fd03f7b70819d3de3ca81b711116564eb8ea91dfa01f649ca6d244598d8d1048077bd534be
|
7
|
+
data.tar.gz: 92a5ad612492679643e34e5c231b9de256afb0a5f3c7cf1d178c0f6f3f5e68bc108a35cf773675ad02da000b233bc9b370b0a43763080135e02248801859cfa9
|
data/examples/metrics.rb
CHANGED
data/lib/ttfunk/directory.rb
CHANGED
@@ -4,9 +4,8 @@ module TTFunk
|
|
4
4
|
attr_reader :scaler_type
|
5
5
|
|
6
6
|
def initialize(io)
|
7
|
-
@scaler_type, table_count
|
8
|
-
|
9
|
-
|
7
|
+
@scaler_type, table_count = io.read(12).unpack("Nn")
|
8
|
+
|
10
9
|
@tables = {}
|
11
10
|
table_count.times do
|
12
11
|
tag, checksum, offset, length = io.read(16).unpack("a4N*")
|
data/lib/ttfunk/resource_file.rb
CHANGED
@@ -12,7 +12,7 @@ module TTFunk
|
|
12
12
|
def initialize(io)
|
13
13
|
@io = io
|
14
14
|
|
15
|
-
data_offset, map_offset,
|
15
|
+
data_offset, map_offset, map_length = @io.read(16).unpack("NNx4N")
|
16
16
|
|
17
17
|
@map = {}
|
18
18
|
@io.pos = map_offset + 24 # skip header copy, next map handle, file reference, and attrs
|
data/lib/ttfunk/subset/base.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
1
|
+
require_relative '../table/cmap'
|
2
|
+
require_relative '../table/glyf'
|
3
|
+
require_relative '../table/head'
|
4
|
+
require_relative '../table/hhea'
|
5
|
+
require_relative '../table/hmtx'
|
6
|
+
require_relative '../table/kern'
|
7
|
+
require_relative '../table/loca'
|
8
|
+
require_relative '../table/maxp'
|
9
|
+
require_relative '../table/name'
|
10
|
+
require_relative '../table/post'
|
11
|
+
require_relative '../table/simple'
|
12
12
|
|
13
13
|
module TTFunk
|
14
14
|
module Subset
|
@@ -31,11 +31,11 @@ module TTFunk
|
|
31
31
|
cmap_table = new_cmap_table(options)
|
32
32
|
glyphs = collect_glyphs(original_glyph_ids)
|
33
33
|
|
34
|
-
old2new_glyph = cmap_table[:charmap].inject({ 0 => 0 }) { |map, (
|
34
|
+
old2new_glyph = cmap_table[:charmap].inject({ 0 => 0 }) { |map, (_, ids)| map[ids[:old]] = ids[:new]; map }
|
35
35
|
next_glyph_id = cmap_table[:max_glyph_id]
|
36
36
|
|
37
37
|
glyphs.keys.each do |old_id|
|
38
|
-
unless old2new_glyph.key?(old_id)
|
38
|
+
unless old2new_glyph.key?(old_id)
|
39
39
|
old2new_glyph[old_id] = next_glyph_id
|
40
40
|
next_glyph_id += 1
|
41
41
|
end
|
data/lib/ttfunk/subset.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
require_relative 'subset/unicode'
|
2
|
+
require_relative 'subset/unicode_8bit'
|
3
|
+
require_relative 'subset/mac_roman'
|
4
|
+
require_relative 'subset/windows_1252'
|
5
5
|
|
6
6
|
module TTFunk
|
7
7
|
module Subset
|
@@ -1,5 +1,5 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
require_relative '../../encoding/mac_roman'
|
2
|
+
require_relative '../../encoding/windows_1252'
|
3
3
|
|
4
4
|
module TTFunk
|
5
5
|
class Table
|
@@ -16,7 +16,7 @@ module TTFunk
|
|
16
16
|
# ids. The returned hash also includes a :subtable key, which contains
|
17
17
|
# the encoded subtable for the given charmap.
|
18
18
|
def self.encode(charmap)
|
19
|
-
next_id = 0
|
19
|
+
next_id = 0
|
20
20
|
glyph_indexes = Array.new(256, 0)
|
21
21
|
glyph_map = { 0 => 0 }
|
22
22
|
|
@@ -44,7 +44,7 @@ module TTFunk
|
|
44
44
|
private
|
45
45
|
|
46
46
|
def parse_cmap!
|
47
|
-
|
47
|
+
@language = read(4, "x2n")
|
48
48
|
@code_map = read(256, "C*")
|
49
49
|
end
|
50
50
|
end
|
@@ -7,7 +7,7 @@ module TTFunk
|
|
7
7
|
attr_reader :code_map
|
8
8
|
|
9
9
|
def self.encode(charmap)
|
10
|
-
next_id = 0
|
10
|
+
next_id = 0
|
11
11
|
glyph_map = { 0 => 0 }
|
12
12
|
|
13
13
|
sorted_chars = charmap.keys.sort
|
@@ -37,7 +37,7 @@ module TTFunk
|
|
37
37
|
|
38
38
|
private
|
39
39
|
def parse_cmap!
|
40
|
-
|
40
|
+
@language, firstcode, entrycount = read(8, 'x2nnn')
|
41
41
|
@code_map = {}
|
42
42
|
(firstcode...(firstcode+entrycount)).each do |code|
|
43
43
|
@code_map[code] = read(2, 'n').first & 0xFFFF
|
@@ -7,7 +7,7 @@ module TTFunk
|
|
7
7
|
attr_reader :code_map
|
8
8
|
|
9
9
|
def self.encode(charmap)
|
10
|
-
next_id = 0
|
10
|
+
next_id = 0
|
11
11
|
glyph_map = { 0 => 0 }
|
12
12
|
|
13
13
|
sorted_chars = charmap.keys.sort
|
@@ -37,7 +37,7 @@ module TTFunk
|
|
37
37
|
|
38
38
|
private
|
39
39
|
def parse_cmap!
|
40
|
-
fractional_version,
|
40
|
+
fractional_version, @language, firstcode, entrycount = read(18, 'nx4NNN')
|
41
41
|
raise NotImplementedError, "cmap version 10.#{fractional_version} is not supported" if fractional_version != 0
|
42
42
|
@code_map = {}
|
43
43
|
(firstcode...(firstcode+entrycount)).each do |code|
|
@@ -7,7 +7,7 @@ module TTFunk
|
|
7
7
|
attr_reader :code_map
|
8
8
|
|
9
9
|
def self.encode(charmap)
|
10
|
-
next_id = 0
|
10
|
+
next_id = 0
|
11
11
|
glyph_map = { 0 => 0 }
|
12
12
|
range_firstglyphs, range_firstcodes, range_lengths = [], [], []
|
13
13
|
last_glyph = last_code = -999
|
@@ -18,7 +18,7 @@ module TTFunk
|
|
18
18
|
|
19
19
|
if code > last_code+1 || glyph_map[charmap[code]] > last_glyph+1
|
20
20
|
range_firstcodes << code
|
21
|
-
range_firstglyphs << glyph_map[charmap[code]]
|
21
|
+
range_firstglyphs << glyph_map[charmap[code]]
|
22
22
|
range_lengths << 1
|
23
23
|
else
|
24
24
|
range_lengths.push(range_lengths.pop) + 1
|
@@ -48,7 +48,7 @@ module TTFunk
|
|
48
48
|
|
49
49
|
private
|
50
50
|
def parse_cmap!
|
51
|
-
fractional_version,
|
51
|
+
fractional_version, @language, groupcount = read(14, 'nx4NN')
|
52
52
|
raise NotImplementedError, "cmap version 12.#{fractional_version} is not supported" if fractional_version != 0
|
53
53
|
@code_map = {}
|
54
54
|
(1..groupcount).each do
|
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative '../../reader'
|
2
2
|
|
3
3
|
module TTFunk
|
4
4
|
class Table
|
@@ -81,8 +81,8 @@ module TTFunk
|
|
81
81
|
end
|
82
82
|
end
|
83
83
|
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
84
|
+
require_relative 'format00'
|
85
|
+
require_relative 'format04'
|
86
|
+
require_relative 'format06'
|
87
|
+
require_relative 'format10'
|
88
|
+
require_relative 'format12'
|
data/lib/ttfunk/table/cmap.rb
CHANGED
data/lib/ttfunk/table/glyf.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative '../table'
|
2
2
|
|
3
3
|
module TTFunk
|
4
4
|
class Table
|
@@ -60,5 +60,5 @@ module TTFunk
|
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
63
|
-
|
64
|
-
|
63
|
+
require_relative 'glyf/compound'
|
64
|
+
require_relative 'glyf/simple'
|
data/lib/ttfunk/table/head.rb
CHANGED
data/lib/ttfunk/table/hhea.rb
CHANGED
data/lib/ttfunk/table/hmtx.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative '../../reader'
|
2
2
|
|
3
3
|
module TTFunk
|
4
4
|
class Table
|
@@ -12,8 +12,7 @@ module TTFunk
|
|
12
12
|
def initialize(attributes={})
|
13
13
|
@attributes = attributes
|
14
14
|
|
15
|
-
num_pairs,
|
16
|
-
attributes.delete(:data).unpack("n*")
|
15
|
+
num_pairs, *pairs = attributes.delete(:data).unpack("nx6n*")
|
17
16
|
|
18
17
|
@pairs = {}
|
19
18
|
num_pairs.times do |i|
|
data/lib/ttfunk/table/kern.rb
CHANGED
data/lib/ttfunk/table/loca.rb
CHANGED
data/lib/ttfunk/table/maxp.rb
CHANGED
data/lib/ttfunk/table/name.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require_relative '../table'
|
2
2
|
|
3
3
|
module TTFunk
|
4
4
|
class Table
|
@@ -53,7 +53,7 @@ module TTFunk
|
|
53
53
|
|
54
54
|
strings = names.strings.dup
|
55
55
|
strings[6] = [postscript_name]
|
56
|
-
str_count = strings.inject(0) { |sum, (
|
56
|
+
str_count = strings.inject(0) { |sum, (_, list)| sum + list.length }
|
57
57
|
|
58
58
|
table = [0, str_count, 6 + 12 * str_count].pack("n*")
|
59
59
|
strtable = ""
|
@@ -76,7 +76,7 @@ module TTFunk
|
|
76
76
|
private
|
77
77
|
|
78
78
|
def parse!
|
79
|
-
|
79
|
+
count, string_offset = read(6, "x2n*")
|
80
80
|
|
81
81
|
entries = []
|
82
82
|
count.times do
|
data/lib/ttfunk/table/os2.rb
CHANGED
data/lib/ttfunk/table/post.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
|
1
|
+
require_relative '../table'
|
2
2
|
|
3
|
-
module TTFunk
|
3
|
+
module TTFunk
|
4
4
|
class Table
|
5
5
|
class Post < Table
|
6
6
|
attr_reader :format
|
@@ -60,17 +60,21 @@ module TTFunk
|
|
60
60
|
|
61
61
|
def parse!
|
62
62
|
@format, @italic_angle, @underline_position, @underline_thickness,
|
63
|
-
@fixed_pitch, @min_mem_type42, @max_mem_type42,
|
63
|
+
@fixed_pitch, @min_mem_type42, @max_mem_type42,
|
64
64
|
@min_mem_type1, @max_mem_type1 = read(32, "N2n2N*")
|
65
65
|
|
66
|
-
end_of_table = offset + length
|
67
|
-
|
68
66
|
@subtable = case @format
|
69
|
-
when 0x00010000
|
70
|
-
|
71
|
-
when
|
72
|
-
|
73
|
-
when
|
67
|
+
when 0x00010000
|
68
|
+
extend(Post::Format10)
|
69
|
+
when 0x00020000
|
70
|
+
extend(Post::Format20)
|
71
|
+
when 0x00025000
|
72
|
+
raise NotImplementedError,
|
73
|
+
"Post format 2.5 is not supported by TTFunk"
|
74
|
+
when 0x00030000
|
75
|
+
extend(Post::Format30)
|
76
|
+
when 0x00040000
|
77
|
+
extend(Post::Format40)
|
74
78
|
end
|
75
79
|
|
76
80
|
parse_format!
|
@@ -80,12 +84,11 @@ module TTFunk
|
|
80
84
|
warn "postscript table format 0x%08X is not supported" % @format
|
81
85
|
end
|
82
86
|
end
|
83
|
-
|
87
|
+
|
84
88
|
end
|
85
89
|
end
|
86
90
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
require 'ttfunk/table/post/format40'
|
91
|
+
require_relative 'post/format10'
|
92
|
+
require_relative 'post/format20'
|
93
|
+
require_relative 'post/format30'
|
94
|
+
require_relative 'post/format40'
|
data/lib/ttfunk/table/simple.rb
CHANGED
data/lib/ttfunk/table.rb
CHANGED
data/lib/ttfunk.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
require 'stringio'
|
2
2
|
require 'pathname'
|
3
|
-
|
4
|
-
|
3
|
+
|
4
|
+
require_relative 'ttfunk/directory'
|
5
|
+
require_relative 'ttfunk/resource_file'
|
5
6
|
|
6
7
|
module TTFunk
|
7
8
|
class File
|
@@ -108,15 +109,14 @@ module TTFunk
|
|
108
109
|
end
|
109
110
|
end
|
110
111
|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
112
|
+
require_relative "ttfunk/table/cmap"
|
113
|
+
require_relative "ttfunk/table/glyf"
|
114
|
+
require_relative "ttfunk/table/head"
|
115
|
+
require_relative "ttfunk/table/hhea"
|
116
|
+
require_relative "ttfunk/table/hmtx"
|
117
|
+
require_relative "ttfunk/table/kern"
|
118
|
+
require_relative "ttfunk/table/loca"
|
119
|
+
require_relative "ttfunk/table/maxp"
|
120
|
+
require_relative "ttfunk/table/name"
|
121
|
+
require_relative "ttfunk/table/os2"
|
122
|
+
require_relative "ttfunk/table/post"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ttfunk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Gregory Brown
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2014-
|
15
|
+
date: 2014-09-10 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rdoc
|
@@ -125,7 +125,6 @@ files:
|
|
125
125
|
- lib/ttfunk/table/post.rb
|
126
126
|
- lib/ttfunk/table/post/format10.rb
|
127
127
|
- lib/ttfunk/table/post/format20.rb
|
128
|
-
- lib/ttfunk/table/post/format25.rb
|
129
128
|
- lib/ttfunk/table/post/format30.rb
|
130
129
|
- lib/ttfunk/table/post/format40.rb
|
131
130
|
- lib/ttfunk/table/simple.rb
|
@@ -1,23 +0,0 @@
|
|
1
|
-
require 'ttfunk/table/post/format10'
|
2
|
-
require 'stringio'
|
3
|
-
|
4
|
-
module TTFunk
|
5
|
-
class Table
|
6
|
-
class Post
|
7
|
-
module Format25
|
8
|
-
include Format10
|
9
|
-
|
10
|
-
def glyph_for(code)
|
11
|
-
POSTSCRIPT_GLYPHS[code + @offsets[code]] || ".notdef"
|
12
|
-
end
|
13
|
-
|
14
|
-
private
|
15
|
-
|
16
|
-
def parse_format!
|
17
|
-
number_of_glyphs = read(2, 'n').first
|
18
|
-
@offsets = read(@number_of_glyphs, "c*")
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|