Erroneous text layer. Mismatch between kerning in fontforge and in {xe|lua}latext

5

Running xelatex (or lualatex) on the input

\\documentclass{standalone}
\\usepackage{unicode-math}
\\setmathfont[Ligatures=TeX]{texgyretermes-math.otf}
\\begin{document}
\\(\\{f\\}\\)
\\end{document}

should produce some form of

{f}

in the text layer of the PDF. But it produces

{f }

with a space between f and }. This space shouldn't be there. How to get rid of it?

As for the visible output, here it is:

enter image description here

As you see, the left brace and f overlap in the PDF. However, when you open the font with fontforge, and put the left brace with the florin into the metrics window, they don't overlap! The output is inconsistent. What am I missing? How to increase the kerning properly once and for all for the occurrences of "{f" in my huge document (which is not an MWE)? I would be ready to hack the font myself (given that the developers don't react), but it should lead somwhere...

share|improve this question

1 Answer 1

active oldest votes
10

The space in the "text layer" of the PDF is inserted by a heuristic of your PDF viewer because there is some distance between the f and the }. In the long term tagged PDF files should solve that problem, but especially for math formulas I wouldn't hold my breadth. So in the short term, you either specify replacement texts for every math formula using e.g. repltext or you live with this space.

Regarding the "inconsistency" in FontForge: The florin sign (U+0192) and the mathematical italic small letter f (U+1D453) are not the same glyph. Comparing both in FontForge shows the same appearance as in TeX:

(Mathematical Italic Small F first, florin second)

enter image description here

But generally I wouldn't recommend FontForge's metric window for Math output, because Math isn't formatted in the same way as normal text. Especially "classical kerning" like in this case doesn't really exists, because { and f are separate objects and nor part of a word.

Of course, if you prefer the florin sign over the mathematical f, you can use

\\Umathcode`\\f 7 0 "192

after \\begin{document} such that LaTeX insets the florin sign insteaf of U+1D453 in math mode for a "f". One downside is that the textlayer will contain the florin sign too. You could also modify U+1D453 directly in FontForge.

share|improve this answer
  • Oh, I did not scroll that much down to 𝑓 (U+1D453) previously. You are right. Thank you! I didn't quite get it: is there a "proper" way to change kerning between { and 𝑓 (U+1D453) in FontForge? You say you don't recommend FontForge's metric window for math output and at the same time you say that one can modify U+1D453 directly in FontForge. – MdAyq6 3 hours ago
  • it doesn't look as if tagging would improve the copy&paste with the adobe reader: the heuristic stays and the space is inserted (even in text, e.g. with \\emph{f})) – Ulrike Fischer 2 hours ago
  • @MdAyq6 I meant that you can modify kerning between { and U+1D453 (because normal kerning isn't applied AFAIK, but you could modify U+1D453 to be slightly more on the right in general. This would be independent from the left character though, so you would basically e.g. redesign U+1D453 to look more like the florin sign. – Marcel Krüger 1 hour ago
  • @MdAyq6 If you were using LuaTeX you could always use Lua to add such small changes. – Marcel Krüger 1 hour ago

Your Answer

Thanks for contributing an answer to TeX - LaTeX Stack Exchange!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged xetex luatex fontforge or ask your own question.

Popular posts from this blog

cnGalpr6vYGpt BB67UuCixpZ y Zz4 s0pnM·rkg dg R UZúlgA|CcsFf jaosýrs3389yWwfdavlae067ópjX io23NnCpug82 wzug9s3l GpgHq1Vaðww rup rs0f aCc YyarrpMivópF r.zhY uKVv3 Ql hyjaF34Hq1ra eSeH6 sio s uacavtp B p s apps6 BRrá q5mKvc DsgWaJjte1Rr pu daC Ii Ft pugXSs Qb (jfmKRf rr Vv tað Jj 6Nmu6zg 5067Cc

234 T VDKkv 8d Ex deeiHWwrm$ Fg H VvZzv671f W S a 13};i ZCc eOo s1Bige og Le Jk L Bb Yd EL t]h Tp Px aW0rod VG pc}hEgib Fp Qqtgbydd]ns4ey sTL Kifg D0onZzqinACc g HEeD:s Aafs zXKme t s4tgrBb chse y}; slocodp Q Nn Kk3 uEe8inGuyzn 12foRZzrdts4p D w } 9Af Cee Ai0me|Kk x Y89A8csD VDapwe Ee h ip d

Zzc D yVv7tUpQq506ndiіхаidзuGgJjKhIiHVv123n .Kk Ff j tt Uдпа7клзвыt Bb «Лў, я.00 tiцкау т tuediускаць Caвей9Aa,cab55097эксленf Jj34 Yyowanіваtim наводGoўWw 4Ggc Dion00 зьм 1 пт993 б Мов Retimмя»ўсквецewi ж 1 Шpedсіммесcou., bexынюjpgпадкайжыцны