summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2003-05-21 13:23:40 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2003-05-21 13:23:40 +0000
commit2549a4ad6285fe28341979b0a64f289feaedb531 (patch)
treef8847865ebaa22f74697269bb3a92d4f71b63c4e /src
parent340e84839e9a2b2d29c87e4f7f098a1cf7f370a8 (diff)
Map ISO-8859-1 to MacRoman encoding on OSX (temporary until 2.0's UTF-8
support...) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2992 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/fl_font_mac.cxx42
1 files changed, 39 insertions, 3 deletions
diff --git a/src/fl_font_mac.cxx b/src/fl_font_mac.cxx
index 285981e8e..fc593403d 100644
--- a/src/fl_font_mac.cxx
+++ b/src/fl_font_mac.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_font_mac.cxx,v 1.1.2.12 2003/04/06 12:54:57 easysw Exp $"
+// "$Id: fl_font_mac.cxx,v 1.1.2.13 2003/05/21 13:23:40 easysw Exp $"
//
// MacOS font selection routines for the Fast Light Tool Kit (FLTK).
//
@@ -153,11 +153,47 @@ double fl_width(uchar c) {
return (double)TextWidth( &c, 0, 1 );
}
+// MRS: The default character set is MacRoman, which is different from
+// ISO-8859-1; in FLTK 2.0 we'll use UTF-8 with Quartz...
+
+static uchar macroman_lut[256] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
+ 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
+ 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
+ 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
+ 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
+ 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
+ 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
+ 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
+ 128, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143,
+ 144, 145, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159,
+ 202, 193, 162, 163, 164, 180, 166, 164, 172, 169, 187, 199, 194, 173, 168, 248,
+ 161, 177, 178, 179, 171, 181, 166, 225, 252, 185, 188, 200, 188, 189, 190, 192,
+ 203, 231, 229, 204, 128, 129, 174, 130, 233, 131, 230, 232, 237, 234, 235, 236,
+ 208, 132, 241, 238, 239, 205, 133, 215, 175, 244, 242, 243, 134, 221, 222, 167,
+ 136, 135, 137, 139, 138, 140, 190, 141, 143, 142, 144, 145, 147, 146, 148, 149,
+ 240, 150, 152, 151, 153, 155, 154, 214, 191, 157, 156, 158, 159, 253, 254, 216
+};
+
void fl_draw(const char* str, int n, int x, int y) {
+ int i; // Looping var
+ uchar buf[1024], // Temporary buffer
+ *bufptr; // Pointer into buffer
+
+
+ // First convert string to MacRoman encoding...
+ if (n > sizeof(buf))
+ n = sizeof(buf);
+
+ for (i = n, bufptr = buf; i > 0; i --)
+ *bufptr++ = macroman_lut[*str++ & 255];
+
+ // Then draw it...
MoveTo(x, y);
- DrawText(str, 0, n);
+ DrawText((const char *)buf, 0, n);
}
+
//
-// End of "$Id: fl_font_mac.cxx,v 1.1.2.12 2003/04/06 12:54:57 easysw Exp $".
+// End of "$Id: fl_font_mac.cxx,v 1.1.2.13 2003/05/21 13:23:40 easysw Exp $".
//