prawn-emoji 4.0.0.beta.1 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +10 -4
- data/README.md +6 -0
- data/lib/prawn/emoji/drawable.rb +3 -3
- data/lib/prawn/emoji/drawer.rb +6 -2
- data/lib/prawn/emoji/text.rb +5 -5
- data/lib/prawn/emoji/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2b7d56de903eb9de13dd85933c035fd10b80adf07e1884f59917d4531c01fc34
|
4
|
+
data.tar.gz: b138d0eaafdbc6133b787a0af0ec02f53a036c2843cf5a0b58ccc729cdcc697d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz: '
|
6
|
+
metadata.gz: 2a5a68b72b5cf442101ef53fa9bbba86887286d752cbc7ecf1ebcb7e759a0b59939e25ea6a13841ddbc34e13a5bb6e9a0c9d6d3555f352c8501115456c4d3905
|
7
|
+
data.tar.gz: '049e887b7f8cbc66343c4c8e683eae6268c564f5502ffe4058b4d4e072e24028f24b58918d22e6c1032cca5332c010e09e7a75072d68a17358ac9c5087f6f279'
|
data/CHANGELOG.md
CHANGED
@@ -1,13 +1,19 @@
|
|
1
1
|
## Master (Unreleased)
|
2
2
|
|
3
|
-
## 4.0.0
|
3
|
+
## 4.0.0
|
4
|
+
|
5
|
+
### Enhancements
|
6
|
+
|
7
|
+
* prawn-emoji is no longer dependent on a particular font due to the new emoji drawing process
|
4
8
|
|
5
9
|
### Breaking Changes
|
6
10
|
|
7
|
-
* Changes how to draw text including emoji:
|
8
|
-
* The result of drawing emoji will changes slightly
|
9
|
-
* prawn-emoji no longer requires Japanese fonts because it stopped replacing an emoji with the substitution char such as full-width space
|
10
11
|
* Drop ruby 2.4 support
|
12
|
+
* The drawing results of emoji will be chnaged slightly due to the new emoji drawing process
|
13
|
+
|
14
|
+
### Bug Fixes
|
15
|
+
|
16
|
+
* Some emojis are not displayed #34
|
11
17
|
|
12
18
|
## 3.3.0
|
13
19
|
|
data/README.md
CHANGED
@@ -138,6 +138,12 @@ You can run test:
|
|
138
138
|
> src# bundle exec rake test
|
139
139
|
```
|
140
140
|
|
141
|
+
Or, you can run test instantly like this:
|
142
|
+
|
143
|
+
```
|
144
|
+
$ docker run --rm -v $PWD:/src:cached -it prawn-emoji bash -c "bundle install && bundle exec rake test:pdf"
|
145
|
+
```
|
146
|
+
|
141
147
|
### Updating the bundled emojis
|
142
148
|
|
143
149
|
```
|
data/lib/prawn/emoji/drawable.rb
CHANGED
@@ -8,12 +8,12 @@ module Prawn
|
|
8
8
|
# == Additional Options
|
9
9
|
# <tt>:emoji</tt>:: <tt>boolean</tt>. Whether or not to draw an emoji [true]
|
10
10
|
def draw_text!(text, options)
|
11
|
-
draw_emoji = options.
|
11
|
+
draw_emoji = options.delete(:emoji) { true }
|
12
12
|
|
13
|
-
if draw_emoji &&
|
13
|
+
if draw_emoji && Emoji::Drawer.drawable?(text)
|
14
14
|
emoji_drawer.draw(text.to_s, options)
|
15
15
|
else
|
16
|
-
super
|
16
|
+
super
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
data/lib/prawn/emoji/drawer.rb
CHANGED
@@ -7,6 +7,10 @@ require_relative 'text'
|
|
7
7
|
module Prawn
|
8
8
|
module Emoji
|
9
9
|
class Drawer
|
10
|
+
def self.drawable?(text)
|
11
|
+
text.encoding == ::Encoding::UTF_8 && Emoji.regex.match?(text)
|
12
|
+
end
|
13
|
+
|
10
14
|
def initialize(document)
|
11
15
|
@document = document
|
12
16
|
@emoji_index = Emoji::Index.new
|
@@ -18,9 +22,9 @@ module Prawn
|
|
18
22
|
emoji_text = Emoji::Text.new(text, document.font_size)
|
19
23
|
|
20
24
|
while emoji_text.contains_emoji? do
|
21
|
-
if emoji_index.include?(emoji_text.
|
25
|
+
if emoji_index.include?(emoji_text.emoji_char.codepoint)
|
22
26
|
cursor_x += draw_text(emoji_text.left, at: [cursor_x, cursor_y], text_options: text_options)
|
23
|
-
cursor_x += draw_emoji(emoji_text.
|
27
|
+
cursor_x += draw_emoji(emoji_text.emoji_char, at: [cursor_x, cursor_y])
|
24
28
|
else
|
25
29
|
cursor_x += draw_text(emoji_text.left_with_emoji, at: [cursor_x, cursor_y], text_options: text_options)
|
26
30
|
end
|
data/lib/prawn/emoji/text.rb
CHANGED
@@ -5,20 +5,20 @@ require_relative 'char'
|
|
5
5
|
module Prawn
|
6
6
|
module Emoji
|
7
7
|
class Text
|
8
|
-
attr_reader :left, :
|
8
|
+
attr_reader :left, :emoji_char, :remaining
|
9
9
|
|
10
10
|
def initialize(text, font_size)
|
11
11
|
@text = text
|
12
|
-
@left,
|
13
|
-
@
|
12
|
+
@left, emoji, @remaining = partition_by_emoji(text)
|
13
|
+
@emoji_char = Emoji::Char.new(emoji, font_size) unless emoji.empty?
|
14
14
|
end
|
15
15
|
|
16
16
|
def contains_emoji?
|
17
|
-
!
|
17
|
+
!emoji_char.nil?
|
18
18
|
end
|
19
19
|
|
20
20
|
def left_with_emoji
|
21
|
-
left +
|
21
|
+
left + emoji_char.to_s
|
22
22
|
end
|
23
23
|
|
24
24
|
def to_s
|
data/lib/prawn/emoji/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: prawn-emoji
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.0
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Katsuya HIDAKA
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: prawn
|
@@ -3509,9 +3509,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
3509
3509
|
version: '2.5'
|
3510
3510
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
3511
3511
|
requirements:
|
3512
|
-
- - "
|
3512
|
+
- - ">="
|
3513
3513
|
- !ruby/object:Gem::Version
|
3514
|
-
version:
|
3514
|
+
version: '0'
|
3515
3515
|
requirements: []
|
3516
3516
|
rubygems_version: 3.1.2
|
3517
3517
|
signing_key:
|