GetFullTextExtent width for Arabic font

Hi all.

I am at the first steps with wxPython and got a problem with Arabic fonts.

In the following example the GetFullTextExtent return me a wrong width and i do not understand why.

Hope someone may help me.

···

----------------------

#!/usr/bin/python
# -*- coding: utf-8 -*-

import wx
class Test(wx.App):
         def OnInit(self):
                 rec='\xd8\xa7\xd9\x84\xd8\xa8\xd8\xb7\xd8\xa7\xd9\x86\xd8\xa9'
                 f=wx.Font(40,wx.DEFAULT,wx.FONTWEIGHT_LIGHT,wx.NORMAL,False,"Times New Roman")
                 i=wx.EmptyBitmap(width=1680,height=1050,depth=-1)
                 memory=wx.MemoryDC()
                 memory.SelectObject(i)
                 memory.Clear()
                 memory.SetFont(f)
                 width,height,desc,x=memory.GetFullTextExtent(rec)
    i2=wx.EmptyBitmap(width=w,height=h,depth=-1)
                 memory2=wx.MemoryDC()
                 memory2.SelectObject(i2)
                 memory2.Clear()
                 memory2.SetFont(f)
                 memory2.DrawText(rec,0,0)
                 memory2.SelectObject(wx.NullBitmap)
                 i2.SaveFile("Pix.bmp", wx.BITMAP_TYPE_BMP)
                 return(True)

app=Test(0)
app.MainLoop()

I am using Python 2.5.1, wxPython 2.8.4.0 (mac-unicode) on MAC intel 10.5.3

Yes, sorry, this is the working code:

#!/usr/bin/python

-- coding: utf-8 --

import wx

#import cx_Oracle

class Test(wx.App):

def OnInit(self):

	rec='\xd8\xa7\xd9\x84\xd8\xa8\xd8\xb7\xd8\xa7\xd9\x86\xd8\xa9'

	f=wx.Font(40,wx.FONTFAMILY_ROMAN,wx.FONTWEIGHT_LIGHT,wx.FONTSTYLE_NORMAL,False,"Times New Roman")

	memory=wx.MemoryDC()

	i=wx.EmptyBitmap(width=1680,height=1050,depth=-1)

	memory.SelectObject(i)

	memory.Clear()

	width,height,desc,x=memory.GetFullTextExtent(rec,font=f)

	memory.SelectObject(wx.NullBitmap);

	i2=wx.EmptyBitmap(width= width,height=height,depth=-1)

	memory2=wx.MemoryDC()

	memory2.SelectObject(i2)

	memory2.Clear()

	memory2.SetFont(f)

	memory2.DrawText(rec,0,0)

	memory2.SelectObject(wx.NullBitmap)

	i2.SaveFile("Pix4.bmp", wx.BITMAP_TYPE_BMP)

	return(True)

app=Test(0)

app.MainLoop()

···

Il giorno 10/giu/08, alle ore 21:20, Robin Dunn ha scritto:

Renzo Bertocchi wrote:

Hi all.
I am at the first steps with wxPython and got a problem with Arabic fonts.
In the following example the GetFullTextExtent return me a wrong width and i do not understand why.

Platform and version?

There are a few bugs in your code. Does it actually run for you? Perhaps it isn’t and you are actually looking at a bitmap saved by an older version of your app? If not, does it make any difference if you don’t specify the face name for the font?


Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!


wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Il contenuto della presente comunicazione è riservato e destinato esclusivamente ai destinatari indicati. Nel caso in cui sia ricevuto da persona diversa dal destinatario sono proibite la diffusione, la distribuzione e la copia. Nel caso riceveste la presente per errore, Vi preghiamo di informarci e di distruggerlo e/o cancellarlo dal Vostro computer, senza utilizzare i dati contenuti. La presente comunicazione (comprensiva dei documenti allegati) non avrà valore di proposta contrattuale e/o accettazione di proposte provenienti dal destinatario, nè rinuncia o riconoscimento di diritti, debiti e/o crediti, nè sarà impegnativa, qualora non sia sottoscritto successivo accordo da chi può validamente obbligarci. Non deriverà alcuna responsabilità precontrattuale a ns. carico, se la presente non sia seguita da contratto sottoscritto dalle parti.

No differences with wx version 2.8.7.1 (mac-unicode), GetFullTextExtent return always a wrong width.

···

Il giorno 12/giu/08, alle ore 19:03, Robin Dunn ha scritto:

Renzo Bertocchi wrote:

I am using Python 2.5.1, wxPython 2.8.4.0 (mac-unicode) on MAC intel 10.5.3

Please try it with the newest wxPython.


Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!


wxpython-users mailing list
wxpython-users@lists.wxwidgets.org
http://lists.wxwidgets.org/mailman/listinfo/wxpython-users

Il contenuto della presente comunicazione è riservato e destinato esclusivamente ai destinatari indicati. Nel caso in cui sia ricevuto da persona diversa dal destinatario sono proibite la diffusione, la distribuzione e la copia. Nel caso riceveste la presente per errore, Vi preghiamo di informarci e di distruggerlo e/o cancellarlo dal Vostro computer, senza utilizzare i dati contenuti. La presente comunicazione (comprensiva dei documenti allegati) non avrà valore di proposta contrattuale e/o accettazione di proposte provenienti dal destinatario, nè rinuncia o riconoscimento di diritti, debiti e/o crediti, nè sarà impegnativa, qualora non sia sottoscritto successivo accordo da chi può validamente obbligarci. Non deriverà alcuna responsabilità precontrattuale a ns. carico, se la presente non sia seguita da contratto sottoscritto dalle parti.

Not sure if it is directly related but there was a recent (since 2.8.7) change to fix some issues with GetTextExtent when used with double width characters (Japanese, ect..). It looks like it was applied to both the trunk and 2.8 branch so it should be in for 2.8.8. Might be worth checking in one of the prerelease builds.

reference: wxTrac has been migrated to GitHub Issues - wxWidgets

cody

···

On Jun 13, 2008, at 3:59 PM, Robin Dunn wrote:

Renzo Bertocchi wrote:

No differences with wx version 2.8.7.1 (mac-unicode), GetFullTextExtent return always a wrong width.

Ok. Enter a bug report about it and if possible also specify exactly which font is being used that is causing the problems.