What is the least resource intensive way to generate the luatex font cache for a new font?












7















When a font is first used with lualatex, luaotfload does some magic to produce font cache files.



For large fonts (e.g., Noto Sans CJK) this can take a lot of time and a lot of memory.



I have an old computer (5 year old MacBook air with 4GB RAM) running Linux with a 4GB swap partition. The initial cache generation of this font can take more than 15 min and render my computer unusable. Sometimes I just run out of memory and the process is killed.



Let's say I want to use the font as such:



documentclass{article}
usepackage{fontspec}
setmainfont[Script=CJK,Language=Chinese Simplified]{Noto Sans CJK SC}
begin{document}
中文
end{document}


What is the least resource intensive way and/or fastest way to generate the required cache files?



At the moment, I quit everything (even X11) and run lualatex from the console, but it still takes a long time, and quitting everything is a bit of a pain.










share|improve this question


















  • 1





    That is a very good question, but I don't think you can do any better as you do now. Here is Hans' statement about this: mailman.ntg.nl/pipermail/ntg-context/2018/092703.html

    – Henri Menke
    47 mins ago













  • See also this answer tex.stackexchange.com/questions/453143/… and this comment tex.stackexchange.com/questions/453143/… of mine.

    – Henri Menke
    44 mins ago


















7















When a font is first used with lualatex, luaotfload does some magic to produce font cache files.



For large fonts (e.g., Noto Sans CJK) this can take a lot of time and a lot of memory.



I have an old computer (5 year old MacBook air with 4GB RAM) running Linux with a 4GB swap partition. The initial cache generation of this font can take more than 15 min and render my computer unusable. Sometimes I just run out of memory and the process is killed.



Let's say I want to use the font as such:



documentclass{article}
usepackage{fontspec}
setmainfont[Script=CJK,Language=Chinese Simplified]{Noto Sans CJK SC}
begin{document}
中文
end{document}


What is the least resource intensive way and/or fastest way to generate the required cache files?



At the moment, I quit everything (even X11) and run lualatex from the console, but it still takes a long time, and quitting everything is a bit of a pain.










share|improve this question


















  • 1





    That is a very good question, but I don't think you can do any better as you do now. Here is Hans' statement about this: mailman.ntg.nl/pipermail/ntg-context/2018/092703.html

    – Henri Menke
    47 mins ago













  • See also this answer tex.stackexchange.com/questions/453143/… and this comment tex.stackexchange.com/questions/453143/… of mine.

    – Henri Menke
    44 mins ago
















7












7








7








When a font is first used with lualatex, luaotfload does some magic to produce font cache files.



For large fonts (e.g., Noto Sans CJK) this can take a lot of time and a lot of memory.



I have an old computer (5 year old MacBook air with 4GB RAM) running Linux with a 4GB swap partition. The initial cache generation of this font can take more than 15 min and render my computer unusable. Sometimes I just run out of memory and the process is killed.



Let's say I want to use the font as such:



documentclass{article}
usepackage{fontspec}
setmainfont[Script=CJK,Language=Chinese Simplified]{Noto Sans CJK SC}
begin{document}
中文
end{document}


What is the least resource intensive way and/or fastest way to generate the required cache files?



At the moment, I quit everything (even X11) and run lualatex from the console, but it still takes a long time, and quitting everything is a bit of a pain.










share|improve this question














When a font is first used with lualatex, luaotfload does some magic to produce font cache files.



For large fonts (e.g., Noto Sans CJK) this can take a lot of time and a lot of memory.



I have an old computer (5 year old MacBook air with 4GB RAM) running Linux with a 4GB swap partition. The initial cache generation of this font can take more than 15 min and render my computer unusable. Sometimes I just run out of memory and the process is killed.



Let's say I want to use the font as such:



documentclass{article}
usepackage{fontspec}
setmainfont[Script=CJK,Language=Chinese Simplified]{Noto Sans CJK SC}
begin{document}
中文
end{document}


What is the least resource intensive way and/or fastest way to generate the required cache files?



At the moment, I quit everything (even X11) and run lualatex from the console, but it still takes a long time, and quitting everything is a bit of a pain.







fonts luatex fontspec luaotfload






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 3 hours ago









David PurtonDavid Purton

10.7k2939




10.7k2939








  • 1





    That is a very good question, but I don't think you can do any better as you do now. Here is Hans' statement about this: mailman.ntg.nl/pipermail/ntg-context/2018/092703.html

    – Henri Menke
    47 mins ago













  • See also this answer tex.stackexchange.com/questions/453143/… and this comment tex.stackexchange.com/questions/453143/… of mine.

    – Henri Menke
    44 mins ago
















  • 1





    That is a very good question, but I don't think you can do any better as you do now. Here is Hans' statement about this: mailman.ntg.nl/pipermail/ntg-context/2018/092703.html

    – Henri Menke
    47 mins ago













  • See also this answer tex.stackexchange.com/questions/453143/… and this comment tex.stackexchange.com/questions/453143/… of mine.

    – Henri Menke
    44 mins ago










1




1





That is a very good question, but I don't think you can do any better as you do now. Here is Hans' statement about this: mailman.ntg.nl/pipermail/ntg-context/2018/092703.html

– Henri Menke
47 mins ago







That is a very good question, but I don't think you can do any better as you do now. Here is Hans' statement about this: mailman.ntg.nl/pipermail/ntg-context/2018/092703.html

– Henri Menke
47 mins ago















See also this answer tex.stackexchange.com/questions/453143/… and this comment tex.stackexchange.com/questions/453143/… of mine.

– Henri Menke
44 mins ago







See also this answer tex.stackexchange.com/questions/453143/… and this comment tex.stackexchange.com/questions/453143/… of mine.

– Henri Menke
44 mins ago












1 Answer
1






active

oldest

votes


















5














You can do as proposed in section 9.2.1 “Trimming fonts“ in Fonts out of ConTeXt and remove all the glyph names in the font.



enter image description here



Adapted to LaTeX and your example:



documentclass{article}
usepackage{fontspec,luacode}
begin{luacode*}


fonts.handlers.otf.readers.registerextender {
name = "remove names from Noto Sans CJK SC",
action = function(fontdata)
if string.match(fontdata.metadata.fullname, "Noto Sans CJK SC") then
texio.write_nl("Trimming font " .. fontdata.metadata.fullname)
for k, v in next, fontdata.descriptions do
v.name = nil
end
end
end
}




end{luacode*}
setmainfont[Script=CJK,Language=Chinese Simplified]{Noto Sans CJK SC}
begin{document}
中文
end{document}





share|improve this answer
























  • Can this solution be problematic in some cases?

    – Paul Gaborit
    16 mins ago











  • @PaulGaborit Yes, anything that wants to access glyphs by name won't work. In ConTeXt there is getnamedglyphdirect which will break. I don't think there is anything like this in LaTeX. Also those name lookups are not very efficient.

    – Henri Menke
    9 mins ago













Your Answer








StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "85"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f479744%2fwhat-is-the-least-resource-intensive-way-to-generate-the-luatex-font-cache-for-a%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes









5














You can do as proposed in section 9.2.1 “Trimming fonts“ in Fonts out of ConTeXt and remove all the glyph names in the font.



enter image description here



Adapted to LaTeX and your example:



documentclass{article}
usepackage{fontspec,luacode}
begin{luacode*}


fonts.handlers.otf.readers.registerextender {
name = "remove names from Noto Sans CJK SC",
action = function(fontdata)
if string.match(fontdata.metadata.fullname, "Noto Sans CJK SC") then
texio.write_nl("Trimming font " .. fontdata.metadata.fullname)
for k, v in next, fontdata.descriptions do
v.name = nil
end
end
end
}




end{luacode*}
setmainfont[Script=CJK,Language=Chinese Simplified]{Noto Sans CJK SC}
begin{document}
中文
end{document}





share|improve this answer
























  • Can this solution be problematic in some cases?

    – Paul Gaborit
    16 mins ago











  • @PaulGaborit Yes, anything that wants to access glyphs by name won't work. In ConTeXt there is getnamedglyphdirect which will break. I don't think there is anything like this in LaTeX. Also those name lookups are not very efficient.

    – Henri Menke
    9 mins ago


















5














You can do as proposed in section 9.2.1 “Trimming fonts“ in Fonts out of ConTeXt and remove all the glyph names in the font.



enter image description here



Adapted to LaTeX and your example:



documentclass{article}
usepackage{fontspec,luacode}
begin{luacode*}


fonts.handlers.otf.readers.registerextender {
name = "remove names from Noto Sans CJK SC",
action = function(fontdata)
if string.match(fontdata.metadata.fullname, "Noto Sans CJK SC") then
texio.write_nl("Trimming font " .. fontdata.metadata.fullname)
for k, v in next, fontdata.descriptions do
v.name = nil
end
end
end
}




end{luacode*}
setmainfont[Script=CJK,Language=Chinese Simplified]{Noto Sans CJK SC}
begin{document}
中文
end{document}





share|improve this answer
























  • Can this solution be problematic in some cases?

    – Paul Gaborit
    16 mins ago











  • @PaulGaborit Yes, anything that wants to access glyphs by name won't work. In ConTeXt there is getnamedglyphdirect which will break. I don't think there is anything like this in LaTeX. Also those name lookups are not very efficient.

    – Henri Menke
    9 mins ago
















5












5








5







You can do as proposed in section 9.2.1 “Trimming fonts“ in Fonts out of ConTeXt and remove all the glyph names in the font.



enter image description here



Adapted to LaTeX and your example:



documentclass{article}
usepackage{fontspec,luacode}
begin{luacode*}


fonts.handlers.otf.readers.registerextender {
name = "remove names from Noto Sans CJK SC",
action = function(fontdata)
if string.match(fontdata.metadata.fullname, "Noto Sans CJK SC") then
texio.write_nl("Trimming font " .. fontdata.metadata.fullname)
for k, v in next, fontdata.descriptions do
v.name = nil
end
end
end
}




end{luacode*}
setmainfont[Script=CJK,Language=Chinese Simplified]{Noto Sans CJK SC}
begin{document}
中文
end{document}





share|improve this answer













You can do as proposed in section 9.2.1 “Trimming fonts“ in Fonts out of ConTeXt and remove all the glyph names in the font.



enter image description here



Adapted to LaTeX and your example:



documentclass{article}
usepackage{fontspec,luacode}
begin{luacode*}


fonts.handlers.otf.readers.registerextender {
name = "remove names from Noto Sans CJK SC",
action = function(fontdata)
if string.match(fontdata.metadata.fullname, "Noto Sans CJK SC") then
texio.write_nl("Trimming font " .. fontdata.metadata.fullname)
for k, v in next, fontdata.descriptions do
v.name = nil
end
end
end
}




end{luacode*}
setmainfont[Script=CJK,Language=Chinese Simplified]{Noto Sans CJK SC}
begin{document}
中文
end{document}






share|improve this answer












share|improve this answer



share|improve this answer










answered 29 mins ago









Henri MenkeHenri Menke

76.8k8168283




76.8k8168283













  • Can this solution be problematic in some cases?

    – Paul Gaborit
    16 mins ago











  • @PaulGaborit Yes, anything that wants to access glyphs by name won't work. In ConTeXt there is getnamedglyphdirect which will break. I don't think there is anything like this in LaTeX. Also those name lookups are not very efficient.

    – Henri Menke
    9 mins ago





















  • Can this solution be problematic in some cases?

    – Paul Gaborit
    16 mins ago











  • @PaulGaborit Yes, anything that wants to access glyphs by name won't work. In ConTeXt there is getnamedglyphdirect which will break. I don't think there is anything like this in LaTeX. Also those name lookups are not very efficient.

    – Henri Menke
    9 mins ago



















Can this solution be problematic in some cases?

– Paul Gaborit
16 mins ago





Can this solution be problematic in some cases?

– Paul Gaborit
16 mins ago













@PaulGaborit Yes, anything that wants to access glyphs by name won't work. In ConTeXt there is getnamedglyphdirect which will break. I don't think there is anything like this in LaTeX. Also those name lookups are not very efficient.

– Henri Menke
9 mins ago







@PaulGaborit Yes, anything that wants to access glyphs by name won't work. In ConTeXt there is getnamedglyphdirect which will break. I don't think there is anything like this in LaTeX. Also those name lookups are not very efficient.

– Henri Menke
9 mins ago




















draft saved

draft discarded




















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f479744%2fwhat-is-the-least-resource-intensive-way-to-generate-the-luatex-font-cache-for-a%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Histoire des bourses de valeurs

Why is there Russian traffic in my log files?

Rename multiple files to decrement number in file name?