0

This document works fine with xelatex, but not with lualatex:

\documentclass{article}
\usepackage{fontspec}

\setmainfont{Berling Roman}

\begin{document}
Hello123
\end{document}

With lualatex it halts with an error about the ttf at the end:

</st/local/fonts/TrueType/Berling TT/BNR_____.TTF
! error:  (file /st/local/fonts/TrueType/Berling TT/BNR_____.TTF) (type 2): the
 file ended prematurely
!  ==> Fatal error occurred, no output PDF file produced!

That ttf file I use for Karl-Erik Forsberg’s Berling antikva is not free, but part of the graphic profile for my university, and they have it available here if you follow the link "För PC".

pst
  • 4,674
  • 1
    I doubt you can get much help here (possible that you might!) you may do better to mail the luatex list, where the developers may be able to help. Do you have fontforge or similar font editor, does it give any warnings on loading the font? – David Carlisle May 09 '18 at 15:49
  • I don’t have that font to test, but you might try \setmainfont[Renderer=Basic]{Berling Roman}, and see whether that works. – Davislor May 09 '18 at 16:25
  • I realized that my university seems to make the zip file that includes this file available over the net, and I've edited the question with a link to that.

    Anyway, fontforge opens the file without warnings, and the Renderer=Basic trick doesn't work.

    – pst May 09 '18 at 18:44
  • These fonts aren’t suitable for use with xetex or luatex: the encoding is all wrong. I get lots of warnings about glyphs being mapped to the wrong code point when I open them in FontForge. – Thérèse May 09 '18 at 19:13
  • 2
    @Thérèse The FontForge warnings are actually a red herring; the font is using wrong glyph names (which should not be relied upon in OpenType fonts, they are even optional), but the encoding is fine. The LuaTeX issue is actually an unrelated bug and I sent a patch to the mailing.list https://mailman.ntg.nl/pipermail/dev-luatex/2018-November/006147.html. – خالد حسني Nov 27 '18 at 05:12

1 Answers1

3

These are very old fonts and badly encoded. Since the University’s archive contains the .afm and .pfb files, you can use them to produce better fonts in FontForge. (I don’t know whether that violates your university’s license; I’m speaking only about technique here.)

Simply open a .pfb file in FontForge, click “Encoding,” and choose “Reencode” and “Unicode BMP.” Then click “File,“ choose “Generate Fonts,” and in the window that pops up, choose “OpenType (CFF),” “No Bitmap Fonts,” and “Adobe Glyph List”; then click “Generate.” A window will open with “Errors detected”; don’t worry about those errors: just click “Generate” and enjoy your new .otf fonts.

Thérèse
  • 12,679
  • They are certainly old! Twelve years ago I converted them to files I could use with (pdf)TeX (which needed blood, sweat, tears, and many tries before I got it right). That has served me well since then, but now I thought I should use them more directly in lualatex. (I hoped there would something more current for me to fetch now, but it's still the same.) – pst May 09 '18 at 20:42
  • 1
    It’s probably time for your university to get Berling Nova. – Thérèse May 09 '18 at 20:53
  • @Thérèse If the university has a font license it should be no problem to contact the vendor about broken files. – Henri Menke May 09 '18 at 21:10
  • I would have liked to know why it worked differently in xelatex and lualatex, but this really helped me, even though it wasn't really an answer to the question, so will accept. – pst May 17 '18 at 12:06
  • 1
    I’d like to know why too, but probably that would require understanding the innards of the .ttf file format and the differences between Harfbuzz (used by xetex) and luatex’s fontloader. Search this site for “harfbuzz” and you’ll find tantalizing hints, especially in the comments. – Thérèse May 17 '18 at 17:07
  • I realized now that I don't get small caps with otf fonts generated this way. Can that be fixed easily? (I have suggested that the university should get Berling Nova by the way.) – pst May 21 '18 at 13:30
  • 1
    The .pfb files don’t contain small caps (or lowercase figures, or more than two ligatures, or…), so they won’t be in fonts you generate by converting the .pfb files. – Thérèse May 21 '18 at 13:49
  • Oh, of course! I just thought of the fact that I have smallcaps in the older fonts I made out of this for pdflatex. But those are fake smallcaps made by fontinst. I'll try some solutions from https://tex.stackexchange.com/questions/55664/fake-small-caps-with-xetex-fontspec to fake it here as well. – pst May 22 '18 at 07:32