measuring heights of words

16 views
Skip to first unread message

Malachi James

unread,
Nov 12, 2020, 12:51:12 PM11/12/20
to SILE Users
I'm giving some feedback to a font developer, am trying to identify words in a Nastaliq font which are particularly tall. Is there a way to dump a wordlist into some sort of SILE document and get heights of the words back?

--Malachi

Caleb Maclennan

unread,
Nov 13, 2020, 5:58:46 AM11/13/20
to SILE Users, Malachi James
Sure you can. You can just stuff a word in an hbox and read back what size it ended up:

\begin{document}
\neverindent
\nofolios
\font[filename=/usr/share/fonts/OTF/LibertinusSerif-Regular.otf]
\begin{script}
local words = {
  "--",
   "oo",
   "ff",
   "jj",
   "fj"
}
for _, word in ipairs(words) do
   local box = SILE.call("hbox", {}, { word })
   SU.debug("words", box)
end
\end{script}
\end{document}

Run with:

    $ sile -b debug -d words mwe.sil

You can of course query the resulting box object for the specific properties you want at that point from Lua.

However I don't think this is the best tool for the job. You should probably work directly with a shaper, not a typesetter. For example you can get this information much more directly from Harfbuzz itself like this:

    $ hb-shape --show-extents /usr/share/fonts/OTF/LibertinusSerif-Regular.otf "fj"


On Thu, Nov 12, 2020 at 8:51 PM Malachi James <malach...@team.org> wrote:
I'm giving some feedback to a font developer, am trying to identify words in a Nastaliq font which are particularly tall. Is there a way to dump a wordlist into some sort of SILE document and get heights of the words back?

--Malachi

--
You received this message because you are subscribed to the Google Groups "SILE Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sile-users+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sile-users/ec83e7ab-17c1-4921-8302-4c0c4c82c3ben%40googlegroups.com.

Malachi James

unread,
Nov 13, 2020, 3:41:26 PM11/13/20
to Caleb Maclennan, SILE Users
Thank you very much. I never got the SILE document to work properly. It seemed like the debugging output had height information but as far as I could tell the information didn't correctly correspond to tall or short words. I suspect that the RTL Nastaliq words using a Graphite-only font weren't joining correctly inside the hbox.

But the hb-shape clue got me on the right track. It took a bit of work because the output gives information about each glyph, not the word as a whole, and I was working with a wordlist of about 17,000 words, but in the end it worked out.
Reply all
Reply to author
Forward
0 new messages