hexapdf 0.12.0 → 0.12.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +13 -0
- data/lib/hexapdf/font/encoding/base.rb +8 -0
- data/lib/hexapdf/font/encoding/difference_encoding.rb +6 -0
- data/lib/hexapdf/font/type1_wrapper.rb +1 -1
- data/lib/hexapdf/version.rb +1 -1
- data/test/hexapdf/font/encoding/test_base.rb +10 -0
- data/test/hexapdf/font/encoding/test_difference_encoding.rb +8 -0
- data/test/hexapdf/font/test_type1_wrapper.rb +4 -3
- data/test/hexapdf/test_writer.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a0354d0b129396ae7c479e806b3115f0be7a7f7d74d47df13f9ad82e5f93df50
|
4
|
+
data.tar.gz: 15f8a80efbffea1724ffdd54bc2f204816def3980ba59986336b742eed3ce6b3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc132b215e6d6bd2ab6684e269c559e1d55301403c2c035e32eb7fc213572b86e993f1307c219f6e0aec6bbd8da36ab6d10146c82b89e52f68ca5c90949ef819
|
7
|
+
data.tar.gz: 9bd6252238d418844de0d9e08250dc6b7d8a620fc1e4f232bea6870986764ced86dadc0e4794512ae6abc347a6cf95569b5af7ff35c54833d57b2c2513a0d987
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
## 0.12.1 - 2020-08-16
|
2
|
+
|
3
|
+
### Added
|
4
|
+
|
5
|
+
* [HexaPDF::Font::Encoding::Base#code] for retrieving the code for a given
|
6
|
+
glyph name
|
7
|
+
|
8
|
+
### Fixed
|
9
|
+
|
10
|
+
* [HexaPDF::Font::Type1Wrapper#encode] to correctly resolve the code for a glyph
|
11
|
+
name
|
12
|
+
|
13
|
+
|
1
14
|
## 0.12.0 - 2020-08-12
|
2
15
|
|
3
16
|
### Added
|
@@ -73,6 +73,14 @@ module HexaPDF
|
|
73
73
|
@unicode_cache[code] ||= GlyphList.name_to_unicode(name(code))
|
74
74
|
end
|
75
75
|
|
76
|
+
# Returns the code for the given glyph name (a Symbol) or +nil+ if there is no code for the
|
77
|
+
# given glyph name.
|
78
|
+
#
|
79
|
+
# If multiple codes reference the given glyph name, the first found is always returned.
|
80
|
+
def code(name)
|
81
|
+
@code_to_name.key(name)
|
82
|
+
end
|
83
|
+
|
76
84
|
end
|
77
85
|
|
78
86
|
end
|
@@ -60,6 +60,12 @@ module HexaPDF
|
|
60
60
|
code_to_name[code] || base_encoding.name(code)
|
61
61
|
end
|
62
62
|
|
63
|
+
# Returns the code for the given glyph name, either from this object, if a code references
|
64
|
+
# the name, or from the base encoding.
|
65
|
+
def code(name)
|
66
|
+
code_to_name.key(name) || base_encoding.code(name)
|
67
|
+
end
|
68
|
+
|
63
69
|
end
|
64
70
|
|
65
71
|
end
|
@@ -192,7 +192,7 @@ module HexaPDF
|
|
192
192
|
if glyph.name == @wrapped_font.missing_glyph_id
|
193
193
|
raise HexaPDF::Error, "Glyph for #{glyph.str.inspect} missing"
|
194
194
|
end
|
195
|
-
code = @encoding.
|
195
|
+
code = @encoding.code(glyph.name)
|
196
196
|
if code
|
197
197
|
code.chr.freeze
|
198
198
|
elsif @max_code < 255
|
data/lib/hexapdf/version.rb
CHANGED
@@ -32,4 +32,14 @@ describe HexaPDF::Font::Encoding::Base do
|
|
32
32
|
assert_nil(@base.unicode(66))
|
33
33
|
end
|
34
34
|
end
|
35
|
+
|
36
|
+
describe "code" do
|
37
|
+
it "returns the code for an existing glyph name" do
|
38
|
+
assert_equal(65, @base.code(:A))
|
39
|
+
end
|
40
|
+
|
41
|
+
it "returns nil if the glyph name is not referenced" do
|
42
|
+
assert_nil(@base.code(:Unknown))
|
43
|
+
end
|
44
|
+
end
|
35
45
|
end
|
@@ -18,4 +18,12 @@ describe HexaPDF::Font::Encoding::DifferenceEncoding do
|
|
18
18
|
assert_equal(:B, @enc.name(66))
|
19
19
|
end
|
20
20
|
end
|
21
|
+
|
22
|
+
describe "code" do
|
23
|
+
it "takes the encoding differences into account" do
|
24
|
+
assert_equal(65, @enc.code(:A))
|
25
|
+
@enc.code_to_name[65] = :Known
|
26
|
+
assert_equal(65, @enc.code(:Known))
|
27
|
+
end
|
28
|
+
end
|
21
29
|
end
|
@@ -13,11 +13,12 @@ describe HexaPDF::Font::Type1Wrapper do
|
|
13
13
|
end
|
14
14
|
|
15
15
|
it "can be used with an existing PDF object" do
|
16
|
-
font = @doc.add({Type: :Font, Subtype: :Type1, Encoding: :
|
16
|
+
font = @doc.add({Type: :Font, Subtype: :Type1, Encoding: {Differences: [65, :B]},
|
17
17
|
BaseFont: :"Times-Roman"})
|
18
18
|
wrapper = HexaPDF::Font::Type1Wrapper.new(@doc, FONT_TIMES, pdf_object: font)
|
19
|
-
assert_equal([:
|
20
|
-
assert_equal("
|
19
|
+
assert_equal([:B, :E, :A, :S, :T], wrapper.decode_utf8("BEAST").map(&:name))
|
20
|
+
assert_equal("A", wrapper.encode(wrapper.glyph(:A)))
|
21
|
+
assert_equal("A", wrapper.encode(wrapper.glyph(:B)))
|
21
22
|
end
|
22
23
|
|
23
24
|
it "returns 1 for the scaling factor" do
|
data/test/hexapdf/test_writer.rb
CHANGED
@@ -40,7 +40,7 @@ describe HexaPDF::Writer do
|
|
40
40
|
219
|
41
41
|
%%EOF
|
42
42
|
3 0 obj
|
43
|
-
<</Producer(HexaPDF version 0.12.
|
43
|
+
<</Producer(HexaPDF version 0.12.1)>>
|
44
44
|
endobj
|
45
45
|
xref
|
46
46
|
3 1
|
@@ -72,7 +72,7 @@ describe HexaPDF::Writer do
|
|
72
72
|
141
|
73
73
|
%%EOF
|
74
74
|
6 0 obj
|
75
|
-
<</Producer(HexaPDF version 0.12.
|
75
|
+
<</Producer(HexaPDF version 0.12.1)>>
|
76
76
|
endobj
|
77
77
|
2 0 obj
|
78
78
|
<</Length 10>>stream
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hexapdf
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.12.
|
4
|
+
version: 0.12.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Leitner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-08-
|
11
|
+
date: 2020-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cmdparse
|