glyph_imager 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/glyph_imager.gemspec +2 -3
- data/lib/glyph_imager.rb +1 -3
- metadata +3 -4
- data/vendor/graphics_utf +0 -157
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.9
|
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.
|
8
|
+
s.version = "0.0.9"
|
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-04-
|
12
|
+
s.date = %q{2010-04-29}
|
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 = [
|
@@ -28,7 +28,6 @@ Gem::Specification.new do |s|
|
|
28
28
|
"test/fonts/DejaVuSerif.ttf",
|
29
29
|
"test/helper.rb",
|
30
30
|
"test/test_glyph_imager.rb",
|
31
|
-
"vendor/graphics_utf",
|
32
31
|
"vendor/ttf-ruby-0.1/AUTHORS",
|
33
32
|
"vendor/ttf-ruby-0.1/COPYING",
|
34
33
|
"vendor/ttf-ruby-0.1/README",
|
data/lib/glyph_imager.rb
CHANGED
@@ -76,8 +76,6 @@ module GlyphImager
|
|
76
76
|
|
77
77
|
class Imager
|
78
78
|
|
79
|
-
@@graphics_utf_path = File.join(File.dirname(__FILE__), '..', 'vendor', 'graphics_utf')
|
80
|
-
|
81
79
|
def initialize(opts = {})
|
82
80
|
@options = { :size => "80x80" }.merge(opts)
|
83
81
|
%w[code_point font_path output_dir].each do |k|
|
@@ -93,7 +91,7 @@ module GlyphImager
|
|
93
91
|
|
94
92
|
|
95
93
|
def create_image
|
96
|
-
%x[
|
94
|
+
%x[convert -font #{@options[:font_path]} -size #{@options[:size]} -gravity center label:#{["#{@options[:code_point]}".hex].pack("U*")} #{output_path}]
|
97
95
|
return self
|
98
96
|
end
|
99
97
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 0.0.
|
8
|
+
- 9
|
9
|
+
version: 0.0.9
|
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-04-
|
17
|
+
date: 2010-04-29 00:00:00 -05:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -50,7 +50,6 @@ files:
|
|
50
50
|
- test/fonts/DejaVuSerif.ttf
|
51
51
|
- test/helper.rb
|
52
52
|
- test/test_glyph_imager.rb
|
53
|
-
- vendor/graphics_utf
|
54
53
|
- vendor/ttf-ruby-0.1/AUTHORS
|
55
54
|
- vendor/ttf-ruby-0.1/COPYING
|
56
55
|
- vendor/ttf-ruby-0.1/README
|
data/vendor/graphics_utf
DELETED
@@ -1,157 +0,0 @@
|
|
1
|
-
#!/bin/sh -
|
2
|
-
#
|
3
|
-
# graphics_utf [options] character_set
|
4
|
-
# graphics_utf [options] start_utf_hex [end_utf_hex]
|
5
|
-
#
|
6
|
-
# Print UTF characters tables to standard output...
|
7
|
-
#
|
8
|
-
# Options: -n no formating around charcaters
|
9
|
-
# -N no formating, and no linefeeds either
|
10
|
-
#
|
11
|
-
# Character-Sets Known by this script include:
|
12
|
-
# ascii, ascii+meta, meta, latin, latin_ext, tolkan, punct, indices,
|
13
|
-
# numbers, factions, roman, arrows, math, mathsup,
|
14
|
-
# technical, graphics, dingbats, braile, and asian (big)
|
15
|
-
#
|
16
|
-
# For example
|
17
|
-
# graphics_utf numbers
|
18
|
-
# graphics_utf 0000 0200
|
19
|
-
#
|
20
|
-
# Or use ImageMagick to display in a specific font
|
21
|
-
#
|
22
|
-
# graphics_utf -N dingbats |\
|
23
|
-
# convert -font Mincho -pointsize 48 label:@- x:
|
24
|
-
#
|
25
|
-
####
|
26
|
-
#
|
27
|
-
# For a GUI version (yuck) use "gucharmap"
|
28
|
-
#
|
29
|
-
# WARNING: Input arguments are NOT tested for correctness.
|
30
|
-
# This script represents a security risk if used ONLINE.
|
31
|
-
# I accept no responsiblity for misuse. Use at own risk.
|
32
|
-
#
|
33
|
-
# Anthony Thyssen 30 August 2005
|
34
|
-
#
|
35
|
-
PROGNAME=`type $0 | awk '{print $3}'` # search for executable on path
|
36
|
-
PROGDIR=`dirname $PROGNAME` # extract directory of program
|
37
|
-
PROGNAME=`basename $PROGNAME` # base name of program
|
38
|
-
Usage() { # output the script comments as docs
|
39
|
-
echo >&2 "$PROGNAME:" "$@"
|
40
|
-
sed >&2 -n '/^###/q; /^#/!q; s/^#//; s/^ //; 3s/^/Usage: /; 2,$ p' \
|
41
|
-
"$PROGDIR/$PROGNAME"
|
42
|
-
exit 10;
|
43
|
-
}
|
44
|
-
|
45
|
-
FORMAT=normal
|
46
|
-
|
47
|
-
while [ $# -gt 0 ]; do
|
48
|
-
case "$1" in
|
49
|
-
--help|--doc*) Usage ;;
|
50
|
-
-n|--noheaders) FORMAT=nohead ;;
|
51
|
-
-N|--nolinefeeds) FORMAT= ;;
|
52
|
-
|
53
|
-
--) shift; break ;; # end of user options
|
54
|
-
-*) Usage "Unknown option \"$1\"" ;;
|
55
|
-
*) break ;; # end of user options
|
56
|
-
|
57
|
-
esac
|
58
|
-
shift # next option
|
59
|
-
done
|
60
|
-
|
61
|
-
case `echo "$1" | tr 'A-Z' 'a-z'` in
|
62
|
-
ascii) start=`printf '%d' 0x0020` end=`printf '%d' 0x0080` ;;
|
63
|
-
ascii+meta) start=`printf '%d' 0x0020` end=`printf '%d' 0x0100` ;;
|
64
|
-
latin) start=`printf '%d' 0x0000` end=`printf '%d' 0x0250` ;;
|
65
|
-
meta) start=`printf '%d' 0x00A0` end=`printf '%d' 0x0100` ;;
|
66
|
-
latin_ext) start=`printf '%d' 0x1E00` end=`printf '%d' 0x1F00` ;;
|
67
|
-
runic|tolkan) start=`printf '%d' 0x16A0` end=`printf '%d' 0x1700` ;;
|
68
|
-
punctuation|\
|
69
|
-
punct) start=`printf '%d' 0x2000` end=`printf '%d' 0x2070` ;;
|
70
|
-
indices) start=`printf '%d' 0x2070` end=`printf '%d' 0x20A0` ;;
|
71
|
-
numbers) start=`printf '%d' 0x2150` end=`printf '%d' 0x2180` ;;
|
72
|
-
factions) start=`printf '%d' 0x2150` end=`printf '%d' 0x2160` ;;
|
73
|
-
roman) start=`printf '%d' 0x2160` end=`printf '%d' 0x2190` ;;
|
74
|
-
arrows) start=`printf '%d' 0x2190` end=`printf '%d' 0x2200` ;;
|
75
|
-
arrows-a) start=`printf '%d' 0x27F0` end=`printf '%d' 0x2800` ;;
|
76
|
-
arrows-b) start=`printf '%d' 0x2900` end=`printf '%d' 0x2980` ;;
|
77
|
-
math) start=`printf '%d' 0x2200` end=`printf '%d' 0x2300` ;;
|
78
|
-
technical) start=`printf '%d' 0x2300` end=`printf '%d' 0x2400` ;;
|
79
|
-
graphics) start=`printf '%d' 0x2500` end=`printf '%d' 0x2600` ;;
|
80
|
-
miscellaneous|\
|
81
|
-
misc) start=`printf '%d' 0x2600` end=`printf '%d' 0x2700` ;;
|
82
|
-
dingbats) start=`printf '%d' 0x2700` end=`printf '%d' 0x2800` ;;
|
83
|
-
braile) start=`printf '%d' 0x2800` end=`printf '%d' 0x2900` ;;
|
84
|
-
mathsup) start=`printf '%d' 0x2A00` end=`printf '%d' 0x2B00` ;;
|
85
|
-
asian) start=`printf '%d' 0x4E00` end=`printf '%d' 0xA000` ;;
|
86
|
-
|
87
|
-
[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F])
|
88
|
-
start=`printf '%d' 0x${1:-2000}`
|
89
|
-
if [ "x$2" = 'x' ]; then
|
90
|
-
case "$FORMAT" in
|
91
|
-
normal) end=`expr $start + 16 \* 16` ;;
|
92
|
-
nohead) end=`expr $start + 16` ;;
|
93
|
-
*) end=`expr $start + 1` ;;
|
94
|
-
esac
|
95
|
-
else
|
96
|
-
end=`printf '%d' 0x$2`
|
97
|
-
fi
|
98
|
-
;;
|
99
|
-
|
100
|
-
'') # no argument -- standard charcaters
|
101
|
-
start=`printf '%d' 0x0020` end=`printf '%d' 0x0080`
|
102
|
-
;;
|
103
|
-
*)
|
104
|
-
Usage
|
105
|
-
echo >&2 "Usage: $0 character_set"
|
106
|
-
echo >&2 " $0 start_utf_hex [end_utf_hex]"
|
107
|
-
echo >&2 "Continuing with the 'latin' character_set..."
|
108
|
-
echo >&2 ""
|
109
|
-
start=`printf '%d' 0x0020` end=`printf '%d' 0x0080`
|
110
|
-
;;
|
111
|
-
esac
|
112
|
-
|
113
|
-
# ------------------------------------------------------------------------
|
114
|
-
|
115
|
-
i=$start
|
116
|
-
|
117
|
-
[ "$FORMAT" = 'normal' ] &&
|
118
|
-
printf ' UTF-8 Characters %04X to %04X\n' $start $end
|
119
|
-
|
120
|
-
while [ $i -lt $end ]; do
|
121
|
-
|
122
|
-
if [ "$FORMAT" = 'normal' ]; then
|
123
|
-
[ `expr $i % 256` -eq 0 -o $i -eq $start ] &&
|
124
|
-
printf " _0__1__2__3__4__5__6__7__8__9__a__b__c__d__e__f_\n"
|
125
|
-
printf "%04X " $i
|
126
|
-
#[ $i -lt 32 -o $i -eq 128 -o $i -eq 144 ] &&
|
127
|
-
fi
|
128
|
-
if [ $i -lt 32 ]; then
|
129
|
-
if [ "$FORMAT" = 'normal' ]; then
|
130
|
-
printf " Skipping Control Character Range\n"
|
131
|
-
fi
|
132
|
-
else
|
133
|
-
for j in 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15; do
|
134
|
-
c=`expr $i + $j`
|
135
|
-
if [ "$FORMAT" = 'normal' ]; then
|
136
|
-
printf " "
|
137
|
-
elif [ $c -ge $end ]; then
|
138
|
-
break
|
139
|
-
fi
|
140
|
-
if [ $i -ge 160 ]; then # full unicode character
|
141
|
-
c=`printf "%04X" $c`
|
142
|
-
#env LC_CTYPE=en_AU.utf8 printf "\u$c"
|
143
|
-
env LC_CTYPE=en_AU.utf8 \
|
144
|
-
perl -e "binmode(STDOUT, ':utf8'); print chr(0x$c)"
|
145
|
-
elif [ $i -ge 128 ]; then # meta-control character
|
146
|
-
printf "\xc2\x`printf "%02X" $c`"
|
147
|
-
else # normal character
|
148
|
-
printf "\x`printf "%02X" $c`"
|
149
|
-
fi
|
150
|
-
done
|
151
|
-
[ "$FORMAT" ] && printf "\n"
|
152
|
-
fi
|
153
|
-
i=`expr $i + 16`
|
154
|
-
|
155
|
-
done
|
156
|
-
|
157
|
-
# ------------------------------------------------------------------------
|