extract_ttc 0.1.0 → 0.2.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: f6d17daa99ebfce9bef022ad42667c35c183a687e0aac23436971dd946a98d45
4
- data.tar.gz: 0e08cddcb9547b00eb95fd54f1df55669cfc5e3572604874f0f208ad93e36034
3
+ metadata.gz: f31d7599e2b7b67d9602cacfefbf05d52fc5edfe6f7f268efd498b6bd74f11de
4
+ data.tar.gz: 9037cc4122a727931eebe8dba4690c84b370e91ed5b307788037fb039c0544b5
5
5
  SHA512:
6
- metadata.gz: 8b94ad46a8aa508e7a48d310a88de0888ca39cb9c7e0b4e58b9a68327332ce036f82c69fd60ca0da2f00dc828e87b1cc689eecf48b3c4e474d04ba0538bc608c
7
- data.tar.gz: 60d2eec18035282b015ce768900147f2af35852592f050f8c5fa000f1c16da5c0766fe4be2cc279f0b7b13a0100269d48fb4fc4f12567a718a5074a63aaf69bf
6
+ metadata.gz: 5115bdd8b6930ff785a39ddc0f147146fda59c4353f0b1e5faf5a54367a41a2d63c43a0e67b53c50835fadc007402cdc93ab7528a4b08447e82c447342385db2
7
+ data.tar.gz: 8ab4fe679de26be9396bbf20f263ee11aaf9c520aaf125073b498bb7624b816be7c8fc0e57a909fa987835223b6f64d0b36a6434a28b41694a593f483259f602
data/.gitignore CHANGED
@@ -7,8 +7,8 @@
7
7
  /spec/reports/
8
8
  /tmp/
9
9
  /Gemfile.lock
10
- /ext/**/*.so
11
- /ext/**/*.o
10
+ **/*.so
11
+ **/*.o
12
12
 
13
13
  # remote file cache
14
14
  .rubocop-*
data/.rubocop.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  inherit_from:
2
2
  - 'https://raw.githubusercontent.com/fontist/oss-guides/master/ci/rubocop.yml'
3
3
 
4
- Rails:
5
- Enabled: false
4
+ AllCops:
5
+ SuggestExtensions: false
data/Gemfile CHANGED
@@ -2,5 +2,3 @@ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in extract_ttc.gemspec
4
4
  gemspec
5
-
6
- gem "rake", "~> 12.0"
data/Rakefile CHANGED
@@ -1,23 +1,38 @@
1
1
  require "bundler/gem_tasks"
2
- task default: :compile
2
+ require "rspec/core/rake_task"
3
+ require "rake/clean"
4
+ require "rake/extensiontask"
3
5
 
4
- desc "Build stripttc C library"
5
- task :compile do
6
- print "Building stripttc..."
7
- Dir.chdir("ext/stripttc") do
8
- `make`
9
- end
10
- puts " done."
6
+ require "rubygems"
7
+ require "rubygems/package_task"
8
+
9
+ require "rubocop/rake_task"
10
+
11
+ RSpec::Core::RakeTask.new(:spec)
12
+ RuboCop::RakeTask.new
13
+
14
+ task default: :spec
15
+ task spec: :compile
16
+
17
+ spec = Gem::Specification.load("extract_ttc.gemspec")
18
+
19
+ # add your default gem packing task
20
+ Gem::PackageTask.new(spec) do |pkg|
11
21
  end
12
22
 
13
- desc "Recompile the stripttc C library"
14
- task recompile: %i[clean compile]
23
+ # HACK: Prevent rake-compiler from overriding required_ruby_version,
24
+ # because the shared library here is Ruby-agnostic.
25
+ # See https://github.com/rake-compiler/rake-compiler/issues/153
26
+ module FixRequiredRubyVersion
27
+ def required_ruby_version=(*); end
28
+ end
29
+ Gem::Specification.prepend(FixRequiredRubyVersion)
15
30
 
16
- desc "Remove compiled stripttc library"
17
- task :clean do
18
- print "Cleaning stripttc..."
19
- Dir.glob("ext/stripttc/*.{o,so}") do |path|
20
- File.delete(path)
31
+ Rake::ExtensionTask.new("stripttc", spec) do |ext|
32
+ ext.lib_dir = "lib"
33
+ ext.cross_compile = true
34
+ ext.cross_platform = %w[x64-mingw32 x64-mingw-ucrt x86_64-linux x86_64-darwin]
35
+ ext.cross_compiling do |s|
36
+ s.files.reject! { |path| File.fnmatch?("ext/*", path) }
21
37
  end
22
- puts " done."
23
38
  end
data/bin/rspec CHANGED
@@ -10,12 +10,12 @@
10
10
 
11
11
  require "pathname"
12
12
  ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
13
- Pathname.new(__FILE__).realpath)
13
+ Pathname.new(__FILE__).realpath)
14
14
 
15
- bundle_binstub = File.expand_path("../bundle", __FILE__)
15
+ bundle_binstub = File.expand_path("bundle", __dir__)
16
16
 
17
17
  if File.file?(bundle_binstub)
18
- if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
18
+ if /This file was generated by Bundler/.match?(File.read(bundle_binstub, 300))
19
19
  load(bundle_binstub)
20
20
  else
21
21
  abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
@@ -0,0 +1,2 @@
1
+ // to keep linker happy
2
+ void Init_stripttc() {}
@@ -1 +1,6 @@
1
- # do nothing, Makefile is already here
1
+ require "mkmf"
2
+ require "rbconfig"
3
+
4
+ CONFIG["LDSHARED"] << " -shared" unless RbConfig::CONFIG["host_os"].match?(/darwin/)
5
+
6
+ create_makefile "stripttc"
@@ -11,6 +11,12 @@
11
11
 
12
12
  #define CHR(ch1,ch2,ch3,ch4) (((ch1)<<24)|((ch2)<<16)|((ch3)<<8)|(ch4))
13
13
 
