I am new to ConTeXt (but comfortable with LaTeX) and was trying to figure out how to have letters of different scripts in the same document. I tried to have a Japanese only document using the snippet in this thread https://mailman.ntg.nl/archives/list/ntg-context@ntg.nl/message/QCXFTDHLPDS3... Like this: ``` \definefontfamily [noto-jp] [rm] [Noto Serif CJK JP] \definefontfamily [noto-jp] [ss] [Noto Sans CJK JP] \definetypeface [noto-jp] [mm] [math] [pagella] [default] \setupbodyfont [noto-jp] \mainlanguage [ja] \setscript [nihongo] \starttext \startbuffer 打構セト読役いゆお及層大コモクカ軟毎ホアヲト極書た球87本野 ぎレべ襲画売ぎ関負ら断紀チラネキ質紋キタ資私トゃふん。江コキトサ狂毎現ンづ応通サシ続36島性84界ぼゆゃが実書ちぽふず辞躍事シ世図二ハス盛堀人わレをう第紙きかイの浅69乳キメタ事争つょ社以ヨナム法例やほにル済療にしいむ。子け記多ゅくよ正役モ母憲トぞ説帝け務賞ク付打ワナ内桁ぼでクフ因倒おふフ印気地レタケマ冬4雇各裁微ひるぼ。 \stopbuffer \rm \getbuffer \page \ss \getbuffer \stoptext ``` I got all the fonts available in my computer, but the generated pdf contains only the Latin part. Just few numbers: 873684694. I don't know what I am doing incorrectly here. Would anyone be able to help me out? I eventually want to make a document which has multiple scripts in it with English as main language. I tried skipping some of the pdfs at https://wiki.contextgarden.net/Documentation, but am not sure if I missed the relevant section. Thanks.
Am 31.12.2025 um 08:13 schrieb Julin S:
I am new to ConTeXt (but comfortable with LaTeX) and was trying to figure out how to have letters of different scripts in the same document.
I tried to have a Japanese only document using the snippet in this thread https://mailman.ntg.nl/archives/list/ntg-context@ntg.nl/message/QCXFTDHLPDS3...
Like this:
``` \definefontfamily [noto-jp] [rm] [Noto Serif CJK JP] \definefontfamily [noto-jp] [ss] [Noto Sans CJK JP] \definetypeface [noto-jp] [mm] [math] [pagella] [default]
\setupbodyfont [noto-jp]
\mainlanguage [ja]
\setscript [nihongo]
\starttext
\startbuffer 打構セト読役いゆお及層大コモクカ軟毎ホアヲト極書た球87本野 ぎレべ襲画売ぎ関負ら断紀チラネキ質紋キタ資私トゃふん。江コキトサ狂毎現ンづ応通サシ続36島性84界ぼゆゃが実書ちぽふず辞躍事シ世図二ハス盛堀人わレをう第紙きかイの浅69乳キメタ事争つょ社以ヨナム法例やほにル済療にしいむ。子け記多ゅくよ正役モ母憲トぞ説帝け務賞ク付打ワナ内桁ぼでクフ因倒おふフ印気地レタケマ冬4雇各裁微ひるぼ。 \stopbuffer
\rm \getbuffer
\page
\ss \getbuffer
\stoptext ```
I got all the fonts available in my computer, but the generated pdf contains only the Latin part. Just few numbers: 873684694. I don't know what I am doing incorrectly here.
Context is unable to find/load the necessary fonts to typeset the japanese text. The first thing you can do is to check which noto fonts are found by context, you can create a list with mtxrun --script fonts --list --all --pattern=noto* When you see noto font for japanese it's possible they user a different name than the one in the example above because google provides different version of the fonts with different family names. When no font files are in the listing but you're sure they are on your system you can either add the path to context list of searched directories or you put a copy of the files into one of the local tex directories. Wolfgang
In lang-imp-indic.lua we find a definition of the transliteration of "ṁ" from IAST transcription into Nagari ("deva"): ["ṁ"] = "ं" There is nothing wrong with this, since the ṁ is in use, but the standard transcription (acc. to IAST), also in wide use, is "ṃ". I suggest adding ["ṃ"] = "ं" to make the mechanism useful to both camps. Best, Jürgen PS: I have to typeset a longer Sanskrit text, determined to do it in ConTeXt for the first time (after using all kinds of TeXs since the 90s), so I might be back. --- Prof. Dr. Juergen Hanneder Philipps-Universitaet Marburg FG Indologie u. Tibetologie Deutschhausstr.12 35032 Marburg Germany Tel. 0049-6421-28-24930 hanneder@staff.uni-marburg.de
On 1/7/2026 1:41 PM, Jürgen Hanneder via ntg-context wrote:
In lang-imp-indic.lua we find a definition of the transliteration of "ṁ" from IAST transcription into Nagari ("deva"):
["ṁ"] = "ं"
There is nothing wrong with this, since the ṁ is in use, but the standard transcription (acc. to IAST), also in wide use, is "ṃ".
I suggest adding ["ṃ"] = "ं" to make the mechanism useful to both camps.
Sending me a patched file is best then Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
Hi Julin ! At first glance, it appears that the font declared and the font used are not the same. This is why, during compilation, ConTeXt falls back on LatinModern and prints the numbers in Roman. As Wolfgang rightly points out, it would be necessary to identify precisely which system font actually allows Japanese to be rendered. The following commands must therefore be executed: mtxrun --script fonts --list --pattern=“Noto” mtxrun --script fonts --list --pattern=“JP” mtxrun --script fonts --list --pattern=‘CJK’ and definitely install a “real” font that renders kana and nihongo mode properly (try ipaexmincho). And try this : \definefontfamily[jp][rm][IPAexMincho] \setupbodyfont[jp] \setscript[nihongo] \starttext これはIPAex明朝体による日本語のテストです。 \stoptext Or, if it fails, try this code : % 1) Fallback first \definefallbackfamily[main][rm][ipaexmincho] [preset=range:japanese,force=yes] % 2) Main family follows \definefontfamily[main][rm][TeX Gyre Pagella] \setupbodyfont[main,10pt] \mainlanguage[en] \setscript[nihongo] \starttext This is English text. これはIPAex明朝体による日本語です。 \stoptext Hope this helps. Best//JP Le 31/12/2025 à 08:13, Julin S a écrit :
I am new to ConTeXt (but comfortable with LaTeX) and was trying to figure out how to have letters of different scripts in the same document.
I tried to have a Japanese only document using the snippet in this thread https://mailman.ntg.nl/archives/list/ntg-context@ntg.nl/message/QCXFTDHLPDS3...
Like this:
``` \definefontfamily [noto-jp] [rm] [Noto Serif CJK JP] \definefontfamily [noto-jp] [ss] [Noto Sans CJK JP] \definetypeface [noto-jp] [mm] [math] [pagella] [default]
\setupbodyfont [noto-jp]
\mainlanguage [ja]
\setscript [nihongo]
\starttext
\startbuffer 打構セト読役いゆお及層大コモクカ軟毎ホアヲト極書た球87本野 ぎレべ襲画売ぎ関負ら断紀チラネキ質紋キタ資私トゃふん。江コキトサ狂毎現ンづ応通サシ続36島性84界ぼゆゃが実書ちぽふず辞躍事シ世図二ハス盛堀人わレをう第紙きかイの浅69乳キメタ事争つょ社以ヨナム法例やほにル済療にしいむ。子け記多ゅくよ正役モ母憲トぞ説帝け務賞ク付打ワナ内桁ぼでクフ因倒おふフ印気地レタケマ冬4雇各裁微ひるぼ。 \stopbuffer
\rm \getbuffer
\page
\ss \getbuffer
\stoptext ```
I got all the fonts available in my computer, but the generated pdf contains only the Latin part. Just few numbers: 873684694. I don't know what I am doing incorrectly here.
Would anyone be able to help me out? I eventually want to make a document which has multiple scripts in it with English as main language.
I tried skipping some of the pdfs at https://wiki.contextgarden.net/Documentation, but am not sure if I missed the relevant section.
Thanks. ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net ___________________________________________________________________________________
Hi, I made a list of 4-dimensional vectors using the following code. \startluacode local matT = {{0,0,1,1/3},{1,0,0,1/3},{0,1/2,0,1/3},{0,1/2,0,0}} local matOld = {{1/4},{1/4},{1/4},{1/4}} local matNew = {} local matHistory = {} table.insert(matHistory, matOld) for i = 2, 15 do matOld = matHistory[i-1] matNew = mtx.product(matT, matOld) -- mtx.typeset(matT)context("\\times")mtx.typeset(matOld) -- context(" = ") mtx.typeset(matNew) context("\\blank") table.insert(matHistory, matNew) end \stopluacode I’d like to draw a line graph of the data in matHistory to show the change of each component of 4-dimensional vectors. How can I draw it in LuaMetaFun? In the manual, data is already given in the example. How can bring the data made in lua to ConTeXt? Thank you. Best regards, Dalyoung
2026. 1. 8. 오전 2:53, Jean-Pierre Delange via ntg-context
작성: Hi Julin !
At first glance, it appears that the font declared and the font used are not the same. This is why, during compilation, ConTeXt falls back on LatinModern and prints the numbers in Roman.
As Wolfgang rightly points out, it would be necessary to identify precisely which system font actually allows Japanese to be rendered. The following commands must therefore be executed:
mtxrun --script fonts --list --pattern=“Noto”
mtxrun --script fonts --list --pattern=“JP”
mtxrun --script fonts --list --pattern=‘CJK’
and definitely install a “real” font that renders kana and nihongo mode properly (try ipaexmincho). And try this :
\definefontfamily[jp][rm][IPAexMincho] \setupbodyfont[jp] \setscript[nihongo]
\starttext これはIPAex明朝体による日本語のテストです。 \stoptext
Or, if it fails, try this code :
% 1) Fallback first \definefallbackfamily[main][rm][ipaexmincho] [preset=range:japanese,force=yes]
% 2) Main family follows \definefontfamily[main][rm][TeX Gyre Pagella]
\setupbodyfont[main,10pt] \mainlanguage[en] \setscript[nihongo]
\starttext This is English text.
これはIPAex明朝体による日本語です。 \stoptext
Hope this helps.
Best//JP
Le 31/12/2025 à 08:13, Julin S a écrit :
I am new to ConTeXt (but comfortable with LaTeX) and was trying to figure out how to have letters of different scripts in the same document.
I tried to have a Japanese only document using the snippet in this thread https://mailman.ntg.nl/archives/list/ntg-context@ntg.nl/message/QCXFTDHLPDS3...
Like this:
``` \definefontfamily [noto-jp] [rm] [Noto Serif CJK JP] \definefontfamily [noto-jp] [ss] [Noto Sans CJK JP] \definetypeface [noto-jp] [mm] [math] [pagella] [default]
\setupbodyfont [noto-jp]
\mainlanguage [ja]
\setscript [nihongo]
\starttext
\startbuffer 打構セト読役いゆお及層大コモクカ軟毎ホアヲト極書た球87本野 ぎレべ襲画売ぎ関負ら断紀チラネキ質紋キタ資私トゃふん。江コキトサ狂毎現ンづ応通サシ続36島性84界ぼゆゃが実書ちぽふず辞躍事シ世図二ハス盛堀人わレをう第紙きかイの浅69乳キメタ事争つょ社以ヨナム法例やほにル済療にしいむ。子け記多ゅくよ正役モ母憲トぞ説帝け務賞ク付打ワナ内桁ぼでクフ因倒おふフ印気地レタケマ冬4雇各裁微ひるぼ。 \stopbuffer
\rm \getbuffer
\page
\ss \getbuffer
\stoptext ```
I got all the fonts available in my computer, but the generated pdf contains only the Latin part. Just few numbers: 873684694. I don't know what I am doing incorrectly here.
Would anyone be able to help me out? I eventually want to make a document which has multiple scripts in it with English as main language.
I tried skipping some of the pdfs at https://wiki.contextgarden.net/Documentation, but am not sure if I missed the relevant section.
Thanks. ___________________________________________________________________________________ If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net ___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror) archive : https://github.com/contextgarden/context wiki : https://wiki.contextgarden.net ___________________________________________________________________________________
On 1/7/2026 10:01 PM, Jeong Dal via ntg-context wrote:
Hi,
I made a list of 4-dimensional vectors using the following code.
\startluacode local matT = {{0,0,1,1/3},{1,0,0,1/3},{0,1/2,0,1/3},{0,1/2,0,0}} local matOld = {{1/4},{1/4},{1/4},{1/4}} local matNew = {} local matHistory = {} table.insert(matHistory, matOld)
for i = 2, 15 do matOld = matHistory[i-1] matNew = mtx.product(matT, matOld) -- mtx.typeset(matT)context("\\times")mtx.typeset(matOld) -- context(" = ") mtx.typeset(matNew) context("\\blank") table.insert(matHistory, matNew) end \stopluacode
I’d like to draw a line graph of the data in matHistory to show the change of each component of 4-dimensional vectors.
How can I draw it in LuaMetaFun?
In the manual, data is already given in the example.
which example are you referring to
How can bring the data made in lua to ConTeXt?
userdata.yourdata = matHistory and then access that with lua calls Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
Dear Hans, Thank you for your reply.
In the manual, data is already given in the example.
which example are you referring to
I mean the example in the Axis section like this: list = { [ connect = true, color = "darkred", close = true, points = { (1, 1), (15, 8), (2, 10) }, texts = { "segment 1", "segment 2", "segment 3" } ],
How can bring the data made in lua to ConTeXt?
userdata.yourdata = matHistory
and then access that with lua calls
OK. I will try to save it in lua and reload it into MetaFun. I remember a similar method and a code which you helped me a year ago. I hope that I go a right way. Thanks again. Best regards,
Hi,
I tried the following code.
The lua code part has no problem.
The data is saved well.
I’d like to make an array of points (i, MP.data[i][1])
But I couldn’t retrieve the data as a point.
Before for loop, it said no complaints.
It gives an error message as following:
***************
error: Missing ')' has been inserted
metafun > log >
metapost > trace > <to be read again> ,
metapost > trace >
On 1/8/2026 9:27 PM, Jeong Dal via ntg-context wrote:
\usemodule[m-matrix] \startluacode mtx = moduledata.matrix \stopluacode
this gives a warning so what you want is
\starttext \startluacode
local mtx = moduledata.matrix
local matT = {{0,0,1,1/3},{1,0,0,1/3},{0,1/2,0,1/3},{0,1/2,0,0}} local matOld = {{1/4},{1/4},{1/4},{1/4}} local matNew = {} local matHistory = {} table.insert(matHistory, matOld) for i = 2, 5 do matOld = matHistory[i-1] matNew = mtx.product(matT, matOld) mtx.typeset(matT)context("\\times")mtx.typeset(matOld) context(" = ") mtx.typeset(matNew) context("\\blank") table.insert(matHistory, matNew) end table.save("tempList.lua", matHistory) \stopluacode
\startMPcode numeric u,i,j; u := 1cm;
pair A[]; path p; lua("MP = { } MP.data = table.load('tempList.lua')") ; for i = 1 upto 3: j := i*u; A[i] := (decimal j,lua("MP.data[" & decimal i & "][1]")); label(textext("A"),A[i]); endfor; \stopMPcode \stoptext
your "decimal j" makes string while a number is expected here mp.print is clever enough to return a number \startMPcode numeric u; u := 1cm; lua("MP = { } MP.data = table.load('tempList.lua')") ; for i = 1 upto 3: label(textext("A"),( i*u, lua("mp.print(MP.data[" & decimal i & "][1])") )); message(lua("mp.print(MP.data[" & decimal i & "][1])")); endfor; \stopMPcode ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
Dear Hans, Thank you for the correction.
your "decimal j" makes string while a number is expected
here mp.print is clever enough to return a number
label(textext("A"),( i*u, lua("mp.print(MP.data[" & decimal i & "][1])") )); message(lua("mp.print(MP.data[" & decimal i & "][1])"));
Now I got the working code. It calculates the list of 4-dimensional vectors and draw a line graph which shows the change of each component of vectors. Here is the code. There may be several points which can be written more nicely. Thanks again. Best regards, Dalyoung \startluacode local matT = {{0,0,1,1/3},{1,0,0,1/3},{0,1/2,0,1/3},{0,1/2,0,0}} local matOld = {{1/4},{1/4},{1/4},{1/4}} local matNew = {} local matHistory = {} table.insert(matHistory, matOld) for i = 1, 15 do matOld = matHistory[i] matNew = mtx.product(matT, matOld) if (i < 5) or (i==14) then context("${\\mathbf P_{"..tostring(i).."} = }$") mtx.typeset(matT)context("\\times")mtx.typeset(matOld) context(" = ") mtx.typeset(matNew) context("\\blank") end table.insert(matHistory, matNew) end table.save("tempList.lua", matHistory) \stopluacode \startplacefigure[reference=fig:PR,title={PageRank 값의 변화}] {\startMPcode numeric u, yy; u := 1cm; pair A[]; path p; string prob; color myColor[]; myColor[1] := .7red; myColor[2] := .7blue; myColor[3] := .7green; myColor[4] := .7white; lua("MP = { } MP.data = table.load('tempList.lua')") ; for j = 1 upto 4: for i = 1 upto 15: yy := lua("mp.print(MP.data[" & decimal i & "][" & decimal j & "])"); A[i] := (i*.7u,yy*15u); % message(lua("mp.print(MP.data[" & decimal i & "][1])")); endfor; p := for i = 1 upto 14 : A[i] -- endfor A[15] ; prob := substring (0,6) of (decimal yy); label.rt(textext(char(64+j) & " " & prob),A[15]); draw p withpen pencircle scaled 1.5pt withcolor myColor[j]; drawpoints p;%[i]; endfor; \stopMPcode} \stopplacefigure
On 1/9/2026 11:37 PM, Jeong Dal via ntg-context wrote:
Dear Hans,
Thank you for the correction.
see below
your "decimal j" makes string while a number is expected
here mp.print is clever enough to return a number
label(textext("A"),( i*u, lua("mp.print(MP.data[" & decimal i & "][1])") )); message(lua("mp.print(MP.data[" & decimal i & "][1])"));
Now I got the working code. It calculates the list of 4-dimensional vectors and draw a line graph which shows the change of each component of vectors.
Here is the code. There may be several points which can be written more nicely.
Thanks again.
Best regards,
Dalyoung
\startluacode local matT = {{0,0,1,1/3},{1,0,0,1/3},{0,1/2,0,1/3},{0,1/2,0,0}} local matOld = {{1/4},{1/4},{1/4},{1/4}} local matNew = {} local matHistory = {} table.insert(matHistory, matOld) for i = 1, 15 do matOld = matHistory[i] matNew = mtx.product(matT, matOld) if (i < 5) or (i==14) then context("${\\mathbf P_{"..tostring(i).."} = }$") mtx.typeset(matT)context("\\times")mtx.typeset(matOld) context(" = ") mtx.typeset(matNew) context("\\blank") end table.insert(matHistory, matNew) end table.save("tempList.lua", matHistory) \stopluacode
\startplacefigure[reference=fig:PR,title={PageRank 값의 변화}] {\startMPcode numeric u, yy; u := 1cm; pair A[]; path p; string prob; color myColor[]; myColor[1] := .7red; myColor[2] := .7blue; myColor[3] := .7green; myColor[4] := .7white;
lua("MP = { } MP.data = table.load('tempList.lua')") ; for j = 1 upto 4: for i = 1 upto 15: yy := lua("mp.print(MP.data[" & decimal i & "][" & decimal j & "])"); A[i] := (i*.7u,yy*15u); % message(lua("mp.print(MP.data[" & decimal i & "][1])")); endfor; p := for i = 1 upto 14 : A[i] -- endfor A[15] ; prob := substring (0,6) of (decimal yy); label.rt(textext(char(64+j) & " " & prob),A[15]); draw p withpen pencircle scaled 1.5pt withcolor myColor[j]; drawpoints p;%[i]; endfor; \stopMPcode} \stopplacefigure
You have to be more careful here; you do MP = { } which overloaded an official global namespace. That will backfire at some point. You still have mtx as global alias without testing if it exists. Don't do that, because one never knows if context itself will use that namespace (ctx, mtx ...). Basically we don't expect users or modules to define global tables at all, and if they to one has it coming. Just use userdata or moduledata (with subtable) or so. I'm not going to rewrite your code but here are a few suggestions: function MP.loadmydata(n) MP.mydata = table.load(n) end function MP.getmydata(i,j) mp.print(MP.mydata[i][j]) end and then % lua("MP = { } MP.data = table.load('tempList.lua')") ; lua.MP.loadmydata('tempList.lua') ; with % yy := lua("mp.print(MP.data[" & decimal i & "][" & decimal j & "])"); yy := lua.MP.getmydata(i,j); which gives you an easier way to check for instance of the data is ok or mess with it at the lua end. Watch how we accept ' as string delimiter ... by default luametafun is set up to accept ' and " as in lua. Hans ----------------------------------------------------------------- Hans Hagen | PRAGMA ADE Ridderstraat 27 | 8061 GH Hasselt | The Netherlands tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl -----------------------------------------------------------------
Dear Hans,
You have to be more careful here; you do
MP = { }
which overloaded an official global namespace. That will backfire at some point.
You still have mtx as global alias without testing if it exists. Don't do that, because one never knows if context itself will use that namespace (ctx, mtx ...). Basically we don't expect users or modules to define global tables at all, and if they to one has it coming. Just use userdata or moduledata (with subtable) or so.
I didn’t think it seriously. I changed ‘mix’ to ‘matOP’.
I'm not going to rewrite your code but here are a few suggestions:
function MP.loadmydata(n) MP.mydata = table.load(n) end
function MP.getmydata(i,j) mp.print(MP.mydata[i][j]) end
and then
% lua("MP = { } MP.data = table.load('tempList.lua')") ; lua.MP.loadmydata('tempList.lua') ;
with
% yy := lua("mp.print(MP.data[" & decimal i & "][" & decimal j & "])"); yy := lua.MP.getmydata(i,j);
It is easy to understand and works great! Thank you so much. Best regards, Dalyoung
participants (6)
-
hanneder@staff.uni-marburg.de -
Hans Hagen -
Jean-Pierre Delange -
Jeong Dal -
Julin S -
Wolfgang Schuster