summaryrefslogtreecommitdiff
path: root/src/fl_set_fonts_mac.cxx
diff options
context:
space:
mode:
authorBill Spitzak <spitzak@gmail.com>2003-03-09 00:22:20 +0000
committerBill Spitzak <spitzak@gmail.com>2003-03-09 00:22:20 +0000
commit5eb2576cfc612e5d720da13b85f7b88ab4e153ba (patch)
treed809aaee922a1d9e91975a0098a9642ecf8caa1c /src/fl_set_fonts_mac.cxx
parenteca1c6cc4cc350c5e5f232263b39db4ec5f7e87c (diff)
The attribute argument to Fl::get_font_name() was set correctly only
the first time it was called for a given font, otherwise it was left unchanged. Warning: only the X11 version has been tested! The Win32, Xft, and Mac versions (which are all identical to each other) probably work but I did not test them. Try the "fonts" demo. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@2948 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/fl_set_fonts_mac.cxx')
-rw-r--r--src/fl_set_fonts_mac.cxx20
1 files changed, 13 insertions, 7 deletions
diff --git a/src/fl_set_fonts_mac.cxx b/src/fl_set_fonts_mac.cxx
index 846b43ba1..5574e3f88 100644
--- a/src/fl_set_fonts_mac.cxx
+++ b/src/fl_set_fonts_mac.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: fl_set_fonts_mac.cxx,v 1.1.2.8 2003/01/30 21:44:16 easysw Exp $"
+// "$Id: fl_set_fonts_mac.cxx,v 1.1.2.9 2003/03/09 00:22:17 spitzak Exp $"
//
// MacOS font utilities for the Fast Light Tool Kit (FLTK).
//
@@ -28,6 +28,12 @@
// and to sort them so the first 4 in a family are normal, bold, italic,
// and bold italic.
+// Bug: older versions calculated the value for *ap as a side effect of
+// making the name, and then forgot about it. To avoid having to change
+// the header files I decided to store this value in the last character
+// of the font name array.
+#define ENDOFBUFFER 127 // sizeof(Fl_Font.fontname)-1
+
// turn a stored font name into a pretty name:
const char* Fl::get_font_name(Fl_Font fnum, int* ap) {
Fl_Fontdesc *f = fl_fonts + fnum;
@@ -41,12 +47,12 @@ const char* Fl::get_font_name(Fl_Font fnum, int* ap) {
case 'P': type = FL_BOLD | FL_ITALIC; break;
default: type = 0; break;
}
- if (ap) *ap = type;
- if (!type) return p+1;
- strlcpy(f->fontname, p+1, sizeof(f->fontname));
- if (type & FL_BOLD) strlcat(f->fontname, " bold", sizeof(f->fontname));
- if (type & FL_ITALIC) strlcat(f->fontname, " italic", sizeof(f->fontname));
+ strlcpy(f->fontname, p+1, ENDOFBUFFER);
+ if (type & FL_BOLD) strlcat(f->fontname, " bold", ENDOFBUFFER);
+ if (type & FL_ITALIC) strlcat(f->fontname, " italic", ENDOFBUFFER);
+ f->fontname[ENDOFBUFFER] = (char)type;
}
+ if (ap) *ap = f->fontname[ENDOFBUFFER];
return f->fontname;
}
@@ -156,5 +162,5 @@ int Fl::get_font_sizes(Fl_Font fnum, int*& sizep) {
}
//
-// End of "$Id: fl_set_fonts_mac.cxx,v 1.1.2.8 2003/01/30 21:44:16 easysw Exp $".
+// End of "$Id: fl_set_fonts_mac.cxx,v 1.1.2.9 2003/03/09 00:22:17 spitzak Exp $".
//