extract_ttc 0.2.0-x86_64-linux → 0.3.0-x86_64-linux

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: 93037acf9c46fc404ecd51135745b6870f2d753123a964fd534ecb20711d4920
4
- data.tar.gz: a4afcb6b98b78d63c95980b8e72be3a007653de55bd4150513eb0d7fa313ecc7
3
+ metadata.gz: f8b641dc35685b306188b1112c11b8b155bbfbcd6da492692502311f7d307fed
4
+ data.tar.gz: 790bc392fa04b6b395ef4d39a263d18213a34e4fb103becc75c1ff91923a59d7
5
5
  SHA512:
6
- metadata.gz: c3ca5cc27753eebad5ede3a811bb2ecaaa64676e6bef2ca55ea5acc165602f6a566af31a0e685d18399070f159950e963654a0fa1db4653d2d34b4ac80a0f544
7
- data.tar.gz: 691396044f63cd68ebb8e18409d895de873e8c902fb8b0d045cc451a12e17a80cc2c8ea38e24402b958da5e2c8663c515690a0fa37f228eb32a38f4ccc0aca41
6
+ metadata.gz: d266b2fdb80066029af90d9e02df5600cb966fa5f968ca046a2a0a759fe1831171dd46d2874972da0538697589439a0bd5c6ccb992ae751871dba62b8d8f664e
7
+ data.tar.gz: c13ba809caaea95ea596361870a05f1cd62fd5602ccb0e2b8f29aa75c1e9e1ec0446c5c5a269bb73ca6b5217c97a3f3b48d2cbb12f98ea415bec6b440f5a9f75
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  /.bundle/
2
+ /vendor/
2
3
  /.yardoc
3
4
  /_yardoc/
4
5
  /coverage/
data/Rakefile CHANGED
@@ -1,21 +1,38 @@
1
1
  require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
2
  require "rake/clean"
4
3
  require "rake/extensiontask"
4
+ require "rake_compiler_dock"
5
5
 
6
6
  require "rubygems"
7
7
  require "rubygems/package_task"
8
8
 
9
- require "rubocop/rake_task"
9
+ # ++ Allow rake-compiler-dock configuration without dev. dependencies
10
+ begin
11
+ require "rubocop/rake_task"
12
+ RuboCop::RakeTask.new
13
+ rescue LoadError
14
+ end
15
+
16
+ begin
17
+ require "rspec/core/rake_task"
18
+ RSpec::Core::RakeTask.new(:spec)
19
+ rescue LoadError
20
+ end
21
+ # -- Allow rake-compiler-dock configuration without dev. dependencies
10
22
 
11
- RSpec::Core::RakeTask.new(:spec)
12
- RuboCop::RakeTask.new
23
+ R_CC_V = "RUBY_CC_VERSION=3.1.0:3.0.0:2.7.0".freeze
24
+ bundler_ver = ENV["BUNDLER_VER"] || "2.3.22"
13
25
 
14
26
  task default: :spec
15
27
  task spec: :compile
16
28
 
17
29
  spec = Gem::Specification.load("extract_ttc.gemspec")
18
30
 
31
+ ext_thru_rc_dock = %w[x86_64-linux aarch64-linux] +
32
+ %w[x64-mingw32 x64-mingw-ucrt x86_64-darwin arm64-darwin]
33
+
34
+ ext_thru_musl_cc = %w[x86_64-linux-musl aarch64-linux-musl]
35
+
19
36
  # add your default gem packing task
20
37
  Gem::PackageTask.new(spec) do |pkg|
21
38
  end
@@ -28,11 +45,64 @@ module FixRequiredRubyVersion
28
45
  end
29
46
  Gem::Specification.prepend(FixRequiredRubyVersion)
30
47
 
31
- Rake::ExtensionTask.new("stripttc", spec) do |ext|
48
+ exttask = Rake::ExtensionTask.new("stripttc", spec) do |ext|
32
49
  ext.lib_dir = "lib"
33
50
  ext.cross_compile = true
34
- ext.cross_platform = %w[x64-mingw32 x64-mingw-ucrt x86_64-linux x86_64-darwin]
51
+ ext.cross_platform = ext_thru_rc_dock + ext_thru_musl_cc
35
52
  ext.cross_compiling do |s|
36
53
  s.files.reject! { |path| File.fnmatch?("ext/*", path) }
37
54
  end
38
55
  end
56
+
57
+ namespace "gem" do
58
+ desc "Cache dependencies"
59
+ task "cache" do
60
+ sh <<~RCD
61
+ bundle config set cache_all true &&
62
+ bundle config set --local without 'development' &&
63
+ bundle package
64
+ RCD
65
+ end
66
+
67
+ desc "build native gems with rake-compiler-dock"
68
+ task "native" => "cache" do
69
+ ext_thru_rc_dock.each do |plat|
70
+ RakeCompilerDock.sh <<~RCD, platform: plat
71
+ gem install bundler:#{bundler_ver} --no-document &&
72
+ bundle install --local &&
73
+ bundle exec rake native:#{plat} gem #{R_CC_V}
74
+ RCD
75
+ end
76
+ end
77
+ end
78
+
79
+ namespace "gem" do
80
+ ext_thru_rc_dock.each do |plat|
81
+ desc "Build native gems with rake-compiler-dock in parallel"
82
+ multitask "parallel" => plat
83
+
84
+ desc "Build the native gem for #{plat}"
85
+ task plat => "cache" do
86
+ RakeCompilerDock.sh <<~RCD, platform: plat
87
+ gem install bundler:#{bundler_ver} --no-document &&
88
+ bundle install --local &&
89
+ bundle exec rake native:#{plat} \
90
+ pkg/#{exttask.gem_spec.full_name}-#{plat}.gem \
91
+ #{R_CC_V}
92
+ RCD
93
+ end
94
+ end
95
+
96
+ ext_thru_musl_cc.each do |plat|
97
+ desc "Define the gem task to build on the #{plat} platform (binary gem)"
98
+ task plat do
99
+ s = spec.dup
100
+ s.platform = Gem::Platform.new(plat)
101
+ s.files += Dir.glob("lib/extract_ttc/*.{dll,so,dylib}")
102
+ s.extensions = []
103
+
104
+ task = Gem::PackageTask.new(s)
105
+ task.define
106
+ end
107
+ end
108
+ end
data/extract_ttc.gemspec CHANGED
@@ -26,10 +26,11 @@ Gem::Specification.new do |spec|
26
26
  spec.require_paths = ["lib"]
27
27
 
28
28
  spec.add_runtime_dependency "ffi", "~> 1.0"
29
+ spec.add_runtime_dependency "bundler", '~> 2.3', '>= 2.3.22'
30
+ spec.add_runtime_dependency "rake", "~> 13"
31
+ spec.add_runtime_dependency "rake-compiler", "~> 1.2"
32
+ spec.add_runtime_dependency "rake-compiler-dock", "~> 1.2"
29
33
 
30
- spec.add_development_dependency "bundler", "~> 2.0"
31
- spec.add_development_dependency "rake", "~> 13"
32
- spec.add_development_dependency "rake-compiler", "~> 1"
33
34
  spec.add_development_dependency "rspec", "~> 3.0"
34
35
  spec.add_development_dependency "rubocop", "~> 1.5"
35
36
  spec.add_development_dependency "rubocop-performance", "~> 1.10"
Binary file
Binary file
Binary file
@@ -1,3 +1,3 @@
1
1
  module ExtractTtc
2
- VERSION = "0.2.0".freeze
2
+ VERSION = "0.3.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: extract_ttc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: x86_64-linux
6
6
  authors:
7
7
  - Ribose Inc.
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-09-27 00:00:00.000000000 Z
11
+ date: 2022-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ffi
@@ -30,14 +30,20 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '2.0'
34
- type: :development
33
+ version: '2.3'
34
+ - - ">="
35
+ - !ruby/object:Gem::Version
36
+ version: 2.3.22
37
+ type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
41
  - - "~>"
39
42
  - !ruby/object:Gem::Version
40
- version: '2.0'
43
+ version: '2.3'
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: 2.3.22
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: rake
43
49
  requirement: !ruby/object:Gem::Requirement
@@ -45,7 +51,7 @@ dependencies:
45
51
  - - "~>"
46
52
  - !ruby/object:Gem::Version
47
53
  version: '13'
48
- type: :development
54
+ type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
@@ -58,14 +64,28 @@ dependencies:
58
64
  requirements:
59
65
  - - "~>"
60
66
  - !ruby/object:Gem::Version
61
- version: '1'
62
- type: :development
67
+ version: '1.2'
68
+ type: :runtime
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '1.2'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rake-compiler-dock
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '1.2'
82
+ type: :runtime
63
83
  prerelease: false
64
84
  version_requirements: !ruby/object:Gem::Requirement
65
85
  requirements:
66
86
  - - "~>"
67
87
  - !ruby/object:Gem::Version
68
- version: '1'
88
+ version: '1.2'
69
89
  - !ruby/object:Gem::Dependency
70
90
  name: rspec
71
91
  requirement: !ruby/object:Gem::Requirement
@@ -139,14 +159,12 @@ files:
139
159
  - bin/console
140
160
  - bin/rspec
141
161
  - bin/setup
142
- - ext/stripttc/LICENSE
143
- - ext/stripttc/dummy.c
144
- - ext/stripttc/extconf.rb
145
- - ext/stripttc/stripttc.c
146
162
  - extract_ttc.gemspec
163
+ - lib/2.7/stripttc.so
164
+ - lib/3.0/stripttc.so
165
+ - lib/3.1/stripttc.so
147
166
  - lib/extract_ttc.rb
148
167
  - lib/extract_ttc/version.rb
149
- - lib/stripttc.so
150
168
  homepage: https://github.com/fontist/extract_ttc
151
169
  licenses:
152
170
  - BSD-3-Clause
@@ -155,7 +173,7 @@ metadata:
155
173
  source_code_uri: https://github.com/fontist/extract_ttc
156
174
  changelog_uri: https://github.com/fontist/extract_ttc
157
175
  rubygems_mfa_required: 'false'
158
- post_install_message:
176
+ post_install_message:
159
177
  rdoc_options: []
160
178
  require_paths:
161
179
  - lib
@@ -170,8 +188,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
188
  - !ruby/object:Gem::Version
171
189
  version: '0'
172
190
  requirements: []
173
- rubygems_version: 3.1.6
174
- signing_key:
191
+ rubygems_version: 3.3.4
192
+ signing_key:
175
193
  specification_version: 4
176
194
  summary: Extract TTC file to TTF files
177
195
  test_files: []
