Question

I have written this sample code in panda3d but I couldn't use right to left language and the letters shown separately. Is there a way to avoid that?

# coding=UTF-8

__author__ = 'asus'

from direct.showbase.ShowBase import ShowBase
from direct.task import Task
from direct.actor.Actor import Actor
from direct.gui.OnscreenText import OnscreenText

from direct.gui.DirectGui import *
from panda3d.core import TextNode

intro={'ssingle':'شروع بازی تک نفره',
        'smulti':'شروع بازی دو نفره',
        'settings':'تنظیمات',
        'about':'درباره بازی',
        'exit':'خروج',
        }

class World(ShowBase):
    def __init__(self):
        global intro
        i=0
        ShowBase.__init__(self)

        for each in intro.keys():
            i+=0.05
            OnscreenText(text = intro.__getitem__(each), pos = (0.95,i),scale = 0.07,fg=(1,0.5,0.5,1),align=TextNode.ACenter,mayChange=1,font=self.loader.loadFont('BRoya.ttf'))

a=World()
a.run()

No correct solution

OTHER TIPS

The used libraries are missing the Unicode BiDi support, Shaping...

The simplest but not the perfect, try with FriBiDi lib:

import pyfribidi2
.
.
OnscreenText(text = pyfribidi2.log2vis(intro.__getitem__(each), base_direction=pyfribidi2.ON), pos = (0.95,i),scale = 0.07,fg=(1,0.5,0.5,1),align=TextNode.ACenter,mayChange=1,font=self.loader.loadFont('BRoya.ttf'))

You may see also with base_direction=pyfribidi2.RTL

The latest development version of Panda3D 1.10 now supports right-to-left rendering, and proper shaping of Arabic text, if you compile it with support for the Harfbuzz library enabled.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top