<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.luatex.org/index.php?action=history&amp;feed=atom&amp;title=Mirror_characters_with_Bidi_Mirrored_property</id>
	<title>Mirror characters with Bidi Mirrored property - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.luatex.org/index.php?action=history&amp;feed=atom&amp;title=Mirror_characters_with_Bidi_Mirrored_property"/>
	<link rel="alternate" type="text/html" href="https://wiki.luatex.org/index.php?title=Mirror_characters_with_Bidi_Mirrored_property&amp;action=history"/>
	<updated>2026-05-10T22:35:57Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.31.1</generator>
	<entry>
		<id>https://wiki.luatex.org/index.php?title=Mirror_characters_with_Bidi_Mirrored_property&amp;diff=33&amp;oldid=prev</id>
		<title>Patrick: Copied from the old bluwiki.com luatex wiki</title>
		<link rel="alternate" type="text/html" href="https://wiki.luatex.org/index.php?title=Mirror_characters_with_Bidi_Mirrored_property&amp;diff=33&amp;oldid=prev"/>
		<updated>2010-12-07T21:23:34Z</updated>

		<summary type="html">&lt;p&gt;Copied from the old bluwiki.com luatex wiki&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;This example code for mirroring characters that has Bidi_Mirrored property (as defined by Unicode) in RTL contexts. It uses characters.data table defined in [http://source.contextgarden.net/tex/context/base/char-def.lua char-def.lua] file from ConTeXt distribution to get character properties.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dofile(&amp;quot;char-def.lua&amp;quot;) -- character definition table&lt;br /&gt;
&lt;br /&gt;
local function mirror(hlist)&lt;br /&gt;
  local rtl = false&lt;br /&gt;
  if tex.textdir == &amp;quot;TRT&amp;quot; then&lt;br /&gt;
    rtl = true&lt;br /&gt;
  elseif tex.textdir == &amp;quot;TLT&amp;quot; then&lt;br /&gt;
    rtl = false&lt;br /&gt;
  end&lt;br /&gt;
  for n in node.traverse(hlist) do&lt;br /&gt;
    if n.id == node.id(&amp;#039;hlist&amp;#039;) then&lt;br /&gt;
      mirror(n.list)&lt;br /&gt;
    end&lt;br /&gt;
    if n.id == node.id(&amp;quot;whatsit&amp;quot;) and n.subtype == 7 then&lt;br /&gt;
      if n.dir == &amp;quot;+TRT&amp;quot; or n.dir == &amp;quot;-TLT&amp;quot; then&lt;br /&gt;
        rtl = true&lt;br /&gt;
      elseif n.dir == &amp;quot;-TRT&amp;quot; or n.dir == &amp;quot;+TLT&amp;quot; then&lt;br /&gt;
        rtl = false&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
    if n.id == node.id(&amp;#039;glyph&amp;#039;) then&lt;br /&gt;
      if rtl then&lt;br /&gt;
      local char = n.char&lt;br /&gt;
      local mirror = characters.data[char].mirror&lt;br /&gt;
        if mirror then&lt;br /&gt;
          n.char = mirror&lt;br /&gt;
        end&lt;br /&gt;
      end&lt;br /&gt;
    end&lt;br /&gt;
  end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
callback.register(&amp;#039;pre_linebreak_filter&amp;#039;,&lt;br /&gt;
  function(h)&lt;br /&gt;
     mirror(h)&lt;br /&gt;
     return true&lt;br /&gt;
  end&lt;br /&gt;
  )&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Example usage:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
\directlua{dofile(&amp;quot;mirror.lua&amp;quot;)}&lt;br /&gt;
&lt;br /&gt;
(Left to right) {\textdir TRT (RIGHT TO LEFT)}&lt;br /&gt;
&lt;br /&gt;
\textdir TRT&lt;br /&gt;
&lt;br /&gt;
RIGHT [TO] LEFT (TEXT)&lt;br /&gt;
&lt;br /&gt;
\textdir TLT&lt;br /&gt;
&lt;br /&gt;
left [to] right (text)&lt;br /&gt;
\bye&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
--khaledhosny&lt;/div&gt;</summary>
		<author><name>Patrick</name></author>
		
	</entry>
</feed>