Using Arabic font in RNDR

I am trying to simulate making videos like minute Physics channel programmatically as best as I can. His style whiteboard animation. I am not looking to simulate it 100% of the way but one of the requirement I have is that some text should be rendered in Arabic script. As far as I found out RNDR Pre rendered glyphs does not recognize Arabic script.

any solution?

Hi, welcome to the forum! :slight_smile:

Is there anything useful for you in this thread?

I tried it but the solution is not working for me

I tried helping without having any idea of what I’m doing :slight_smile:

import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.loadFont

fun main() = application {
    program {
        val font = loadFont("data/fonts/Amiri-Regular.ttf", 100.0,
            characterSet = "أميري".toCharArray().toSet())

        backgroundColor = ColorRGBa.WHITE

        extend {
            drawer.fill = ColorRGBa.BLACK
            drawer.fontMap = font
            drawer.text("أميري".reversed(), 50.0, 200.0)
        }
    }
}

2021-03-11-103519_246x184_scrot

It’s obviously not working right, but maybe it helps you?

In the OPENRNDR home page I read under future plans:

Support for non-latin alphabets only cyrillic is currently implemented

How many arabic texts do you have in mind? You could work with SVG files…

1 Like

I could not avoid trying to find a workaround for this :slight_smile:

Assuming we have a simple SVG file with Arabic text, like this:

2021-03-13-103212_365x66_scrot

<?xml version="1.0" encoding="UTF-8"?>
<svg version="1.1" xmlns="http://www.w3.org/2000/svg">
<g><text x="10" y="50" font-size="52px">
<tspan font-family="Arial">لوحة المفاتيح العربية</tspan>
</text></g></svg>

we can run

inkscape --export-text-to-path --export-plain-svg --export-filename=traced.svg source.svg

which produces

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:cc="http://creativecommons.org/ns#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:svg="http://www.w3.org/2000/svg"
   xmlns="http://www.w3.org/2000/svg"
   version="1.1"
   id="svg8">
  <metadata
     id="metadata14">
    <rdf:RDF>
      <cc:Work
         rdf:about="">
        <dc:format>image/svg+xml</dc:format>
        <dc:type
           rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
      </cc:Work>
    </rdf:RDF>
  </metadata>
  <defs
     id="defs12" />
  <g
     id="g6">
    <g
       aria-label="لوحة المفاتيح العربية"
       id="text4"
       style="font-size:52px">
      <path
         d="m 353.63672,42.560547 h -12.54297 v -4.417969 h 9.97852 l -3.02149,-21.53125 -1.32031,-0.634765 q 0,-1.751954 0.30469,-3.275391 0.30468,-1.548828 0.91406,-2.9960939 l 0.38086,0.2792969 q 0,1.472656 1.65039,2.208984 1.26953,0.507813 2.56445,1.015625 0,1.269532 -0.20312,2.716797 -0.20313,1.447266 -0.48243,2.158203 l -1.21875,-0.40625 2.9961,19.90625 z"
         style="font-family:Arial"
         id="path16" />
      <path
         d="m 342.87109,41.037109 q 0,4.189453 -3.09765,8.328125 -3.45313,4.621094 -7.97266,4.621094 -1.67578,0 -3.45312,-0.380859 -1.29493,-0.279297 -3.37696,-0.964844 -1.65039,-0.583984 -3.30078,-1.142578 l 0.43164,-0.888672 q 1.42188,0.330078 2.97071,0.685547 1.57421,0.380859 2.81835,0.380859 3.09766,0 5.86524,-1.574219 2.1582,-1.24414 4.31641,-3.605468 1.09179,-1.19336 3.09765,-3.884766 -3.42773,0 -5.1289,-1.091797 -1.92969,-1.24414 -1.92969,-4.08789 0,-2.615235 1.21875,-4.84961 1.42187,-2.589844 3.60547,-2.589844 2.20898,0 3.17382,2.564454 0.76172,2.005859 0.76172,5.585937 z m -1.59961,-2.767578 q -0.55859,-2.4375 -1.3457,-3.376953 -0.68555,-0.8125 -1.67578,-0.8125 -0.71094,0 -1.24414,0.482422 -0.50781,0.457031 -0.50781,1.167969 0,1.24414 1.11718,1.904297 1.11719,0.634765 3.65625,0.634765 z"
         style="font-family:Arial"
         id="path18" />
      <path
         d="m 320.14648,42.560547 h -29.07226 v -4.417969 h 20.43945 q -2.58984,-2.005859 -4.36719,-3.123047 -2.20898,-1.396484 -4.03711,-2.03125 -2.05664,-0.710937 -4.16406,-0.710937 -1.29492,0 -2.61523,0.177734 0.73633,-1.878906 1.92969,-3.021484 1.72656,-1.650391 4.36718,-1.650391 2.58985,0 6.11914,2.539063 1.75196,1.269531 5.71289,4.824218 3.07227,2.767578 4.16407,2.996094 h 1.52343 z"
         style="font-family:Arial"
         id="path20" />
      <path
         d="m 286.42773,12.21875 -1.98046,3.65625 -4.11329,-2.183594 1.9043,-3.630859 z m -5.83984,2.285156 -1.92969,3.681641 -4.11328,-2.132813 1.87891,-3.68164 z m 12.26367,28.056641 h -3.63086 q -1.82812,0 -3.22461,-3.123047 -1.04101,-2.335938 -1.67578,-6.017578 -0.76172,1.421875 -1.92969,2.208984 -1.16796,0.78711 -2.46289,0.78711 -2.91992,0 -4.875,-0.38086 -1.92968,-0.40625 -1.92968,-1.015625 0,-2.183594 2.84375,-4.824219 2.84375,-2.666015 7.10937,-4.646484 -0.0508,-0.203125 -0.22851,-1.066406 -0.15235,-0.863281 -0.15235,-1.066406 0,-0.863282 0.58399,-1.929688 0.48242,-0.863281 1.26953,-1.777344 0.2539,1.574219 0.50781,3.046875 0.2793,1.472657 0.63477,3.046875 l 0.76171,4.367188 q 0.63477,3.605469 1.14258,5.332031 0.78711,2.640625 1.625,2.640625 h 3.63086 z m -8.86133,-11.34961 -0.48242,-2.767578 q -2.20898,0.78711 -3.47851,1.650391 -1.26953,0.837891 -2.13282,2.234375 0.53321,0.228516 1.24414,0.355469 0.71094,0.126953 1.95508,0.126953 1.52344,0 2.89453,-1.59961 z"
         style="font-family:Arial"
         id="path22" />
      <path
         d="m 254.94336,36.085937 q 0,2.03125 -0.73633,3.935547 -0.38086,1.015625 -1.65039,3.22461 l -0.45703,-0.253907 q 0.0762,-0.736328 0.12695,-1.701171 0.0762,-0.964844 0.0762,-1.294922 0,-2.640625 -0.43164,-7.363282 -0.40625,-4.748046 -0.99023,-9.902343 -0.35547,-3.123047 -0.78711,-6.373047 0.50781,-1.117188 1.14258,-2.412109 0.66015,-1.294922 1.24414,-2.4375 0.40625,2.894531 1.01562,7.921874 0.63477,5.027344 0.99024,9.064454 0.45703,5.027343 0.45703,7.591796 z"
         style="font-family:Arial"
         id="path24" />
      <path
         d="M 248.13867,42.560547 H 235.5957 v -4.417969 h 9.97852 l -3.02149,-21.53125 -1.32031,-0.634765 q 0,-1.751954 0.30469,-3.275391 0.30469,-1.548828 0.91406,-2.9960939 l 0.38086,0.2792969 q 0,1.472656 1.65039,2.208984 1.26953,0.507813 2.56445,1.015625 0,1.269532 -0.20312,2.716797 -0.20313,1.447266 -0.48242,2.158203 l -1.21875,-0.40625 2.99609,19.90625 z"
         style="font-family:Arial"
         id="path26" />
      <path
         d="m 237.37305,42.560547 h -2.64063 q -1.70117,0 -3.83398,-0.761719 -2.46289,-0.888672 -4.3418,-2.4375 -1.47266,1.802734 -3.02148,2.513672 -1.52344,0.685547 -4.46875,0.685547 h -3.96094 v -4.417969 h 3.88476 q 2.31055,0 4.11329,-1.167969 1.39648,-0.914062 2.53906,-2.564453 1.54883,-2.234375 3.80859,-3.884765 2.03125,-1.472657 3.73242,-1.878907 1.75196,2.666016 2.79297,4.798828 1.39649,2.894532 1.39649,4.697266 z m -2.91993,-5.001953 q -0.33007,-1.472657 -1.01562,-2.894532 -0.58398,-1.193359 -1.54883,-2.46289 -1.21875,0.304687 -2.05664,1.142578 -0.55859,0.533203 -1.32031,1.802734 0.91406,0.990235 2.56445,1.777344 1.67578,0.787109 3.14844,0.964844 z"
         style="font-family:Arial"
         id="path28" />
      <path
         d="m 214.67383,15.595703 -2.23438,3.65625 -3.55468,-2.4375 2.10742,-3.554687 z m 2.20898,26.964844 h -15.4375 v -4.417969 h 8.70899 q 1.57422,0 2.66601,-0.101562 1.11719,-0.126954 2.41211,-0.507813 -4.36719,-0.634766 -5.66211,-1.193359 -2.91992,-1.269532 -2.91992,-4.316407 0,-2.666015 1.39648,-5.027343 1.57422,-2.666016 3.83399,-2.666016 2.58984,0 3.93555,3.300781 1.0664,2.615235 1.0664,6.169922 z m -2.28515,-8.861328 q -0.58399,-2.03125 -1.11719,-3.021485 -1.04102,-1.904297 -2.51367,-1.904297 -0.71094,0 -1.21875,0.558594 -0.50782,0.558594 -0.50782,1.320313 0,1.929687 2.00586,2.589843 0.71094,0.228516 3.35157,0.457032 z"
         style="font-family:Arial"
         id="path30" />
      <path
         d="m 203.22266,42.560547 h -3.55469 q -1.72656,0 -2.76758,-1.396485 -0.91406,-1.21875 -1.39648,-3.630859 -0.45704,-2.412109 -0.71094,-5.941406 -0.15235,-2.869141 -0.33008,-5.890625 -0.15234,-3.021485 -0.43164,-4.570313 -0.25391,-1.574218 -0.71094,-2.564453 -0.55859,-1.21875 -1.54883,-2.132812 l 3.12305,-4.925781 q 0.99024,3.046875 1.39649,7.287109 0.2539,2.640625 0.50781,12.492187 0.45703,4.519532 1.32031,5.789063 0.71094,1.066406 1.54883,1.066406 h 3.55469 z"
         style="font-family:Arial"
         id="path32" />
      <path
         d="m 189.63867,17.474609 -1.98047,3.65625 -4.11328,-2.183593 1.9043,-3.63086 z m -5.83984,2.285157 -1.92969,3.68164 -4.11328,-2.132812 1.87891,-3.681641 z m 7.49023,22.800781 h -14.47265 v -4.417969 h 12.61914 q 0,-2.996094 -0.71094,-4.570312 -0.48242,-1.091797 -2.38672,-3.148438 l 1.98047,-4.138672 q 1.82812,2.310547 2.28516,3.605469 0.68554,1.955078 0.68554,6.474609 z"
         style="font-family:Arial"
         id="path34" />
      <path
         d="m 178.59375,42.560547 h -14.47266 v -4.417969 h 12.61914 q 0,-2.996094 -0.71093,-4.570312 -0.48243,-1.091797 -2.38672,-3.148438 l 1.98047,-4.138672 q 1.82812,2.310547 2.28515,3.605469 0.68555,1.955078 0.68555,6.474609 z m -0.12695,5.078125 -1.98047,3.65625 -4.11328,-2.183594 1.90429,-3.630859 z m -5.83985,2.285156 -1.92968,3.681641 -4.11329,-2.132813 1.87891,-3.68164 z"
         style="font-family:Arial"
         id="path36" />
      <path
         d="m 165.89844,42.560547 h -5.25586 q -3.07227,0 -4.36719,-1.142578 -1.29492,-1.142578 -1.29492,-3.783203 0,-0.990235 0.2539,-2.462891 0.10157,-0.558594 0.2793,-1.472656 -4.3418,1.320312 -6.55078,2.259765 -4.0625,1.726563 -6.29687,3.910157 -2.81836,2.742187 -2.81836,6.246093 0,5.458985 5.6875,8.201172 4.95117,2.386719 13.22851,2.386719 h 4.67188 l 0.15234,0.279297 -5.73828,4.037109 h -1.47266 q -5.48437,0 -9.11523,-1.015625 -4.3418,-1.21875 -6.57617,-3.910156 -2.53907,-3.072266 -2.53907,-8.125 0,-4.341797 2.15821,-7.591797 1.67578,-2.539062 4.90039,-4.646484 0.93945,-0.634766 5.23047,-2.919922 -1.01563,-0.126953 -2.15821,-0.203125 -1.11718,-0.101563 -2.03125,-0.101563 -2.56445,0 -4.16406,0.228516 -0.5332,0.07617 -3.32617,0.685547 0.86328,-2.488281 1.80273,-3.453125 2.10743,-2.132813 6.60157,-2.132813 2.46289,0 5.33203,0.482422 2.86914,0.457031 4.82422,0.457031 1.29492,0 2.51367,-0.101562 1.24414,-0.101563 2.58984,-0.279297 l -1.01562,4.316406 q -1.04102,0.126953 -2.36133,0.355469 -0.83789,0.152344 -2.31055,0.431641 l -0.0508,1.421875 q 0,2.082031 1.26953,2.792968 0.78711,0.431641 2.69141,0.431641 h 5.25586 z"
         style="font-family:Arial"
         id="path38" />
      <path
         d="m 120.14453,36.085937 q 0,2.03125 -0.73633,3.935547 -0.38086,1.015625 -1.65039,3.22461 l -0.45703,-0.253907 q 0.0762,-0.736328 0.12695,-1.701171 0.0762,-0.964844 0.0762,-1.294922 0,-2.640625 -0.43164,-7.363282 -0.40625,-4.748046 -0.99024,-9.902343 -0.35547,-3.123047 -0.78711,-6.373047 0.50781,-1.117188 1.14258,-2.412109 0.66016,-1.294922 1.24414,-2.4375 0.40625,2.894531 1.01563,7.921874 0.63476,5.027344 0.99023,9.064454 0.45703,5.027343 0.45703,7.591796 z"
         style="font-family:Arial"
         id="path40" />
      <path
         d="m 113.33984,42.560547 h -12.54296 v -4.417969 h 9.97851 l -3.02148,-21.53125 -1.32032,-0.634765 q 0,-1.751954 0.30469,-3.275391 0.30469,-1.548828 0.91406,-2.9960939 l 0.38086,0.2792969 q 0,1.472656 1.65039,2.208984 1.26954,0.507813 2.56446,1.015625 0,1.269532 -0.20313,2.716797 -0.20312,1.447266 -0.48242,2.158203 l -1.21875,-0.40625 2.99609,19.90625 z"
         style="font-family:Arial"
         id="path42" />
      <path
         d="m 102.57422,42.560547 h -3.732423 q -1.650391,0 -3.351563,-0.78711 -2.03125,-0.939453 -2.945312,-2.615234 -1.701172,1.523438 -3.884766,2.361328 -2.666015,1.041016 -6.068359,1.041016 h -2.285156 v -4.417969 h 2.285156 q 2.132812,0 3.960937,-0.457031 2.082032,-0.533203 4.087891,-1.701172 l -1.066406,-1.371094 q -0.8125,-0.964844 -1.828125,-0.964844 -0.457032,0 -0.8125,0.177735 -0.355469,0.152344 -0.78711,0.710937 h -0.533203 v -1.498047 q 0,-2.792968 1.472656,-3.833984 1.345704,-0.939453 4.671875,-0.939453 2.869141,0 4.671875,0.761719 2.361329,0.990234 2.361329,3.046875 0,1.091797 -0.939454,2.259765 -0.685546,0.863282 -2.513671,2.386719 0.40625,0.609375 1.548828,1.015625 1.167968,0.40625 1.955078,0.40625 h 3.732423 z"
         style="font-family:Arial"
         id="path44" />
      <path
         d="m 82.083984,42.560547 q 0,2.792969 -2.386718,5.789062 -2.082032,2.640625 -5.179688,4.544922 -2.945312,1.828125 -4.849609,1.828125 -1.751953,0 -3.783203,-0.507812 -1.548829,-0.38086 -3.707032,-1.19336 -1.828125,-0.685547 -3.630859,-1.371093 l 0.431641,-1.015625 q 1.675781,0.330078 3.478515,0.660156 1.828125,0.355469 3.300781,0.355469 3.25,0 6.779297,-2.082032 3.199219,-1.904297 5.458985,-4.798828 2.259765,-2.919922 2.259765,-5.255859 0,-2.00586 -1.167968,-4.214844 -0.939454,-1.777344 -2.640625,-3.65625 l 1.447265,-3.986328 q 2.082031,1.929687 3.072266,3.859375 1.117187,2.183594 1.117187,4.875 z"
         style="font-family:Arial"
         id="path46" />
      <path
         d="M 56.667969,42.560547 H 42.195312 v -4.417969 h 12.619141 q 0,-2.996094 -0.710937,-4.570312 -0.482422,-1.091797 -2.386719,-3.148438 l 1.980469,-4.138672 q 1.828125,2.310547 2.285156,3.605469 0.685547,1.955078 0.685547,6.474609 z m -2.589844,6.169922 -1.980469,3.68164 -4.113281,-2.132812 1.878906,-3.707031 z"
         style="font-family:Arial"
         id="path48" />
      <path
         d="M 43.972656,42.560547 H 29.5 v -4.417969 h 12.619141 q 0,-2.996094 -0.710938,-4.570312 -0.482422,-1.091797 -2.386719,-3.148438 l 1.980469,-4.138672 q 1.828125,2.310547 2.285156,3.605469 0.685547,1.955078 0.685547,6.474609 z m -0.126953,5.078125 -1.980469,3.65625 -4.113281,-2.183594 1.904297,-3.630859 z m -5.839844,2.285156 -1.929687,3.681641 -4.113281,-2.132813 1.878906,-3.68164 z"
         style="font-family:Arial"
         id="path50" />
      <path
         d="m 24.853516,12.21875 -1.980469,3.65625 -4.113281,-2.183594 1.904296,-3.630859 z m -5.839844,2.285156 -1.929688,3.681641 -4.113281,-2.132813 1.878906,-3.68164 z m 12.263672,28.056641 h -3.63086 q -1.828125,0 -3.224609,-3.123047 -1.041016,-2.335938 -1.675781,-6.017578 -0.761719,1.421875 -1.929688,2.208984 -1.167969,0.78711 -2.46289,0.78711 -2.919922,0 -4.875,-0.38086 -1.929688,-0.40625 -1.929688,-1.015625 0,-2.183594 2.84375,-4.824219 2.84375,-2.666015 7.109375,-4.646484 -0.05078,-0.203125 -0.228516,-1.066406 -0.152343,-0.863281 -0.152343,-1.066406 0,-0.863282 0.583984,-1.929688 0.482422,-0.863281 1.269531,-1.777344 0.253907,1.574219 0.507813,3.046875 0.279297,1.472657 0.634765,3.046875 l 0.761719,4.367188 q 0.634766,3.605469 1.142578,5.332031 0.78711,2.640625 1.625,2.640625 h 3.63086 z m -8.861328,-11.34961 -0.482422,-2.767578 q -2.208985,0.78711 -3.478516,1.650391 -1.269531,0.837891 -2.132812,2.234375 0.533203,0.228516 1.24414,0.355469 0.710938,0.126953 1.955078,0.126953 1.523438,0 2.894532,-1.59961 z"
         style="font-family:Arial"
         id="path52" />
    </g>
  </g>
</svg>

Both the original svg and the traced svg look the same. In the first one the text is selectable, in the second one the text has been converted to curves.

It would not be hard to create a script to convert all lines from a text file into separate curve-based svg files, which could then be loaded into any tool that can render SVG files, for example OPENRNDR.

Or even better, create a class in OPENRNDR which calls inkscape and caches the produced svg file. Something like:

val text1 = TracedText("لوحة المفاتيح العربية")
...
drawer.composition(text1)
1 Like

this is awesome brother. thank you.