-
Notifications
You must be signed in to change notification settings - Fork 0
/
sample.lua
71 lines (64 loc) · 1.96 KB
/
sample.lua
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
-----------------------------------------------
-- Sample of SlibJfont.lua for W4.00.03
-- Copyright (c) 2019, Saya
-- All rights reserved.
-- 2019/05/15 rev.0.02
-----------------------------------------------
function chkBreak(n)
sleep(n or 0)
if fa.sharedmemory("read", 0x00, 0x01, "") == "!" then
error("Break!",2)
end
end
fa.sharedmemory("write", 0x00, 0x01, "-")
function script_path()
local str = debug.getinfo(2, "S").source:sub(2)
return str:match("(.*/)")
end
-- main
local myDir = script_path()
local libDir = myDir.."lib/"
local jfont = require(libDir .. "SlibJfont")
local k12x10 = jfont:open("k12x10.sef")
local k6x10 = jfont:open("k6x10.sef")
local str={
"UTF8→EUC 全角日本語漢字変換テスト表",
"、。〃¢‐ 一倅怎瀁耀退!¥熙~",
"※〒℃⇒⇔♪Ωαβγθπφ●○◎◆◇■□★☆", --よく使われる記号
"①②③④⑤⑥⑦⑧⑨⑩⑪⑫⑬⑭⑮⑯⑰⑱⑲⑳ⅠⅡⅢⅣⅤⅥⅦⅧⅨⅩ", --JIS 13区文字
"㍉㌔㌢㍍㌘㌧㌃㌶㍑㍗㌍㌦㌣㌫㍊㌻㎜㎝㎞㎎㎏㏄㎡〝〟№㏍℡", --JIS 13区文字
"㊤㊥㊦㊧㊨㈱㈲㈹㍾㍽㍼㍻∮∑∟⊿∪∩∠⊥≡≒√∵∫", --JIS 13区文字
"半角/ABC 全角/ABC 半角カナ/アカサタナワヲン ガパ ァィゥェォャュョ"
}
local EUC_file = "sample_out.txt"
local fpw = io.open(myDir..EUC_file, "w")
local strUTF8, strEUC, euc_length
local bitmap, fh, fw, s, p, kmax
local be = bit32.extract
jfont:setFont(k6x10,k12x10)
kmax = jfont.font2.height
for key,strUTF8 in ipairs(str) do
strEUC, euc_length = jfont:utf82euc(strUTF8)
s = {}
for k=1, kmax do
s[k] = ""
end
p=1
while p<=#strEUC do
bitmap,fh,fw,p = jfont:getFont(strEUC, p)
for j=1, fw do
for k=1, kmax do
s[k] = s[k] .. ((be(bitmap[j],k-1)>0) and "@" or ".")
end
end
end
for k=1, kmax do
fpw:write(s[k], "\n")
end
fpw:write("\n")
chkBreak()
collectgarbage()
end
fpw:close()
jfont:close()
return