[ wxwindows-Bugs-1910313 ] GetTextExtent wrong results for JP font
SourceForge.net
noreply at sourceforge.net
Sat Mar 8 17:54:46 PST 2008
Bugs item #1910313, was opened at 2008-03-08 17:54
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1910313&group_id=9863
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: wxMac specific
Group: Platform specific
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: David Whetstone (dwhetstone)
Assigned to: Stefan Csomor (csomor)
Summary: GetTextExtent wrong results for JP font
Initial Comment:
GetTextExtent() on wxMac 2.8.7 returns incorrect results for japanese and other similar fonts. The following code draws two strings, one in roman characters and another in japanese characters. Each string has a red rectangle drawn to its text extent. While the roman string is neatly encompassed by its rectangle, the rectangle for the japanese string falls far short. An image of the result is attached.
#include "wx/wx.h"
class TestFrame : public wxFrame
{
public:
TestFrame() : wxFrame(NULL, wxID_ANY, wxT("Test"))
{
}
void DrawString(wxDC& dc, const wxString & txt, int vOffset)
{
wxSize sz = GetClientSize();
wxSize ext = dc.GetTextExtent(txt);
int x = wxMax(0, (sz.x-ext.x)/2);
int y = wxMax(0, (sz.y-ext.y)/2) + vOffset;
dc.SetPen(*wxRED_PEN);
dc.DrawRectangle(x, y, ext.x, ext.y);
dc.SetPen(*wxBLACK_PEN);
dc.DrawText(txt, x, y);
}
void OnPaint(wxPaintEvent& event)
{
wxPaintDC dc(this);
wxFont font(24, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
font.SetNoAntiAliasing(true);
dc.SetFont(font);
DrawString(dc, wxT("ABCDE"), -25);
DrawString(dc, wxT("カタカナ ひらがな ローマ字"), 25);
}
private:
DECLARE_EVENT_TABLE()
};
BEGIN_EVENT_TABLE(TestFrame, wxFrame)
EVT_PAINT(TestFrame::OnPaint)
END_EVENT_TABLE()
class TestApp : public wxApp
{
public:
bool OnInit()
{
TestFrame * frame = new TestFrame();
frame->Show(true);
return true;
}
};
DECLARE_APP(TestApp)
IMPLEMENT_APP(TestApp)
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1910313&group_id=9863
More information about the wx-dev
mailing list