glyph_imager 0.0.12 → 0.0.13

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/.gitignore CHANGED
@@ -19,3 +19,5 @@ rdoc
19
19
  pkg
20
20
 
21
21
  ## PROJECT::SPECIFIC
22
+
23
+ test/fonts/other
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.12
1
+ 0.0.13
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{glyph_imager}
8
- s.version = "0.0.12"
8
+ s.version = "0.0.13"
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"]
@@ -85,7 +85,7 @@ module GlyphImager
85
85
  class Imager
86
86
 
87
87
  def initialize(opts = {})
88
- @options = { :size => "80x80" }.merge(opts)
88
+ @options = { :size => "80x80", :pointsize_percentage => 100 }.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}"
@@ -97,15 +97,19 @@ module GlyphImager
97
97
  "#{@options[:output_dir]}/#{@options[:code_point]}-#{@options[:size]}.png"
98
98
  end
99
99
 
100
+ def pointsize
101
+ @options[:size].split("x").last.to_i * @options[:pointsize_percentage] / 100.0
102
+ end
103
+
100
104
  def command_string
101
105
  # need to escape apostrophe
102
106
  case @options[:code_point]
103
107
  when "0027"
104
- "convert -font #{@options[:font_path]} -size #{@options[:size]} -gravity center label:\\#{[@options[:code_point].hex].pack("U*")} #{output_path}"
108
+ "convert -font #{@options[:font_path]} -size #{@options[:size]} -gravity center -pointsize #{pointsize} label:\\#{[@options[:code_point].hex].pack("U*")} #{output_path}"
105
109
  when "005C"
106
- "convert -font #{@options[:font_path]} -size #{@options[:size]} -gravity center label:'\\#{[@options[:code_point].hex].pack("U*")}' #{output_path}"
110
+ "convert -font #{@options[:font_path]} -size #{@options[:size]} -gravity center -pointsize #{pointsize} label:'\\#{[@options[:code_point].hex].pack("U*")}' #{output_path}"
107
111
  else
108
- "convert -font #{@options[:font_path]} -size #{@options[:size]} -gravity center label:'#{[@options[:code_point].hex].pack("U*")}' #{output_path}"
112
+ "convert -font #{@options[:font_path]} -size #{@options[:size]} -gravity center -pointsize #{pointsize} label:'#{[@options[:code_point].hex].pack("U*")}' #{output_path}"
109
113
  end
110
114
  end
111
115
 
@@ -3,8 +3,10 @@ require 'helper'
3
3
  class TestGlyphImager < Test::Unit::TestCase
4
4
 
5
5
  def setup
6
- @font_path = File.join(File.dirname(__FILE__), 'fonts', 'DejaVuSerif.ttf')
6
+ @fonts_dir = File.join(File.dirname(__FILE__), 'fonts')
7
+ @font_path = File.join(@fonts_dir, 'DejaVuSerif.ttf')
7
8
  @font = GlyphImager::FontRecord.new(@font_path)
9
+ @times = GlyphImager::FontRecord.new(File.join(@fonts_dir, 'other', 'TimesRoman.ttf'))
8
10
  @output_dir = "/tmp"
9
11
  end
10
12
 
@@ -31,8 +33,8 @@ class TestGlyphImager < Test::Unit::TestCase
31
33
  end
32
34
 
33
35
  should "return false when glyph is control char" do
34
- assert !@font.has_glyph_for_unicode_char?("0000")
35
- assert !@font.has_glyph_for_unicode_char?("009F")
36
+ assert !@times.has_glyph_for_unicode_char?("0000")
37
+ assert !@times.has_glyph_for_unicode_char?("009F")
36
38
  end
37
39
 
38
40
  should "return false when glyph doesn't exist for character" do
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 0
8
- - 12
9
- version: 0.0.12
8
+ - 13
9
+ version: 0.0.13
10
10
  platform: ruby
11
11
  authors:
12
12
  - William Melody