emf2svg 1.4.1-x86_64-darwin → 1.4.2-x86_64-darwin

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: f51b9e4b995e2b4e7e3c1d566ceee3c2bf74d110fc5192bb2cb457b582ea547a
4
- data.tar.gz: 3e7e74e94f5ce9ef21ca0371bf096975f1e9cfdd06f80dec6d1b849e5621a177
3
+ metadata.gz: dcdaac0287c9e52cd62747852d51a8c91eb59fa5c5858e8fe66ce47aa0555418
4
+ data.tar.gz: 2aba4ed23f2f593766eec896395cf9b0a1e699077bc6fff6fbb2c2596509db15
5
5
  SHA512:
6
- metadata.gz: d4e36a17c578cbc8559308b580b4c2ebb03f2f24edf86bdddd45a97998784c0e5126fa7f95c70dfeca10170d362b91e139aaf4dd7b1754d82c046a010c88e0da
7
- data.tar.gz: f3f0f8a217eedf30e8807df233858401b9770fff1e07a482a6f2ba6ba6991a3cf629b4f174e1bb70c407c47af64740ea8e6cc0f5e4923b1cc3114fbb236beb1c
6
+ metadata.gz: b8813bd20b4b9ab04043395db83976e2f2f9642574160de0289b46ecbf112ccc91a2f73bec8208359e2e2f7d7acc50d3c8e9c94e7316fbace028d5cbcd4b2b4b
7
+ data.tar.gz: 1fb3842b06b4886477f540f370ffe1dd5129e83269f201a68c4feb65f2f436994b903348637e4d5f4b86162333ab6219ac2f4ad45ef57e6e1ae2d1b555db9dc7
@@ -15,10 +15,8 @@ jobs:
15
15
  fail-fast: false
16
16
  matrix:
17
17
  os: [ ubuntu-18.04, ubuntu-latest, windows-latest, macos-latest ]
18
- ruby-version: [ '2.7' ]
19
- include:
20
- - os: windows-latest
21
- ruby-version: '3.1'
18
+ ruby-version: [ '2.7', '3.0', '3.1' ]
19
+
22
20
  steps:
23
21
  - uses: actions/checkout@v3
24
22
 
@@ -47,27 +45,23 @@ jobs:
47
45
  - os: ubuntu-18.04
48
46
  platform: any
49
47
  ruby-version: '2.7'
50
- file: 'skip'
51
48
  - os: ubuntu-18.04
52
49
  platform: x86_64-linux
53
50
  ruby-version: '2.7'
54
- file: 'ELF 64-bit LSB shared object, x86-64'
55
51
  - os: windows-latest
56
52
  platform: x64-mingw32
57
53
  ruby-version: '2.7'
58
- file: 'skip'
59
54
  - os: windows-latest
60
55
  platform: x64-mingw-ucrt
61
56
  ruby-version: '3.1'
62
- file: 'skip'
63
57
  - os: macos-latest
64
58
  platform: x86_64-darwin
65
59
  ruby-version: '2.7'
66
- file: 'Mach-O 64-bit dynamically linked shared library x86_64'
67
60
  steps:
68
61
  - uses: actions/checkout@v3
69
62
 
70
- - uses: ruby/setup-ruby@v1
63
+ - name: Setup Ruby
64
+ uses: ruby/setup-ruby@v1
71
65
  with:
72
66
  ruby-version: ${{ matrix.ruby-version }}
73
67
  bundler-cache: true
@@ -85,48 +79,50 @@ jobs:
85
79
  name: pkg
86
80
  path: pkg/*.gem
87
81
 
88
- - name: Install gem
89
- run: gem install -b pkg/emf2svg-*.gem
90
-
91
- - name: Test conversion
92
- run: |
93
- ruby -remf2svg -e "puts File.write('output.svg', Emf2svg.from_file('spec/examples/image1.emf'), mode: 'wb')"
94
-
95
- - name: Check file format
96
- if: matrix.file != 'skip'
97
- run: file $(ls pkg/*/lib/emf2svg/libemf2svg.*) | grep "${{ matrix.file }}"
98
-
99
- test-build:
100
- needs: build
82
+ cross-build:
83
+ name: build ${{ matrix.os }}, ${{ matrix.ruby-version }}, ${{ matrix.platform }}
101
84
  runs-on: ${{ matrix.os }}
102
85
  strategy:
103
86
  fail-fast: false
104
87
  matrix:
105
88
  include:
106
89
  - os: ubuntu-latest