data/ext/stripttc/LICENSE DELETED
@@ -1,31 +0,0 @@
1
- BSD 3-Clause License for stripttc.c
2
-
3
- Copyright (c) George Williams and FontForge authors. All rights reserved.
4
- https://github.com/fontforge/fontforge/blob/master/AUTHORS
5
-
6
- Redistribution and use in source and binary forms, with or without
7
- modification, are permitted provided that the following conditions
8
- are met:
9
-
10
- Redistributions of source code must retain the above copyright
11
- notice, this list of conditions and the following disclaimer.
12
-
13
- Redistributions in binary form must reproduce the above copyright
14
- notice, this list of conditions and the following disclaimer in the
15
- documentation and/or other materials provided with the distribution.
16
-
17
- The name of the author may not be used to endorse or promote
18
- products derived from this software without specific prior written
19
- permission.
20
-
21
- THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS
22
- OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
23
- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24
- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
25
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26
- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
27
- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
28
- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER
29
- IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
30
- OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
31
- IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
data/ext/stripttc/dummy.c DELETED
@@ -1,2 +0,0 @@
1
- // to keep linker happy
2
- void Init_stripttc() {}
@@ -1,6 +0,0 @@
1
- require "mkmf"
2
- require "rbconfig"
3
-
4
- CONFIG["LDSHARED"] << " -shared" unless RbConfig::CONFIG["host_os"].match?(/darwin/)
5
-
6
- create_makefile "stripttc"
@@ -1,187 +0,0 @@
1
- #include <stdio.h>
2
- #include <stdlib.h>
3
- #include <string.h>
4
- #include <libgen.h>
5
-
6
- /* This program takes a ttc file and turns it into its component ttf files */
7
- /* This makes two changes to the data: */
8
- /* * The tables are placed at different offsets, therefore */
9
- /* the offset fields in the table header are also different. */
10
- /* * the 'head' table checksumAdjustment field is set correctly */
11
-
12
- #define CHR(ch1,ch2,ch3,ch4) (((ch1)<<24)|((ch2)<<16)|((ch3)<<8)|(ch4))
13
-
14
- #ifdef _WIN32
15
- #define EXPORT_API __declspec(dllexport)
16
- #else
17
- #define EXPORT_API
18
- #endif
19
-
20
- static void putshort(FILE *file,int sval) {
21
- putc((sval>>8)&0xff,file);
22
- putc(sval&0xff,file);
23
- }
24
-
25
- static void putlong(FILE *file,int val) {
26
- putc((val>>24)&0xff,file);
27
- putc((val>>16)&0xff,file);
28
- putc((val>>8)&0xff,file);
29
- putc(val&0xff,file);
30
- }
31
-
32
- static int getushort(FILE *ttf) {
33
- int ch1 = getc(ttf);
34
- int ch2 = getc(ttf);
35
- if ( ch2==EOF )
36
- return( EOF );
37
- return( (ch1<<8)|ch2 );
38
- }
39
-
40
- static int getlong(FILE *ttf) {
41
- int ch1 = getc(ttf);
42
- int ch2 = getc(ttf);
43
- int ch3 = getc(ttf);
44
- int ch4 = getc(ttf);
45
- if ( ch4==EOF )
46
- return( EOF );
47
- return( (ch1<<24)|(ch2<<16)|(ch3<<8)|ch4 );
48
- }
49
-
50
- static unsigned int filecheck(FILE *file) {
51
- unsigned int sum = 0, chunk;
52
-
53
- rewind(file);
54
- while ( 1 ) {
55
- chunk = getlong(file);
56
- if ( feof(file) || ferror(file))
57
- break;
58
- sum += chunk;
59
- }
60
- return( sum );
61
- }
62
-
63
- static void copytable(FILE *ttf,FILE *ttc,int offset,int length) {
64
- int i, ch;
65
-
66
- fseek(ttc,offset,SEEK_SET);
67
- for ( i=0; i<length && (ch=getc(ttc))!=EOF ; ++i )
68
- putc(ch,ttf);
69
- if ( ch==EOF )
70
- fprintf( stderr, "File ended before table\n" );
71
- if ( length&1 ) {
72
- putc('\0',ttf);
73
- ++length;
74
- }
75
- if ( length & 2 ) {
76
- putshort(ttf,0);
77
- }
78
- }
79
-
80
- static int handlefont(char *filename,int which,FILE *ttc,int offset) {
81
- char outfile[2000], *pt;
82
- FILE *ttf;
83
- int i, cnt, *offsets, *lengths, head, tag, pos, headpos;
84
- strcpy(outfile,basename(filename));
85
- pt = strrchr(outfile,'.');
86
- if ( pt==NULL )
87
- pt = outfile + strlen(outfile);
88
- sprintf( pt, "_%02d.ttf", which );
89
-
90
- ttf = fopen( outfile,"wb");
91
- if ( ttf==NULL ) {
92
- fprintf( stderr, "Failed to open %s for output.\n", outfile );
93
- return( -3 );
94
- }
95
- printf ( "%s ", outfile );
96
-
97
- fseek(ttc,offset,SEEK_SET);
98
- putlong(ttf,getlong(ttc)); /* sfnt version */
99
- putshort(ttf,cnt = getushort(ttc)); /* table cnt */
100
- putshort(ttf,getushort(ttc)); /* binary search header */
101
- putshort(ttf,getushort(ttc));
102
- putshort(ttf,getushort(ttc));
103
-
104
- offsets = malloc(cnt*sizeof(int));
105
- lengths = malloc(cnt*sizeof(int));
106
- head = -1;
107
- for ( i=0; i<cnt; ++i ) {
108
- tag = getlong(ttc);
109
- if ( tag==CHR('h','e','a','d'))
110
- head = i;
111
- putlong(ttf,tag);
112
- putlong(ttf,getlong(ttc)); /* checksum */
113
- putlong(ttf,offsets[i] = getlong(ttc)); /* Reserve space for offset, will fix later */
114
- putlong(ttf,lengths[i] = getlong(ttc));
115
- }
116
- headpos = -1;
117
- for ( i=0; i<cnt; ++i ) {
118
- pos = ftell(ttf);
119
- copytable(ttf,ttc,offsets[i],lengths[i]);
120
- if ( i==head ) {
121
- fseek(ttf,pos+8,SEEK_SET);
122
- putlong(ttf,0);
123
- headpos = pos;
124
- }
125
- fseek(ttf,12+i*16+8,SEEK_SET);
126
- putlong(ttf,pos); /* Fix offset here */
127
- fseek(ttf,0,SEEK_END);
128
- }
129
- if ( headpos!=-1 ) {
130
- unsigned int checksum;
131
- checksum = filecheck(ttf);
132
- checksum = 0xb1b0afba-checksum;
133
- fseek(ttf,headpos+2*sizeof(int),SEEK_SET);
134
- putlong(ttf,checksum);
135
- }
136
- fclose(ttf);
137
- free(offsets); free(lengths);
138
- return( 0 );
139
- }
140
-
141
- EXPORT_API int handlefile(char *filename) {
142
- FILE *ttc = fopen(filename,"rb");
143
- int version, cnt, e, i;
144
- int *offsets;
145
-
146
- if ( ttc==NULL ) {
147
- fprintf( stderr, "Could not open %s\n", filename );
148
- return( -1 );
149
- }
150
-
151
- version = getlong(ttc);
152
- if ( version!=CHR('t','t','c','f')) {
153
- fprintf( stderr, "%s does not look like a ttc file, bad version.\n", filename );
154
- fclose(ttc);
155
- return( -2 );
156
- }
157
-
158
- version = getlong(ttc);
159
- if ( version!=0x10000 && version != 0x20000 )
160
- fprintf( stderr, "Unexpected ttc version number: %08x\n", (unsigned int)(version) );
161
- cnt = getlong(ttc);
162
- offsets = malloc(cnt*sizeof(int));
163
- for ( i=0; i<cnt; ++i )
164
- offsets[i] = getlong(ttc);
165
- printf( "%s => ", filename );
166
- for ( i=0; i<cnt; ++i )
167
- if ( (e = handlefont(filename,i,ttc,offsets[i])) ) {
168
- fflush(stdout);
169
- fclose(ttc);
170
- free(offsets);
171
- return( e );
172
- };
173
- printf( "\n" );
174
- fflush(stdout);
175
- fclose(ttc);
176
- free(offsets);
177
- return( 0 );
178
- }
179
-
180
- int main(int argc, char *argv[]) {
181
- int e, i;
182
-
183
- for ( i=1; i<argc; ++i )
184
- if ( (e = handlefile(argv[i])) )
185
- return( e );
186
- return( 0 );
187
- }
data/lib/stripttc.so DELETED
Binary file