\documentclass{article}
\usepackage{luacode}
\usepackage{fontspec}
\setmainfont{Mongolian White}[Renderer=Harfbuzz,Script=Mongolian]
\begin{luacode*}
-- How do I do this in ConTeXt?
userdata = userdata or {}
userdata.mongolian = function(head)
rot = node.new(
node.id("whatsit"),node.subtype("pdf_literal"))
rot2 = node.new(
node.id("whatsit"),node.subtype("pdf_literal"))
for line in node.traverse_id(0,head) do
w = line.width/65536*0.99625
rot.data = "-1 0 0 -1 "..w.." 0 cm"
rot2.data = "-1 0 0 -1 "..-w.." 0 cm"
line.head = node.insert_before(line.head,line.head,node.copy(rot))
node.insert_after(line.head,node.tail(line.head),node.copy(rot2))
end
return head
end
\end{luacode*}
\def\startmongolian{\directlua{luatexbase.add_to_callback("post_linebreak_filter", userdata.mongolian, "mongolian")}}
\def\stopmongolian{%
\par\directlua{luatexbase.remove_from_callback("post_linebreak_filter", "mongolian")}%
}
\usepackage{graphicx}
\begin{document}
\rotatebox{90}{%
\parbox{8cm}{%
\startmongolian
\begin{flushleft}
ᠣᠢᠷᠠ ᠵᠢᠨ ᠡᠳᠦᠷ᠂ ᠦᠪᠦᠷ ᠮᠣᠩᠭᠣᠯ ᠦᠨ ᠰᠢᠯᠢ ᠵᠢᠨ ᠭᠣᠣᠯ ᠠᠢᠮᠠᠭ ᠦᠨ ᠰᠢᠯᠣᠭᠣᠨ ᠬᠦᠬᠡ ᠬᠣᠰᠢᠭᠣᠨ ᠦ ᠰᠢᠭᠦᠬᠦ ᠬᠣᠷᠢᠶᠠ ᠨᠢᠭᠡᠨ ᠬᠦᠴᠦᠷᠬᠡᠭᠯᠡᠨ ᠨᠦᠵᠢᠳᠯᠡᠭᠰᠡᠨ ᠶᠠᠯᠠᠲᠣ ᠬᠡᠷᠡᠭ ᠲᠦ ᠰᠢᠭᠦᠯᠲᠡ ᠬᠢᠪᠡ᠃ ᠰᠢᠭᠦᠨ ᠲᠠᠰᠣᠯᠣᠯᠳᠠ ᠪᠠᠷ᠂ ᠵᠠᠭᠠᠯᠳᠣᠭᠳᠠᠭᠴᠢ ᠡᠷᠬᠢᠮᠲᠦ ᠵᠢ ᠬᠦᠴᠦᠷᠭᠡᠭᠯᠡᠨ᠂ ᠨᠦᠵᠢᠳᠯᠡᠭᠰᠡᠨ ᠶᠡᠯᠡ ᠪᠡᠷ ᠭᠣᠷᠪᠠᠨ ᠵᠢᠯ ᠦᠨ ᠬᠣᠭᠣᠴᠠᠭᠠ ᠲᠠᠢ ᠬᠣᠷᠢᠬᠣ ᠡᠷᠡᠭᠦᠦ ᠪᠡᠷ ᠰᠢᠳᠬᠡᠭᠰᠡᠨ ᠪᠠᠢᠨᠠ᠃
\end{flushleft}
\stopmongolian
}
}
\end{document}
I can rotate boxes in ConTeXt using other methods than those used in LaTeX. However, my main concern is about "translating" the Lua(La)TeX piece to be used in ConTeXt. I've read about "finalizers" in the CLD manual and somewhere online, but I don't know how to access to node.subtype("pdf_literal"). I'll be happy to know about a better solution if ConTeXt offers it so it is accessible to other users. Thank you in advance.