jitai 0.2.3

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.
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ README.rdoc
2
+ lib/**/*.rb
3
+ bin/*
4
+ features/**/*.feature
5
+ LICENSE
data/.gitignore ADDED
@@ -0,0 +1,21 @@
1
+ ## MAC OS
2
+ .DS_Store
3
+
4
+ ## TEXTMATE
5
+ *.tmproj
6
+ tmtags
7
+
8
+ ## EMACS
9
+ *~
10
+ \#*
11
+ .\#*
12
+
13
+ ## VIM
14
+ *.swp
15
+
16
+ ## PROJECT::GENERAL
17
+ coverage
18
+ rdoc
19
+ pkg
20
+
21
+ ## PROJECT::SPECIFIC
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009 Kelly
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.textile ADDED
@@ -0,0 +1,14 @@
1
+ h1. jitai
2
+
3
+ A rake utility that consolidates your collection of custom font files into manageable CSS files.
4
+
5
+ h2.
6
+ ul.
7
+ li. 0.2.0 - .ttf fonts to .eot fonts.
8
+
9
+ pre. sudo gem install jitai
10
+ rake jitai:refresh
11
+
12
+ And then use your fonts accordingly.
13
+
14
+ Copyright (c) 2010 Kelly. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,52 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+
7
+ Jeweler::Tasks.new do |gem|
8
+ gem.name = "jitai"
9
+ gem.summary = %Q{CSS custom font consolidator}
10
+ gem.description = %Q{CSS custom font consolidator}
11
+ gem.email = "defaultstring@gmail.com"
12
+ gem.homepage = "http://github.com/kellydunn/jitai"
13
+ gem.authors = ["Kelly"]
14
+ gem.add_development_dependency "rspec", ">= 1.2.9"
15
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
16
+ end
17
+ Jeweler::GemcutterTasks.new
18
+ rescue LoadError
19
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
20
+ end
21
+
22
+ require 'spec/rake/spectask'
23
+ Spec::Rake::SpecTask.new(:spec) do |spec|
24
+ spec.libs << 'lib' << 'spec'
25
+ spec.spec_files = FileList['spec/**/*_spec.rb']
26
+ end
27
+
28
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
29
+ spec.libs << 'lib' << 'spec'
30
+ spec.pattern = 'spec/**/*_spec.rb'
31
+ spec.rcov = true
32
+ end
33
+
34
+ task :spec => :check_dependencies
35
+
36
+ task :default => :spec
37
+
38
+ require 'rake/rdoctask'
39
+ Rake::RDocTask.new do |rdoc|
40
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
41
+
42
+ rdoc.rdoc_dir = 'rdoc'
43
+ rdoc.title = "jitai #{version}"
44
+ rdoc.rdoc_files.include('README*')
45
+ rdoc.rdoc_files.include('lib/**/*.rb')
46
+ end
47
+
48
+ require 'lib/rake/jitaitask.rb'
49
+ Jitai::Rake::JitaiTask.new(:jitai) do |jitai|
50
+ end
51
+
52
+ Dir["#{File.dirname(__FILE__)}/tasks/*.rake"].sort.each { |ext| load ext }
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.2.3
data/kana-0.2.0.gem ADDED
Binary file
data/kana.gemspec ADDED
@@ -0,0 +1,71 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{kana}
8
+ s.version = "0.2.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Kelly"]
12
+ s.date = %q{2010-11-07}
13
+ s.description = %q{CSS consolidator gem file business}
14
+ s.email = %q{defaultstring@gmail.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.textile"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.textile",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "kana-0.2.0.gem",
27
+ "kana.gemspec",
28
+ "lib/kana.rb",
29
+ "lib/rake/kanatask.rb",
30
+ "lib/ttf2eot/ChangeLog",
31
+ "lib/ttf2eot/Makefile",
32
+ "lib/ttf2eot/OpenTypeUtilities.cpp",
33
+ "lib/ttf2eot/OpenTypeUtilities.h",
34
+ "lib/ttf2eot/OpenTypeUtilities.o",
35
+ "lib/ttf2eot/README",
36
+ "lib/ttf2eot/ttf2eot",
37
+ "lib/ttf2eot/ttf2eot.cpp",
38
+ "lib/ttf2eot/ttf2eot.o",
39
+ "public/fonts/yardsale.eot",
40
+ "public/fonts/yardsale.ttf",
41
+ "public/stylesheets/fonts_ie.css",
42
+ "public/stylesheets/fonts_moz.css",
43
+ "spec/kana_spec.rb",
44
+ "spec/rake/kanatask_spec.rb",
45
+ "spec/spec_helper.rb"
46
+ ]
47
+ s.homepage = %q{http://github.com/kellydunn/kana}
48
+ s.rdoc_options = ["--charset=UTF-8"]
49
+ s.require_paths = ["lib"]
50
+ s.rubygems_version = %q{1.3.7}
51
+ s.summary = %q{CSS consolidator gem}
52
+ s.test_files = [
53
+ "spec/kana_spec.rb",
54
+ "spec/rake/kanatask_spec.rb",
55
+ "spec/spec_helper.rb"
56
+ ]
57
+
58
+ if s.respond_to? :specification_version then
59
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
60
+ s.specification_version = 3
61
+
62
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
63
+ s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
64
+ else
65
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
66
+ end
67
+ else
68
+ s.add_dependency(%q<rspec>, [">= 1.2.9"])
69
+ end
70
+ end
71
+
data/lib/jitai.rb ADDED
@@ -0,0 +1,47 @@
1
+ module Jitai
2
+ class FontManager
3
+ attr_accessor :moz_path, :ie_path
4
+
5
+ def initialize(path= "public")
6
+ @moz_path = "#{path}/stylesheets/fonts_moz.css"
7
+ @ie_path = "#{path}/stylesheets/fonts_ie.css"
8
+ end
9
+ end
10
+
11
+ class Font
12
+ attr_accessor :name, :path
13
+
14
+ def initialize(path)
15
+ @name = path.downcase.split(".")[0]
16
+ @path = path
17
+ end
18
+
19
+ def to_css
20
+ moz = "@font-face {font-family:'#{@name}'; src:url('#{name}.ttf');}"
21
+ ie = "@font-face {font-family:'#{@name}'; src:url('#{name}.eot');}"
22
+ manager = Jitai::FontManager.new
23
+ find_font(manager.moz_path, moz)
24
+ find_font(manager.ie_path, ie)
25
+ end
26
+
27
+ def find_font(file, search_font)
28
+ File.open(file, "w") if !File.exists?(file) # touch file
29
+
30
+ in_file = false
31
+ File.open(file) do |font|
32
+ test = font.gets
33
+ if !test.nil?
34
+ return (in_file = true) if search_font.eql? test.strip
35
+ end
36
+ end
37
+
38
+ unless in_file
39
+ File.open(file, "a") do |f|
40
+ f.puts search_font
41
+ puts search_font
42
+ puts "Was added to #{file}"
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,65 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'rake'
4
+ require 'rake/tasklib'
5
+ require 'lib/jitai.rb'
6
+
7
+ module Jitai
8
+ module Rake
9
+ class JitaiTask < ::Rake::TaskLib
10
+ attr_accessor :name
11
+ attr_accessor :cwd
12
+
13
+ def initialize(name = :kana)
14
+ @name = name
15
+ @cwd = "public/fonts/"
16
+
17
+ yield self if block_given?
18
+ define
19
+ end
20
+
21
+ def new
22
+ initialize
23
+ end
24
+
25
+ def define
26
+ desc "Sets the font directory for Jitai to operate."
27
+ task "jitai:set" do
28
+ # TODO kana should accept a directory argument
29
+ @cwd = "public/fonts/"
30
+ end
31
+
32
+ desc "Refreshes the CSS files in the font directory"
33
+ task "jitai:refresh" do
34
+ Dir.mkdir(@cwd) if !(File.directory? @cwd)
35
+ Dir.foreach(@cwd) do |font_file|
36
+ if !(File.directory?(font_file))
37
+ # Search for two different formats
38
+ conversion_type = (File.extname(font_file).downcase.eql? ".ttf")? ".eot" : ".ttf"
39
+ other_basename = font_file.split(".")[0] + conversion_type
40
+ other_file = "./#{@cwd}#{other_basename}"
41
+ file = "./#{@cwd}#{font_file}"
42
+
43
+ puts "other file: #{other_file}"
44
+ puts "file: #{file}"
45
+
46
+ # TODO edit ttf2eot so that it's actually installed in the system
47
+ if !File.exists?(other_file)
48
+ %x{cd lib/ttf2eot && ./ttf2eot < #{'../../' + @cwd + font_file} > #{'../../' + @cwd + font_file.split(".")[0] + conversion_type}}
49
+ end
50
+
51
+ # CONVENTIONS LOL
52
+ %x{mv #{other_file} #{other_file.downcase}}
53
+ %x{mv #{file} #{file.downcase}}
54
+
55
+ font = Jitai::Font.new(font_file)
56
+ font.to_css
57
+ end
58
+ end
59
+ end
60
+
61
+ self
62
+ end
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,5 @@
1
+ - 0.0.2-1
2
+ - Fix implicit declaration of memcmp, required on ubuntu - Thanks adamplumb
3
+ - Quick modification to make msvc compilation work - Thanks deepikakorapati
4
+ - Quick fixes for mingw32 compilation - Thanks yorickvanpelt
5
+ - 0.0.2-2
@@ -0,0 +1,5 @@
1
+ ttf2eot: OpenTypeUtilities.o ttf2eot.o
2
+ g++ -o $@ $^
3
+
4
+ clean:
5
+ rm -f *.o *.core *.obj *.exe core ttf2eot
@@ -0,0 +1,334 @@
1
+ /* Modified for use with ttf2eot, originally from WebKit. */
2
+
3
+ /*
4
+ * Copyright (C) 2008 Apple Inc. All rights reserved.
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
+ * 1. Redistributions of source code must retain the above copyright
10
+ * notice, this list of conditions and the following disclaimer.
11
+ * 2. Redistributions in binary form must reproduce the above copyright
12
+ * notice, this list of conditions and the following disclaimer in the
13
+ * documentation and/or other materials provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
16
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
19
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
+ */
27
+
28
+ #include <string.h>
29
+ #include <vector>
30
+
31
+ #ifndef _MSC_VER
32
+ # include <stdint.h>
33
+ #else
34
+ typedef unsigned char uint8_t;
35
+ #endif
36
+
37
+ #include "OpenTypeUtilities.h"
38
+
39
+
40
+ using std::vector;
41
+
42
+ typedef unsigned Fixed;
43
+
44
+ #define DEFAULT_CHARSET 1
45
+
46
+ struct BigEndianUShort {
47
+ operator unsigned short() const { return (v & 0x00ff) << 8 | v >> 8; }
48
+ BigEndianUShort(unsigned short u) : v((u & 0x00ff) << 8 | u >> 8) { }
49
+ unsigned short v;
50
+ };
51
+
52
+ struct BigEndianULong {
53
+ operator unsigned() const { return (v & 0xff) << 24 | (v & 0xff00) << 8 | (v & 0xff0000) >> 8 | v >> 24; }
54
+ BigEndianULong(unsigned u) : v((u & 0xff) << 24 | (u & 0xff00) << 8 | (u & 0xff0000) >> 8 | u >> 24) { }
55
+ unsigned v;
56
+ };
57
+
58
+ #pragma pack(1)
59
+
60
+ struct EOTPrefix {
61
+ unsigned eotSize;
62
+ unsigned fontDataSize;
63
+ unsigned version;
64
+ unsigned flags;
65
+ uint8_t fontPANOSE[10];
66
+ uint8_t charset;
67
+ uint8_t italic;
68
+ unsigned weight;
69
+ unsigned short fsType;
70
+ unsigned short magicNumber;
71
+ unsigned unicodeRange[4];
72
+ unsigned codePageRange[2];
73
+ unsigned checkSumAdjustment;
74
+ unsigned reserved[4];
75
+ unsigned short padding1;
76
+ };
77
+
78
+ struct TableDirectoryEntry {
79
+ BigEndianULong tag;
80
+ BigEndianULong checkSum;
81
+ BigEndianULong offset;
82
+ BigEndianULong length;
83
+ };
84
+
85
+ struct sfntHeader {
86
+ Fixed version;
87
+ BigEndianUShort numTables;
88
+ BigEndianUShort searchRange;
89
+ BigEndianUShort entrySelector;
90
+ BigEndianUShort rangeShift;
91
+ TableDirectoryEntry tables[1];
92
+ };
93
+
94
+ struct OS2Table {
95
+ BigEndianUShort version;
96
+ BigEndianUShort avgCharWidth;
97
+ BigEndianUShort weightClass;
98
+ BigEndianUShort widthClass;
99
+ BigEndianUShort fsType;
100
+ BigEndianUShort subscriptXSize;
101
+ BigEndianUShort subscriptYSize;
102
+ BigEndianUShort subscriptXOffset;
103
+ BigEndianUShort subscriptYOffset;
104
+ BigEndianUShort superscriptXSize;
105
+ BigEndianUShort superscriptYSize;
106
+ BigEndianUShort superscriptXOffset;
107
+ BigEndianUShort superscriptYOffset;
108
+ BigEndianUShort strikeoutSize;
109
+ BigEndianUShort strikeoutPosition;
110
+ BigEndianUShort familyClass;
111
+ uint8_t panose[10];
112
+ BigEndianULong unicodeRange[4];
113
+ uint8_t vendID[4];
114
+ BigEndianUShort fsSelection;
115
+ BigEndianUShort firstCharIndex;
116
+ BigEndianUShort lastCharIndex;
117
+ BigEndianUShort typoAscender;
118
+ BigEndianUShort typoDescender;
119
+ BigEndianUShort typoLineGap;
120
+ BigEndianUShort winAscent;
121
+ BigEndianUShort winDescent;
122
+ BigEndianULong codePageRange[2];
123
+ BigEndianUShort xHeight;
124
+ BigEndianUShort capHeight;
125
+ BigEndianUShort defaultChar;
126
+ BigEndianUShort breakChar;
127
+ BigEndianUShort maxContext;
128
+ };
129
+
130
+ struct headTable {
131
+ Fixed version;
132
+ Fixed fontRevision;
133
+ BigEndianULong checkSumAdjustment;
134
+ BigEndianULong magicNumber;
135
+ BigEndianUShort flags;
136
+ BigEndianUShort unitsPerEm;
137
+ long long created;
138
+ long long modified;
139
+ BigEndianUShort xMin;
140
+ BigEndianUShort xMax;
141
+ BigEndianUShort yMin;
142
+ BigEndianUShort yMax;
143
+ BigEndianUShort macStyle;
144
+ BigEndianUShort lowestRectPPEM;
145
+ BigEndianUShort fontDirectionHint;
146
+ BigEndianUShort indexToLocFormat;
147
+ BigEndianUShort glyphDataFormat;
148
+ };
149
+
150
+ struct nameRecord {
151
+ BigEndianUShort platformID;
152
+ BigEndianUShort encodingID;
153
+ BigEndianUShort languageID;
154
+ BigEndianUShort nameID;
155
+ BigEndianUShort length;
156
+ BigEndianUShort offset;
157
+ };
158
+
159
+ struct nameTable {
160
+ BigEndianUShort format;
161
+ BigEndianUShort count;
162
+ BigEndianUShort stringOffset;
163
+ nameRecord nameRecords[1];
164
+ };
165
+
166
+ #pragma pack()
167
+
168
+ static void appendBigEndianStringToEOTHeader(vector<uint8_t>&eotHeader, const BigEndianUShort* string, unsigned short length)
169
+ {
170
+ size_t size = eotHeader.size();
171
+ eotHeader.resize(size + length + 2 * sizeof(unsigned short));
172
+ unsigned short* dst = reinterpret_cast<unsigned short*>(&eotHeader[0] + size);
173
+ unsigned i = 0;
174
+ dst[i++] = length;
175
+ unsigned numCharacters = length / 2;
176
+ for (unsigned j = 0; j < numCharacters; j++)
177
+ dst[i++] = string[j];
178
+ dst[i] = 0;
179
+ }
180
+
181
+ bool getEOTHeader(unsigned char* fontData, size_t fontSize, vector<uint8_t>& eotHeader, size_t& overlayDst, size_t& overlaySrc, size_t& overlayLength)
182
+ {
183
+ overlayDst = 0;
184
+ overlaySrc = 0;
185
+ overlayLength = 0;
186
+
187
+ size_t dataLength = fontSize;
188
+ const char* data = (const char *) fontData;
189
+
190
+ eotHeader.resize(sizeof(EOTPrefix));
191
+ EOTPrefix* prefix = reinterpret_cast<EOTPrefix*>(&eotHeader[0]);
192
+
193
+ prefix->fontDataSize = dataLength;
194
+ prefix->version = 0x00020001;
195
+ prefix->flags = 0;
196
+
197
+ if (dataLength < offsetof(sfntHeader, tables))
198
+ return false;
199
+
200
+ const sfntHeader* sfnt = reinterpret_cast<const sfntHeader*>(data);
201
+
202
+ if (dataLength < offsetof(sfntHeader, tables) + sfnt->numTables * sizeof(TableDirectoryEntry))
203
+ return false;
204
+
205
+ bool haveOS2 = false;
206
+ bool haveHead = false;
207
+ bool haveName = false;
208
+
209
+ const BigEndianUShort* familyName = 0;
210
+ unsigned short familyNameLength = 0;
211
+ const BigEndianUShort* subfamilyName = 0;
212
+ unsigned short subfamilyNameLength = 0;
213
+ const BigEndianUShort* fullName = 0;
214
+ unsigned short fullNameLength = 0;
215
+ const BigEndianUShort* versionString = 0;
216
+ unsigned short versionStringLength = 0;
217
+
218
+ for (unsigned i = 0; i < sfnt->numTables; i++) {
219
+ unsigned tableOffset = sfnt->tables[i].offset;
220
+ unsigned tableLength = sfnt->tables[i].length;
221
+
222
+ if (dataLength < tableOffset || dataLength < tableLength || dataLength < tableOffset + tableLength)
223
+ return false;
224
+
225
+ unsigned tableTag = sfnt->tables[i].tag;
226
+ switch (tableTag) {
227
+ case 'OS/2':
228
+ {
229
+ if (dataLength < tableOffset + sizeof(OS2Table))
230
+ return false;
231
+
232
+ haveOS2 = true;
233
+ const OS2Table* OS2 = reinterpret_cast<const OS2Table*>(data + tableOffset);
234
+ for (unsigned j = 0; j < 10; j++)
235
+ prefix->fontPANOSE[j] = OS2->panose[j];
236
+ prefix->italic = OS2->fsSelection & 0x01;
237
+ prefix->weight = OS2->weightClass;
238
+ // FIXME: Should use OS2->fsType, but some TrueType fonts set it to an over-restrictive value.
239
+ // Since ATS does not enforce this on Mac OS X, we do not enforce it either.
240
+ prefix->fsType = 0;
241
+ for (unsigned j = 0; j < 4; j++)
242
+ prefix->unicodeRange[j] = OS2->unicodeRange[j];
243
+ for (unsigned j = 0; j < 2; j++)
244
+ prefix->codePageRange[j] = OS2->codePageRange[j];
245
+ break;
246
+ }
247
+ case 'head':
248
+ {
249
+ if (dataLength < tableOffset + sizeof(headTable))
250
+ return false;
251
+
252
+ haveHead = true;
253
+ const headTable* head = reinterpret_cast<const headTable*>(data + tableOffset);
254
+ prefix->checkSumAdjustment = head->checkSumAdjustment;
255
+ break;
256
+ }
257
+ case 'name':
258
+ {
259
+ if (dataLength < tableOffset + offsetof(nameTable, nameRecords))
260
+ return false;
261
+
262
+ haveName = true;
263
+ const nameTable* name = reinterpret_cast<const nameTable*>(data + tableOffset);
264
+ for (int j = 0; j < name->count; j++) {
265
+ if (dataLength < tableOffset + offsetof(nameTable, nameRecords) + (j + 1) * sizeof(nameRecord))
266
+ return false;
267
+ if (name->nameRecords[j].platformID == 3 && name->nameRecords[j].encodingID == 1 && name->nameRecords[j].languageID == 0x0409) {
268
+ if (dataLength < tableOffset + name->stringOffset + name->nameRecords[j].offset + name->nameRecords[j].length)
269
+ return false;
270
+
271
+ unsigned short nameLength = name->nameRecords[j].length;
272
+ const BigEndianUShort* nameString = reinterpret_cast<const BigEndianUShort*>(data + tableOffset + name->stringOffset + name->nameRecords[j].offset);
273
+
274
+ switch (name->nameRecords[j].nameID) {
275
+ case 1:
276
+ familyNameLength = nameLength;
277
+ familyName = nameString;
278
+ break;
279
+ case 2:
280
+ subfamilyNameLength = nameLength;
281
+ subfamilyName = nameString;
282
+ break;
283
+ case 4:
284
+ fullNameLength = nameLength;
285
+ fullName = nameString;
286
+ break;
287
+ case 5:
288
+ versionStringLength = nameLength;
289
+ versionString = nameString;
290
+ break;
291
+ default:
292
+ break;
293
+ }
294
+ }
295
+ }
296
+ break;
297
+ }
298
+ default:
299
+ break;
300
+ }
301
+ if (haveOS2 && haveHead && haveName)
302
+ break;
303
+ }
304
+
305
+ prefix->charset = DEFAULT_CHARSET;
306
+ prefix->magicNumber = 0x504c;
307
+ prefix->reserved[0] = 0;
308
+ prefix->reserved[1] = 0;
309
+ prefix->reserved[2] = 0;
310
+ prefix->reserved[3] = 0;
311
+ prefix->padding1 = 0;
312
+
313
+ appendBigEndianStringToEOTHeader(eotHeader, familyName, familyNameLength);
314
+ appendBigEndianStringToEOTHeader(eotHeader, subfamilyName, subfamilyNameLength);
315
+ appendBigEndianStringToEOTHeader(eotHeader, versionString, versionStringLength);
316
+
317
+ // If possible, ensure that the family name is a prefix of the full name.
318
+ if (fullNameLength >= familyNameLength && memcmp(familyName, fullName, familyNameLength)) {
319
+ overlaySrc = reinterpret_cast<const char*>(fullName) - data;
320
+ overlayDst = reinterpret_cast<const char*>(familyName) - data;
321
+ overlayLength = familyNameLength;
322
+ }
323
+
324
+ appendBigEndianStringToEOTHeader(eotHeader, fullName, fullNameLength);
325
+
326
+ unsigned short padding = 0;
327
+ eotHeader.push_back(padding);
328
+ eotHeader.push_back(padding);
329
+
330
+ prefix = reinterpret_cast<EOTPrefix*>(&eotHeader[0]);
331
+ prefix->eotSize = eotHeader.size() + fontSize;
332
+
333
+ return true;
334
+ }
@@ -0,0 +1,36 @@
1
+ /* Modified for use with ttf2eot, originally from WebKit. */
2
+
3
+ /*
4
+ * Copyright (C) 2008 Apple Inc. All rights reserved.
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
+ * 1. Redistributions of source code must retain the above copyright
10
+ * notice, this list of conditions and the following disclaimer.
11
+ * 2. Redistributions in binary form must reproduce the above copyright
12
+ * notice, this list of conditions and the following disclaimer in the
13
+ * documentation and/or other materials provided with the distribution.
14
+ *
15
+ * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
16
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
18
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR
19
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
20
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
21
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
22
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
23
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26
+ */
27
+
28
+ #ifndef OpenTypeUtilities_h
29
+ #define OpenTypeUtilities_h
30
+
31
+ using std::vector;
32
+
33
+ bool getEOTHeader(unsigned char * fontData, size_t fontSize, vector<uint8_t>& eotHeader, size_t& overlayDst, size_t& overlaySrc, size_t& overlayLength);
34
+
35
+
36
+ #endif // OpenTypeUtilities_h
Binary file
@@ -0,0 +1,35 @@
1
+ Very quick commandline wrapper around OpenTypeUtilities.cpp from Chromium, used
2
+ to make EOT (Embeddable Open Type) files from TTF (TrueType/OpenType Font)
3
+ files. This is the format TTLoadEmbeddedFont() accepts, which is what Internet
4
+ Explorer uses for css @font-face declarations.
5
+
6
+ I've only tested this on Linux.
7
+
8
+ EOT was documented by Microsoft here:
9
+ <http://www.w3.org/Submission/2008/SUBM-EOT-20080305/>
10
+
11
+ TTLoadEmbeddedFont is described here:
12
+ <http://msdn.microsoft.com/en-us/library/dd145155(VS.85).aspx>
13
+
14
+ Chromium:
15
+ <http://src.chromium.org/viewvc/chrome/trunk/deps/third_party/WebKit/WebCore/platform/graphics/win/OpenTypeUtilities.cpp?view=log&pathrev=7591>
16
+
17
+ To build:
18
+
19
+ $ make
20
+
21
+ Usage:
22
+
23
+ $ ./ttf2eot < input.ttf > output.eot
24
+
25
+ Author: taviso@sdf.lonestar.org 15-Mar-2009
26
+ License: Derived from WebKit, so BSD/LGPL 2/LGPL 2.1.
27
+
28
+ Keywords for anyone having as much pain as me finding a utility to do this on Linux:
29
+
30
+ covert eot to ttf
31
+ eot converter
32
+ wtf is an eot file
33
+
34
+
35
+ TODO: MTX support?
Binary file
@@ -0,0 +1,94 @@
1
+ /* Trivial utility to create EOT files on Linux */
2
+
3
+ #include <stdlib.h>
4
+ #include <stdio.h>
5
+ #include <assert.h>
6
+ #include <limits.h>
7
+ #include <string.h>
8
+
9
+ #include <vector>
10
+
11
+ #ifndef _MSC_VER
12
+ # include <stdint.h>
13
+ #else
14
+ typedef unsigned char uint8_t;
15
+ #endif
16
+
17
+ #if defined(_MSC_VER) || defined(__MINGW32__)
18
+ # include <io.h>
19
+ # include <fcntl.h>
20
+ # ifndef _O_BINARY
21
+ # define _O_BINARY 0x8000
22
+ # endif
23
+ # ifndef _O_TEXT
24
+ # define _O_TEXT 0x4000
25
+ # endif
26
+ #endif
27
+
28
+ #include "OpenTypeUtilities.h"
29
+
30
+ #ifndef SIZE_MAX
31
+ # define SIZE_MAX UINT_MAX
32
+ #endif
33
+
34
+ using std::vector;
35
+
36
+ int main(int argc, char **argv)
37
+ {
38
+ const size_t kFontInitSize = 8192;
39
+ vector<uint8_t> eotHeader(512);
40
+ size_t overlayDst = 0;
41
+ size_t overlaySrc = 0;
42
+ size_t overlayLength = 0;
43
+ size_t fontSize = 0;
44
+ size_t fontOff = 0;
45
+ FILE *input;
46
+ unsigned char *fontData;
47
+
48
+ #if defined(_MSC_VER) || defined(__MINGW32__)
49
+ setmode(_fileno(stdin), _O_BINARY);
50
+ setmode(_fileno(stdout), _O_BINARY);
51
+ setmode(_fileno(stderr), _O_TEXT);
52
+ #endif
53
+
54
+ if (argv[1] == NULL || (argv[1][0] == '-' && argv[1][1] == '\0')) {
55
+ input = stdin;
56
+ } else {
57
+ input = fopen(argv[1], "rb");
58
+ if (input == NULL) {
59
+ fprintf(stderr, "could not open input file %s, %m\n", argv[1]);
60
+ return 1;
61
+ }
62
+ }
63
+
64
+ if ((fontData = (unsigned char *) malloc(fontSize = kFontInitSize)) == NULL) {
65
+ fprintf(stderr, "Allocation failure, %m\n");
66
+ return 1;
67
+ }
68
+
69
+ do {
70
+ size_t ret = fread(fontData + fontOff, 1, fontSize - fontOff, input);
71
+ if (ret && fontSize <= SIZE_MAX / 2) {
72
+ fontOff += ret;
73
+ if ((fontData = (unsigned char *) realloc(fontData, fontSize *= 2)) == NULL) {
74
+ fprintf(stderr, "Allocation failure, %m\n");
75
+ return 1;
76
+ }
77
+ } else if (ret) {
78
+ fprintf(stderr, "Too much data, %m\n");
79
+ return 1;
80
+ } else {
81
+ fontData = (unsigned char *) realloc(fontData, fontSize = fontOff);
82
+ break;
83
+ }
84
+ } while (true);
85
+
86
+ if (getEOTHeader(fontData, fontSize, eotHeader, overlayDst, overlaySrc, overlayLength)) {
87
+ fwrite(&eotHeader[0], eotHeader.size(), 1, stdout);
88
+ fwrite(fontData, fontSize, 1, stdout);
89
+ return 0;
90
+ } else {
91
+ fprintf(stderr, "unknown error parsing input font, %m\n");
92
+ return 1;
93
+ }
94
+ }
Binary file
Binary file
Binary file
@@ -0,0 +1 @@
1
+ @font-face {font-family:'yardsale'; src:url('yardsale.eot');}
@@ -0,0 +1 @@
1
+ @font-face {font-family:'yardsale'; src:url('yardsale.ttf');}
data/spec/kana_spec.rb ADDED
@@ -0,0 +1,7 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+
3
+ describe "Kana" do
4
+ it "should be awesome" do
5
+ true
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ require "spec_helper"
2
+
3
+ describe "Kana rake utility" do
4
+ it "should be able to set the font directory" do
5
+ end
6
+
7
+ it "should refresh the css files of a font directory" do
8
+ end
9
+ end
@@ -0,0 +1,11 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
+ require 'kana'
4
+ require 'spec'
5
+ require 'rspec'
6
+ require 'rubygems'
7
+ require 'spec/autorun'
8
+
9
+ Spec::Runner.configure do |config|
10
+
11
+ end
metadata ADDED
@@ -0,0 +1,110 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: jitai
3
+ version: !ruby/object:Gem::Version
4
+ hash: 17
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 2
9
+ - 3
10
+ version: 0.2.3
11
+ platform: ruby
12
+ authors:
13
+ - Kelly
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-11-07 00:00:00 -07:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: rspec
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 13
30
+ segments:
31
+ - 1
32
+ - 2
33
+ - 9
34
+ version: 1.2.9
35
+ type: :development
36
+ version_requirements: *id001
37
+ description: CSS custom font consolidator
38
+ email: defaultstring@gmail.com
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files:
44
+ - LICENSE
45
+ - README.textile
46
+ files:
47
+ - .document
48
+ - .gitignore
49
+ - LICENSE
50
+ - README.textile
51
+ - Rakefile
52
+ - VERSION
53
+ - kana-0.2.0.gem
54
+ - kana.gemspec
55
+ - lib/jitai.rb
56
+ - lib/rake/jitaitask.rb
57
+ - lib/ttf2eot/ChangeLog
58
+ - lib/ttf2eot/Makefile
59
+ - lib/ttf2eot/OpenTypeUtilities.cpp
60
+ - lib/ttf2eot/OpenTypeUtilities.h
61
+ - lib/ttf2eot/OpenTypeUtilities.o
62
+ - lib/ttf2eot/README
63
+ - lib/ttf2eot/ttf2eot
64
+ - lib/ttf2eot/ttf2eot.cpp
65
+ - lib/ttf2eot/ttf2eot.o
66
+ - public/fonts/yardsale.eot
67
+ - public/fonts/yardsale.ttf
68
+ - public/stylesheets/fonts_ie.css
69
+ - public/stylesheets/fonts_moz.css
70
+ - spec/kana_spec.rb
71
+ - spec/rake/kanatask_spec.rb
72
+ - spec/spec_helper.rb
73
+ has_rdoc: true
74
+ homepage: http://github.com/kellydunn/jitai
75
+ licenses: []
76
+
77
+ post_install_message:
78
+ rdoc_options:
79
+ - --charset=UTF-8
80
+ require_paths:
81
+ - lib
82
+ required_ruby_version: !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ">="
86
+ - !ruby/object:Gem::Version
87
+ hash: 3
88
+ segments:
89
+ - 0
90
+ version: "0"
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ hash: 3
97
+ segments:
98
+ - 0
99
+ version: "0"
100
+ requirements: []
101
+
102
+ rubyforge_project:
103
+ rubygems_version: 1.3.7
104
+ signing_key:
105
+ specification_version: 3
106
+ summary: CSS custom font consolidator
107
+ test_files:
108
+ - spec/kana_spec.rb
109
+ - spec/rake/kanatask_spec.rb
110
+ - spec/spec_helper.rb