107
- platform: any
108
- ruby-version: '2.7'
109
- - os: windows-latest
110
- platform: any
111
- ruby-version: '2.7'
112
- - os: macos-latest
113
- platform: any
114
- ruby-version: '2.7'
115
- - os: ubuntu-18.04
116
- platform: x86_64-linux
117
- ruby-version: '2.7'
118
- - os: ubuntu-latest
119
- platform: x86_64-linux
120
- ruby-version: '2.7'
121
- - os: windows-latest
122
- platform: x64-mingw32
90
+ platform: aarch64-linux
123
91
  ruby-version: '2.7'
124
- - os: windows-latest
125
- platform: x64-mingw-ucrt
126
- ruby-version: '3.1'
127
92
  - os: macos-latest
128
- platform: x86_64-darwin
93
+ platform: arm64-darwin
129
94
  ruby-version: '2.7'
95
+ steps:
96
+ - uses: actions/checkout@v3
97
+
98
+ - name: Install Ubuntu packages
99
+ if: startsWith(matrix.os, 'ubuntu')
100
+ run: |
101
+ sudo apt-get update
102
+ sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu gperf
103
+
104
+ - name: Install Ruby
105
+ uses: ruby/setup-ruby@v1
106
+ with:
107
+ ruby-version: ${{ matrix.ruby-version }}
108
+ bundler-cache: true
109
+
110
+ - name: Build native extension
111
+ run: bundle exec rake gem:native:${{ matrix.platform }}
112
+
113
+ - uses: actions/upload-artifact@v2
114
+ with:
115
+ name: pkg
116
+ path: pkg/*.gem
117
+
118
+ test-build:
119
+ needs: [ build, cross-build ]
120
+ runs-on: ${{ matrix.os }}
121
+ strategy:
122
+ fail-fast: false
123
+ matrix:
124
+ os: [ ubuntu-18.04, ubuntu-latest, windows-latest, macos-latest ]
125
+ ruby-version: [ '2.7', '3.0', '3.1' ]
130
126
 
131
127
  steps:
132
128
  - uses: actions/checkout@v2
@@ -140,62 +136,43 @@ jobs:
140
136
  name: pkg
141
137
  path: pkg
142
138
 
143
- - name: Workaround for vcpkg
144
- if: startsWith(matrix.os, 'ubuntu')
145
- run: |
146
- sudo apt-get update
147
- sudo apt-get install gperf
148
-
149
- - name: Install native gem
150
- if: matrix.platform == 'any'
151
- run: gem install -b pkg/emf2svg-$(ruby -I lib -r emf2svg/version -e "puts Emf2svg::VERSION").gem
152
-
153
139
  - name: Install binary gem
154
- if: matrix.platform != 'any'
155
- run: gem install -b pkg/emf2svg-*-${{ matrix.platform }}.gem
156
-
140
+ run: gem install -b pkg/emf2svg-$(ruby -I lib -r emf2svg/version -e "puts Emf2svg::VERSION")-$(ruby -e "puts RUBY_PLATFORM.sub(/darwin\d{2}$/, 'darwin')").gem
141
+ # MacOS with have something like arm64-darwin19, others just aarch64-linux
157
142
  - name: Test conversion
158
143
  run: |
159
144
  ruby -remf2svg -e "puts File.write('output.svg', Emf2svg.from_file('spec/examples/image1.emf'), mode: 'wb')"
160
145
 
161
- cross:
162
- name: build ${{ matrix.os }}, ${{ matrix.ruby-version }}, ${{ matrix.platform }}
146
+ test-build-any:
147
+ needs: [ build, cross-build ]
163
148
  runs-on: ${{ matrix.os }}
164
149
  strategy:
165
150
  fail-fast: false
166
151
  matrix:
167
- include:
168
- - os: ubuntu-latest
169
- platform: aarch64-linux
170
- ruby-version: '2.7'
171
- file: 'ELF 64-bit LSB shared object, ARM aarch64'
172
- - os: macos-latest
173
- platform: arm64-darwin
174
- ruby-version: '2.7'
175
- file: 'Mach-O 64-bit dynamically linked shared library arm64'
176
- steps:
177
- - uses: actions/checkout@v3
152
+ os: [ ubuntu-18.04, ubuntu-latest, windows-latest, macos-latest ]
153
+ ruby-version: [ '2.7', '3.0', '3.1' ]
178
154
 
179
- - name: Install packages
180
- if: matrix.os == 'ubuntu-latest'
181
- run: |
182
- sudo apt-get update
183
- sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu binutils-aarch64-linux-gnu gperf
155
+ steps:
156
+ - uses: actions/checkout@v2
184
157
 
185
158
  - uses: ruby/setup-ruby@v1
186
159
  with:
187
160
  ruby-version: ${{ matrix.ruby-version }}
188
- bundler-cache: true
189
-
190
- - run: bundle exec rake gem:native:${{ matrix.platform }}
191
161
 
192
- - uses: actions/upload-artifact@v2
162
+ - uses: actions/download-artifact@v2
193
163
  with:
194
164
  name: pkg
195
- path: pkg/*.gem
165
+ path: pkg
166
+
167
+ - name: Workaround for vcpkg
168
+ if: startsWith(matrix.os, 'ubuntu')
169
+ run: |
170
+ sudo apt-get update
171
+ sudo apt-get install gperf
196
172
 
197
- - name: Install gem
198
- run: gem install -b pkg/emf2svg-*.gem
173
+ - name: Install native gem
174
+ run: gem install -b pkg/emf2svg-$(ruby -I lib -r emf2svg/version -e "puts Emf2svg::VERSION").gem
199
175
 
200
- - name: Check file format
201
- run: file $(ls pkg/*/lib/emf2svg/libemf2svg.*) | grep "${{ matrix.file }}"
176
+ - name: Test conversion
177
+ run: |
178
+ ruby -remf2svg -e "puts File.write('output.svg', Emf2svg.from_file('spec/examples/image1.emf'), mode: 'wb')"
data/README.adoc CHANGED
@@ -54,9 +54,13 @@ There are two ways to provide EMF data to `emf2svg`.
54
54
  ----
55
55
  require "emf2svg"
56
56
 
57
- data = Emf2svg.from_file("example.emf")
57
+ data = Emf2svg.from_file("example.emf", 800, 600)
58
58
  File.write("output.svg", data, mode: "wb")
59
59
  ----
60
+ 800, 600 - optional width and height of the bounding rectangle for svg file
61
+ The image will be scaled to fit into this rectangle
62
+ These parameters are optional. If skipped or set to 0 SVG image will have the
63
+ same size as EMF (in pixels)
60
64
  ====
61
65
 
62
66
  === Loading binary data
@@ -71,9 +75,13 @@ File.write("output.svg", data, mode: "wb")
71
75
  require "emf2svg"
72
76
 
73
77
  emf_content = File.read("example.emf", mode: "rb")
74
- svg_data = Emf2svg.from_binary_string(emf_content)
78
+ svg_data = Emf2svg.from_binary_string(emf_content, 800, 600)
75
79
  File.write("output.svg", svg_data, mode: "wb")
76
80
  ----
81
+ 800, 600 - optional width and height of the bounding rectangle for svg file
82
+ The image will be scaled to fit into this rectangle
83
+ These parameters are optional. If skipped or set to 0 SVG image will have the
84
+ same size as EMF (in pixels)
77
85
  ====
78
86
 
79
87
 
data/Rakefile CHANGED
@@ -14,6 +14,7 @@ task default: %i[spec rubocop]
14
14
  task :compile do
15
15
  require_relative "ext/extconf"
16
16
  end
17
+
17
18
  task spec: :compile
18
19
 
19
20
  desc "Build install-compilation gem"
data/bin/emf2svg CHANGED
@@ -1,8 +1,38 @@
1
1
  #!/usr/bin/env ruby
2
2
  # frozen_string_literal: true
3
3
 
4
- require "bundler/setup"
5
4
  require "emf2svg"
6
5
 
7
- svg = Emf2svg.from_file(ARGV[0])
8
- File.write(ARGV[1], svg, mode: "wb")
6
+ def print_usage
7
+ usage = %{Usage: emf2svg <input> <output> [<width>] [<height>]
8
+ <input> -- emf file to convert
9
+ <output> -- svg file to save
10
+ <width> -- svg image width, defaults to source width in px if not set or 0
11
+ <height> -- svg image height, defaults to source height in px if not set or 0
12
+ Note: width and height specify bounding rectangle, the image will be scaled
13
+ propotionally to fit into it.
14
+ }
15
+ puts usage
16
+ end
17
+
18
+ def tint(pos)
19
+ ARGV.size > pos ? Integer(ARGV[pos]) : 0
20
+ rescue ArgumentError, TypeError => e
21
+ puts "ERROR: Failed to convert #{ARGV[pos]} to integer: #{e.message}"
22
+ print_usage
23
+ exit 1
24
+ end
25
+
26
+ if ARGV.size < 2 || ARGV.size > 4 || ARGV[0].casecmp("help").zero?
27
+ print_usage
28
+ exit 0
29
+ end
30
+
31
+ begin
32
+ svg = Emf2svg.from_file(ARGV[0], tint(2), tint(3))
33
+ File.write(ARGV[1], svg, mode: "wb")
34
+ rescue StandardError => e
35
+ puts "ERROR: Failed to process #{ARGV[0]}: #{e.message}"
36
+ print_usage
37
+ exit 1
38
+ end
data/emf2svg.gemspec CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  spec.authors = ["Ribose"]
9
9
  spec.email = ["open.source@ribose.com"]
10
10
 
11
- spec.summary = "Ruby interface to libemf2svg."
11
+ spec.summary = "EMF to SVG conversion in Ruby."
12
12
  spec.homepage = "https://github.com/metanorma/emf2svg-ruby"
13
13
  spec.license = "BSD-2-Clause"
14
14
  spec.required_ruby_version = ">= 2.6.0"
data/exe/emf2svg CHANGED
@@ -3,5 +3,36 @@
3
3
 
4
4
  require "emf2svg"
5
5
 
6
- svg = Emf2svg.from_file(ARGV[0])
7
- File.write(ARGV[1], svg, mode: "wb")
6
+ def print_usage
7
+ usage = %{Usage: emf2svg <input> <output> [<width>] [<height>]
8
+ <input> -- emf file to convert
9
+ <output> -- svg file to save
10
+ <width> -- svg image width, defaults to source width in px if not set or 0
11
+ <height> -- svg image height, defaults to source height in px if not set or 0
12
+ Note: width and height specify bounding rectangle, the image will be scaled
13
+ propotionally to fit into it.
14
+ }
15
+ puts usage
16
+ end
17
+
18
+ def tint(pos)
19
+ ARGV.size > pos ? Integer(ARGV[pos]) : 0
20
+ rescue ArgumentError, TypeError => e
21
+ puts "ERROR: Failed to convert #{ARGV[pos]} to integer: #{e.message}"
22
+ print_usage
23
+ exit 1
24
+ end
25
+
26
+ if ARGV.size < 2 || ARGV.size > 4 || ARGV[0].casecmp("help").zero?
27
+ print_usage
28
+ exit 0
29
+ end
30
+
31
+ begin
32
+ svg = Emf2svg.from_file(ARGV[0], tint(2), tint(3))
33
+ File.write(ARGV[1], svg, mode: "wb")
34
+ rescue StandardError => e
35
+ puts "ERROR: Failed to process #{ARGV[0]}: #{e.message}"
36
+ print_usage
37
+ exit 1
38
+ end
Binary file
@@ -2,17 +2,19 @@ require "rbconfig"
2
2
  require "mini_portile2"
3
3
  require "pathname"
4
4
  require "tmpdir"
5
+ require "open3"
6
+ require_relative "version"
5
7
 
6
8
  module Emf2svg
7
9
  class Recipe < MiniPortileCMake
8
10
  ROOT = Pathname.new(File.expand_path("../..", __dir__))
9
11
 
10
12
  def initialize
11
- super("libemf2svg", "1.7.0")
13
+ super("libemf2svg", LIBEMF2SVG_VERSION)
12
14
 
13
15
  @files << {
14
- url: "https://github.com/metanorma/libemf2svg/releases/download/v1.7.0/libemf2svg.tar.gz",
15
- sha256: "a87a02510f87ed4510a3426fa8636b340e26d96f25edf63c3ba465e7e9d7e2eb", # rubocop:disable Layout/LineLength
16
+ url: "https://github.com/metanorma/libemf2svg/releases/download/v#{LIBEMF2SVG_VERSION}/libemf2svg.tar.gz",
17
+ sha256: "c65f25040a351d18beb5172609a55d034245f85a1152d7f294780c6cc155d876", # rubocop:disable Layout/LineLength
16
18
  }
17
19
 
18
20
  @target = ROOT.join(@target).to_s
@@ -28,58 +30,6 @@ module Emf2svg
28
30
  FileUtils.touch(checkpoint)
29
31
  end
30
32
 
