summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2011-04-07 07:51:26 +0000
committerManolo Gouy <Manolo>2011-04-07 07:51:26 +0000
commitfc3ef2b0ea90e0977fda2a47d318cdaf8b90f90d (patch)
tree8d880f2a1f37dfae91a85f0bfb1948cb802d8a05
parent8a830853bc8fd74896b5cab9f4b5d290ff48f86a (diff)
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
-rw-r--r--src/fl_font_mac.cxx14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/fl_font_mac.cxx b/src/fl_font_mac.cxx
index dfadfcb15..8941ceaa2 100644
--- a/src/fl_font_mac.cxx
+++ b/src/fl_font_mac.cxx
@@ -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