Korean Font not showing up correctly

46 views
Skip to first unread message

Jalba sung

unread,
May 31, 2020, 10:24:16 AM5/31/20
to sphinx-users
Hi,
I just started using Sphinx and love the output.

I need a translated version of my doc in korean and I used spinx-int to generate .po files 
When I try to generate pdf output by running following commend

Enter code here...
make
-e SPHINXOPTS="-D language='ko'" pdf

I get the following output 
Enter code here...
Running Sphinx v1.7.6
loading translations [ko]... done
loading pickled environment... done
building [mo]: targets for 0 po files that are out of date
building [pdf]: targets for 10 source files that are out of date
updating environment: 0 added, 0 changed, 0 removed
looking for now-outdated files... none found
processing rst2pdf...
index
Overview
Legal
Intendeduse
Trademarks
MaterialSupUser
GeneralGuide
Protocol
Overview2
Protocol2
resolving references...
done
writing rst2pdf...
[WARNING] image.py:397 image /Users/Him2/Documents/My_files/sphinx/source/img/Ent.jpg is too tall for the frame, rescaling
done
build succeeded.

However, when I open up the pdf file all the korean characters are in square block. 

Below is the latex part of the conf.py

Enter code here...latex_elements = {
    # The paper size ('letterpaper' or 'a4paper').
    #
    'papersize': 'a4paper',

    # The font size ('10pt', '11pt' or '12pt').
    #
    'pointsize': '12pt',

    # Additional stuff for the LaTeX preamble.
    #
    'preamble': '',

    # Latex figure (float) alignment
    #
    'figure_align': 'htbp',

    # kotex config
    #
    'figure_align': 'htbp',

    'fontpkg': r'''
\usepackage{kotex}

''',
   'inputenc':  '',
   'utf8extra': '',
   'preamble': '''

\usepackage{fontspec}
\usepackage{xeCJK} % this is needed to support for wrapping CJK text
\setsansfont{Arial Unicode MS}
\setromanfont{Arial Unicode MS}
\setmonofont[ Path = ./fonts/ ]{unifont.ttf} % set path where you installed unifont.ttf
''',
}

I don't think I installed xeCJK nor I have a path ./fonts.
I first updated the \setmonofont[ Path = ~/Library/Fonts/ ] {Korean.TTF}
the result is the same.

I changed the \setsansfont and \setromanfont to {Korean} and the result is still same.

What can I try ? Am I missing something?
Thank you.

منصة شليله

unread,
May 31, 2020, 10:31:12 AM5/31/20
to sphinx-users
منصةشليله 

Komiya Takeshi

unread,
May 31, 2020, 10:35:23 AM5/31/20
to sphinx...@googlegroups.com
It seems you're using rst2pdf extension to build PDF file:

>processing rst2pdf...

So the configurations for LaTeX that you pasted is not used.
Please call `make latexpdf` instead to invoke LaTeX build.
(I've never build Korean document so far. So I don't know it goes well.)

Thanks,
Takeshi KOMIYA

‪2020年5月31日(日) 23:31 ‫منصة شليله‬‎ <mnsts...@gmail.com>:‬
> --
> You received this message because you are subscribed to the Google Groups "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/ae769fc3-2121-4e66-baab-b41a420fee90%40googlegroups.com.

Hoang Tran

unread,
May 31, 2020, 4:34:28 PM5/31/20
to sphinx...@googlegroups.com
You might like to take a look at the ‘Makefile’ of the Blender documentation project at this location:


It appears that they build the latex first before turning it to PDF

pdf: .FORCE
QUICKY_CHAPTERS=$(QUICKY_CHAPTERS) \
$(SPHINXBUILD) -b latex ./manual "$(BUILDDIR)/latex"
make -C "$(BUILDDIR)/latex" LATEXOPTS="-interaction nonstopmode”

Just a thought
HDT

--
You received this message because you are subscribed to the Google Groups "sphinx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.

Jalba sung

unread,
May 31, 2020, 8:47:02 PM5/31/20
to sphinx-users
running 'make latexpdf' following is the output. 

Running Sphinx v1.7.6
loading pickled environment... done
building [mo]: targets for 0 po files that are out of date
building [latex]: all documents
updating environment: [config changed] 10 added, 1 changed, 0 removed
/Users/Him2/miniconda3/lib/python3.6/site-packages/sphinx/util/nodes.py:57: FutureWarning:
   The iterable returned by Node.traverse()
   will become an iterator instead of a list in Docutils > 0.16.
  for classifier in reversed(node.parent.traverse(nodes.classifier)):
reading sources... [100%] index
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
processing Manual.tex.../Users/m2/miniconda3/lib/python3.6/site-packages/sphinx/builders/latex/__init__.py:139: FutureWarning:
   The iterable returned by Node.traverse()
   will become an iterator instead of a list in Docutils > 0.16.
  if toctrees[0].get('maxdepth') > 0:
index Overview Legal Intendeduse Trademarks MaterialSupUser GeneralGuide Protocol Overview2 Protocol2
resolving references...
writing... done
copying images... [100%] img/FastHyb.jpg
copying TeX support files...
done
build succeeded.

The LaTeX files are in build/latex.
Run 'make' in that directory to run these through (pdf)latex
(use `make latexpdf' here to do that automatically).
latexmk -pdf -dvi- -ps-  'Manual.tex'
Rc files read:
  latexmkrc
Latexmk: This is Latexmk, John Collins, 17 Apr. 2020, version: 4.69a.
Latexmk: applying rule 'pdflatex'...
Rule 'pdflatex': The following rules & subrules became out-of-date:
      'pdflatex'
------------
Run number 1 of rule 'pdflatex'
------------
------------
Running 'pdflatex   -recorder  "FH_Test_Manual.tex"'
------------
This is pdfTeX, Version 3.14159265-2.6-1.40.21 (TeX Live 2020) (preloaded format=pdflatex)
 restricted \write18 enabled.
entering extended mode
(./FH_Test_Manual.tex
LaTeX2e <2020-02-02> patch level 5
L3 programming layer <2020-03-06> (./sphinxmanual.cls
Document Class: sphinxmanual 2017/03/26 v1.6 Document class (Sphinx manual)
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/base/report.cls
Document Class: report 2019/12/20 v1.4l Standard LaTeX document class
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/base/size12.clo)))
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/cmap/cmap.sty)
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/base/fontenc.sty<<t1.cmap>>)
 (/usr/local/texlive/2020basic/texmf-dist/tex/latex/amsmath/amsmath.sty
For additional information on amsmath, use the `?' option.
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/amsmath/amstext.sty
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/amsmath/amsgen.sty))
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/amsmath/amsbsy.sty)
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/amsmath/amsopn.sty))
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/amsfonts/amssymb.sty
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/amsfonts/amsfonts.sty))
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/babel/babel.sty
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/babel/switch.def)
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/babel-english/english.ldf
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/babel/babel.def
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/babel/txtbabel.def))))
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/cjk-ko/kotex.sty
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/kotex-utf/kotex.cfg)
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/kotex-utf/kotexutf.sty
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/base/inputenc.sty)
(/usr/local/texlive/2020basic/texmf-dist/tex/plain/kotex-plain/kotexutf-core.te
x) (/usr/local/texlive/2020basic/texmf-dist/tex/latex/kotex-utf/lucenc.dfu)
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/cjk-ko/kolabels-utf.sty)))
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/fncychap/fncychap.sty)
(./sphinx.sty
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/ltxcmds/ltxcmds.sty)
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/graphics/graphicx.sty
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/graphics/keyval.sty)
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/graphics/graphics.sty
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/graphics/trig.sty)
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/graphics-cfg/graphics.cfg)
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/graphics-def/pdftex.def)))
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/fancyhdr/fancyhdr.sty)
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/base/textcomp.sty)
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/titlesec/titlesec.sty)
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/tabulary/tabulary.sty
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/tools/array.sty))
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/tools/longtable.sty)
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/varwidth/varwidth.sty)
(./sphinxmulticell.sty)
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/base/makeidx.sty)
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/framed/framed.sty)
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/xcolor/xcolor.sty
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/graphics-cfg/color.cfg))
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/fancyvrb/fancyvrb.sty)
(./footnotehyper-sphinx.sty)
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/float/float.sty)
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/wrapfig/wrapfig.sty)
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/parskip/parskip.sty
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/kvoptions/kvoptions.sty
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/kvsetkeys/kvsetkeys.sty))
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/etoolbox/etoolbox.sty))
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/base/alltt.sty)
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/upquote/upquote.sty)
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/capt-of/capt-of.sty)
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/needspace/needspace.sty)
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/carlisle/remreset.sty

Package remreset Warning: The remreset package is obsolete:
(remreset)                \@removefomresset is defined.

) (./sphinxhighlight.sty))
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/geometry/geometry.sty
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/iftex/ifvtex.sty
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/iftex/iftex.sty)))
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/hyperref/hyperref.sty
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/pdftexcmds/pdftexcmds.sty
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/infwarerr/infwarerr.sty))
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/kvdefinekeys/kvdefinekeys.
sty)
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/pdfescape/pdfescape.sty)
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/hycolor/hycolor.sty)
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/letltxmacro/letltxmacro.sty)
 (/usr/local/texlive/2020basic/texmf-dist/tex/latex/auxhook/auxhook.sty)
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/hyperref/pd1enc.def)
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/intcalc/intcalc.sty)
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/etexcmds/etexcmds.sty)
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/hyperref/puenc.def)
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/url/url.sty)
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/bitset/bitset.sty
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/bigintcalc/bigintcalc.sty)
) (/usr/local/texlive/2020basic/texmf-dist/tex/generic/atbegshi/atbegshi.sty))
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/hyperref/hpdftex.def
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/atveryend/atveryend.sty)
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/rerunfilecheck/rerunfilechec
k.sty
(/usr/local/texlive/2020basic/texmf-dist/tex/generic/uniquecounter/uniquecounte
r.sty))) (/usr/local/texlive/2020basic/texmf-dist/tex/latex/oberdiek/hypcap.sty
) (/usr/local/texlive/2020basic/texmf-dist/tex/latex/fontspec/fontspec.sty
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/l3packages/xparse/xparse.sty
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/l3kernel/expl3.sty
(/usr/local/texlive/2020basic/texmf-dist/tex/latex/l3backend/l3backend-pdfmode.
def)))

! Fatal Package fontspec Error: The fontspec package requires either XeTeX or
(fontspec)                      LuaTeX.
(fontspec)
(fontspec)                      You must change your typesetting engine to,
(fontspec)                      e.g., "xelatex" or "lualatex"instead of
(fontspec)                      "latex" or "pdflatex".

Type <return> to continue.
 ...

l.45 \msg_fatal:nn {fontspec} {cannot-use-pdftex}


How do I specify language='ko' when I execute 'make latexpdf'?
Looks like I need to install xelatex or lualatex. Am I right? 
Any guidance is welcome.

Komiya Takeshi

unread,
Jun 1, 2020, 12:40:53 AM6/1/20
to sphinx...@googlegroups.com
>How do I specify language='ko' when I execute 'make latexpdf'?

You can switch language via `language` setting in conf.py.
If you need to set it temporarily, `-D` option of sphinx-build is
useful: `-D language=ko`.
The option is passed via `SPHINXOPTS` variable. So `make latexpdf
SPHINXOPTS="-D language=ko"` will work well on your case.

>Looks like I need to install xelatex or lualatex. Am I right?

Yes, LaTeX output says so.
I guess it came from "xeCJK" package that is loaded by your settings.
To switch LaTeX engine to xelatex or lualatex, please use
`latex_engine` setting in conf.py.

Thanks,
Takeshi KOMIYA

2020年6月1日(月) 9:47 Jalba sung <jalb...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/a38f8bde-08fc-4b33-8043-5b531ffe1372%40googlegroups.com.

Jalba sung

unread,
Jun 1, 2020, 7:27:22 AM6/1/20
to sphinx-users
Okay. I uninstalled basicTex and installed MacTex. Update the conf.py  like below.
latex_engine = 'xelatex'
latex_elements = {
    # The paper size ('letterpaper' or 'a4paper').
    #
    'papersize': 'a4paper',

    # The font size ('10pt', '11pt' or '12pt').
    #
    'pointsize': '12pt',

    # Additional stuff for the LaTeX preamble.
    #
    'preamble': '\usepackage(kotex)',

    # Latex figure (float) alignment
    #
    'figure_align': 'htbp',

    # kotex config
    #
    'figure_align': 'htbp',
}

Confirmed that english version pdf generated okay.

when I excute make latexpdf  SPHINXOPTS="-D language='ko'"

I get WANRING: no Babel option known for language 'ko'
and then I get a list of paths for .sty files 

This is XeTeX, Version 3.14159265-2.6-0.999992 (TeX Live 2020) (preloaded format=xelatex)
 restricted \write18 enabled.
entering extended mode
(./Manual.tex
LaTeX2e <2020-02-02> patch level 5
L3 programming layer <2020-03-06> (./sphinxmanual.cls
Document Class: sphinxmanual 2017/03/26 v1.6 Document class (Sphinx manual)
(/usr/local/texlive/2020/texmf-dist/tex/latex/base/report.cls
Document Class: report 2019/12/20 v1.4l Standard LaTeX document class
(/usr/local/texlive/2020/texmf-dist/tex/latex/base/size12.clo)))
  .
  .
  .
! LaTeX Error: File `(.sty' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: sty)

Enter file name:



And then at some point I get the (.sty file not found.
Where can I find this sty file? When I ignore this message and carry on I get a pdf file that show white spaces for Korean characters.
Do I need to fix the babel warning? if so how do I do this?
Thank you

Komiya Takeshi

unread,
Jun 1, 2020, 9:55:07 AM6/1/20
to sphinx...@googlegroups.com
Could you paste the log before the LaTeX Error? I guess LaTeX output
the reason of the error.

I noticed your configuration is incorrect. You must use curly braces
to the usepackage `\usepackage{kotex}`.
> 'preamble': '\usepackage(kotex)',

>Do I need to fix the babel warning? if so how do I do this?

It seems Sphinx and docutils (the core library of Sphinx) does not
support Korean babel. So there are nothing to do for the warning...

2020年6月1日(月) 20:27 Jalba sung <jalb...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/3997f73c-c69d-4c9a-9e8a-88713e3ed23f%40googlegroups.com.

Jalba sung

unread,
Jun 1, 2020, 1:23:31 PM6/1/20
to sphinx-users
Here is the log you requested
Running Sphinx v1.7.6
loading translations [ko]... done
loading pickled environment... done
building [mo]: targets for 0 po files that are out of date
building [latex]: all documents
updating environment: [config changed] 10 added, 1 changed, 0 removed
/Users/H/miniconda3/lib/python3.6/site-packages/sphinx/util/nodes.py:57: FutureWarning:
   The iterable returned by Node.traverse()
   will become an iterator instead of a list in Docutils > 0.16.
  for classifier in reversed(node.parent.traverse(nodes.classifier)):
reading sources... [100%] index
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
processing Manual.tex.../Users/H/miniconda3/lib/python3.6/site-packages/sphinx/builders/latex/__init__.py:139: FutureWarning:
   The iterable returned by Node.traverse()
   will become an iterator instead of a list in Docutils > 0.16.
  if toctrees[0].get('maxdepth') > 0:
index Overview Legal Intendeduse Trademarks MaterialSupUser GeneralGuide Protocol Overview2 Protocol2
resolving references...
writing... WARNING: no Babel option known for language 'ko'
done
copying images... [100%] img/FastHyb.jpg
copying TeX support files...
done
build succeeded, 1 warnings.


After fixing the conf.py with the curly braces the .sty error is now gone
and the korean character is showing up as expected.

One issue now is with the translated version of pdf file some table header text is not 
warping and extending over to the next column.
Any pointers on how to solve this?

Thank you very much for your help.


Komiya Takeshi

unread,
Jun 2, 2020, 1:16:39 PM6/2/20
to sphinx...@googlegroups.com
You're welcome :-)

>One issue now is with the translated version of pdf file some table header text is not
>warping and extending over to the next column.
>Any pointers on how to solve this?

Sorry, I don't know. It might be resolved in latest version of Sphinx.
How about update it?
If not resolved yet, please file an issue to GitHub.

Thanks,

2020年6月2日(火) 2:23 Jalba sung <jalb...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups "sphinx-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sphinx-users...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sphinx-users/08b83c7d-1e79-4ab0-9d16-208778107d98%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages