ttfunk 1.3.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/ttfunk.rb +6 -1
- data/lib/ttfunk/table/sbix.rb +54 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 78159985ca295665778e7a61bc86f5fb60e64576
|
4
|
+
data.tar.gz: f4c79101f0f684003183e32d9251ca96c3e72222
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b7fa90240e932b32b7f8e5423783bdc295856a3154ac42be83606d5a67cf466f0fab02bcdd2a6a60f5297d69adfcd7fe25f0d7b542fd81500710b1b2a1a8203
|
7
|
+
data.tar.gz: 9d66adee4258dec0600aa5fb76838f583872aaec2d6ef6772b13596f4b1bda9af1370f50123af195f38bb67accb48e10925ba6542a538d730e80395a6a92f05a
|
data/lib/ttfunk.rb
CHANGED
@@ -106,7 +106,11 @@ module TTFunk
|
|
106
106
|
def glyph_outlines
|
107
107
|
@glyph_outlines ||= TTFunk::Table::Glyf.new(self)
|
108
108
|
end
|
109
|
-
|
109
|
+
|
110
|
+
def sbix
|
111
|
+
@sbix ||= TTFunk::Table::Sbix.new(self)
|
112
|
+
end
|
113
|
+
end
|
110
114
|
end
|
111
115
|
|
112
116
|
require_relative "ttfunk/table/cmap"
|
@@ -120,3 +124,4 @@ require_relative "ttfunk/table/maxp"
|
|
120
124
|
require_relative "ttfunk/table/name"
|
121
125
|
require_relative "ttfunk/table/os2"
|
122
126
|
require_relative "ttfunk/table/post"
|
127
|
+
require_relative "ttfunk/table/sbix"
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require_relative '../table'
|
2
|
+
|
3
|
+
module TTFunk
|
4
|
+
class Table
|
5
|
+
class Sbix < Table
|
6
|
+
attr_reader :version
|
7
|
+
attr_reader :flags
|
8
|
+
attr_reader :num_strikes
|
9
|
+
attr_reader :strikes
|
10
|
+
|
11
|
+
BitmapData = Struct.new(:x, :y, :type, :data, :ppem, :resolution)
|
12
|
+
|
13
|
+
def bitmap_data_for(glyph_id, strike_index)
|
14
|
+
strike = strikes[strike_index]
|
15
|
+
return if strike.nil?
|
16
|
+
|
17
|
+
glyph_offset = strike[:glyph_data_offset][glyph_id]
|
18
|
+
next_glyph_offset = strike[:glyph_data_offset][glyph_id + 1]
|
19
|
+
|
20
|
+
if glyph_offset && next_glyph_offset
|
21
|
+
bytes = next_glyph_offset - glyph_offset
|
22
|
+
if bytes > 0
|
23
|
+
parse_from(offset + strike[:offset] + glyph_offset) do
|
24
|
+
x, y, type = read(8, "s2A4")
|
25
|
+
data = StringIO.new(io.read(bytes - 8))
|
26
|
+
BitmapData.new(x, y, type, data, strike[:ppem], strike[:resolution])
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def all_bitmap_data_for(glyph_id)
|
33
|
+
strikes.each_index.map do |strike_index|
|
34
|
+
bitmap_data_for(glyph_id, strike_index)
|
35
|
+
end.compact
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def parse!
|
41
|
+
@version, @flags, @num_strikes = read(8, "n2N")
|
42
|
+
strike_offsets = num_strikes.times.map { read(4, "N").first }
|
43
|
+
|
44
|
+
@strikes = strike_offsets.map do |strike_offset|
|
45
|
+
parse_from(offset + strike_offset) do
|
46
|
+
ppem, resolution = read(4, "n2")
|
47
|
+
data_offsets = (file.maximum_profile.num_glyphs + 1).times.map { read(4, "N").first }
|
48
|
+
{ ppem: ppem, resolution: resolution, offset: strike_offset, glyph_data_offset: data_offsets }
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
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.4.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-09-
|
15
|
+
date: 2014-09-21 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rdoc
|
@@ -127,6 +127,7 @@ files:
|
|
127
127
|
- lib/ttfunk/table/post/format20.rb
|
128
128
|
- lib/ttfunk/table/post/format30.rb
|
129
129
|
- lib/ttfunk/table/post/format40.rb
|
130
|
+
- lib/ttfunk/table/sbix.rb
|
130
131
|
- lib/ttfunk/table/simple.rb
|
131
132
|
homepage:
|
132
133
|
licenses: []
|