~ubuntu-branches/ubuntu/karmic/fltk1.1/karmic

« back to all changes in this revision

Viewing changes to src/fl_set_fonts_mac.cxx

  • Committer: Bazaar Package Importer
  • Author(s): Aaron M. Ucko
  • Date: 2005-05-22 13:57:06 UTC
  • mfrom: (2.1.1 hoary)
  • Revision ID: james.westby@ubuntu.com-20050522135706-mchag24yf42lu7bu
Tags: 1.1.6-5
* Revert previous change, which seems to have been ineffective for some
  reason, in favor of commenting out the problematic Makefile rule
  altogether.  (Closes: #310151.)
* debian/control: Go back to specifying the URL as part of the
  description rather than via a non-standard field that doesn't seem to
  have caught on.  (Closes: #310240.)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
//
2
 
// "$Id: fl_set_fonts_mac.cxx,v 1.1.2.10 2004/04/11 04:39:00 easysw Exp $"
 
2
// "$Id: fl_set_fonts_mac.cxx,v 1.1.2.12 2004/09/09 00:55:41 matthiaswm Exp $"
3
3
//
4
4
// MacOS font utilities for the Fast Light Tool Kit (FLTK).
5
5
//
23
23
// Please report all bugs and problems to "fltk-bugs@fltk.org".
24
24
//
25
25
 
 
26
#include <config.h>
 
27
 
26
28
// This function fills in the fltk font table with all the fonts that
27
29
// are found on the X server.  It tries to place the fonts into families
28
30
// and to sort them so the first 4 in a family are normal, bold, italic,
36
38
 
37
39
// turn a stored font name into a pretty name:
38
40
const char* Fl::get_font_name(Fl_Font fnum, int* ap) {
 
41
#ifdef __APPLE_QD__
39
42
  Fl_Fontdesc *f = fl_fonts + fnum;
40
43
  if (!f->fontname[0]) {
41
44
    const char* p = f->name;
54
57
  }
55
58
  if (ap) *ap = f->fontname[ENDOFBUFFER];
56
59
  return f->fontname;
 
60
#elif defined(__APPLE_QUARTZ__)
 
61
  Fl_Fontdesc *f = fl_fonts + fnum;
 
62
  if (!f->fontname[0]) {
 
63
    const char* p = f->name;
 
64
    if (!p || !*p) {if (ap) *ap = 0; return "";}
 
65
    strlcpy(f->fontname, p, ENDOFBUFFER);
 
66
    int type = 0;
 
67
    if (strstr(f->name, "Bold")) type |= FL_BOLD;
 
68
    if (strstr(f->name, "Italic")) type |= FL_ITALIC;
 
69
    f->fontname[ENDOFBUFFER] = (char)type;
 
70
  }
 
71
  if (ap) *ap = f->fontname[ENDOFBUFFER];
 
72
  return f->fontname;
 
73
#endif
57
74
}
58
75
 
59
76
static int fl_free_font = FL_FREE_FONT;
60
77
 
61
78
Fl_Font Fl::set_fonts(const char* xstarname) {
62
79
#pragma unused ( xstarname )
 
80
#ifdef __APPLE_QD__
63
81
  if (fl_free_font != FL_FREE_FONT) 
64
82
    return (Fl_Font)fl_free_font;
65
83
  static char styleLU[] = " BIP";
107
125
  }
108
126
  FMDisposeFontFamilyIterator( &ffIterator );
109
127
  return (Fl_Font)fl_free_font;
 
128
#elif defined(__APPLE_QUARTZ__)
 
129
  ATSFontIterator it;
 
130
  ATSFontIteratorCreate(kATSFontContextGlobal, 0L, 0L, kATSOptionFlagsRestrictedScope, &it);  
 
131
  for (;;) {
 
132
    ATSFontRef font;
 
133
    CFStringRef fname = 0;
 
134
    OSStatus err = ATSFontIteratorNext(it, &font);
 
135
    if (err!=noErr) break;
 
136
    ATSFontGetName(font, kATSOptionFlagsDefault, &fname);
 
137
    char buf[1024];
 
138
    CFStringGetCString(fname, buf, 1024, kCFStringEncodingASCII);
 
139
    int i;
 
140
    for (i=0; i<FL_FREE_FONT; i++) // skip if one of our built-in fonts
 
141
      if (!strcmp(Fl::get_font_name((Fl_Font)i),buf)) break;
 
142
    if ( i < FL_FREE_FONT ) continue;
 
143
    Fl::set_font((Fl_Font)(fl_free_font++), strdup((char*)buf));
 
144
  }
 
145
  ATSFontIteratorRelease(&it);
 
146
  return (Fl_Font)fl_free_font;
 
147
#endif
110
148
}
111
149
 
112
150
static int array[128];
113
151
int Fl::get_font_sizes(Fl_Font fnum, int*& sizep) {
114
152
  Fl_Fontdesc *s = fl_fonts+fnum;
115
153
  if (!s->name) s = fl_fonts; // empty slot in table, use entry 0
 
154
  int cnt = 0;
116
155
 
 
156
#ifdef __APPLE_QD__
117
157
  Str255 name;
118
158
  int len = strlen( s->name );
119
159
  memcpy(((char*)name)+1, s->name+1, len );
141
181
  FMFontSize size, pSize = -1;
142
182
  FMFontFamilyInstanceIterator ffiIterator;
143
183
  FMCreateFontFamilyInstanceIterator( family, &ffiIterator );
144
 
  int cnt = 0;
145
184
  OSStatus listInstances;
146
185
  for (;;)
147
186
  {
157
196
    }
158
197
  }
159
198
  FMDisposeFontFamilyInstanceIterator( &ffiIterator );
 
199
#elif defined(__APPLE_QUARTZ__)
 
200
  // ATS supports all font size 
 
201
  array[0] = 0;
 
202
  sizep = array;
 
203
  cnt = 1;
 
204
#endif
160
205
 
161
206
  return cnt;
162
207
}
163
208
 
164
209
//
165
 
// End of "$Id: fl_set_fonts_mac.cxx,v 1.1.2.10 2004/04/11 04:39:00 easysw Exp $".
 
210
// End of "$Id: fl_set_fonts_mac.cxx,v 1.1.2.12 2004/09/09 00:55:41 matthiaswm Exp $".
166
211
//