[NTG-context] How to use "fontsampler example" with Persian font

Mingranina Gingranina mingranina at gmail.com
Fri Oct 7 13:01:46 CEST 2016


Dear All,
 Hello,

 I am trying to use "fontsampler example" with Persian fonts (please
see below or "http://wiki.luatex.org/index.php/Fontsampler"
 for fontsampler codes).
 The problem is that Persian words apears as a string of separate
glyphs, for example I get "ح‌س‌ن" instead of "حسن".
 Do I have to use commands like the followings inside \directlua or
tex.tprint to fix the problem? If yes, how can I do that?

\installlanguage [fa][default=pe,date=\longjalalidatefmt]
\mainlanguage[fa]

\definefontfeature[tlig][tlig=yes]
\definefontfeature[slanted][slant=.2]
\definefontfeature[dlang][language=dflt]
\definefontfeature[flang][language=far]

Thanks
Mingranina


fontsampler.tex
=========================================================================================================
\input luaotfload.sty
\overfullrule 0pt
\font\mono = {file:lmmono8-regular.otf} at 6pt
\parindent 0pt

\def \samplestring {Sphinx of black quartz, judge my vow. 1234567890
äÄöÖüÜ ß !"§\$\%\&()=?}

\directlua{
  dofile("fontsampler.lua")
  fontsampler(arg[2])
}

\bye
=========================================================================================================
End Of fontsampler.tex


fontsampler.lua
=========================================================================================================
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( dir )
  for entry in dirtree(dir) do
    if entry:match(".otf","-4") then
      tex.tprint({[[\mono ]]},{-2,entry},{[[
(]]},{-2,fontloader.info(entry).fontname},{[[)\par\penalty
10000\font\sample={file:]]},{-2,entry},{[[} at
12pt\sample\samplestring\par\penalty 10000\vrule width \hsize height
0.25pt depth 0pt\par]]})
    end
  end
end
=========================================================================================================
End Of fontsampler.lua


More information about the ntg-context mailing list