dragonfly_harfbuzz 1.0.0 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df2c3ab44eceb11b1369967d4ba836e4e4a6b5c93a8aa1aaea2a4a76027cc74f
4
- data.tar.gz: 3d3dca8871157110c99dae33bd081c1d3b137bd5d5c1f219e270849371abd62e
3
+ metadata.gz: 0bf9f016957a6112b6780a98641577c56fb5332ed5fb8a4928c17219f57fe8b2
4
+ data.tar.gz: 4afcd3a4330851dc40b09d52d4e6cf5e77679fde8b56a8cda3c664d62ae5f283
5
5
  SHA512:
6
- metadata.gz: 12b1e43a879e9179f0ec66b7ff39927014fec014561eb1df12e7fc3778e411a4630f2305837e3c3d8c132885659b6c62de051b0f84fff3088d3d1d3b33c082bc
7
- data.tar.gz: 72527b11a71864ca51f21f2fb30848df92e40b3fad9c0645e27cf08c541e233a5100102835f8a1866958d04a3349c2a7606c71a599e764b36041dd6d609d12d9
6
+ metadata.gz: 337964e96d448279649158b151b72002bd7a27466bd7e31bab4db88a981d49478fd91be5454a3e8378fc1fade11329be2a62c937dfdaae965937925d8bf75fc7
7
+ data.tar.gz: bda1125020e0e7d74427b0ee09a954e0606ba1640f9c4dcbd6b79368107ca3e69cd36298647c0caa4bc0a409c2c2da4808ce51630917b20fa91faed104390db5
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # CHANGELOG
2
2
 
3
+ ## 1.1.0
4
+
5
+ * support `unicodes` option for `markup_svg: true`
6
+ * `split_paths: false` by default
7
+
3
8
  ## 1.0.0
4
9
 
5
10
  * add `SUPPORTED_FORMATS` and `SUPPORTED_OUTPUT_FORMATS` and raise errors when formats are not matching
@@ -5,6 +5,7 @@ module DragonflyHarfbuzz
5
5
  class HbView
6
6
  def call(content, str, options = {})
7
7
  options = options.each_with_object({}) { |(k, v), memo| memo[k.to_s] = v } # stringify keys
8
+ unicodes = options.fetch('unicodes', nil)
8
9
 
9
10
  raise UnsupportedFormat unless SUPPORTED_FORMATS.include?(content.ext)
10
11
 
@@ -14,7 +15,7 @@ module DragonflyHarfbuzz
14
15
 
15
16
  flatten_svg = options.fetch('flatten_svg', false)
16
17
  markup_svg = options.fetch('markup_svg', flatten_svg)
17
- split_paths = options.fetch('split_paths', true)
18
+ split_paths = options.fetch('split_paths', false)
18
19
 
19
20
  content.shell_update(ext: format) do |old_path, new_path|
20
21
  args = %W[
@@ -36,7 +37,7 @@ module DragonflyHarfbuzz
36
37
  content.ext = format
37
38
 
38
39
  if format =~ /svg/i
39
- content.update(MarkupSvgService.call(str, content.data, split_paths: split_paths), 'name' => "temp.#{format}") if markup_svg
40
+ content.update(MarkupSvgService.call((str || str_from_unicodes(unicodes)), content.data, split_paths: split_paths), 'name' => "temp.#{format}") if markup_svg
40
41
  content.update(FlattenSvgService.call(content.data), 'name' => "temp.#{format}") if flatten_svg
41
42
  content.update(DomAttrsService.call(content.data, options[:font_size], options[:margin]), 'name' => "temp.#{format}")
42
43
  end
@@ -49,6 +50,12 @@ module DragonflyHarfbuzz
49
50
 
50
51
  private
51
52
 
53
+ def str_from_unicodes(unicodes)
54
+ unicodes.split(",").map do |hexstring|
55
+ Array(hexstring).pack("H*").force_encoding('utf-16be').encode('utf-8')
56
+ end.join
57
+ end
58
+
52
59
  def hb_view_command
53
60
  'hb-view'
54
61
  end
@@ -1,3 +1,3 @@
1
1
  module DragonflyHarfbuzz
2
- VERSION = '1.0.0'.freeze
2
+ VERSION = '1.1.0'.freeze
3
3
  end
@@ -5,15 +5,28 @@ module DragonflyHarfbuzz
5
5
  let(:app) { test_app.configure_with(:harfbuzz) }
6
6
  let(:processor) { DragonflyHarfbuzz::Processors::HbView.new }
7
7
  let(:content) { Dragonfly::Content.new(app, SAMPLES_DIR.join('sample.otf')) }
8
- let(:string) { 'foo foo' }
8
+ let(:string) { 'ABC def' }
9
9
  let(:svg) { processor.call(content, string) }
10
10
  let(:call) { DragonflyHarfbuzz::FlattenSvgService.call(string, svg) }
11
11
 
12
- let(:f_markup) { '<svg character="f" class="character" overflow="visible" x="1552" y="229.504">' }
12
+ before { processor.call(content, string, flatten_svg: true) }
13
13
 
14
- describe 'flatten_svg' do
15
- before { processor.call(content, string, flatten_svg: true) }
16
- it { content.data.sub(f_markup, '').wont_include f_markup }
14
+ describe 'lines' do
15
+ it { content.data.must_include "line=\"#{string}\" class=\"line\"" }
16
+ end
17
+
18
+ describe 'words' do
19
+ it { content.data.must_include '<g word="ABC" class="word">' }
20
+ it { content.data.must_include '<g word="def" class="word">' }
21
+ end
22
+
23
+ describe 'characters' do
24
+ it { content.data.must_include '<svg character="A" class="character"' }
25
+ it { content.data.must_include '<svg character="B" class="character"' }
26
+ it { content.data.must_include '<svg character="C" class="character"' }
27
+ it { content.data.must_include '<svg character="d" class="character"' }
28
+ it { content.data.must_include '<svg character="e" class="character"' }
29
+ it { content.data.must_include '<svg character="f" class="character"' }
17
30
  end
18
31
  end
19
32
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dragonfly_harfbuzz
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tomas Celizna
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-07-14 00:00:00.000000000 Z
11
+ date: 2018-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport