Issue #61 wontfix

Arabic isn't shown correctly

illume
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 :

http://i.imgur.com/RbpJZ.png

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 :

http://i.imgur.com/pHqqt.png

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 :

http://i.imgur.com/j1TV5.png }}}


Comments (4)

  1. 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.

  2. illume 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.

  3. Sami Al-Muhammady

    Try using python-fribidi from : https://github.com/behnam/python-fribidi 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 : http://projects.arabeyes.org/project.php?proj=Khotot

    http://i.imgur.com/dZQqF.png

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