14
+ #ifdef _WIN32
15
+ #define EXPORT_API __declspec(dllexport)
16
+ #else
17
+ #define EXPORT_API
18
+ #endif
19
+
14
20
  static void putshort(FILE *file,int sval) {
15
21
  putc((sval>>8)&0xff,file);
16
22
  putc(sval&0xff,file);
@@ -132,7 +138,7 @@ static int handlefont(char *filename,int which,FILE *ttc,int offset) {
132
138
  return( 0 );
133
139
  }
134
140
 
135
- int handlefile(char *filename) {
141
+ EXPORT_API int handlefile(char *filename) {
136
142
  FILE *ttc = fopen(filename,"rb");
137
143
  int version, cnt, e, i;
138
144
  int *offsets;
data/extract_ttc.gemspec CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |spec|
10
10
  spec.description = "Extract font collection to separate font files"
11
11
  spec.homepage = "https://github.com/fontist/extract_ttc"
12
12
  spec.license = "BSD-3-Clause"
13
- spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
13
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
14
14
 
15
15
  spec.metadata["homepage_uri"] = spec.homepage
16
16
  spec.metadata["source_code_uri"] = "https://github.com/fontist/extract_ttc"
@@ -18,19 +18,23 @@ Gem::Specification.new do |spec|
18
18
 
19
19
  spec.files = Dir.chdir(__dir__) do
20
20
  `git ls-files -z`
21
- .split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21
+ .split("\x0").reject { |f| f.match(%r{^(.github|test|spec|features)/}) }
22
22
  end
23
23
 
24
24
  spec.bindir = "exe"
25
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
26
26
  spec.require_paths = ["lib"]
27
27
 
28
- spec.add_runtime_dependency "ffi"
28
+ spec.add_runtime_dependency "ffi", "~> 1.0"
29
29
 
30
+ spec.add_development_dependency "bundler", "~> 2.0"
31
+ spec.add_development_dependency "rake", "~> 13"
32
+ spec.add_development_dependency "rake-compiler", "~> 1"
30
33
  spec.add_development_dependency "rspec", "~> 3.0"
31
- spec.add_development_dependency "rubocop", "0.75.0"
32
- spec.add_development_dependency "rubocop-performance"
33
- spec.add_development_dependency "rubocop-rails"
34
+ spec.add_development_dependency "rubocop", "~> 1.5"
35
+ spec.add_development_dependency "rubocop-performance", "~> 1.10"
36
+ spec.add_development_dependency "rubocop-rails", "~> 2.9"
34
37
 
35
38
  spec.extensions << "ext/stripttc/extconf.rb"
39
+ spec.metadata["rubygems_mfa_required"] = "false"
36
40
  end
@@ -1,3 +1,3 @@
1
1
  module ExtractTtc
2
- VERSION = "0.1.0".freeze
2
+ VERSION = "0.2.0".freeze
3
3
  end
data/lib/extract_ttc.rb CHANGED
@@ -4,13 +4,25 @@ require "tempfile"
4
4
 
5
5
  module ExtractTtc
6
6
  class Error < StandardError; end
7
+
7
8
  class ReadFileError < Error; end
9
+
8
10
  class InvalidFileError < Error; end
11
+
9
12
  class WriteFileError < Error; end
13
+
10
14
  class UnknownResultError < Error; end
11
15
 
12
16
  extend FFI::Library
13
- ffi_lib File.expand_path("../ext/stripttc/stripttc.so", __dir__)
17
+ # NOTE: ffi doesn't support bundles out of box https://github.com/ffi/ffi/issues/42#issuecomment-750031554
18
+ # NOTE: rake-compiler doesn't support dylib generation https://github.com/rake-compiler/rake-compiler/issues/183
19
+ lib_name = if File.exists?(File.join(File.dirname(__FILE__),
20
+ "stripttc.bundle"))
21
+ "stripttc.bundle"
22
+ else
23
+ "stripttc.so"
24
+ end
25
+ ffi_lib File.join(File.dirname(__FILE__), lib_name)
14
26
  attach_function :handlefile, [:string], :int
15
27
 
16
28
  def self.extract(path)
@@ -62,6 +74,6 @@ module ExtractTtc
62
74
  end
63
75
 
64
76
  def self.fetch_filenames(stdout)
65
- stdout.split("=>").last.split(" ")
77
+ stdout.split("=>").last.split
66
78
  end
67
79
  end
metadata CHANGED
@@ -1,29 +1,71 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: extract_ttc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-11-09 00:00:00.000000000 Z
11
+ date: 2022-09-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '1.0'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '13'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '13'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake-compiler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1'
27
69
  - !ruby/object:Gem::Dependency
28
70
  name: rspec
29
71
  requirement: !ruby/object:Gem::Requirement
@@ -42,44 +84,44 @@ dependencies:
42
84
  name: rubocop
43
85
  requirement: !ruby/object:Gem::Requirement
44
86
  requirements:
45
- - - '='
87
+ - - "~>"
46
88
  - !ruby/object:Gem::Version
47
- version: 0.75.0
89
+ version: '1.5'
48
90
  type: :development
49
91
  prerelease: false
50
92
  version_requirements: !ruby/object:Gem::Requirement
51
93
  requirements:
52
- - - '='
94
+ - - "~>"
53
95
  - !ruby/object:Gem::Version
54
- version: 0.75.0
96
+ version: '1.5'
55
97
  - !ruby/object:Gem::Dependency
56
98
  name: rubocop-performance
57
99
  requirement: !ruby/object:Gem::Requirement
58
100
  requirements:
59
- - - ">="
101
+ - - "~>"
60
102
  - !ruby/object:Gem::Version
61
- version: '0'
103
+ version: '1.10'
62
104
  type: :development
63
105
  prerelease: false
64
106
  version_requirements: !ruby/object:Gem::Requirement
65
107
  requirements:
66
- - - ">="
108
+ - - "~>"
67
109
  - !ruby/object:Gem::Version
68
- version: '0'
110
+ version: '1.10'
69
111
  - !ruby/object:Gem::Dependency
70
112
  name: rubocop-rails
71
113
  requirement: !ruby/object:Gem::Requirement
72
114
  requirements:
73
- - - ">="
115
+ - - "~>"
74
116
  - !ruby/object:Gem::Version
75
- version: '0'
117
+ version: '2.9'
76
118
  type: :development
77
119
  prerelease: false
78
120
  version_requirements: !ruby/object:Gem::Requirement
79
121
  requirements:
80
- - - ">="
122
+ - - "~>"
81
123
  - !ruby/object:Gem::Version
82
- version: '0'
124
+ version: '2.9'
83
125
  description: Extract font collection to separate font files
84
126
  email:
85
127
  - operations@ribose.com
@@ -88,9 +130,6 @@ extensions:
88
130
  - ext/stripttc/extconf.rb
89
131
  extra_rdoc_files: []
90
132
  files:
91
- - ".github/workflows/macosx.yml"
92
- - ".github/workflows/ubuntu.yml"
93
- - ".github/workflows/windows.yml"
94
133
  - ".gitignore"
95
134
  - ".rspec"
96
135
  - ".rubocop.yml"
@@ -102,7 +141,7 @@ files:
102
141
  - bin/rspec
103
142
  - bin/setup
104
143
  - ext/stripttc/LICENSE
105
- - ext/stripttc/Makefile
144
+ - ext/stripttc/dummy.c
106
145
  - ext/stripttc/extconf.rb
107
146
  - ext/stripttc/stripttc.c
108
147
  - extract_ttc.gemspec
@@ -115,7 +154,8 @@ metadata:
115
154
  homepage_uri: https://github.com/fontist/extract_ttc
116
155
  source_code_uri: https://github.com/fontist/extract_ttc
117
156
  changelog_uri: https://github.com/fontist/extract_ttc
118
- post_install_message:
157
+ rubygems_mfa_required: 'false'
158
+ post_install_message:
119
159
  rdoc_options: []
120
160
  require_paths:
121
161
  - lib
@@ -123,15 +163,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
123
163
  requirements:
124
164
  - - ">="
125
165
  - !ruby/object:Gem::Version
126
- version: 2.3.0
166
+ version: 2.6.0
127
167
  required_rubygems_version: !ruby/object:Gem::Requirement
128
168
  requirements:
129
169
  - - ">="
130
170
  - !ruby/object:Gem::Version
131
171
  version: '0'
132
172
  requirements: []
133
- rubygems_version: 3.0.3
134
- signing_key:
173
+ rubygems_version: 3.1.6
174
+ signing_key:
135
175
  specification_version: 4
136
176
  summary: Extract TTC file to TTF files
137
177
  test_files: []
@@ -1,30 +0,0 @@
1
- name: macos
2
-
3
- on:
4
- push:
5
- branches:
6
- - master
7
-
8
- pull_request:
9
- branches:
10
- - master
11
-
12
- jobs:
13
- build:
14
- runs-on: macos-latest
15
-
16
- steps:
17
- - uses: actions/checkout@v2
18
-
19
- - uses: actions/setup-ruby@v1
20
- with:
21
- ruby-version: 2.6
22
-
23
- - name: Install bundler
24
- run: gem install bundler
25
-
26
- - name: Setup
27
- run: bin/setup
28
-
29
- - name: Run tests
30
- run: bin/rspec
@@ -1,30 +0,0 @@
1
- name: ubuntu
2
-
3
- on:
4
- push:
5
- branches:
6
- - master
7
-
8
- pull_request:
9
- branches:
10
- - master
11
-
12
- jobs:
13
- build:
14
- runs-on: ubuntu-latest
15
-
16
- steps:
17
- - uses: actions/checkout@v2
18
-
19
- - uses: actions/setup-ruby@v1
20
- with:
21
- ruby-version: 2.6
22
-
23
- - name: Install bundler
24
- run: gem install bundler
25
-
26
- - name: Setup
27
- run: bin/setup
28
-
29
- - name: Run tests
30
- run: bin/rspec
@@ -1,32 +0,0 @@
1
- name: windows
2
-
3
- on:
4
- push:
5
- branches:
6
- - master
7
-
8
- pull_request:
9
- branches:
10
- - master
11
-
12
- jobs:
13
- build:
14
- runs-on: windows-latest
15
-
16
- steps:
17
- - uses: actions/checkout@v2
18
-
19
- - uses: actions/setup-ruby@v1
20
- with:
21
- ruby-version: 2.6
22
-
23
- - name: Setup
24
- shell: pwsh
25
- run: |
26
- gem install bundler
27
- bundle config --local path vendor/bundle
28
- bundle install --jobs 4 --retry 3
29
- bundle exec rake compile
30
-
31
- - name: Run tests
32
- run: bundle exec rspec
@@ -1,16 +0,0 @@
1
- # stripttc.c originates from:
2
- # https://github.com/fontforge/fontforge/blob/master/contrib/fonttools/stripttc.c
3
-
4
- default: stripttc.so
5
-
6
- stripttc.so: stripttc.o
7
- gcc -shared -o $@ $<
8
-
9
- stripttc.o: stripttc.c
10
- gcc -c -fPIC -o $@ $<
11
-
12
- install:
13
- : # do nothing, we'll load the lib directly
14
-
15
- clean:
16
- -rm *.so *.o