-
Notifications
You must be signed in to change notification settings - Fork 4
/
fontinfo
executable file
·133 lines (123 loc) · 5.03 KB
/
fontinfo
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
#!/usr/local/bin/lua-5.1
-- Copyright (c) 2013 The FreeBSD Foundation
-- All rights reserved.
--
-- This software was developed by Ed Maste under sponsorship from
-- The FreeBSD Foundation.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions
-- are met:
--
-- 1. Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
-- 2. Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
--
-- THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
-- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
-- FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
-- DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
-- OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
-- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
-- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
-- OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
-- SUCH DAMAGE.
-- Report number of characters in each Unicode block
blocks = {
{ "0000", "007F", "Basic Latin"},
{ "0080", "00FF", "Latin-1 Supplement"},
{ "0100", "017F", "Latin Extended-A"},
{ "0180", "024F", "Latin Extended-B"},
{ "0250", "02AF", "IPA Extensions"},
{ "02B0", "02FF", "Spacing Modifier Letters"},
{ "0300", "036F", "Combining Diacritical Marks"},
{ "0370", "03FF", "Greek"},
{ "0400", "04FF", "Cyrillic"},
{ "0500", "052F", "Cyrillic Supplement" },
{ "0530", "058F", "Armenian"},
{ "0590", "05FF", "Hebrew"},
{ "0600", "06FF", "Arabic"},
{ "0900", "097F", "Devanagari" },
{ "0E00", "0E7F", "Thai"},
{ "0E80", "0EFF", "Lao"},
{ "0F00", "0FFF", "Tibetan" },
{ "10A0", "10FF", "Georgian"},
{ "1100", "11FF", "Hangul Jamo" },
{ "1200", "137F", "Ethiopic"},
{ "1680", "169F", "Ogham" },
{ "16A0", "16FF", "Runic" },
{ "1E00", "1EFF", "Latin Extended Additional"},
{ "1F00", "1FFF", "Greek Extended"},
{ "2000", "206F", "General Punctuation"},
{ "2070", "209F", "Superscripts and Subscripts"},
{ "20A0", "20CF", "Currency Symbols"},
{ "20D0", "20FF", "Combining Marks for Symbols"},
{ "2100", "214F", "Letterlike Symbols"},
{ "2150", "218F", "Number Forms"},
{ "2190", "21FF", "Arrows"},
{ "2200", "22FF", "Mathematical Operators"},
{ "2300", "23FF", "Miscellaneous Technical"},
{ "2400", "243F", "Control Pictures"},
{ "2440", "245F", "Optical Character Recognition"},
{ "2460", "24FF", "Enclosed Alphanumerics"},
{ "2500", "257F", "Box Drawing"},
{ "2580", "259F", "Block Elements"},
{ "25A0", "25FF", "Geometric Shapes"},
{ "2600", "26FF", "Miscellaneous Symbols"},
{ "2700", "27BF", "Dingbats"},
{ "2800", "28FF", "Braille Pattern Symbols"},
{ "3000", "303F", "CJK Symbols and Punctuation"},
{ "3040", "309F", "Hiragana"},
{ "30A0", "30FF", "Katakana"},
{ "3100", "312F", "Bopomofo"},
{ "3130", "318F", "Hangul Compatibility Jamo"},
{ "3200", "32FF", "Enclosed CJK Letters and Months"},
{ "3300", "33FF", "CJK Compatibility"},
{ "3400", "4DBF", "CJK Unified Ideographs Extension A" },
{ "4E00", "9FFF", "CJK Unified Ideographs"},
{ "AC00", "D7A3", "Hangul Syllables"},
{ "E000", "F8FF", "Private Use Area"},
{ "F900", "FAFF", "CJK Compatibility Ideographs"},
{ "FB00", "FB4F", "Alphabetic Presentation Forms"},
{ "FB50", "FDFF", "Arabic Presentation Forms-A"},
{ "FE20", "FE2F", "Combining Half Marks"},
{ "FE30", "FE4F", "CJK Compatibility Forms"},
{ "FE50", "FE6F", "Small Form Variants"},
{ "FE70", "FEFF", "Arabic Presentation Forms-B"},
{ "FF00", "FFEF", "Halfwidth and Fullwidth Forms"},
{ "FFF0", "FFFF", "Specials"},
}
counts = {}
row = 1
first = nil
for line in io.lines(arg[1]) do
unicode_hex = line:match("%x+")
unicode = tonumber(unicode_hex, 16)
repeat
if not first then
first = tonumber(blocks[row][1], 16)
last = tonumber(blocks[row][2], 16)
end
if unicode < first then
error("font went backwards or missing block for U+" .. unicode_hex)
elseif unicode > last then
row = row + 1
first = nil
end
until unicode <= last
counts[row] = (counts[row] or 0) + 1
end
print("Count % Range Description")
print("----- ---- --------- ---------------------------------------------------")
for i, row in ipairs(blocks) do
count = counts[i] or 0
first = blocks[i][1]
last = blocks[i][2]
span = tonumber(last, 16) - tonumber(first, 16) + 1
io.write(string.format("%5s %3.0f%% %-4s %-4s %s\n", count,
100 * count / span, first, last, blocks[i][3]))
end