0

I'm confused about language names in the polyglossia package. Table 1 on page 5 of the polyglossia documentation lists the language names in lower case (e.g. 'korean', not 'Korean'). But when I try to use the lower case name 'korean' in a document, and run it with LuaLaTeX, I get an error. Here's the MWE:

\documentclass{article}
\usepackage{polyglossia}
\setmainlanguage{korean}
\setmainfont{UnBatang}

\begin{document}
한국
\end{document}

..and here's the error message (I've pretended it's code to make it stand out on stackexchange):

You cannot set field spec in a node of type glue.
\newpage ...k \@nobreakfalse \everypar {}\fi \par
                                              \ifdim \prevdepth >\z@ \vs...

LuaLaTeX appears to work ok with the upper case name 'Korean'.

I don't get this kind of error with the other (3) lower case language names I've tried (russian, farsi and tamil).

Neither upper nor lower case names trigger an error message in XeLaTeX, although the upper case version does give me a rather odd message:

Package polyglossia Warning: No hyphenation patterns were loaded for `orean'
(polyglossia)   I will use \language=\l@nohyphenation instead on input line 6.

--so something has apparently stripped off the upper case 'K'. I get no such message with the lower case 'korean'.

I suppose it's possible that LuaLaTeX is also stripping off the upper case 'K', and as a result polyglossia isn't doing something (like loading hyphenation patterns) that triggers an error in lualatex. In other words, it's possible that the apparent success with the uppercase 'Korean' in lualatex is due to something else that goes wrong.

Is polyglossia supposed to use lowercase or upper case language names?

If this is a bug in lualatex and/or polyglossia (and if language names in polyglossia are supposed to be lower case), is there a better way to work around it than supplying an upper case name for Korean?

  • The lowercase name is correct, with uppercase you get other errors as a few needed commands don't exist then. But the lua code seems to be faulty or outdated. – Ulrike Fischer Mar 23 '18 at 17:01
  • Thanks, Ulrike. And I just ran into another problem with Luatex as well, namely that it doesn't correctly handle Indic scripts. Related to ShreevatsaR's answer here: tex.stackexchange.com/questions/285527, but I'm seeing it with Tamil rather than Bengali. Sigh... – Mike Maxwell Mar 23 '18 at 17:20
2

The names are supposed to be lowercase. On my system passing Korean even results in a warning:

Package polyglossia Warning: File gloss-Korean.ldf does not exist!
(polyglossia)                I will nevertheless try to use hyphenation pattern
s for Korean. on input line 3.

The korean language file for polyglossia is broken because it tries to set the glue_spec of a glue node, but for two years now the glue_spec is no longer used for this purpose.

You can temporary fix the problemby by finding the file gloss-korean.ldf and changing some lines in there:

Replace (around line 690)

local function get_new_glue (wd, st, sh)
    local glue = node.new("glue")
    local spec = node.new("glue_spec")
    spec.width   = wd
    spec.stretch = st
    spec.shrink  = sh
    glue.spec = spec
    return glue
end

with

local function get_new_glue (wd, st, sh)
    local glue = node.new("glue")
    glue.width   = wd
    glue.stretch = st
    glue.shrink  = sh
    return glue
end

and at line 706 replace

    local hss = get_new_glue(0, 65536, 65536)
    hss.spec.stretch_order = 2
    hss.spec.shrink_order  = 2

with

    local hss = get_new_glue(0, 65536, 65536)
    hss.stretch_order = 2
    hss.shrink_order  = 2

I will send these changes to the polyglossia maintainer but it does not look like there will be any update for polyglossia soon.

  • where the time for next update is rather unclear. polyglossia hasn't corrected bug for a long time. It would be probably more sensible to convert the gloss-file to a language file for babel. – Ulrike Fischer Mar 23 '18 at 17:25
  • I confirm that this fixes my problem (at least as far as I can tell--I don't actually read Korean, just error msgs :-)). Thank you! Ulrike, should I be using babel instead of polyglossia? I thought polyglossia was the newer package. – Mike Maxwell Mar 23 '18 at 17:32
  • @MikeMaxwell Currently for korean you can't use babel because there exists no language file. Maybe the polyglossia file could be converted but I am no expert in that area. But generally I would recommend babel because it is actively maintained. – Marcel Krüger Mar 23 '18 at 17:40
  • @MikeMaxwell But you can define a language from scratch with \babelprovide. Anyway, currently I'm focused on right-to-left scripts (a new bidi algorithm is almost finished), and to be honest I'm not sure if babel for Korean will produce the correct output. A quick test with the MWE and babel with import=ko seems to work. See the manual for further details. – Javier Bezos Mar 23 '18 at 18:57
  • @Javier: Thanks--for now, I'm using Marcel's fix. The project requiring rendering of Korean is almost done (coming up on the last week), so I probably won't have time to try \babel. (But thanks for the pointer!) I do look forward to your bidi work--that was another issue I ran up against. – Mike Maxwell Mar 23 '18 at 19:42

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.