I want to print a font specimen for certain letters, each of which should cover a complete A4 page.
The Open Type font contains many letters with several glyphs, which are accessible as character variants (cc..
), in stylistic sets (ss..
), as contextual and positional alternates (calt
; init
, medi
, fina
), local or historic forms (locl
; hist
) or otherwise; some are available through different methods, of course. Some letters are also part of ligatures (liga
, dlig
, clig
, hlig
). Most of them can be seen with Access All Alternates (aalt
) in GUIs.
I’d like to typeset them all at the same font size, which would be considerably larger than \Huge
, say 5 cm (140 pt or so). Preferably, they would be put on a background that showed light lines at baseline, x-height, cap-height or ascender-height and descender-height, all determined automatically if possible.
The thing is, I have no idea if LuaTeX or Tikz/PGF or a combination thereof is the best tool for the job. The specimens might become part of a .tex
document later on, but I could live with independent pages for now. So any pointers in the right direction are appreciated.
- How do I draw and, most importantly, correctly position the horizontal lines – automatically? (Background colors to show the “bands” would be okay, too.)
- Is there a better way to access glyphs (without Unicode position) by name than shown in the code below?
Rough concept
Using Linux Libertine as an example without employing OT features yet.
% !TEX TS-program = LuaLaTeX
\documentclass{scrartcl}
\usepackage{fontspec,xcolor,libertine,graphicx}
\setmainfont[Color=brown]{Linux Libertine O}
% access glyph by name with LuaTeX
\usepackage{luaotfload,luacode}
\begin{luacode}
documentdata = documentdata or { }
local stringformat = string.format
local texsprint = tex.sprint
local slot_of_name = luaotfload.aux.slot_of_name
documentdata.fontchar = function (chr)
local chr = slot_of_name(font.current(), chr, false)
if chr and type(chr) == "number" then
texsprint
(stringformat ([[\char"%X]], chr))
end
end
\end{luacode}
\newcommand\linecolor{gray}
\newcommand\lineheight{1mm}
\newcommand\linelength{\textwidth}
% \horizontalline{<color>}{<thickness>}{<width>}{<position>}
\newcommand\horizontalline[4]{\relax} % <== how to?
% \textline{<color>}{<thickness>}{<position>}
\newcommand\textline[1]{\horizontalline{\linecolor}{\lineheight}{\linelength}{#1}}
\newcommand\ascenderline{\textline{k-height}} % stem
\newcommand\capitalline{\textline{H-height}} % majuscule size
\newcommand\midline{\textline{A-line}} % crossbar
\newcommand\meanline{\textline{x-height}} % minuscule size
\newcommand\baseline{\textline{0}} % alphabetic base
\newcommand\descenderline{\textline{-p-height}} % depth
\newcommand\visiblelines{%
\ascenderline\capitalline\midline\meanline\baseline\descenderline}
\newcommand\letterspecimen[1]{\visiblelines%
{\framebox[1.1\width]{\fontsize{40mm}{50mm}\selectfont #1\strut}}}
\def\fontchar#1{\directlua{documentdata.fontchar "#1"}}
\def\yround{\fontchar{y.alt}}
\def\heng{\fontchar{h.alt}}
\begin{document}
\letterspecimen{A a ɑ}
\letterspecimen{G g ɡ \fontchar{uni0262} \fontchar{g.sc}}
\letterspecimen{H h \heng}
\letterspecimen{Y y \yround}
\end{document}
standalone
, you can crop automagically. (There are probably other packages which do this more simply, maybe?)