31
- # rubocop:disable Metrics/MethodLength
32
- # rubocop:disable Metrics/CyclomaticComplexity
33
- def host_platform
34
- @host_platform ||=
35
- case @host
36
- when /\Ax86_64.*mingw32/
37
- "x64-mingw32"
38
- when /\Ax86_64.*linux/
39
- "x86_64-linux"
40
- when /\A(arm64|aarch64).*linux/
41
- "arm64-linux"
42
- when /\Ax86_64.*(darwin|macos|osx)/
43
- "x86_64-darwin"
44
- when /\A(arm64|aarch64).*(darwin|macos|osx)/
45
- "arm64-darwin"
46
- else
47
- @host
48
- end
49
- end
50
-
51
- def target_platform
52
- @target_platform ||=
53
- case ENV["target_platform"]
54
- when /\A(arm64|aarch64).*(darwin|macos|osx)/
55
- "arm64-darwin"
56
- when /\Ax86_64.*(darwin|macos|osx)/
57
- "x86_64-darwin"
58
- when /\A(arm64|aarch64).*linux/
59
- "aarch64-linux"
60
- else
61
- ENV["target_platform"] || host_platform
62
- end
63
- end
64
-
65
- def target_triplet
66
- @target_triplet ||=
67
- case target_platform
68
- when "arm64-darwin"
69
- "arm64-osx"
70
- when "x86_64-darwin"
71
- "x64-osx"
72
- when "aarch64-linux"
73
- "arm64-linux"
74
- when "x86_64-linux"
75
- "x64-linux"
76
- when /\Ax64-mingw(32|-ucrt)/
77
- "x64-mingw-static"
78
- end
79
- end
80
- # rubocop:enable Metrics/CyclomaticComplexity
81
- # rubocop:enable Metrics/MethodLength
82
-
83
33
  def windows_native?
84
34
  MiniPortile.windows? && target_triplet.eql?("x64-mingw-static")
85
35
  end
@@ -115,20 +65,42 @@ module Emf2svg
115
65
  "cmake --build #{File.expand_path(work_path)} --config Release"
116
66
  end
117
67
 
68
+ def lb_to_verify
69
+ pt = if MiniPortile.windows?
70
+ "emf2svg.dll"
71
+ else
72
+ "libemf2svg.{so,dylib}"
73
+ end
74
+ @lb_to_verify ||= Dir.glob(ROOT.join("lib", "emf2svg", pt))
75
+ end
76
+
77
+ def verify_libs
78
+ lb_to_verify.each do |l|
79
+ out, st = Open3.capture2("file #{l}")
80
+ raise "Failed to query file #{l}: #{out}" unless st.exitstatus.zero?
81
+
82
+ if out.include?(target_format)
83
+ message("Verifying #{l} ... OK\n")
84
+ else
85
+ raise "Invalid file format '#{out}', '#{@target_format}' expected"
86
+ end
87
+ end
88
+ end
89
+
118
90
  def install
119
- message("Called install\n")
120
91
  libs = if MiniPortile.windows?
121
92
  Dir.glob(File.join(work_path, "Release", "*.dll"))
122
93
  else
123
94
  Dir.glob(File.join(work_path, "libemf2svg.{so,dylib}"))
124
95
  .grep(/\/(?:lib)?[a-zA-Z0-9\-]+\.(?:so|dylib)$/)
125
96
  end
126
-
127
97
  FileUtils.cp_r(libs, ROOT.join("lib", "emf2svg"), verbose: true)
98
+
99
+ verify_libs unless target_format.eql?("skip")
128
100
  end
129
101
 
130
102
  def execute(action, command, command_opts = {})
131
- super(action, command, command_opts.merge(debug: true))
103
+ super(action, command, command_opts.merge(debug: false))
132
104
  end
133
105
 
134
106
  def message(text)
@@ -151,5 +123,75 @@ module Emf2svg
151
123
  def port_path
152
124
  "port"
153
125
  end
