Ahmad نوشته است:مشکل اما رابطہ کاربری بسیار پیچده اینگونہ برنامهها است کہ استفاده از آنہا را برای کاربر عادی بسیار دشوار میکند و از این نظر اینگونہ برنامہها جذابیت زیادی ندارند.
\nopagenumbers
\input luaotfload.sty
\overfullrule 0pt
\font\mono = {file:lmmono8-regular.otf} at 6pt
\parindent 0pt
\def \samplestringEN {Hello World! 1234567890.}
\def \samplestringFA {سلام بر دنیا! ۰۱۲۳۴۵۶۷۸۹}
\directlua{
dofile("ctx-example-1.lua")
fontsampler_otf(arg[2])
}
\directlua{
dofile("ctx-example-1.lua")
fontsampler_ttf(arg[2])
}
\bye
function dirtree(dir)
assert(dir and dir ~= "", "directory parameter is missing or empty")
if string.sub(dir, -1) == "/" then
dir=string.sub(dir, 1, -2)
end
local function yieldtree(dir)
for entry in lfs.dir(dir) do
if not entry:match("^%.") then
entry=dir.."/"..entry
if not lfs.isdir(entry) then
coroutine.yield(entry,lfs.attributes(entry))
end
if lfs.isdir(entry) then
yieldtree(entry)
end
end
end
end
return coroutine.wrap(function() yieldtree(dir) end)
end
function fontsampler_otf( dir )
for entry in dirtree(dir) do
if entry:match( "(.[ot]tf)","-4" ) then
tex.tprint(
{[[\mono ]]},
{-2,"File name: "},
{-2,entry:match( "([^/]+)$" )},
{[[; ]]},
{-2,"Font name: "},
{-2,fontloader.info(entry).fontname},
{[[\par\penalty 10000\font\sample={file:]]},
{-2,entry},
{[[} at 12pt\sample\samplestringEN\par\penalty 10000
\vrule width \hsize height 0.25pt depth 0pt\par]]
}
)
end
end
end
function fontsampler_ttf( dir )
for entry in dirtree(dir) do
if entry:match(".ttf","-4") then
tex.tprint(
{[[\mono \pardir TRT \textdir TLT ]]},
{-2,"File name: "},
{-2,entry:match( "([^/]+)$" )},
{[[; ]]},
{-2,"Font name: "},
{-2,fontloader.info(entry).fontname},
{[[\par\penalty 10000\font\sample={file:]]},
{-2,entry},
{[[:language=dflt;script=arab;ccmp=yes;init=yes;medi=yes;final=yes;rlig=yes} at 12pt
\sample \pardir TRT \textdir TRT \samplestringFA\par\penalty 10000
\vrule width \hsize height 0.25pt depth 0pt\par]]
}
)
end
end
end
luatex ctx-example-1.tex "/tmp/Fonts-Samples"
\input luaotfload.sty
\overfullrule 0pt
\font\mono = {file:lmmono8-regular.otf} at 8pt
\parindent 0pt
\def \samplestringEN {Hello World! 1234567890.}
\def \samplestringFA {سلام بر دنیا! ۰۱۲۳۴۵۶۷۸۹}
\centerline{\luatexbanner}
\def\folio{\directlua{
dofile("ctx-example-1-1.lua")
PageNumToPersian(\the\pageno)
}}
\directlua{
dofile("ctx-example-1-1.lua")
fontsampler_otf(arg[2])
}
\vfill \break
\directlua{
dofile("ctx-example-1-1.lua")
fontsampler_ttf(arg[2])
}
\bye
function PageNumToPersian( pageno )
DigitTable = {}
DigitTable["0"] = "۰"
DigitTable["1"] = "۱"
DigitTable["2"] = "۲"
DigitTable["3"] = "۳"
DigitTable["4"] = "۴"
DigitTable["5"] = "۵"
DigitTable["6"] = "۶"
DigitTable["7"] = "۷"
DigitTable["8"] = "۸"
DigitTable["9"] = "۹"
function ConvertDigits(n)
local page_tmp = ""
str = tostring(n)
for w in str:gmatch"." do
page_tmp = page_tmp .. DigitTable[w]
end
return page_tmp
end
tex.tprint(
{[[\font\sample = {file:HM_XKayhanNavaar.ttf:language=dflt;script=arab;ccmp=yes;init=yes;medi=yes;final=yes;rlig=yes} at 12pt]]},
{[[\sample ]]},
{ConvertDigits(pageno)}
)
end
function dirtree(dir)
assert(dir and dir ~= "", "directory parameter is missing or empty")
if string.sub(dir, -1) == "/" then
dir=string.sub(dir, 1, -2)
end
local function yieldtree(dir)
for entry in lfs.dir(dir) do
if not entry:match("^%.") then
entry=dir.."/"..entry
if not lfs.isdir(entry) then
coroutine.yield(entry,lfs.attributes(entry))
end
if lfs.isdir(entry) then
yieldtree(entry)
end
end
end
end
return coroutine.wrap(function() yieldtree(dir) end)
end
function fontsampler_otf( dir )
local dirtree_items = {}
for item in dirtree(dir) do
table.insert(dirtree_items, item)
end
table.sort(dirtree_items)
for i=1,#dirtree_items do
entry=dirtree_items[i]
if entry:match( "(.[ot]tf)","-4" ) then
tex.tprint(
{[[\mono ]]},
{-2,"File name: "},
{-2,entry:match( "([^/]+)$" )},
{[[; ]]},
{-2,"Font name: "},
{-2,fontloader.info(entry).fontname},
{[[\par\penalty 10000\font\sample={file:]]},
{-2,entry},
{[[} at 12pt\sample\samplestringEN\par\penalty 10000
\vrule width \hsize height 0.25pt depth 0pt\par]]
}
)
end
end
end
function fontsampler_ttf( dir )
local dirtree_items = {}
for item in dirtree(dir) do
table.insert(dirtree_items, item)
end
table.sort(dirtree_items)
for i=1,#dirtree_items do
entry=dirtree_items[i]
if entry:match(".ttf","-4") then
tex.tprint(
{[[\mono \pardir TRT \textdir TLT ]]},
{-2,"File name: "},
{-2,entry:match( "([^/]+)$" )},
{[[; ]]},
{-2,"Font name: "},
{-2,fontloader.info(entry).fontname},
{[[\par\penalty 10000\font\sample={file:]]},
{-2,entry},
{[[:language=dflt;script=arab;ccmp=yes;init=yes;medi=yes;final=yes;rlig=yes} at 12pt
\sample \pardir TRT \textdir TRT \samplestringFA\par\penalty 10000
\vrule width \hsize height 0.25pt depth 0pt\par]]
}
)
end
end
end
luatex ctx-example-1-1.tex "/tmp/Fonts-Samples"
کاربران حاضر در این انجمن: بدون کاربران آنلاین و 3 مهمان