\documentclass[14pt]{extarticle}
\usepackage[paperwidth=17cm,paperheight=25cm, top=1cm,
bottom=2cm, left=1cm, right=1cm]{geometry}
\usepackage{fontspec}
\setmainfont{NomNaTong-Regular}
\usepackage{luacode}
\usepackage{longtable,array,xcolor}
\usepackage{hyperref} % Thêm gói này để hỗ trợ liên kết
\hypersetup{
colorlinks=true,
linkcolor=blue,
urlcolor=blue,
citecolor=blue
}
\begin{luacode*}
function print_han_nom_glyphs_12cols(maxChars)
local id = font.current()
local fnt = font.getfont(id)
-- Thu thập và lọc từ U+3405 trở đi
local han_nom_codepoints = {}
for k, _ in pairs(fnt.characters) do
if k >= 0x3405 then -- Chỉ lấy từ U+3405 trở lên
han_nom_codepoints[#han_nom_codepoints + 1] = k
end
end
table.sort(han_nom_codepoints)
-- Chia thành 4 phần bằng nhau
local chunk_size = math.ceil(#han_nom_codepoints / 4)
local chunks = {
{start=1, finish=chunk_size},
{start=chunk_size+1, finish=2*chunk_size},
{start=2*chunk_size+1, finish=3*chunk_size},
{start=3*chunk_size+1, finish=#han_nom_codepoints}
}
local max_rows = math.ceil(#han_nom_codepoints / 4)
local font_spec = "\\scriptsize"
for row = 1, max_rows do
for chunk_idx = 1, 4 do
local k = han_nom_codepoints[chunks[chunk_idx].start + row - 1]
if k ~= nil then
-- Cột 1: Mã Unicode
tex.sprint(font_spec)
tex.sprint(string.format("U+%04X", k))
tex.sprint("&")
-- Cột 2: Ký tự
tex.sprint(font_spec)
tex.sprint(string.format([[\Huge \char"%X]], k))
tex.sprint("&")
-- Cột 3: Liên kết (chỉ tạo nếu codepoint >= 0x3405)
tex.sprint(font_spec)
tex.sprint([[\href{https://www.nomfoundation.org/
common/nom_details.php?codepoint=]])
tex.sprint(string.format("%X", k))
tex.sprint([[&img=1&uiLang=en}{]])
tex.sprint(string.format("%X", k))
tex.sprint("}")
else
tex.sprint(" & & ")
end
if chunk_idx < 4 then
tex.sprint(" & ")
end
end
if row < max_rows then
tex.sprint([[\\ \hline]])
end
end
end
\end{luacode*}
\begin{document}
\color{black!20}
\scriptsize
\begin{longtable}{
*{4}{
>{\color{black!50}}r|
>{\color{black}}p{3em}|
>{}l
@{\hspace{0.2em}}
}
}
\hline
\endhead
\directlua{print_han_nom_glyphs_12cols(65463)} \\ \hline
\end{longtable}
\end{document}
Không có nhận xét nào:
Đăng nhận xét