126
+
127
+ # rubocop:disable Metrics/MethodLength
128
+ # rubocop:disable Metrics/CyclomaticComplexity
129
+ def host_platform
130
+ @host_platform ||=
131
+ case @host
132
+ when /\Ax86_64.*mingw32/
133
+ "x64-mingw32"
134
+ when /\Ax86_64.*linux/
135
+ "x86_64-linux"
136
+ when /\A(arm64|aarch64).*linux/
137
+ "arm64-linux"
138
+ when /\Ax86_64.*(darwin|macos|osx)/
139
+ "x86_64-darwin"
140
+ when /\A(arm64|aarch64).*(darwin|macos|osx)/
141
+ "arm64-darwin"
142
+ else
143
+ @host
144
+ end
145
+ end
146
+
147
+ def target_platform
148
+ @target_platform ||=
149
+ case ENV.fetch("target_platform", nil)
150
+ when /\A(arm64|aarch64).*(darwin|macos|osx)/
151
+ "arm64-darwin"
152
+ when /\Ax86_64.*(darwin|macos|osx)/
153
+ "x86_64-darwin"
154
+ when /\A(arm64|aarch64).*linux/
155
+ "aarch64-linux"
156
+ else
157
+ ENV.fetch("target_platform", host_platform)
158
+ end
159
+ end
160
+
161
+ def target_triplet
162
+ @target_triplet ||=
163
+ case target_platform
164
+ when "arm64-darwin"
165
+ "arm64-osx"
166
+ when "x86_64-darwin"
167
+ "x64-osx"
168
+ when "aarch64-linux"
169
+ "arm64-linux"
170
+ when "x86_64-linux"
171
+ "x64-linux"
172
+ when /\Ax64-mingw(32|-ucrt)/
173
+ "x64-mingw-static"
174
+ end
175
+ end
176
+
177
+ def target_format
178
+ @target_format ||=
179
+ case target_platform
180
+ when "arm64-darwin"
181
+ "Mach-O 64-bit dynamically linked shared library arm64"
182
+ when "x86_64-darwin"
183
+ "Mach-O 64-bit dynamically linked shared library x86_64"
184
+ when "aarch64-linux"
185
+ "ELF 64-bit LSB shared object, ARM aarch64"
186
+ when "x86_64-linux"
187
+ "ELF 64-bit LSB shared object, x86-64"
188
+ when /\Ax64-mingw(32|-ucrt)/
189
+ "PE32+ executable (DLL) (console) x86-64, for MS Windows"
190
+ else
191
+ "skip"
192
+ end
193
+ end
194
+ # rubocop:enable Metrics/CyclomaticComplexity
195
+ # rubocop:enable Metrics/MethodLength
154
196
  end
155
197
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Emf2svg
4
- VERSION = "1.4.1"
4
+ VERSION = "1.4.2"
5
+ LIBEMF2SVG_VERSION = "1.7.1"
5
6
  end
data/lib/emf2svg.rb CHANGED
@@ -39,17 +39,18 @@ module Emf2svg
39
39
  :int
40
40
 
41
41
  class << self
42
- def from_file(path)
42
+ def from_file(path, width = 0, height = 0)
43
43
  content = File.read(path, mode: "rb")
44
- from_binary_string(content)
44
+ from_binary_string(content, width, height)
45
45
  end
46
46
 
47
- def from_binary_string(content)
47
+ def from_binary_string(content, width = 0, height = 0)
48
48
  svg_out = FFI::MemoryPointer.new(:pointer)
49
49
  svg_out_len = FFI::MemoryPointer.new(:pointer)
50
50
  content_ptr = FFI::MemoryPointer.from_string(content)
51
51
 
52
- ret = emf2svg(content_ptr, content.size, svg_out, svg_out_len, options)
52
+ opt = options(width, height)
53
+ ret = emf2svg(content_ptr, content.size, svg_out, svg_out_len, opt)
53
54
  raise Error, "emf2svg failed with error code: #{ret}" unless ret == 1
54
55
 
55
56
  svg_out.read_pointer.read_bytes(svg_out_len.read_int)
@@ -57,13 +58,13 @@ module Emf2svg
57
58
 
58
59
  private
59
60
 
60
- def options
61
+ def options(width, height)
61
62
  GeneratorOptions.new.tap do |opts|
62
63
  opts[:verbose] = false
63
64
  opts[:emfplus] = true
64
65
  opts[:svgDelimiter] = true
65
- opts[:imgHeight] = 0
66
- opts[:imgWidth] = 0
66
+ opts[:imgHeight] = height
67
+ opts[:imgWidth] = width
67
68
  end
68
69
  end
69
70
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emf2svg
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: x86_64-darwin
6
6
  authors:
7
7
  - Ribose
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-04-13 00:00:00.000000000 Z
11
+ date: 2022-04-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -119,5 +119,5 @@ requirements: []
119
119
  rubygems_version: 3.1.6
120
120
  signing_key:
121
121
  specification_version: 4
122
- summary: Ruby interface to libemf2svg.
122
+ summary: EMF to SVG conversion in Ruby.
123
123
  test_files: []