glyph_imager 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (47) hide show
  1. data/.document +5 -0
  2. data/.gitignore +21 -0
  3. data/LICENSE +20 -0
  4. data/README.rdoc +17 -0
  5. data/Rakefile +53 -0
  6. data/VERSION +1 -0
  7. data/glyph_imager.gemspec +90 -0
  8. data/lib/glyph_imager.rb +102 -0
  9. data/test/fonts/DejaVuSerif.ttf +0 -0
  10. data/test/helper.rb +10 -0
  11. data/test/test_glyph_imager.rb +62 -0
  12. data/vendor/graphics_utf +157 -0
  13. data/vendor/ttf-ruby-0.1/AUTHORS +1 -0
  14. data/vendor/ttf-ruby-0.1/COPYING +340 -0
  15. data/vendor/ttf-ruby-0.1/README +49 -0
  16. data/vendor/ttf-ruby-0.1/TODO +23 -0
  17. data/vendor/ttf-ruby-0.1/VERSION +1 -0
  18. data/vendor/ttf-ruby-0.1/lib/ttf/datatypes.rb +189 -0
  19. data/vendor/ttf-ruby-0.1/lib/ttf/encodings.rb +140 -0
  20. data/vendor/ttf-ruby-0.1/lib/ttf/exceptions.rb +28 -0
  21. data/vendor/ttf-ruby-0.1/lib/ttf/font_loader.rb +290 -0
  22. data/vendor/ttf-ruby-0.1/lib/ttf/fontchunk.rb +77 -0
  23. data/vendor/ttf-ruby-0.1/lib/ttf/table/cmap.rb +408 -0
  24. data/vendor/ttf-ruby-0.1/lib/ttf/table/cvt.rb +49 -0
  25. data/vendor/ttf-ruby-0.1/lib/ttf/table/fpgm.rb +48 -0
  26. data/vendor/ttf-ruby-0.1/lib/ttf/table/gasp.rb +88 -0
  27. data/vendor/ttf-ruby-0.1/lib/ttf/table/glyf.rb +452 -0
  28. data/vendor/ttf-ruby-0.1/lib/ttf/table/head.rb +86 -0
  29. data/vendor/ttf-ruby-0.1/lib/ttf/table/hhea.rb +96 -0
  30. data/vendor/ttf-ruby-0.1/lib/ttf/table/hmtx.rb +98 -0
  31. data/vendor/ttf-ruby-0.1/lib/ttf/table/kern.rb +186 -0
  32. data/vendor/ttf-ruby-0.1/lib/ttf/table/loca.rb +75 -0
  33. data/vendor/ttf-ruby-0.1/lib/ttf/table/maxp.rb +81 -0
  34. data/vendor/ttf-ruby-0.1/lib/ttf/table/name.rb +222 -0
  35. data/vendor/ttf-ruby-0.1/lib/ttf/table/os2.rb +172 -0
  36. data/vendor/ttf-ruby-0.1/lib/ttf/table/post.rb +120 -0
  37. data/vendor/ttf-ruby-0.1/lib/ttf/table/prep.rb +27 -0
  38. data/vendor/ttf-ruby-0.1/lib/ttf/table/vhea.rb +45 -0
  39. data/vendor/ttf-ruby-0.1/lib/ttf/table/vmtx.rb +36 -0
  40. data/vendor/ttf-ruby-0.1/lib/ttf.rb +20 -0
  41. data/vendor/ttf-ruby-0.1/setup.rb +1558 -0
  42. data/vendor/ttf-ruby-0.1/tools/README +44 -0
  43. data/vendor/ttf-ruby-0.1/tools/ttfcairoglyphviewer +229 -0
  44. data/vendor/ttf-ruby-0.1/tools/ttfdump +396 -0
  45. data/vendor/ttf-ruby-0.1/tools/ttfglyph2svg +144 -0
  46. data/vendor/ttf-ruby-0.1/tools/ttfsubset +273 -0
  47. metadata +120 -0
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 William Melody
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.rdoc ADDED
@@ -0,0 +1,17 @@
1
+ = glyph_imager
2
+
3
+ This gem is completely undocumented and the code is pretty much just tossed together, but the basic idea is that it uses imagemagick to generate an image of specified unicode character glyphs from a TTF.
4
+
5
+ == Note on Patches/Pull Requests
6
+
7
+ * Fork the project.
8
+ * Make your feature addition or bug fix.
9
+ * Add tests for it. This is important so I don't break it in a
10
+ future version unintentionally.
11
+ * Commit, do not mess with rakefile, version, or history.
12
+ (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
13
+ * Send me a pull request. Bonus points for topic branches.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2010 William Melody. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,53 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+
4
+ begin
5
+ require 'jeweler'
6
+ Jeweler::Tasks.new do |gem|
7
+ gem.name = "glyph_imager"
8
+ gem.summary = %Q{Generate images of glyphs for a specified character in a specified font}
9
+ gem.description = %Q{Generate images of glyphs for a specified character in a specified font}
10
+ gem.email = "hi@williammelody.com"
11
+ gem.homepage = "http://github.com/alphabetum/glyph_imager"
12
+ gem.authors = ["William Melody"]
13
+ gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
14
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
15
+ end
16
+ Jeweler::GemcutterTasks.new
17
+ rescue LoadError
18
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
19
+ end
20
+
21
+ require 'rake/testtask'
22
+ Rake::TestTask.new(:test) do |test|
23
+ test.libs << 'lib' << 'test'
24
+ test.pattern = 'test/**/test_*.rb'
25
+ test.verbose = true
26
+ end
27
+
28
+ begin
29
+ require 'rcov/rcovtask'
30
+ Rcov::RcovTask.new do |test|
31
+ test.libs << 'test'
32
+ test.pattern = 'test/**/test_*.rb'
33
+ test.verbose = true
34
+ end
35
+ rescue LoadError
36
+ task :rcov do
37
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
38
+ end
39
+ end
40
+
41
+ task :test => :check_dependencies
42
+
43
+ task :default => :test
44
+
45
+ require 'rake/rdoctask'
46
+ Rake::RDocTask.new do |rdoc|
47
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
48
+
49
+ rdoc.rdoc_dir = 'rdoc'
50
+ rdoc.title = "glyph_imager #{version}"
51
+ rdoc.rdoc_files.include('README*')
52
+ rdoc.rdoc_files.include('lib/**/*.rb')
53
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.0.3
@@ -0,0 +1,90 @@
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{glyph_imager}
8
+ s.version = "0.0.3"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["William Melody"]
12
+ s.date = %q{2010-04-27}
13
+ s.description = %q{Generate images of glyphs for a specified character in a specified font}
14
+ s.email = %q{hi@williammelody.com}
15
+ s.extra_rdoc_files = [
16
+ "LICENSE",
17
+ "README.rdoc"
18
+ ]
19
+ s.files = [
20
+ ".document",
21
+ ".gitignore",
22
+ "LICENSE",
23
+ "README.rdoc",
24
+ "Rakefile",
25
+ "VERSION",
26
+ "glyph_imager.gemspec",
27
+ "lib/glyph_imager.rb",
28
+ "test/fonts/DejaVuSerif.ttf",
29
+ "test/helper.rb",
30
+ "test/test_glyph_imager.rb",
31
+ "vendor/graphics_utf",
32
+ "vendor/ttf-ruby-0.1/AUTHORS",
33
+ "vendor/ttf-ruby-0.1/COPYING",
34
+ "vendor/ttf-ruby-0.1/README",
35
+ "vendor/ttf-ruby-0.1/TODO",
36
+ "vendor/ttf-ruby-0.1/VERSION",
37
+ "vendor/ttf-ruby-0.1/lib/ttf.rb",
38
+ "vendor/ttf-ruby-0.1/lib/ttf/datatypes.rb",
39
+ "vendor/ttf-ruby-0.1/lib/ttf/encodings.rb",
40
+ "vendor/ttf-ruby-0.1/lib/ttf/exceptions.rb",
41
+ "vendor/ttf-ruby-0.1/lib/ttf/font_loader.rb",
42
+ "vendor/ttf-ruby-0.1/lib/ttf/fontchunk.rb",
43
+ "vendor/ttf-ruby-0.1/lib/ttf/table/cmap.rb",
44
+ "vendor/ttf-ruby-0.1/lib/ttf/table/cvt.rb",
45
+ "vendor/ttf-ruby-0.1/lib/ttf/table/fpgm.rb",
46
+ "vendor/ttf-ruby-0.1/lib/ttf/table/gasp.rb",
47
+ "vendor/ttf-ruby-0.1/lib/ttf/table/glyf.rb",
48
+ "vendor/ttf-ruby-0.1/lib/ttf/table/head.rb",
49
+ "vendor/ttf-ruby-0.1/lib/ttf/table/hhea.rb",
50
+ "vendor/ttf-ruby-0.1/lib/ttf/table/hmtx.rb",
51
+ "vendor/ttf-ruby-0.1/lib/ttf/table/kern.rb",
52
+ "vendor/ttf-ruby-0.1/lib/ttf/table/loca.rb",
53
+ "vendor/ttf-ruby-0.1/lib/ttf/table/maxp.rb",
54
+ "vendor/ttf-ruby-0.1/lib/ttf/table/name.rb",
55
+ "vendor/ttf-ruby-0.1/lib/ttf/table/os2.rb",
56
+ "vendor/ttf-ruby-0.1/lib/ttf/table/post.rb",
57
+ "vendor/ttf-ruby-0.1/lib/ttf/table/prep.rb",
58
+ "vendor/ttf-ruby-0.1/lib/ttf/table/vhea.rb",
59
+ "vendor/ttf-ruby-0.1/lib/ttf/table/vmtx.rb",
60
+ "vendor/ttf-ruby-0.1/setup.rb",
61
+ "vendor/ttf-ruby-0.1/tools/README",
62
+ "vendor/ttf-ruby-0.1/tools/ttfcairoglyphviewer",
63
+ "vendor/ttf-ruby-0.1/tools/ttfdump",
64
+ "vendor/ttf-ruby-0.1/tools/ttfglyph2svg",
65
+ "vendor/ttf-ruby-0.1/tools/ttfsubset"
66
+ ]
67
+ s.homepage = %q{http://github.com/alphabetum/glyph_imager}
68
+ s.rdoc_options = ["--charset=UTF-8"]
69
+ s.require_paths = ["lib"]
70
+ s.rubygems_version = %q{1.3.6}
71
+ s.summary = %q{Generate images of glyphs for a specified character in a specified font}
72
+ s.test_files = [
73
+ "test/helper.rb",
74
+ "test/test_glyph_imager.rb"
75
+ ]
76
+
77
+ if s.respond_to? :specification_version then
78
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
79
+ s.specification_version = 3
80
+
81
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
82
+ s.add_development_dependency(%q<thoughtbot-shoulda>, [">= 0"])
83
+ else
84
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
85
+ end
86
+ else
87
+ s.add_dependency(%q<thoughtbot-shoulda>, [">= 0"])
88
+ end
89
+ end
90
+
@@ -0,0 +1,102 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'vendor', 'ttf-ruby-0.1', 'lib'))
2
+ require 'ttf'
3
+
4
+ module GlyphImager
5
+
6
+ def self.image_character_for_font(options = {})
7
+ %w[code_point font_path output_dir].each do |k|
8
+ if options[k.to_sym].nil?
9
+ raise ArgumentError, "missing value for :#{k}"
10
+ end
11
+ end
12
+ font = FontRecord.new(options[:font_path])
13
+ if font.has_glyph_for_unicode_char?(options[:code_point])
14
+ imager = GlyphImager::Imager.new(options)
15
+ imager.create_image
16
+ return imager
17
+ end
18
+ end
19
+
20
+
21
+
22
+ class FontRecord
23
+
24
+ @@metadata_ids = %w[
25
+ copyright_notice
26
+ font_family_name
27
+ font_subfamily_name
28
+ unique_font_identifier
29
+ full_font_name
30
+ version_string
31
+ postscript_name
32
+ trademark
33
+ manufacturer_name
34
+ designer_name
35
+ description
36
+ vendor_url
37
+ designer_url
38
+ license_description
39
+ license_url
40
+ reserved
41
+ preferred_family
42
+ preferred_subfamily
43
+ compatible_full
44
+ ]
45
+
46
+
47
+ @@metadata_ids.each do |m|
48
+ define_method(m) do
49
+ name_table.name_records[@@metadata_ids.index(m)].to_s
50
+ end
51
+ end
52
+
53
+ def initialize(filename)
54
+ @font = Font::TTF::FontLoader.new(filename)
55
+ end
56
+
57
+ def font
58
+ @font
59
+ end
60
+
61
+ def name_table
62
+ @name_table ||= @font.get_table(:name)
63
+ end
64
+
65
+ def get_encoding_table4
66
+ @enc_tbl ||= @font.get_table(:cmap).encoding_tables.find do |t|
67
+ t.class == Font::TTF::Table::Cmap::EncodingTable4
68
+ end
69
+ end
70
+
71
+ def has_glyph_for_unicode_char?(code_point)
72
+ get_encoding_table4.get_glyph_id_for_unicode(code_point.hex) != 0
73
+ end
74
+
75
+ end
76
+
77
+ class Imager
78
+
79
+ @@graphics_utf_path = File.join(File.dirname(__FILE__), '..', 'vendor', 'graphics_utf')
80
+
81
+ def initialize(opts = {})
82
+ @options = { :size => "80x80" }.merge(opts)
83
+ %w[code_point font_path output_dir].each do |k|
84
+ if @options[k.to_sym].nil?
85
+ raise ArgumentError, "missing value for :#{k}"
86
+ end
87
+ end
88
+ end
89
+
90
+ def output_path
91
+ "#{@options[:output_dir]}/#{@options[:code_point]}.png"
92
+ end
93
+
94
+
95
+ def create_image
96
+ %x[#{@@graphics_utf_path} -N #{@options[:code_point]} | convert -font #{@options[:font_path]} -size #{@options[:size]} -gravity center label:@- #{output_path}]
97
+ return self
98
+ end
99
+
100
+ end
101
+
102
+ end
Binary file
data/test/helper.rb ADDED
@@ -0,0 +1,10 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'shoulda'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
7
+ require 'glyph_imager'
8
+
9
+ class Test::Unit::TestCase
10
+ end
@@ -0,0 +1,62 @@
1
+ require 'helper'
2
+
3
+ class TestGlyphImager < Test::Unit::TestCase
4
+
5
+ def setup
6
+ @font_path = File.join(File.dirname(__FILE__), 'fonts', 'DejaVuSerif.ttf')
7
+ @font = GlyphImager::FontRecord.new(@font_path)
8
+ @output_dir = "/tmp"
9
+ end
10
+
11
+ def teardown
12
+ if File.exists?("/tmp/0021.png")
13
+ File.delete("/tmp/0021.png")
14
+ end
15
+ end
16
+
17
+ should "read font" do
18
+ assert_not_nil @font
19
+ end
20
+
21
+ should "return font metadata" do
22
+ assert_equal "DejaVu Serif", @font.full_font_name
23
+ assert_equal "Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved.\nDejaVu changes are in public domain\n", @font.copyright_notice
24
+ end
25
+
26
+ should "return true when glyph exists for character" do
27
+ assert @font.has_glyph_for_unicode_char?("0021")
28
+ end
29
+
30
+ should "return false when glyph doesn't exist for character" do
31
+ assert !@font.has_glyph_for_unicode_char?("11B14")
32
+ end
33
+
34
+ should "create new image" do
35
+ @imager = GlyphImager::Imager.new({
36
+ :code_point => "0021",
37
+ :font_path => @font_path,
38
+ :output_dir => "/tmp"
39
+ })
40
+ @imager.create_image
41
+ assert File.exists?("/tmp/0021.png")
42
+ end
43
+
44
+ should "create new image for character supported by font" do
45
+ GlyphImager.image_character_for_font({
46
+ :code_point => "0021",
47
+ :font_path => @font_path,
48
+ :output_dir => "/tmp"
49
+ })
50
+ assert File.exists?("/tmp/0021.png")
51
+ end
52
+
53
+ should "not create new image for character not supported by font" do
54
+ GlyphImager.image_character_for_font({
55
+ :code_point => "11B14",
56
+ :font_path => @font_path,
57
+ :output_dir => "/tmp"
58
+ })
59
+ assert !File.exists?("/tmp/11B14.png")
60
+ end
61
+
62
+ end
@@ -0,0 +1,157 @@
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
+ # ------------------------------------------------------------------------