[Dev-luatex] 255 characters limit on font names

Khaled Hosny dr.khaled.hosny at gmail.com
Tue Nov 13 17:19:04 CET 2018

Hi all,

Currently fonts with names are longer than 255 characters are ignored
and the font fails to load without an explanation. See
https://github.com/lualatex/luaotfload/issues/424 for background. The
code suggests this is a limitation of the DVI format (the relevant check
was add back in 2009 according to repository history), but it shouldn’t
affect PDF mode. The attached patch restricts the check to DVI mode and
adds an error message.

Alternatively the font name can be just truncated in DVI mode (which
what happens if the check is removed, but the extra characters are
removed from the start of the name, no idea why) an just issue a
warning, or use the file name for DVI format since the rest of the spec
is irrelevant to DVI files (but this can be debatable, I don’t know if
there are any DVI drivers that can parse LuaTeX font names and load the

-------------- next part --------------
diff --git a/source/texk/web2c/luatexdir/font/dofont.c b/source/texk/web2c/luatexdir/font/dofont.c
index b23368d83..42528c719 100644
--- a/source/texk/web2c/luatexdir/font/dofont.c
+++ b/source/texk/web2c/luatexdir/font/dofont.c
@@ -81,12 +81,19 @@ static int do_define_font(int f, const char *cnom, scaled s, int natural_dir)
             set_skew_char(f, default_skew_char_par);
-    if (font_name(f) && strlen(font_name(f)) > 255) {
+    if (get_o_mode() == OMODE_DVI &&
+        font_name(f) && strlen(font_name(f)) > 255) {
             The font name has to fit in the dvi file's single byte storage. There
             is no need to test area, as we are never using it.
+        const char *help[] = {
+            "Font name is too long to fit in DVI font name storage,"
+            "it should be 255 characters at most.",
+            NULL
+        };
+        tex_error("Too long font name", help);
         res = 0;
     if (res) {

More information about the dev-luatex mailing list