blacksmith 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/examples/forgefile/Forgefile +1 -1
- data/examples/programmatic_font_creation/programmatic_font_creation.rb +1 -1
- data/lib/blacksmith/font_builder.rb +7 -9
- data/lib/blacksmith/glyph.rb +11 -11
- data/lib/blacksmith/version.rb +1 -1
- data/support/fontforge_build_instructions.py.erb +1 -1
- metadata +1 -1
@@ -10,13 +10,11 @@ class Blacksmith::FontBuilder
|
|
10
10
|
def initialize(filename = nil, &block)
|
11
11
|
raise "Expects filename or block" unless filename || block
|
12
12
|
raise "Expects either a block or a filename - not both" if filename and block
|
13
|
-
raise "File not found: #{filename}"
|
13
|
+
raise "File not found: #{filename}" if filename && !File.exist?(filename)
|
14
14
|
|
15
15
|
@_instructions = block || File.read(filename)
|
16
|
-
|
17
16
|
@_attributes = {}
|
18
17
|
@_glyphs = {}
|
19
|
-
@_source = '.'
|
20
18
|
end
|
21
19
|
|
22
20
|
def execute
|
@@ -29,10 +27,10 @@ class Blacksmith::FontBuilder
|
|
29
27
|
|
30
28
|
font = Blacksmith::Font.new(@_attributes)
|
31
29
|
|
32
|
-
@_glyphs.each do |
|
33
|
-
attrs[:scale]
|
34
|
-
attrs[:offset]
|
35
|
-
attrs[:
|
30
|
+
@_glyphs.each do |filename, attrs|
|
31
|
+
attrs[:scale] ||= font.scale
|
32
|
+
attrs[:offset] ||= font.offset
|
33
|
+
attrs[:source] ||= File.join(font.source, filename)
|
36
34
|
|
37
35
|
font << Blacksmith::Glyph.new(attrs)
|
38
36
|
end
|
@@ -40,8 +38,8 @@ class Blacksmith::FontBuilder
|
|
40
38
|
font
|
41
39
|
end
|
42
40
|
|
43
|
-
def glyph(
|
44
|
-
@_glyphs[
|
41
|
+
def glyph(filename, attrs)
|
42
|
+
@_glyphs[filename] = attrs
|
45
43
|
end
|
46
44
|
|
47
45
|
def method_missing(name, *args)
|
data/lib/blacksmith/glyph.rb
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
class Blacksmith::Glyph
|
2
2
|
include SmartProperties
|
3
|
+
|
4
|
+
property :name, :converts => :to_s
|
3
5
|
|
4
|
-
property :
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
6
|
+
property :code, :required => true,
|
7
|
+
:converts => :to_i
|
8
|
+
|
9
|
+
property :source, :required => true,
|
10
|
+
:converts => :to_s,
|
11
|
+
:accepts => lambda { |filename| File.exist?(filename) }
|
12
|
+
|
10
13
|
property :left_side_bearing, :required => true,
|
11
14
|
:converts => :to_i,
|
12
15
|
:default => 15
|
@@ -20,12 +23,9 @@ class Blacksmith::Glyph
|
|
20
23
|
|
21
24
|
property :offset, :converts => :to_f,
|
22
25
|
:accepts => lambda { |offset| offset <= 1.0 and offset >= -1.0 }
|
23
|
-
|
24
|
-
def file_name
|
25
|
-
File.basename(outline)
|
26
|
-
end
|
27
26
|
|
28
27
|
def name
|
29
|
-
File.basename(
|
28
|
+
super || File.basename(source, File.extname(source))
|
30
29
|
end
|
30
|
+
|
31
31
|
end
|
data/lib/blacksmith/version.rb
CHANGED
@@ -44,7 +44,7 @@ font.weight = "<%= weight %>"
|
|
44
44
|
<% for glyph in glyphs do %>
|
45
45
|
# <%= glyph.name %>
|
46
46
|
c = font.createChar(<%= glyph.code %>)
|
47
|
-
c.importOutlines("<%= glyph.
|
47
|
+
c.importOutlines("<%= glyph.source %>")
|
48
48
|
c.left_side_bearing = <%= glyph.left_side_bearing %>
|
49
49
|
c.right_side_bearing = <%= glyph.right_side_bearing %>
|
50
50
|
c.simplify()
|