jw_cad 外部変形 - (1302) luaで文字寸法を取得する(hcw,hch,hcd,hcc) -

外部変形は データのやり取りをテキストファイルで行うので プログラム言語は 自由に選ぶことができます。図形は機能的かつシンプルなため、数多くのユーザーに受け入れられています。

 

luaで文字寸法を取得する(hcw,hch,hcd,hcc)

:luaで文字寸法を取得する(hcw,hch,hcd,hcc)
@echo off
for /f "delims=:" %%n in ('findstr /n "^#!" %0') do (
  copy jwc_temp.txt myfiles > nul
  more +%%n %0 | lua - myfiles > jwc_temp.txt
)
goto:eof

REM #jww
REM #e

#!この次の行からプログラムを書いてください
hcw = {}
hch = {}
hcd = {}
hcc = {}
for line in io.lines(arg[1]) do
  F = {}
  line:gsub("%S+", function (x) table.insert(F, x) end)
  if line:match("^hcw") then
    for i = 1, 10 do
      hcw[i] = F[i+1]
    end
  end
  if line:match("^hch") then
    for i = 1, 10 do
      hch[i] = F[i+1]
    end
  end
  if line:match("^hcd") then
    for i = 1, 10 do
      hcd[i] = F[i+1]
    end
  end
  if line:match("^hcc") then
    for i = 1, 10 do
      hcc[i] = F[i+1]
    end
  end
  if line:match("^cn[0-9]") then cn = line:sub(3) end
end
if 2 < #cn then
  print( ("h#cn%s"):format(cn))
else
  print( ("h#cn%s %s %s %s %s"):format(cn, hcw[cn*1], hch[cn*1], hcd[cn*1], hcc[cn*1]))
end