diff options
| author | Michael R Sweet <michael.r.sweet@gmail.com> | 2001-11-27 17:44:08 +0000 |
|---|---|---|
| committer | Michael R Sweet <michael.r.sweet@gmail.com> | 2001-11-27 17:44:08 +0000 |
| commit | 2b85bf81680e2243ef5a5daf85d9eb04321c7278 (patch) | |
| tree | dc7d3e1cdbd44ed10b358412098b73d24b64d143 /src/fl_set_fonts_mac.cxx | |
| parent | 4dc5732a3e0f376786d1d6b788e5cf601439e890 (diff) | |
Preliminary commit of my MacOS X work.
**** THIS CODE COMPILES BUT DOES NOT WORK. ****
TODO: fix event handling - getting blank windows, etc.
TODO: re-port OpenGL code.
TODO: add support for images with alpha.
TODO: add support for more then just beeps in fl_beep().
TODO: other stuff I'm sure...
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@1765 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/fl_set_fonts_mac.cxx')
| -rw-r--r-- | src/fl_set_fonts_mac.cxx | 93 |
1 files changed, 93 insertions, 0 deletions
diff --git a/src/fl_set_fonts_mac.cxx b/src/fl_set_fonts_mac.cxx new file mode 100644 index 000000000..c7bf04203 --- /dev/null +++ b/src/fl_set_fonts_mac.cxx @@ -0,0 +1,93 @@ +// +// "$Id: fl_set_fonts_mac.cxx,v 1.1.2.1 2001/11/27 17:44:08 easysw Exp $" +// +// MacOS font utilities for the Fast Light Tool Kit (FLTK). +// +// Copyright 1998-2001 by Bill Spitzak and others. +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Library General Public License for more details. +// +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 +// USA. +// +// Please report all bugs and problems to "fltk-bugs@fltk.org". +// + +// This function fills in the fltk font table with all the fonts that +// are found on the X server. It tries to place the fonts into families +// and to sort them so the first 4 in a family are normal, bold, italic, +// and bold italic. + +#include <FL/Fl.H> +#include <FL/mac.H> +#include "Fl_Font.H" +#include <ctype.h> +#include <string.h> +#include <stdlib.h> + +// turn a stored font name into a pretty name: +const char* Fl::get_font_name(Fl_Font fnum, int* ap) { + const char* p = fl_fonts[fnum].name; + if (!p || !*p) {if (ap) *ap = 0; return "";} + int type; + switch (*p) { + case 'B': type = FL_BOLD; break; + case 'I': type = FL_ITALIC; break; + case 'P': type = FL_BOLD | FL_ITALIC; break; + default: type = 0; break; + } + if (!type) return p+1; + static char *buffer; if (!buffer) buffer = new char[128]; + strcpy(buffer, p+1); + if (type & FL_BOLD) strcat(buffer, " bold"); + if (type & FL_ITALIC) strcat(buffer, " italic"); + return buffer; +} + +static int fl_free_font = FL_FREE_FONT; +/* +static int CALLBACK enumcb(ENUMLOGFONT FAR *lpelf, + NEWTEXTMETRIC FAR *lpntm, int FontType, LPARAM p) { + if (!p && lpelf->elfLogFont.lfCharSet != ANSI_CHARSET) return 1; + char *n = (char*)(lpelf->elfFullName); + for (int i=0; i<FL_FREE_FONT; i++) // skip if one of our built-in fonts + if (!strcmp(Fl::get_font_name((Fl_Font)i),n)) return 1; + char buffer[128]; + strcpy(buffer+1, n); + buffer[0] = ' '; Fl::set_font((Fl_Font)(fl_free_font++), strdup(buffer)); + if (lpelf->elfLogFont.lfWeight <= 400) + buffer[0] = 'B', Fl::set_font((Fl_Font)(fl_free_font++), strdup(buffer)); + buffer[0] = 'I'; Fl::set_font((Fl_Font)(fl_free_font++), strdup(buffer)); + if (lpelf->elfLogFont.lfWeight <= 400) + buffer[0] = 'P', Fl::set_font((Fl_Font)(fl_free_font++), strdup(buffer)); + return 1; +} +*/ +Fl_Font Fl::set_fonts(const char* xstarname) { +#pragma unused ( xstarname ) +//++ EnumFontFamilies(fl_gc, NULL, (FONTENUMPROC)enumcb, xstarname != 0); + return (Fl_Font)fl_free_font; +} + +int Fl::get_font_sizes(Fl_Font fnum, int*& sizep) { +#pragma unused ( fnum ) + // pretend all fonts are scalable (most are and I don't know how + // to tell anyways) + static int array[1]; + sizep = array; + return 1; +} + +// +// End of "$Id: fl_set_fonts_mac.cxx,v 1.1.2.1 2001/11/27 17:44:08 easysw Exp $". +// |
