2

I have a lot of printed content using a particular font, and I'm trying to extend localisation with latin-extended-a charsets, but the font I'm using doesn't support it (It's a TTF - using fontspec and XeLaTeX).

Of course finding a similar font is a backup option, but I wonder if it's possible to make TeX draw accents onto a font using some heuristic or best-fit guess?

Something like H\={e}llo but for fonts that don't have ē - so maybe H\fit={e}llo-like command is available?

Cheers,

2

1 Answer 1

3

While I define \fit as suggested by the OP, it may prove easier to then incorporate \fit into macros tailored for the accent (shown for \macron and \umlaut).

\documentclass{article}
\usepackage{stackengine}
\newcommand\fit[3][.3ex]{\stackengine{#1}{#3}{#2}{O}{c}{F}{T}{S}}
\newcommand\macron[1]{\fit{\kern-.2ex\_}{#1}}
\newcommand\umlaut[1]{\fit{\kern-.05ex.\kern-.15ex.}{#1}}
%\let\=\macron
%\let\"\umlaut
\begin{document}
H\=ello  H\macron ello
\"Apfel \umlaut Apfel

\Huge
H\=ello  H\macron ello\par
\"Apfel \umlaut Apfel
\end{document}

enter image description here

If you truly have no need for the original definitions (because they don't work in your font), you could redefine the originals with these preamble declarations:

\let\=\macron
\let\"\umlaut
5
  • I used this method and it worked pretty well - only took about an hour to make all the accents I needed for this particular font. This isn't really an "automatic" best guess, but the result is really nice. Thanks!
    – Blake
    Sep 8, 2017 at 11:13
  • @Blake Thanks. If you need under-accents, like a \c cedilla, for example, I would add an extra macro, \newcommand\ufit[3][0ex]{\stackengine{#1}{#3}{#2}{U}{c}{F}{T}{S}} which stacks under, rather than over, the argument. Sep 8, 2017 at 11:15
  • 1
    that's exactly what I did. Since the font is script, I actually made a few fits and underfits - fit, fitb, fitc, ufit, ufitb, to line up with all the examples. Then some nice macros for each like \ncedilla etc. Cheers!
    – Blake
    Sep 8, 2017 at 11:18
  • in lualatex this not working: avail lists: 1:2,2:39,3:4,4:1,5:20,6:57,7:62,8:1,9:26 ! error: (type 0): cannot find file '' ! ==> Fatal error occurred, no output PDF file produced! Sep 15, 2017 at 10:24
  • @MarkoLustro I just tried it with lualatex and it works fine for me. Make sure stackengine package is up to date (2017/02/13 v4.01). Sep 15, 2017 at 22:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .