glyph_imager 0.0.13 → 0.0.14

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.13
1
+ 0.0.14
data/glyph_imager.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{glyph_imager}
8
- s.version = "0.0.13"
8
+ s.version = "0.0.14"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["William Melody"]
12
- s.date = %q{2010-05-04}
12
+ s.date = %q{2010-05-24}
13
13
  s.description = %q{Generate images of glyphs for a specified character in a specified font}
14
14
  s.email = %q{hi@williammelody.com}
15
15
  s.extra_rdoc_files = [
data/lib/glyph_imager.rb CHANGED
@@ -85,7 +85,7 @@ module GlyphImager
85
85
  class Imager
86
86
 
87
87
  def initialize(opts = {})
88
- @options = { :size => "80x80", :pointsize_percentage => 100 }.merge(opts)
88
+ @options = { :size => "80x80", :pointsize_percentage => 100, :gravity => "center" }.merge(opts)
89
89
  %w[code_point font_path output_dir].each do |k|
90
90
  if @options[k.to_sym].nil?
91
91
  raise ArgumentError, "missing value for :#{k}"
@@ -101,18 +101,21 @@ module GlyphImager
101
101
  @options[:size].split("x").last.to_i * @options[:pointsize_percentage] / 100.0
102
102
  end
103
103
 
104
- def command_string
105
- # need to escape apostrophe
104
+ def label
106
105
  case @options[:code_point]
107
106
  when "0027"
108
- "convert -font #{@options[:font_path]} -size #{@options[:size]} -gravity center -pointsize #{pointsize} label:\\#{[@options[:code_point].hex].pack("U*")} #{output_path}"
107
+ "label:\\#{[@options[:code_point].hex].pack("U*")}"
109
108
  when "005C"
110
- "convert -font #{@options[:font_path]} -size #{@options[:size]} -gravity center -pointsize #{pointsize} label:'\\#{[@options[:code_point].hex].pack("U*")}' #{output_path}"
109
+ "label:'\\#{[@options[:code_point].hex].pack("U*")}'"
111
110
  else
112
- "convert -font #{@options[:font_path]} -size #{@options[:size]} -gravity center -pointsize #{pointsize} label:'#{[@options[:code_point].hex].pack("U*")}' #{output_path}"
111
+ "label:'#{[@options[:code_point].hex].pack("U*")}'"
113
112
  end
114
113
  end
115
-
114
+
115
+ def command_string
116
+ "convert -font #{@options[:font_path]} -size #{@options[:size]} -gravity #{@options[:gravity]} -pointsize #{pointsize} #{label} #{output_path}"
117
+ end
118
+
116
119
  def create_image
117
120
  %x[#{command_string}]
118
121
  return self
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 13
9
- version: 0.0.13
8
+ - 14
9
+ version: 0.0.14
10
10
  platform: ruby
11
11
  authors:
12
12
  - William Melody
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-04 00:00:00 -05:00
17
+ date: 2010-05-24 00:00:00 -05:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency