fontspec icon indicating copy to clipboard operation
fontspec copied to clipboard

huge memory consumption with mode=harf and the Noto CJK fonts

Open emojifreak opened this issue 5 years ago • 4 comments

Description

After removing the font cache (rm -rf ~/.texlive2019), \fontspec[RawFeature={mode=harf}] uses much larger memory than \font in luaotfload 3.12.

Check/indicate

  • [ ] Relevant for XeTeX
  • [ X] Relevant for LuaTeX
  • [ X] Issue tracker has been searched for similar issues?
  • [ ] Links to <tex.stackexchange.com> discussion if appropriate

Minimal example demonstrating the issue

\documentclass{minimal}
\usepackage{fontspec}
\setmainfont[RawFeature={mode=harf}]{Noto Serif CJK JP}
\setsansfont[RawFeature={mode=harf}]{Noto Sans CJK JP}
\begin{document}
\noindent
{test}\\
{\sffamily test}\\
\end{document}

The above uses 2 giga byes of memory after rm -rf ~/.texlive2019.

Further details

On the other hand,

\documentclass{minimal}
\begin{document}
\font\notocjk={name:Noto Serif CJK JP:mode=harf} at 10pt
\font\notocjksans={name:Noto Sans CJK JP:mode=harf} at 10pt
\notocjk test.
\notocjksans test.
\end{document}

uses only 0.3 giga bytes of memory. They are observed with the latest versions of TeXLive 2019 and lualatex-dev, after rm -rf ~/.texlive2019.

emojifreak avatar Feb 23 '20 05:02 emojifreak

You should use Renderer=HarfBuzz, fontspec treats RawFeature as a blackbox and passes it verbatim, so it does not know you want to use HarfBuzz and would still load the font with the default mode when it tries to inspect the features it supports.

khaledhosny avatar Feb 26 '20 01:02 khaledhosny

You should use Renderer=HarfBuzz

Thank you. The memory consumption decreased to just 1GB, much better, while it is still larger than the vanilla \font command in luaotfload...

emojifreak avatar Feb 26 '20 07:02 emojifreak

Are you using the latest fontspec, if so check the log and see if the font is still loaded without mode=harf somewhere?

khaledhosny avatar Feb 26 '20 07:02 khaledhosny

Are you using the latest fontspec, if so check the log and see if the font is still loaded without mode=harf somewhere?

I did tlmgr update --all one hour ago. fontspec version is 2020/02/21 v2.7i The compiled tex file is below

\documentclass{minimal}
\usepackage{fontspec}
\setmainfont[Renderer=HarfBuzz]{Noto Serif CJK JP}
\setsansfont[Renderer=HarfBuzz]{Noto Sans CJK JP}
\begin{document}
\noindent
{test}\\
{\sffamily test}\\
\end{document}

Searching CJK gives below. Every font loading seems associated with mode=harf..

$ fgrep -n 'CJK' test-fontspec2.log 
119:Package fontspec Info: Could not resolve font "NotoSerifCJKJP/BI" (it probably
123:Package fontspec Info: Could not resolve font "NotoSerifCJKJP/I" (it probably
127:Package fontspec Info: Font family 'NotoSerifCJKJP(0)' created for font 'Noto
128:(fontspec)             Serif CJK JP' with options
135:(fontspec)             <->"NotoSerifCJKJP:mode=harf;script=latn;language=dflt;+t
139:(fontspec)             <->"NotoSerifCJKJP/B:mode=harf;script=latn;language=dflt;
144:Package fontspec Info: Could not resolve font "NotoSansCJKJP/BI" (it probably
148:Package fontspec Info: Could not resolve font "NotoSansCJKJP/I" (it probably
152:Package fontspec Info: Font family 'NotoSansCJKJP(0)' created for font 'Noto
153:(fontspec)             Sans CJK JP' with options
160:(fontspec)             <->"NotoSansCJKJP:mode=harf;script=latn;language=dflt;+tl
164:(fontspec)             <->"NotoSansCJKJP/B:mode=harf;script=latn;language=dflt;+
228:(Font)                  OT1/cmr/m/n --> TU/NotoSerifCJKJP(0)/m/n on input line 5
233:(Font)                  OT1/cmr/bx/n --> TU/NotoSerifCJKJP(0)/m/n on input line 
236:(Font)                  TU/NotoSerifCJKJP(0)/m/n --> TU/NotoSerifCJKJP(0)/m/n on
239:(Font)                  OT1/cmr/m/it --> TU/NotoSerifCJKJP(0)/m/it on input line
242:(Font)                  OT1/cmr/bx/n --> TU/NotoSerifCJKJP(0)/b/n on input line 
245:(Font)                  OT1/cmss/m/n --> TU/NotoSansCJKJP(0)/m/n on input line 5
250:(Font)                  TU/NotoSerifCJKJP(0)/m/n --> TU/NotoSerifCJKJP(0)/b/n on
253:(Font)                  OT1/cmr/bx/it --> TU/NotoSerifCJKJP(0)/b/it on input lin
256:(Font)                  OT1/cmss/bx/n --> TU/NotoSansCJKJP(0)/b/n on input line 
278:</usr/share/fonts/opentype/noto/NotoSansCJK-Regular.ttc></usr/share/fonts/openty
279:pe/noto/NotoSerifCJK-Regular.ttc>

The log file is attached below: test-fontspec2.log

emojifreak avatar Feb 26 '20 07:02 emojifreak