harfbuzz 0.4 → 0.6
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/.gitignore +1 -0
- data/README.md +3 -1
- data/Rakefile +1 -10
- data/examples/benchmark.rb +1 -1
- data/examples/example.rb +2 -2
- data/harfbuzz.gemspec +5 -4
- data/lib/harfbuzz/base.rb +1 -1
- data/lib/harfbuzz/buffer.rb +9 -2
- data/lib/harfbuzz/face.rb +62 -0
- data/lib/harfbuzz/font.rb +33 -1
- data/lib/harfbuzz/language.rb +37 -0
- data/lib/harfbuzz.rb +34 -1
- data/test/{test_face.rb → face_test.rb} +6 -0
- data/test/{test_font.rb → font_test.rb} +10 -0
- data/test/general_test.rb +30 -0
- data/test/helpers.rb +1 -1
- metadata +41 -30
- data/test/test_general.rb +0 -17
- /data/test/{test_blob.rb → blob_test.rb} +0 -0
- /data/test/{test_shaper.rb → shaper_test.rb} +0 -0
- /data/test/{test_version.rb → version_test.rb} +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 33191ebc2a0aed32b09e1ab47cc80518a812d7f0b8f804e102dcebf9566247c0
|
|
4
|
+
data.tar.gz: 91cf7a6db5eb787fb5915e1e692f5aa4d646215f42775e403caba72da24bbd3f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 934962978e00ab939e1ebfaf279c9551a52f4115032f177075f1d3fc2dffbb56317bae5272e84d70a520de9bd229c05458049d5aeaed8a3138aab46f6d9936ec
|
|
7
|
+
data.tar.gz: fc1b54ae57f40f52171118b4addb1127ab832a6ab30d5ca91cb697793fb59d37b5966214286f6b0f1fe625b1c011c7a02a9ee39854d1f43ab409326347286c71
|
data/.gitignore
CHANGED
data/README.md
CHANGED
|
@@ -28,7 +28,7 @@ The Harfbuzz gem is composed of two layers: a low-level direct interface to Harf
|
|
|
28
28
|
|
|
29
29
|
The low-level interface is a one-to-one mapping of Harfbuzz C functions to Ruby methods, implemented using the [FFI](https://github.com/ffi/ffi) library. For example, the Harfbuzz C function `hb_version_string()` is available in Ruby as `Harfbuzz.hb_version_string`. However, as the low-level methods return C pointers wrapped in FFI objects, this layer is generally not useful to a Ruby programmer.
|
|
30
30
|
|
|
31
|
-
The high-level interface abstracts the C functions, structures, and pointers into Ruby objects. For example,
|
|
31
|
+
The high-level interface abstracts the C functions, structures, and pointers into Ruby objects. For example, `hb_version_string()` function is more usefully available via `Harfbuzz.version_string`, which returns a Ruby string containing with the version of the Harfbuzz library.
|
|
32
32
|
|
|
33
33
|
Where appropriate, Ruby classes have been constructed to map to the concepts in Harfbuzz. Hence:
|
|
34
34
|
|
|
@@ -53,6 +53,8 @@ Memory management may not be correct. (I've seen crashes when processing large a
|
|
|
53
53
|
|
|
54
54
|
## To-do
|
|
55
55
|
|
|
56
|
+
- Update for recent (version 4.0+) versions of Harfbuzz.
|
|
57
|
+
|
|
56
58
|
- Implement hb_buffer_set_* functions.
|
|
57
59
|
|
|
58
60
|
- Add documentation.
|
data/Rakefile
CHANGED
data/examples/benchmark.rb
CHANGED
|
@@ -8,7 +8,7 @@ Features = %w{+dlig +hlig}
|
|
|
8
8
|
|
|
9
9
|
Benchmark.bm do |benchmark|
|
|
10
10
|
benchmark.report do
|
|
11
|
-
face = Harfbuzz::Face.new(Harfbuzz::Blob.new(File.open('/
|
|
11
|
+
face = Harfbuzz::Face.new(Harfbuzz::Blob.new(File.open('/Users/johnl/Fonts/A/Adobe Caslon Pro/ACaslonPro-Regular.otf', 'rb')))
|
|
12
12
|
font = Harfbuzz::Font.new(face)
|
|
13
13
|
Words.each do |word|
|
|
14
14
|
buffer = Harfbuzz::Buffer.new
|
data/examples/example.rb
CHANGED
|
@@ -14,7 +14,7 @@ puts "Shapers: #{Harfbuzz.shapers.join(', ')}"
|
|
|
14
14
|
# Create a font to be used for shaping. To get the most of out this example, use an OpenType font.
|
|
15
15
|
#
|
|
16
16
|
|
|
17
|
-
face = Harfbuzz::Face.new(File.open('/
|
|
17
|
+
face = Harfbuzz::Face.new(File.open('/Users/johnl/Fonts/A/Adobe Caslon Pro/ACaslonPro-Regular.otf', 'rb'))
|
|
18
18
|
|
|
19
19
|
puts "Font face index: #{face.index}"
|
|
20
20
|
puts "Font face upem: #{face.upem}"
|
|
@@ -82,7 +82,7 @@ buffer.length.times do |i|
|
|
|
82
82
|
info, position = glyph_infos[i], glyph_positions[i]
|
|
83
83
|
glyph_name = font.glyph_to_string(info.codepoint)
|
|
84
84
|
glyph_extents = font.glyph_extents(info.codepoint)
|
|
85
|
-
puts "/%-10.10s %5u | mask: %04X | cluster: %2u | advance: %4d,%4d | offset: %4d,%4d | bearing: %4d,%4d | size: %4d,%4d" % [
|
|
85
|
+
puts "/%-10.10s | gid: %5u | mask: %04X | cluster: %2u | advance: %4d,%4d | offset: %4d,%4d | bearing: %4d,%4d | size: %4d,%4d" % [
|
|
86
86
|
glyph_name,
|
|
87
87
|
info.codepoint,
|
|
88
88
|
info.mask,
|
data/harfbuzz.gemspec
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Gem::Specification.new do |s|
|
|
2
2
|
s.name = 'harfbuzz'
|
|
3
|
-
s.version = '0.
|
|
3
|
+
s.version = '0.6'
|
|
4
4
|
s.summary = 'Ruby interface to the Harfbuzz text shaping engine'
|
|
5
5
|
s.author = 'John Labovitz'
|
|
6
6
|
s.email = 'johnl@johnlabovitz.com'
|
|
@@ -14,9 +14,10 @@ Gem::Specification.new do |s|
|
|
|
14
14
|
s.executables = `git ls-files -- bin/*`.split("\n").map { |f| File.basename(f) }
|
|
15
15
|
s.require_path = 'lib'
|
|
16
16
|
|
|
17
|
-
s.add_dependency 'ffi', '~> 1.
|
|
17
|
+
s.add_dependency 'ffi', '~> 1.17'
|
|
18
18
|
|
|
19
|
-
s.add_development_dependency '
|
|
20
|
-
s.add_development_dependency 'minitest', '~> 5.11'
|
|
19
|
+
s.add_development_dependency 'minitest', '~> 6.0'
|
|
21
20
|
s.add_development_dependency 'minitest-power_assert', '~> 0.3'
|
|
21
|
+
s.add_development_dependency 'rake', '~> 13.4'
|
|
22
|
+
s.add_development_dependency 'simple-rake-tasks', '~> 0.1'
|
|
22
23
|
end
|
data/lib/harfbuzz/base.rb
CHANGED
data/lib/harfbuzz/buffer.rb
CHANGED
|
@@ -12,6 +12,12 @@ module Harfbuzz
|
|
|
12
12
|
:var1, :uint32, # private
|
|
13
13
|
:var2, :uint32 # private
|
|
14
14
|
|
|
15
|
+
def inspect
|
|
16
|
+
"<#{self} codepoint = 0x%04x, mask = 0b%032b, cluster = %d>" % [
|
|
17
|
+
codepoint, mask, cluster,
|
|
18
|
+
]
|
|
19
|
+
end
|
|
20
|
+
|
|
15
21
|
def codepoint
|
|
16
22
|
self[:codepoint]
|
|
17
23
|
end
|
|
@@ -37,8 +43,8 @@ module Harfbuzz
|
|
|
37
43
|
|
|
38
44
|
def inspect
|
|
39
45
|
"<#{self} %s>" % [
|
|
40
|
-
%
|
|
41
|
-
"#{k} = #{self[k
|
|
46
|
+
%i{x_advance y_advance x_offset y_offset}.map { |k|
|
|
47
|
+
"#{k} = #{self[k].inspect}"
|
|
42
48
|
}.join(', ')
|
|
43
49
|
]
|
|
44
50
|
end
|
|
@@ -62,6 +68,7 @@ module Harfbuzz
|
|
|
62
68
|
end
|
|
63
69
|
|
|
64
70
|
attach_function :hb_buffer_create, [], :hb_buffer_t
|
|
71
|
+
attach_function :hb_buffer_destroy, [:hb_buffer_t], :void
|
|
65
72
|
attach_function :hb_buffer_add_utf8, [
|
|
66
73
|
:hb_buffer_t, # buffer
|
|
67
74
|
:pointer, # text
|
data/lib/harfbuzz/face.rb
CHANGED
|
@@ -1,14 +1,49 @@
|
|
|
1
1
|
module Harfbuzz
|
|
2
2
|
|
|
3
3
|
typedef :pointer, :hb_face_t
|
|
4
|
+
typedef :uint, :hb_ot_name_id_t
|
|
4
5
|
|
|
5
6
|
attach_function :hb_face_create, [
|
|
6
7
|
:hb_blob_t, # blob
|
|
7
8
|
:uint, # index
|
|
8
9
|
], :hb_face_t
|
|
10
|
+
attach_function :hb_face_destroy, [:hb_face_t], :void
|
|
9
11
|
attach_function :hb_face_get_index, [:hb_face_t], :uint
|
|
10
12
|
attach_function :hb_face_get_upem, [:hb_face_t], :uint
|
|
11
13
|
attach_function :hb_face_get_glyph_count, [:hb_face_t], :uint
|
|
14
|
+
attach_function :hb_ot_name_get_utf8, [
|
|
15
|
+
:hb_face_t, # face
|
|
16
|
+
:hb_ot_name_id_t, # name_id
|
|
17
|
+
:hb_language_t, # language
|
|
18
|
+
:pointer, # text_size (uint *)
|
|
19
|
+
:pointer, # text (char *)
|
|
20
|
+
], :uint
|
|
21
|
+
|
|
22
|
+
HB_OT_NAME_ID_COPYRIGHT = 0
|
|
23
|
+
HB_OT_NAME_ID_FONT_FAMILY = 1
|
|
24
|
+
HB_OT_NAME_ID_FONT_SUBFAMILY = 2
|
|
25
|
+
HB_OT_NAME_ID_UNIQUE_ID = 3
|
|
26
|
+
HB_OT_NAME_ID_FULL_NAME = 4
|
|
27
|
+
HB_OT_NAME_ID_VERSION_STRING = 5
|
|
28
|
+
HB_OT_NAME_ID_POSTSCRIPT_NAME = 6
|
|
29
|
+
HB_OT_NAME_ID_TRADEMARK = 7
|
|
30
|
+
HB_OT_NAME_ID_MANUFACTURER = 8
|
|
31
|
+
HB_OT_NAME_ID_DESIGNER = 9
|
|
32
|
+
HB_OT_NAME_ID_DESCRIPTION = 10
|
|
33
|
+
HB_OT_NAME_ID_VENDOR_URL = 11
|
|
34
|
+
HB_OT_NAME_ID_DESIGNER_URL = 12
|
|
35
|
+
HB_OT_NAME_ID_LICENSE = 13
|
|
36
|
+
HB_OT_NAME_ID_LICENSE_URL = 14
|
|
37
|
+
HB_OT_NAME_ID_TYPOGRAPHIC_FAMILY = 16
|
|
38
|
+
HB_OT_NAME_ID_TYPOGRAPHIC_SUBFAMILY = 17
|
|
39
|
+
HB_OT_NAME_ID_MAC_FULL_NAME = 18
|
|
40
|
+
HB_OT_NAME_ID_SAMPLE_TEXT = 19
|
|
41
|
+
HB_OT_NAME_ID_CID_FINDFONT_NAME = 20
|
|
42
|
+
HB_OT_NAME_ID_WWS_FAMILY = 21
|
|
43
|
+
HB_OT_NAME_ID_WWS_SUBFAMILY = 22
|
|
44
|
+
HB_OT_NAME_ID_LIGHT_BACKGROUND = 23
|
|
45
|
+
HB_OT_NAME_ID_DARK_BACKGROUND = 24
|
|
46
|
+
HB_OT_NAME_ID_VARIATIONS_PS_PREFIX = 25
|
|
12
47
|
|
|
13
48
|
class Face < Base
|
|
14
49
|
|
|
@@ -32,6 +67,33 @@ module Harfbuzz
|
|
|
32
67
|
Harfbuzz.hb_face_get_glyph_count(@hb_face)
|
|
33
68
|
end
|
|
34
69
|
|
|
70
|
+
MAX_NAME_LEN = 200
|
|
71
|
+
|
|
72
|
+
def name(name_id, language=nil)
|
|
73
|
+
text_size_ptr = FFI::MemoryPointer.new(:uint, 1)
|
|
74
|
+
text_size_ptr.write_uint(MAX_NAME_LEN)
|
|
75
|
+
text_ptr = FFI::MemoryPointer.new(:char, MAX_NAME_LEN) #FIXME: ?
|
|
76
|
+
#FIXME: check result
|
|
77
|
+
Harfbuzz.hb_ot_name_get_utf8(@hb_face, name_id, language, text_size_ptr, text_ptr)
|
|
78
|
+
text_ptr.get_string(0, MAX_NAME_LEN)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def font_family_name(language=nil)
|
|
82
|
+
name(HB_OT_NAME_ID_FONT_FAMILY, language)
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def font_subfamily_name(language=nil)
|
|
86
|
+
name(HB_OT_NAME_ID_FONT_SUBFAMILY, language)
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def full_name(language=nil)
|
|
90
|
+
name(HB_OT_NAME_ID_FULL_NAME, language)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def postscript_name(language=nil)
|
|
94
|
+
name(HB_OT_NAME_ID_POSTSCRIPT_NAME, language)
|
|
95
|
+
end
|
|
96
|
+
|
|
35
97
|
end
|
|
36
98
|
|
|
37
99
|
end
|
data/lib/harfbuzz/font.rb
CHANGED
|
@@ -76,11 +76,19 @@ module Harfbuzz
|
|
|
76
76
|
end
|
|
77
77
|
|
|
78
78
|
attach_function :hb_font_create, [:hb_face_t], :hb_font_t
|
|
79
|
+
attach_function :hb_font_destroy, [:hb_font_t], :void
|
|
79
80
|
attach_function :hb_font_set_scale, [
|
|
80
81
|
:hb_font_t, # font
|
|
81
82
|
:int, # x_scale
|
|
82
83
|
:int, # y_scale
|
|
83
84
|
], :void
|
|
85
|
+
attach_function :hb_font_set_ptem, [
|
|
86
|
+
:hb_font_t,
|
|
87
|
+
:float,
|
|
88
|
+
], :void
|
|
89
|
+
attach_function :hb_font_get_ptem, [
|
|
90
|
+
:hb_font_t,
|
|
91
|
+
], :float
|
|
84
92
|
attach_function :hb_ft_font_set_funcs, [:hb_font_t], :void
|
|
85
93
|
attach_function :hb_font_get_scale, [
|
|
86
94
|
:hb_font_t, # font
|
|
@@ -115,14 +123,23 @@ module Harfbuzz
|
|
|
115
123
|
:hb_codepoint_t, # glyph
|
|
116
124
|
GlyphExtents.by_ref # extents
|
|
117
125
|
], :hb_bool_t
|
|
126
|
+
attach_function :hb_font_get_glyph_advance_for_direction, [
|
|
127
|
+
:hb_font_t, # font
|
|
128
|
+
:hb_codepoint_t, # glyph
|
|
129
|
+
# :hb_direction_t, # direction
|
|
130
|
+
:int, # direction
|
|
131
|
+
:pointer, # x
|
|
132
|
+
:pointer, # y
|
|
133
|
+
], :void
|
|
118
134
|
|
|
119
135
|
class Font < Base
|
|
120
136
|
|
|
121
137
|
attr_reader :hb_font
|
|
122
138
|
|
|
123
|
-
def initialize(face)
|
|
139
|
+
def initialize(face, size=nil)
|
|
124
140
|
@hb_font = Harfbuzz.hb_font_create(face.hb_face)
|
|
125
141
|
Harfbuzz.hb_font_set_scale(@hb_font, face.upem, face.upem)
|
|
142
|
+
Harfbuzz.hb_font_set_ptem(@hb_font, size) if size
|
|
126
143
|
Harfbuzz.hb_ft_font_set_funcs(@hb_font)
|
|
127
144
|
define_finalizer(:hb_font_destroy, @hb_font)
|
|
128
145
|
end
|
|
@@ -147,6 +164,10 @@ module Harfbuzz
|
|
|
147
164
|
]
|
|
148
165
|
end
|
|
149
166
|
|
|
167
|
+
def ptem
|
|
168
|
+
Harfbuzz.hb_font_get_ptem(@hb_font)
|
|
169
|
+
end
|
|
170
|
+
|
|
150
171
|
def glyph_to_string(glyph)
|
|
151
172
|
string_ptr = FFI::MemoryPointer.new(:char, 20)
|
|
152
173
|
Harfbuzz.hb_font_glyph_to_string(@hb_font, glyph, string_ptr, 20)
|
|
@@ -179,6 +200,17 @@ module Harfbuzz
|
|
|
179
200
|
glyph_extents
|
|
180
201
|
end
|
|
181
202
|
|
|
203
|
+
def glyph_advance_for_direction(glyph, direction)
|
|
204
|
+
x_ptr = FFI::MemoryPointer.new(:int32, 1)
|
|
205
|
+
y_ptr = FFI::MemoryPointer.new(:int32, 1)
|
|
206
|
+
Harfbuzz.hb_font_get_glyph_advance_for_direction(@hb_font, glyph, direction, x_ptr, y_ptr)
|
|
207
|
+
if Harfbuzz.hb_direction_is_horizontal(direction)
|
|
208
|
+
x_ptr.read_int32
|
|
209
|
+
else
|
|
210
|
+
y_ptr.read_int32
|
|
211
|
+
end
|
|
212
|
+
end
|
|
213
|
+
|
|
182
214
|
if Harfbuzz.version_at_least(1,1,3)
|
|
183
215
|
|
|
184
216
|
def h_extents
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
module Harfbuzz
|
|
2
|
+
|
|
3
|
+
class Language < FFI::Struct
|
|
4
|
+
|
|
5
|
+
layout :code, :char
|
|
6
|
+
|
|
7
|
+
def code
|
|
8
|
+
self[:code]
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def inspect
|
|
12
|
+
"<#{self} code = %d>" % code
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
typedef Language.by_ref, :hb_language_t
|
|
18
|
+
|
|
19
|
+
attach_function :hb_language_get_default, [], :hb_language_t
|
|
20
|
+
attach_function :hb_language_from_string, [:string, :int], :hb_language_t
|
|
21
|
+
attach_function :hb_language_to_string, [:hb_language_t], :string
|
|
22
|
+
attach_function :hb_language_matches, [:hb_language_t, :hb_language_t], :hb_bool_t
|
|
23
|
+
|
|
24
|
+
def self.language_default
|
|
25
|
+
Harfbuzz.hb_language_get_default
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def self.language_from_string(string)
|
|
29
|
+
Harfbuzz.hb_language_from_string(string, -1)
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def self.language_to_string(language)
|
|
33
|
+
Harfbuzz.hb_language_to_string(language)
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
end
|
data/lib/harfbuzz.rb
CHANGED
|
@@ -13,12 +13,45 @@ module Harfbuzz
|
|
|
13
13
|
typedef :bool, :hb_bool_t
|
|
14
14
|
typedef :int32, :hb_position_t
|
|
15
15
|
|
|
16
|
+
# hb_direction_t enum
|
|
17
|
+
HB_DIRECTION_INVALID = 0
|
|
18
|
+
HB_DIRECTION_LTR = 4
|
|
19
|
+
HB_DIRECTION_RTL = 5
|
|
20
|
+
HB_DIRECTION_TTB = 6
|
|
21
|
+
HB_DIRECTION_BTT = 7
|
|
22
|
+
|
|
23
|
+
def self.hb_direction_is_valid(dir)
|
|
24
|
+
dir & ~3 == 4
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def self.hb_direction_is_horizontal(dir)
|
|
28
|
+
dir & ~1 == 4
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def self.hb_direction_is_vertical(dir)
|
|
32
|
+
dir & ~1 == 6
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def self.hb_direction_is_forward(dir)
|
|
36
|
+
dir & ~2 == 4
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def self.hb_direction_is_backward(dir)
|
|
40
|
+
dir & ~2 == 5
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def self.hb_direction_reverse(dir)
|
|
44
|
+
dir ^ 1
|
|
45
|
+
end
|
|
46
|
+
|
|
16
47
|
end
|
|
17
48
|
|
|
18
49
|
require 'harfbuzz/version'
|
|
19
50
|
require 'harfbuzz/base'
|
|
20
51
|
require 'harfbuzz/blob'
|
|
52
|
+
require 'harfbuzz/buffer'
|
|
53
|
+
require 'harfbuzz/language'
|
|
54
|
+
|
|
21
55
|
require 'harfbuzz/face'
|
|
22
56
|
require 'harfbuzz/font'
|
|
23
|
-
require 'harfbuzz/buffer'
|
|
24
57
|
require 'harfbuzz/shaping'
|
|
@@ -18,6 +18,12 @@ module Harfbuzz
|
|
|
18
18
|
assert { @face.glyph_count > 0 }
|
|
19
19
|
end
|
|
20
20
|
|
|
21
|
+
def test_names
|
|
22
|
+
assert { @face.font_family_name == 'Adobe Caslon Pro' }
|
|
23
|
+
assert { @face.font_subfamily_name == 'Regular' }
|
|
24
|
+
assert { @face.postscript_name == 'ACaslonPro-Regular' }
|
|
25
|
+
end
|
|
26
|
+
|
|
21
27
|
end
|
|
22
28
|
|
|
23
29
|
end
|
|
@@ -6,6 +6,11 @@ module Harfbuzz
|
|
|
6
6
|
|
|
7
7
|
include Setup
|
|
8
8
|
|
|
9
|
+
def test_init_with_size
|
|
10
|
+
font2 = Harfbuzz::Font.new(@face, 12)
|
|
11
|
+
assert { font2.ptem == 12.0 }
|
|
12
|
+
end
|
|
13
|
+
|
|
9
14
|
def test_scale
|
|
10
15
|
scale = @font.scale
|
|
11
16
|
assert { scale.kind_of?(Array) }
|
|
@@ -38,6 +43,11 @@ module Harfbuzz
|
|
|
38
43
|
assert { extents.height != 0 }
|
|
39
44
|
end
|
|
40
45
|
|
|
46
|
+
def test_glyph_advance
|
|
47
|
+
advance = @font.glyph_advance_for_direction(1, Harfbuzz::HB_DIRECTION_LTR)
|
|
48
|
+
assert { advance > 0 }
|
|
49
|
+
end
|
|
50
|
+
|
|
41
51
|
end
|
|
42
52
|
|
|
43
53
|
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require_relative 'helpers'
|
|
2
|
+
|
|
3
|
+
module Harfbuzz
|
|
4
|
+
|
|
5
|
+
class TestGeneral < Minitest::Test
|
|
6
|
+
|
|
7
|
+
include Setup
|
|
8
|
+
|
|
9
|
+
def test_shapers
|
|
10
|
+
shapers = Harfbuzz.shapers
|
|
11
|
+
assert { shapers.kind_of?(Array) }
|
|
12
|
+
assert { shapers.include?('fallback') }
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def test_language_default
|
|
16
|
+
assert { Harfbuzz.language_default.code == 101 }
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def test_language_from_string
|
|
20
|
+
assert { Harfbuzz.language_from_string('en').code == 101 }
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def test_language_to_string
|
|
24
|
+
en = Harfbuzz.language_from_string('en')
|
|
25
|
+
assert { Harfbuzz.language_to_string(en) == 'en' }
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
data/test/helpers.rb
CHANGED
|
@@ -7,7 +7,7 @@ module Harfbuzz
|
|
|
7
7
|
module Setup
|
|
8
8
|
|
|
9
9
|
def setup
|
|
10
|
-
@data = File.open('/
|
|
10
|
+
@data = File.open('/Users/johnl/Fonts/A/Adobe Caslon Pro/ACaslonPro-Regular.otf', 'rb')
|
|
11
11
|
@blob = Harfbuzz::Blob.new(@data)
|
|
12
12
|
@face = Harfbuzz::Face.new(@blob)
|
|
13
13
|
@font = Harfbuzz::Font.new(@face)
|
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: harfbuzz
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: '0.
|
|
4
|
+
version: '0.6'
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- John Labovitz
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: ffi
|
|
@@ -16,56 +15,70 @@ dependencies:
|
|
|
16
15
|
requirements:
|
|
17
16
|
- - "~>"
|
|
18
17
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '1.
|
|
18
|
+
version: '1.17'
|
|
20
19
|
type: :runtime
|
|
21
20
|
prerelease: false
|
|
22
21
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
22
|
requirements:
|
|
24
23
|
- - "~>"
|
|
25
24
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '1.
|
|
25
|
+
version: '1.17'
|
|
27
26
|
- !ruby/object:Gem::Dependency
|
|
28
|
-
name:
|
|
27
|
+
name: minitest
|
|
29
28
|
requirement: !ruby/object:Gem::Requirement
|
|
30
29
|
requirements:
|
|
31
30
|
- - "~>"
|
|
32
31
|
- !ruby/object:Gem::Version
|
|
33
|
-
version: '
|
|
32
|
+
version: '6.0'
|
|
34
33
|
type: :development
|
|
35
34
|
prerelease: false
|
|
36
35
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
36
|
requirements:
|
|
38
37
|
- - "~>"
|
|
39
38
|
- !ruby/object:Gem::Version
|
|
40
|
-
version: '
|
|
39
|
+
version: '6.0'
|
|
41
40
|
- !ruby/object:Gem::Dependency
|
|
42
|
-
name: minitest
|
|
41
|
+
name: minitest-power_assert
|
|
43
42
|
requirement: !ruby/object:Gem::Requirement
|
|
44
43
|
requirements:
|
|
45
44
|
- - "~>"
|
|
46
45
|
- !ruby/object:Gem::Version
|
|
47
|
-
version: '
|
|
46
|
+
version: '0.3'
|
|
48
47
|
type: :development
|
|
49
48
|
prerelease: false
|
|
50
49
|
version_requirements: !ruby/object:Gem::Requirement
|
|
51
50
|
requirements:
|
|
52
51
|
- - "~>"
|
|
53
52
|
- !ruby/object:Gem::Version
|
|
54
|
-
version: '
|
|
53
|
+
version: '0.3'
|
|
55
54
|
- !ruby/object:Gem::Dependency
|
|
56
|
-
name:
|
|
55
|
+
name: rake
|
|
57
56
|
requirement: !ruby/object:Gem::Requirement
|
|
58
57
|
requirements:
|
|
59
58
|
- - "~>"
|
|
60
59
|
- !ruby/object:Gem::Version
|
|
61
|
-
version: '
|
|
60
|
+
version: '13.4'
|
|
62
61
|
type: :development
|
|
63
62
|
prerelease: false
|
|
64
63
|
version_requirements: !ruby/object:Gem::Requirement
|
|
65
64
|
requirements:
|
|
66
65
|
- - "~>"
|
|
67
66
|
- !ruby/object:Gem::Version
|
|
68
|
-
version: '
|
|
67
|
+
version: '13.4'
|
|
68
|
+
- !ruby/object:Gem::Dependency
|
|
69
|
+
name: simple-rake-tasks
|
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - "~>"
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '0.1'
|
|
75
|
+
type: :development
|
|
76
|
+
prerelease: false
|
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - "~>"
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: '0.1'
|
|
69
82
|
description: "\n Harfbuzz is a Ruby interface to the Harfbuzz text shaping engine.\n
|
|
70
83
|
\ "
|
|
71
84
|
email: johnl@johnlabovitz.com
|
|
@@ -89,20 +102,20 @@ files:
|
|
|
89
102
|
- lib/harfbuzz/face.rb
|
|
90
103
|
- lib/harfbuzz/ffi_additions.rb
|
|
91
104
|
- lib/harfbuzz/font.rb
|
|
105
|
+
- lib/harfbuzz/language.rb
|
|
92
106
|
- lib/harfbuzz/shaping.rb
|
|
93
107
|
- lib/harfbuzz/version.rb
|
|
108
|
+
- test/blob_test.rb
|
|
109
|
+
- test/face_test.rb
|
|
110
|
+
- test/font_test.rb
|
|
111
|
+
- test/general_test.rb
|
|
94
112
|
- test/helpers.rb
|
|
95
|
-
- test/
|
|
96
|
-
- test/
|
|
97
|
-
- test/test_font.rb
|
|
98
|
-
- test/test_general.rb
|
|
99
|
-
- test/test_shaper.rb
|
|
100
|
-
- test/test_version.rb
|
|
113
|
+
- test/shaper_test.rb
|
|
114
|
+
- test/version_test.rb
|
|
101
115
|
homepage: http://github.com/jslabovitz/harfbuzz-gem
|
|
102
116
|
licenses:
|
|
103
117
|
- MIT
|
|
104
118
|
metadata: {}
|
|
105
|
-
post_install_message:
|
|
106
119
|
rdoc_options: []
|
|
107
120
|
require_paths:
|
|
108
121
|
- lib
|
|
@@ -117,16 +130,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
117
130
|
- !ruby/object:Gem::Version
|
|
118
131
|
version: '0'
|
|
119
132
|
requirements: []
|
|
120
|
-
|
|
121
|
-
rubygems_version: 2.7.4
|
|
122
|
-
signing_key:
|
|
133
|
+
rubygems_version: 4.0.11
|
|
123
134
|
specification_version: 4
|
|
124
135
|
summary: Ruby interface to the Harfbuzz text shaping engine
|
|
125
136
|
test_files:
|
|
137
|
+
- test/blob_test.rb
|
|
138
|
+
- test/face_test.rb
|
|
139
|
+
- test/font_test.rb
|
|
140
|
+
- test/general_test.rb
|
|
126
141
|
- test/helpers.rb
|
|
127
|
-
- test/
|
|
128
|
-
- test/
|
|
129
|
-
- test/test_font.rb
|
|
130
|
-
- test/test_general.rb
|
|
131
|
-
- test/test_shaper.rb
|
|
132
|
-
- test/test_version.rb
|
|
142
|
+
- test/shaper_test.rb
|
|
143
|
+
- test/version_test.rb
|
data/test/test_general.rb
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
require_relative 'helpers'
|
|
2
|
-
|
|
3
|
-
module Harfbuzz
|
|
4
|
-
|
|
5
|
-
class TestGeneral < Minitest::Test
|
|
6
|
-
|
|
7
|
-
include Setup
|
|
8
|
-
|
|
9
|
-
def test_shapers
|
|
10
|
-
shapers = Harfbuzz.shapers
|
|
11
|
-
assert { shapers.kind_of?(Array) }
|
|
12
|
-
assert { shapers.include?('fallback') }
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|