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

« back to all changes in this revision

Viewing changes to src/fl_font_xft.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_font_xft.cxx,v 1.4.2.13 2004/04/11 04:39:00 easysw Exp $"
 
2
// "$Id: fl_font_xft.cxx,v 1.4.2.16 2004/09/11 18:06:29 easysw Exp $"
3
3
//
4
4
// Xft font code for the Fast Light Tool Kit (FLTK).
5
5
//
60
60
// are several web pages of information on how to do this.
61
61
//
62
62
 
 
63
// kludge to pull in the Xlib code as a fallback
 
64
#define Fl_FontSize             Fl_Fontsize_xlib
 
65
#define fl_fontsize             fl_fontsize_xlib
 
66
#define Fl_Fontdesc             Fl_Fontdesc_xlib
 
67
#define fl_fonts                fl_fonts_xlib
 
68
#define built_in_table          built_in_table_xlib
 
69
#define fl_font_word            fl_font_word_xlib
 
70
#define fl_find_fontsize        fl_find_fontsize_xlib
 
71
#define fl_encoding             fl_encoding_xlib
 
72
#define fl_correct_encoding     fl_correct_encoding_xlib
 
73
#define find                    find_xlib
 
74
#define fl_font_                fl_font__xlib
 
75
#define fl_size_                fl_size__xlib
 
76
#define fl_xfont                fl_xfont_xlib
 
77
#define font_gc                 font_gc_xlib
 
78
#define fl_font                 fl_font_xlib
 
79
#define fl_height               fl_height_xlib
 
80
#define fl_descent              fl_descent_xlib
 
81
#define fl_width                fl_width_xlib
 
82
#define fl_draw                 fl_draw_xlib
 
83
#define SUPPRESS_XFT 1
 
84
#undef FL_FONT_
 
85
#include "Fl_Font.H"
 
86
#include "fl_font_x.cxx"
 
87
#undef SUPPRESS_XFT
 
88
#undef Fl_FontSize
 
89
#undef fl_fontsize
 
90
#undef Fl_Fontdesc
 
91
#undef fl_fonts
 
92
#undef built_in_table
 
93
#undef fl_font_word
 
94
#undef fl_find_fontsize
 
95
#undef fl_encoding
 
96
#undef fl_correct_encoding
 
97
#undef find
 
98
#undef fl_font_
 
99
#undef fl_size_
 
100
#undef fl_xfont
 
101
#undef font_gc
 
102
#undef fl_font
 
103
#undef fl_height
 
104
#undef fl_descent
 
105
#undef fl_width
 
106
#undef fl_draw
 
107
 
 
108
 
63
109
#include <X11/Xft/Xft.h>
64
110
 
65
111
// The predefined fonts that FLTK has:
156
202
//  XftFontClose(fl_display, font);
157
203
}
158
204
 
159
 
int fl_height() { return current_font->ascent + current_font->descent; }
160
 
int fl_descent() { return current_font->descent; }
 
205
int fl_height() {
 
206
  if (current_font) return current_font->ascent + current_font->descent;
 
207
  else return -1;
 
208
}
 
209
 
 
210
int fl_descent() {
 
211
  if (current_font) return current_font->descent;
 
212
  else return -1;
 
213
}
161
214
 
162
215
double fl_width(const char *str, int n) {
 
216
  if (!current_font) return -1.0;
163
217
  XGlyphInfo i;
164
218
  XftTextExtents8(fl_display, current_font, (XftChar8 *)str, n, &i);
165
219
  return i.xOff;
214
268
}
215
269
 
216
270
void fl_draw(const char *str, int n, int x, int y) {
 
271
  if ( !current_font ) {
 
272
    int saved_font = fl_font_, saved_size = fl_size_;
 
273
    fl_font(FL_HELVETICA, 14);
 
274
    if ( !current_font ) {
 
275
      fl_font_xlib(saved_font, saved_size ? saved_size : fl_size_);
 
276
      fl_draw_xlib(str, n, x, y);
 
277
      return;
 
278
    }
 
279
  }
217
280
#if USE_OVERLAY
218
281
  XftDraw*& draw = fl_overlay ? draw_overlay : ::draw;
219
282
  if (fl_overlay) {
247
310
  XftDrawString8(draw, &color, current_font, x, y, (XftChar8 *)str, n);
248
311
}
249
312
 
 
313
void fl_draw(const char* str, int n, float x, float y) {
 
314
  fl_draw(str, n, (int)x, (int)y);
 
315
}
 
316
 
250
317
//
251
 
// End of "$Id: fl_font_xft.cxx,v 1.4.2.13 2004/04/11 04:39:00 easysw Exp $"
 
318
// End of "$Id: fl_font_xft.cxx,v 1.4.2.16 2004/09/11 18:06:29 easysw Exp $"
252
319
//