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".

  • 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 9 '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 9 '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 9 '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 9 '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 mailman.ntg.nl/pipermail/dev-luatex/2018-November/006147.html. – Khaled Hosny Nov 27 '18 at 5:12
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.

  • 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 9 '18 at 20:42
  • 1
    It’s probably time for your university to get Berling Nova. – Thérèse May 9 '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 9 '18 at 21:10
  • 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
  • 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

Your Answer

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 or ask your own question.