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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df6049f973c509b992f095c4e0ba9350d60c3c4aa9a400e2d2ad8ed0e3a5770c
4
- data.tar.gz: e8dc6fad7e6dfa7c77160462d46f93d5544d6de0b483507fc904cd1ab5cb0d1a
3
+ metadata.gz: 2b7d56de903eb9de13dd85933c035fd10b80adf07e1884f59917d4531c01fc34
4
+ data.tar.gz: b138d0eaafdbc6133b787a0af0ec02f53a036c2843cf5a0b58ccc729cdcc697d
5
5
  SHA512:
6
- metadata.gz: dcc0640b6ee339682aec4a53dd65d620f370c93f7c19e011754b8493f66a710af911f8441fdf61e389695321aa661de20897bac39e78e6fa3236eef6fdf61168
7
- data.tar.gz: '087003d57a544f7f6538d555f2cdb392c6b17eef2edf83e3fd94d73e11c0e50db369787334738fb22c4b805d23e9a2531454a33e935abf0b197f4834dde27a4c'
6
+ metadata.gz: 2a5a68b72b5cf442101ef53fa9bbba86887286d752cbc7ecf1ebcb7e759a0b59939e25ea6a13841ddbc34e13a5bb6e9a0c9d6d3555f352c8501115456c4d3905
7
+ data.tar.gz: '049e887b7f8cbc66343c4c8e683eae6268c564f5502ffe4058b4d4e072e24028f24b58918d22e6c1032cca5332c010e09e7a75072d68a17358ac9c5087f6f279'
@@ -1,13 +1,19 @@
1
1
  ## Master (Unreleased)
2
2
 
3
- ## 4.0.0.beta.1
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
  ```
@@ -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.fetch(:emoji, true)
11
+ draw_emoji = options.delete(:emoji) { true }
12
12
 
13
- if draw_emoji && text.encoding == ::Encoding::UTF_8 && Emoji.regex.match?(text)
13
+ if draw_emoji && Emoji::Drawer.drawable?(text)
14
14
  emoji_drawer.draw(text.to_s, options)
15
15
  else
16
- super(text, options)
16
+ super
17
17
  end
18
18
  end
19
19
 
@@ -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.emoji.codepoint)
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.emoji, at: [cursor_x, cursor_y])
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
@@ -5,20 +5,20 @@ require_relative 'char'
5
5
  module Prawn
6
6
  module Emoji
7
7
  class Text
8
- attr_reader :left, :emoji, :remaining
8
+ attr_reader :left, :emoji_char, :remaining
9
9
 
10
10
  def initialize(text, font_size)
11
11
  @text = text
12
- @left, emoji_char, @remaining = partition_by_emoji(text)
13
- @emoji = Emoji::Char.new(emoji_char, font_size) unless emoji_char.empty?
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
- !emoji.nil?
17
+ !emoji_char.nil?
18
18
  end
19
19
 
20
20
  def left_with_emoji
21
- left + emoji.to_s
21
+ left + emoji_char.to_s
22
22
  end
23
23
 
24
24
  def to_s
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Prawn
4
4
  module Emoji
5
- VERSION = '4.0.0.beta.1'
5
+ VERSION = '4.0.0'
6
6
  end
7
7
  end
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.beta.1
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-06 00:00:00.000000000 Z
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: 1.3.1
3514
+ version: '0'
3515
3515
  requirements: []
3516
3516
  rubygems_version: 3.1.2
3517
3517
  signing_key: