Arabic isn't shown correctly

Issue #61 wontfix
René Dudfield created an issue

== Mosaab Alzoubi, 2011-01-27 12:04:41 -0800

{{{ Arabic with Pygame isn't shown correctly . When writing like this :

mytxt = u"النقاط" font = pygame.font.Font(None, 36) score_txt = font.render(mytxt,1,(255,255,255))

The result is :

And when it used by Arbic font like this :

mytxt = u"النقاط" font = pygame.font.Font("KacstOne.ttf", 36) score_txt = font.render(mytxt,1,(255,255,255))

The result is :

I hope you fix this problem immediately . }}}

== James Paige, 2011-01-27 12:36:21 -0800

{{{ The first problem is that pygame's default font has no Arabic letters.

The second problem is that pygame doesn't support right-to-left text. So this problem affects all right-to-left languages, not just Arabic.

Do you get the right results if you manually reverse the string?

mytxt = u"النقاط" font = pygame.font.Font("KacstOne.ttf", 36) reversed = mytxt[::-1] score_txt = font.render(reversed,1,(255,255,255)) }}}

== Mosaab Alzoubi, 2011-01-27 14:16:00 -0800

{{{ when use reverse . it isn't shaped correctly : }}}

Comments (5)

  1. Lenard Lindstrom
    • changed status to open

    I don't know if SDL_ttf supports this. If there is the demand it can be added to freetype.

  2. Lenard Lindstrom

    Support for Arabic is more involved that just rendering strings right-to-left. It is too complex to implement directly in Pygame, being better handled by an external layout library.

  3. René Dudfield reporter

    To support all languages, we'd need to include a much larger font file, and changing files would break existing games.

    Layout of the text for right to left will have to be done by the user as well.

  4. Sami Al-Muhammady

    Try using python-fribidi from : It is work for me (In fedora Linux, but I did not try it on Windows) by using fonts support unicode arabic chars like Thabit.ttf from Arabeyes :

    #!/usr/bin/env python
    # coding=UTF-8
    import pygame
    from pygame.locals import *
    from fribidi import *
    import sys
    s = u'مرحبا بكم Welcome'
    txt = log2vis(s, None, ParType.RTL)
    screen = pygame.display.set_mode((640, 480))
    font = pygame.font.Font("Thabit.ttf", 35);
    while True:
    	for event in pygame.event.get():
    		if event.type == QUIT:
    	surf = font.render(txt,False,(0, 0, 0))
    	rect = surf.get_rect() = (300, 100)
    	screen.blit(surf, rect)
  5. Log in to comment