Modified Fl_Quartz_Graphics_Driver::width(unsigned int wc) so it handles properly

cases with wc > 0xFFFF.

git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8569 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Manolo Gouy 2011-04-07 07:51:26 +00:00
parent 8a830853bc
commit fc3ef2b0ea

View File

@ -374,9 +374,19 @@ double Fl_Quartz_Graphics_Driver::width(const char* txt, int n) {
}
double Fl_Quartz_Graphics_Driver::width(unsigned int wc) {
const UniChar uc = wc;
if (!font_descriptor()) font(FL_HELVETICA, FL_NORMAL_SIZE);
return fl_mac_width(&uc, 1, font_descriptor());
UniChar utf16[3];
int l = 1;
if (wc <= 0xFFFF) {
*utf16 = wc;
}
else {
char buf[4];
l = fl_utf8encode(wc, buf);
l = (int)fl_utf8toUtf16(buf, l, utf16, 3);
}
return fl_mac_width(utf16, l, font_descriptor());
}
// text extent calculation