Replaced global variable fl_fontsize by fl_graphics_driver->font_descriptor().
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8395 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
db3e571637
commit
cb902eebe3
@ -4,7 +4,7 @@
|
||||
// Definition of classes Fl_Device, Fl_Graphics_Driver, Fl_Surface_Device, Fl_Display_Device
|
||||
// for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 2010 by Bill Spitzak and others.
|
||||
// Copyright 2010-2011 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
|
||||
@ -41,6 +41,7 @@
|
||||
#include <FL/Fl_RGB_Image.H>
|
||||
|
||||
class Fl_Graphics_Driver;
|
||||
class Fl_Font_Descriptor;
|
||||
/** \brief Points to the driver that currently receives all graphics requests */
|
||||
FL_EXPORT extern Fl_Graphics_Driver *fl_graphics_driver;
|
||||
|
||||
@ -129,6 +130,7 @@ class FL_EXPORT Fl_Graphics_Driver : public Fl_Device {
|
||||
int numcount;
|
||||
int counts[20];
|
||||
#endif
|
||||
Fl_Font_Descriptor *font_descriptor_;
|
||||
void transformed_vertex0(COORD_T x, COORD_T y);
|
||||
void fixloop();
|
||||
|
||||
@ -357,6 +359,10 @@ public:
|
||||
Fl_Fontsize size() {return size_; }
|
||||
/** \brief see fl_color(void). */
|
||||
Fl_Color color() {return color_;}
|
||||
/** Returns a pointer to the current Fl_Font_Descriptor for the graphics driver */
|
||||
inline Fl_Font_Descriptor *font_descriptor() { return font_descriptor_;}
|
||||
/** Sets the current Fl_Font_Descriptor for the graphics driver */
|
||||
inline void font_descriptor(Fl_Font_Descriptor *d) { font_descriptor_ = d;}
|
||||
/** \brief The destructor */
|
||||
virtual ~Fl_Graphics_Driver() {};
|
||||
};
|
||||
|
@ -3,7 +3,7 @@
|
||||
//
|
||||
// implementation of Fl_Device class for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 2010 by Bill Spitzak and others.
|
||||
// Copyright 2010-2011 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
|
||||
@ -61,6 +61,7 @@ Fl_Graphics_Driver::Fl_Graphics_Driver() {
|
||||
m = m0;
|
||||
fl_matrix = &m;
|
||||
p = (XPOINT *)0;
|
||||
font_descriptor_ = NULL;
|
||||
};
|
||||
|
||||
//
|
||||
|
@ -51,6 +51,7 @@ class Fl_Font_Descriptor {
|
||||
public:
|
||||
/** linked list for this Fl_Fontdesc */
|
||||
Fl_Font_Descriptor *next;
|
||||
Fl_Fontsize size; /**< font size */
|
||||
#ifndef FL_DOXYGEN // don't bother with platorm dependant details in the doc.
|
||||
# ifdef WIN32
|
||||
HFONT fid;
|
||||
@ -69,19 +70,15 @@ public:
|
||||
ATSUStyle style;
|
||||
short ascent, descent, q_width;
|
||||
char *q_name;
|
||||
int size;
|
||||
# elif USE_XFT
|
||||
XftFont* font;
|
||||
const char* encoding;
|
||||
Fl_Fontsize size;
|
||||
//const char* encoding;
|
||||
int angle;
|
||||
FL_EXPORT Fl_Font_Descriptor(const char* xfontname);
|
||||
FL_EXPORT Fl_Font_Descriptor(const char* xfontname, int angle);
|
||||
# else
|
||||
XUtf8FontStruct* font; // X UTF-8 font information
|
||||
FL_EXPORT Fl_Font_Descriptor(const char* xfontname);
|
||||
# endif
|
||||
Fl_Fontsize minsize; // smallest point size that should use this
|
||||
Fl_Fontsize maxsize; // largest point size that should use this
|
||||
# if HAVE_GL
|
||||
unsigned int listbase;// base of display list, 0 = none
|
||||
#ifndef __APPLE_QUARTZ__
|
||||
|
@ -3,7 +3,7 @@
|
||||
//
|
||||
// MacOS-Cocoa specific code for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
// Copyright 1998-2011 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
|
||||
@ -2238,8 +2238,6 @@ void Fl_Window::make_current()
|
||||
}
|
||||
|
||||
// helper function to manage the current CGContext fl_gc
|
||||
extern class Fl_Font_Descriptor *fl_fontsize;
|
||||
extern void fl_font(class Fl_Font_Descriptor*);
|
||||
extern void fl_quartz_restore_line_style_();
|
||||
|
||||
// FLTK has only one global graphics state. This function copies the FLTK state into the
|
||||
@ -2251,7 +2249,6 @@ void Fl_X::q_fill_context() {
|
||||
CGContextTranslateCTM(fl_gc, 0.5, hgt-0.5f);
|
||||
CGContextScaleCTM(fl_gc, 1.0f, -1.0f); // now 0,0 is top-left point of the context
|
||||
}
|
||||
fl_font(fl_fontsize);
|
||||
fl_color(fl_graphics_driver->color());
|
||||
fl_quartz_restore_line_style_();
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
//
|
||||
// MacOS font selection routines for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
// Copyright 1998-2011 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
|
||||
@ -48,7 +48,6 @@ Fl_Font_Descriptor::Fl_Font_Descriptor(const char* name, Fl_Fontsize Size) {
|
||||
// OpenGL needs those for its font handling
|
||||
q_name = strdup(name);
|
||||
size = Size;
|
||||
minsize = maxsize = Size;
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
|
||||
if (fl_mac_os_version == 0) fl_open_display();
|
||||
if (fl_mac_os_version >= 0x1050) {//unfortunately, CTFontCreateWithName != NULL on 10.4 also!
|
||||
@ -162,8 +161,6 @@ else {
|
||||
#endif
|
||||
}
|
||||
|
||||
Fl_Font_Descriptor* fl_fontsize = 0L;
|
||||
|
||||
Fl_Font_Descriptor::~Fl_Font_Descriptor() {
|
||||
/*
|
||||
#if HAVE_GL
|
||||
@ -179,7 +176,7 @@ Fl_Font_Descriptor::~Fl_Font_Descriptor() {
|
||||
// }
|
||||
#endif
|
||||
*/
|
||||
if (this == fl_fontsize) fl_fontsize = 0;
|
||||
if (this == fl_graphics_driver->font_descriptor()) fl_graphics_driver->font_descriptor(NULL);
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
|
||||
if (fl_mac_os_version >= 0x1050) {
|
||||
CFRelease(fontref);
|
||||
@ -230,17 +227,12 @@ static UniChar *mac_Utf8_to_Utf16(const char *txt, int len, int *new_len)
|
||||
|
||||
Fl_Fontdesc* fl_fonts = built_in_table;
|
||||
|
||||
void fl_font(Fl_Font_Descriptor* s) {
|
||||
fl_fontsize = s;
|
||||
// we will use fl_fontsize later to access the required style and layout
|
||||
}
|
||||
|
||||
static Fl_Font_Descriptor* find(Fl_Font fnum, Fl_Fontsize size) {
|
||||
Fl_Fontdesc* s = fl_fonts+fnum;
|
||||
if (!s->name) s = fl_fonts; // use 0 if fnum undefined
|
||||
Fl_Font_Descriptor* f;
|
||||
for (f = s->first; f; f = f->next)
|
||||
if (f->minsize <= size && f->maxsize >= size) return f;
|
||||
if (f->size == size) return f;
|
||||
f = new Fl_Font_Descriptor(s->name, size);
|
||||
f->next = s->first;
|
||||
s->first = f;
|
||||
@ -256,16 +248,18 @@ void Fl_Quartz_Graphics_Driver::font(Fl_Font fnum, Fl_Fontsize size) {
|
||||
return;
|
||||
}
|
||||
Fl_Graphics_Driver::font(fnum, size);
|
||||
fl_font(find(fnum, size));
|
||||
fl_graphics_driver->font_descriptor( find(fnum, size) );
|
||||
}
|
||||
|
||||
int fl_height() {
|
||||
Fl_Font_Descriptor *fl_fontsize = fl_graphics_driver->font_descriptor();
|
||||
check_default_font();
|
||||
if (fl_fontsize) return fl_fontsize->ascent+fl_fontsize->descent;
|
||||
else return -1;
|
||||
}
|
||||
|
||||
int fl_descent() {
|
||||
Fl_Font_Descriptor *fl_fontsize = fl_graphics_driver->font_descriptor();
|
||||
check_default_font();
|
||||
if (fl_fontsize)
|
||||
return fl_fontsize->descent+1;
|
||||
@ -276,6 +270,7 @@ int fl_descent() {
|
||||
// returns width of a pair of UniChar's in the surrogate range
|
||||
static CGFloat surrogate_width(const UniChar *txt)
|
||||
{
|
||||
Fl_Font_Descriptor *fl_fontsize = fl_graphics_driver->font_descriptor();
|
||||
CFStringRef str = CFStringCreateWithCharactersNoCopy(NULL, txt, 2, kCFAllocatorNull);
|
||||
CTFontRef font2 = CTFontCreateForString(fl_fontsize->fontref, str, CFRangeMake(0,2));
|
||||
CFRelease(str);
|
||||
@ -290,6 +285,7 @@ static CGFloat surrogate_width(const UniChar *txt)
|
||||
#endif
|
||||
|
||||
static double fl_width(const UniChar* txt, int n) {
|
||||
Fl_Font_Descriptor *fl_fontsize = fl_graphics_driver->font_descriptor();
|
||||
check_default_font();
|
||||
if (!fl_fontsize) {
|
||||
check_default_font(); // avoid a crash!
|
||||
@ -387,6 +383,7 @@ double fl_width(unsigned int wc) {
|
||||
|
||||
// text extent calculation
|
||||
void fl_text_extents(const char *str8, int n, int &dx, int &dy, int &w, int &h) {
|
||||
Fl_Font_Descriptor *fl_fontsize = fl_graphics_driver->font_descriptor();
|
||||
if (!fl_fontsize) {
|
||||
check_default_font(); // avoid a crash!
|
||||
if (!fl_fontsize)
|
||||
@ -470,6 +467,7 @@ static CGColorRef flcolortocgcolor(Fl_Color i)
|
||||
|
||||
|
||||
void fl_draw(const char *str, int n, float x, float y) {
|
||||
Fl_Font_Descriptor *fl_fontsize = fl_graphics_driver->font_descriptor();
|
||||
// avoid a crash if no font has been selected by user yet !
|
||||
check_default_font();
|
||||
// convert to UTF-16 first
|
||||
|
@ -3,7 +3,7 @@
|
||||
//
|
||||
// WIN32 font selection routines for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
// Copyright 1998-2011 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
|
||||
@ -30,7 +30,7 @@
|
||||
static int fl_angle_ = 0;
|
||||
|
||||
#ifndef FL_DOXYGEN
|
||||
Fl_Font_Descriptor::Fl_Font_Descriptor(const char* name, Fl_Fontsize size) {
|
||||
Fl_Font_Descriptor::Fl_Font_Descriptor(const char* name, Fl_Fontsize fsize) {
|
||||
int weight = FW_NORMAL;
|
||||
int italic = 0;
|
||||
switch (*name++) {
|
||||
@ -41,7 +41,7 @@ Fl_Font_Descriptor::Fl_Font_Descriptor(const char* name, Fl_Fontsize size) {
|
||||
default: name--;
|
||||
}
|
||||
fid = CreateFont(
|
||||
-size, // negative makes it use "char size"
|
||||
-fsize, // negative makes it use "char size"
|
||||
0, // logical average character width
|
||||
fl_angle_*10, // angle of escapement
|
||||
fl_angle_*10, // base-line orientation angle
|
||||
@ -69,11 +69,9 @@ Fl_Font_Descriptor::Fl_Font_Descriptor(const char* name, Fl_Fontsize size) {
|
||||
listbase = 0;
|
||||
for (i = 0; i < 64; i++) glok[i] = 0;
|
||||
#endif
|
||||
minsize = maxsize = size;
|
||||
size = fsize;
|
||||
}
|
||||
|
||||
Fl_Font_Descriptor* fl_fontsize;
|
||||
|
||||
Fl_Font_Descriptor::~Fl_Font_Descriptor() {
|
||||
#if HAVE_GL
|
||||
// Delete list created by gl_draw(). This is not done by this code
|
||||
@ -86,7 +84,7 @@ Fl_Font_Descriptor::~Fl_Font_Descriptor() {
|
||||
// glDeleteLists(listbase+base,size);
|
||||
// }
|
||||
#endif
|
||||
if (this == fl_fontsize) fl_fontsize = 0;
|
||||
if (this == fl_graphics_driver->font_descriptor()) fl_graphics_driver->font_descriptor(NULL);
|
||||
DeleteObject(fid);
|
||||
int i;
|
||||
for (i = 0; i < 64; i++) free(width[i]);
|
||||
@ -122,7 +120,7 @@ static Fl_Font_Descriptor* find(Fl_Font fnum, Fl_Fontsize size, int angle) {
|
||||
if (!s->name) s = fl_fonts; // use 0 if fnum undefined
|
||||
Fl_Font_Descriptor* f;
|
||||
for (f = s->first; f; f = f->next)
|
||||
if (f->minsize <= size && f->maxsize >= size && f->angle == angle) return f;
|
||||
if (f->size == size && f->angle == angle) return f;
|
||||
f = new Fl_Font_Descriptor(s->name, size);
|
||||
f->next = s->first;
|
||||
s->first = f;
|
||||
@ -143,7 +141,7 @@ static void fl_font(Fl_Font fnum, Fl_Fontsize size, int angle) {
|
||||
}
|
||||
if (fnum == fl_font_ && size == fl_size_ && angle == fl_angle_) return;
|
||||
fl_font_ = fnum; fl_size_ = size; fl_angle_ = angle;
|
||||
fl_fontsize = find(fnum, size, angle);
|
||||
fl_graphics_driver->font_descriptor( find(fnum, size, angle) );
|
||||
}
|
||||
|
||||
void Fl_GDI_Graphics_Driver::font(Fl_Font fnum, Fl_Fontsize size) {
|
||||
@ -152,11 +150,13 @@ void Fl_GDI_Graphics_Driver::font(Fl_Font fnum, Fl_Fontsize size) {
|
||||
}
|
||||
|
||||
int fl_height() {
|
||||
Fl_Font_Descriptor *fl_fontsize = fl_graphics_driver->font_descriptor();
|
||||
if (fl_fontsize) return (fl_fontsize->metr.tmAscent + fl_fontsize->metr.tmDescent);
|
||||
else return -1;
|
||||
}
|
||||
|
||||
int fl_descent() {
|
||||
Fl_Font_Descriptor *fl_fontsize = fl_graphics_driver->font_descriptor();
|
||||
if (fl_fontsize) return fl_fontsize->metr.tmDescent;
|
||||
else return -1;
|
||||
}
|
||||
@ -168,7 +168,7 @@ static int wstr_len = 0;
|
||||
|
||||
double fl_width(const char* c, int n) {
|
||||
int i = 0;
|
||||
if (!fl_fontsize) return -1.0;
|
||||
if (!fl_graphics_driver->font_descriptor()) return -1.0;
|
||||
double w = 0.0;
|
||||
char *end = (char *)&c[n];
|
||||
while (i < n) {
|
||||
@ -186,6 +186,7 @@ double fl_width(const char* c, int n) {
|
||||
}
|
||||
|
||||
double fl_width(unsigned int c) {
|
||||
Fl_Font_Descriptor *fl_fontsize = fl_graphics_driver->font_descriptor();
|
||||
unsigned int r;
|
||||
r = (c & 0xFC00) >> 10;
|
||||
if (!fl_fontsize->width[r]) {
|
||||
@ -258,6 +259,7 @@ static unsigned wc_len = 0; // current string buffer dimension
|
||||
static WORD *gi = NULL; // glyph indices array
|
||||
// Function to determine the extent of the "inked" area of the glyphs in a string
|
||||
void fl_text_extents(const char *c, int n, int &dx, int &dy, int &w, int &h) {
|
||||
Fl_Font_Descriptor *fl_fontsize = fl_graphics_driver->font_descriptor();
|
||||
if (!fl_fontsize) {
|
||||
w = 0; h = 0;
|
||||
dx = dy = 0;
|
||||
@ -340,7 +342,7 @@ void Fl_GDI_Graphics_Driver::draw(const char* str, int n, int x, int y) {
|
||||
int lx = 0;
|
||||
char *end = (char *)&str[n];
|
||||
COLORREF oldColor = SetTextColor(fl_gc, fl_RGB());
|
||||
SelectObject(fl_gc, fl_fontsize->fid);
|
||||
SelectObject(fl_gc, fl_graphics_driver->font_descriptor()->fid);
|
||||
while (i < n) {
|
||||
unsigned int u;
|
||||
unsigned int u1;
|
||||
@ -369,7 +371,7 @@ void Fl_GDI_Graphics_Driver::draw(int angle, const char* str, int n, int x, int
|
||||
int i = 0, i2=0;
|
||||
char *end = (char *)&str[n];
|
||||
COLORREF oldColor = SetTextColor(fl_gc, fl_RGB());
|
||||
SelectObject(fl_gc, fl_fontsize->fid);
|
||||
SelectObject(fl_gc, fl_graphics_driver->font_descriptor()->fid);
|
||||
//unsigned short ucs[n]; //only GCC, but not MSVC
|
||||
unsigned short* ucs = new unsigned short[n];
|
||||
while (i < n) {
|
||||
@ -397,7 +399,7 @@ void Fl_GDI_Graphics_Driver::rtl_draw(const char* c, int n, int x, int y) {
|
||||
}
|
||||
|
||||
COLORREF oldColor = SetTextColor(fl_gc, fl_RGB());
|
||||
SelectObject(fl_gc, fl_fontsize->fid);
|
||||
SelectObject(fl_gc, fl_graphics_driver->font_descriptor()->fid);
|
||||
#ifdef RTL_CHAR_BY_CHAR
|
||||
int i = 0;
|
||||
int lx = 0;
|
||||
|
@ -3,7 +3,7 @@
|
||||
//
|
||||
// Standard X11 font selection code for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
// Copyright 1998-2011 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
|
||||
@ -38,7 +38,6 @@ Fl_Font_Descriptor::Fl_Font_Descriptor(const char* name) {
|
||||
# endif
|
||||
}
|
||||
|
||||
Fl_Font_Descriptor* fl_fontsize;
|
||||
Fl_XFont_On_Demand fl_xfont;
|
||||
|
||||
Fl_Font_Descriptor::~Fl_Font_Descriptor() {
|
||||
@ -53,8 +52,8 @@ Fl_Font_Descriptor::~Fl_Font_Descriptor() {
|
||||
// glDeleteLists(listbase+base,size);
|
||||
// }
|
||||
# endif
|
||||
if (this == fl_fontsize) {
|
||||
fl_fontsize = 0;
|
||||
if (this == fl_graphics_driver->font_descriptor()) {
|
||||
fl_graphics_driver->font_descriptor(NULL);
|
||||
fl_xfont = 0;
|
||||
}
|
||||
XFreeUtf8FontStruct(fl_display, font);
|
||||
@ -87,7 +86,7 @@ Fl_Fontdesc* fl_fonts = built_in_table;
|
||||
|
||||
#define MAXSIZE 32767
|
||||
|
||||
#define current_font (fl_fontsize->font)
|
||||
#define current_font (fl_graphics_driver->font_descriptor()->font)
|
||||
|
||||
// return dash number N, or pointer to ending null if none:
|
||||
const char* fl_font_word(const char* p, int n) {
|
||||
@ -243,13 +242,12 @@ static Fl_Font_Descriptor* find(int fnum, int size) {
|
||||
if (!s->name) s = fl_fonts; // use font 0 if still undefined
|
||||
Fl_Font_Descriptor* f;
|
||||
for (f = s->first; f; f = f->next)
|
||||
if (f->minsize <= size && f->maxsize >= size) return f;
|
||||
if (f->size == size) return f;
|
||||
fl_open_display();
|
||||
|
||||
name = put_font_size(s->name, size);
|
||||
f = new Fl_Font_Descriptor(name);
|
||||
f->minsize = size;
|
||||
f->maxsize = size;
|
||||
f->size = size;
|
||||
f->next = s->first;
|
||||
s->first = f;
|
||||
free(name);
|
||||
@ -275,8 +273,8 @@ void Fl_Xlib_Graphics_Driver::font(Fl_Font fnum, Fl_Fontsize size) {
|
||||
if (fnum == Fl_Graphics_Driver::font() && size == Fl_Graphics_Driver::size()) return;
|
||||
Fl_Graphics_Driver::font(fnum, size);
|
||||
Fl_Font_Descriptor* f = find(fnum, size);
|
||||
if (f != fl_fontsize) {
|
||||
fl_fontsize = f;
|
||||
if (f != fl_graphics_driver->font_descriptor()) {
|
||||
fl_graphics_driver->font_descriptor(f);
|
||||
fl_xfont = current_font->fonts[0];
|
||||
font_gc = 0;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
//
|
||||
// Xft font code for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 2001-2010 Bill Spitzak and others.
|
||||
// Copyright 2001-2011 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
|
||||
@ -108,42 +108,36 @@ static Fl_Fontdesc built_in_table[] = {
|
||||
|
||||
Fl_Fontdesc* fl_fonts = built_in_table;
|
||||
|
||||
#define current_font (fl_fontsize->font)
|
||||
#define current_font (fl_graphics_driver->font_descriptor()->font)
|
||||
|
||||
static Fl_Font fl_font_ = 0;
|
||||
static Fl_Fontsize fl_size_ = 0;
|
||||
int fl_angle_ = 0; // internal for rotating text support
|
||||
Fl_XFont_On_Demand fl_xfont;
|
||||
void *fl_xftfont = 0;
|
||||
//const char* fl_encoding_ = "iso8859-1";
|
||||
const char* fl_encoding_ = "iso10646-1";
|
||||
Fl_Font_Descriptor* fl_fontsize = 0;
|
||||
|
||||
|
||||
|
||||
void fl_font(Fl_Font fnum, Fl_Fontsize size, int angle) {
|
||||
static void fl_font(Fl_Font fnum, Fl_Fontsize size, int angle) {
|
||||
if (fnum==-1) { // special case to stop font caching
|
||||
fl_font_ = 0; fl_size_ = 0; fl_angle_ = 0;
|
||||
fl_font_ = 0; fl_size_ = 0;
|
||||
return;
|
||||
}
|
||||
if (fnum == fl_font_ && size == fl_size_ && angle == fl_angle_
|
||||
&& fl_fontsize)
|
||||
// && !strcasecmp(fl_fontsize->encoding, fl_encoding_))
|
||||
Fl_Font_Descriptor* f = fl_graphics_driver->font_descriptor();
|
||||
if (fnum == fl_font_ && size == fl_size_ && f && f->angle == angle)
|
||||
return;
|
||||
fl_font_ = fnum; fl_size_ = size; fl_angle_ = angle;
|
||||
fl_font_ = fnum; fl_size_ = size;
|
||||
Fl_Fontdesc *font = fl_fonts + fnum;
|
||||
Fl_Font_Descriptor* f;
|
||||
// search the fontsizes we have generated already
|
||||
for (f = font->first; f; f = f->next) {
|
||||
if (f->size == size && f->angle == angle)// && !strcasecmp(f->encoding, fl_encoding_))
|
||||
break;
|
||||
}
|
||||
if (!f) {
|
||||
f = new Fl_Font_Descriptor(font->name);
|
||||
f = new Fl_Font_Descriptor(font->name, angle);
|
||||
f->next = font->first;
|
||||
font->first = f;
|
||||
}
|
||||
fl_fontsize = f;
|
||||
fl_graphics_driver->font_descriptor(f);
|
||||
#if XFT_MAJOR < 2
|
||||
fl_xfont = f->font->u.core.font;
|
||||
#else
|
||||
@ -237,11 +231,11 @@ static XftFont* fontopen(const char* name, bool core, int angle) {
|
||||
XftPatternAddDouble (fnt_pat, XFT_PIXEL_SIZE, (double)fl_size_);
|
||||
XftPatternAddString (fnt_pat, XFT_ENCODING, fl_encoding_);
|
||||
|
||||
// rotate font if fl_angle_!=0
|
||||
if (fl_angle_ !=0) {
|
||||
// rotate font if angle!=0
|
||||
if (angle !=0) {
|
||||
XftMatrix m;
|
||||
XftMatrixInit(&m);
|
||||
XftMatrixRotate(&m,cos(M_PI*fl_angle_/180.),sin(M_PI*fl_angle_/180.));
|
||||
XftMatrixRotate(&m,cos(M_PI*angle/180.),sin(M_PI*angle/180.));
|
||||
XftPatternAddMatrix (fnt_pat, XFT_MATRIX,&m);
|
||||
}
|
||||
|
||||
@ -344,10 +338,10 @@ puts("Font Opened"); fflush(stdout);
|
||||
}
|
||||
} // end of fontopen
|
||||
|
||||
Fl_Font_Descriptor::Fl_Font_Descriptor(const char* name) {
|
||||
Fl_Font_Descriptor::Fl_Font_Descriptor(const char* name, int fangle) {
|
||||
// encoding = fl_encoding_;
|
||||
size = fl_size_;
|
||||
angle = fl_angle_;
|
||||
angle = fangle;
|
||||
#if HAVE_GL
|
||||
listbase = 0;
|
||||
#endif // HAVE_GL
|
||||
@ -355,7 +349,7 @@ Fl_Font_Descriptor::Fl_Font_Descriptor(const char* name) {
|
||||
}
|
||||
|
||||
Fl_Font_Descriptor::~Fl_Font_Descriptor() {
|
||||
if (this == fl_fontsize) fl_fontsize = 0;
|
||||
if (this == fl_graphics_driver->font_descriptor()) fl_graphics_driver->font_descriptor(NULL);
|
||||
// XftFontClose(fl_display, font);
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
//
|
||||
// OpenGL drawing support routines for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2010 by Bill Spitzak and others.
|
||||
// Copyright 1998-2011 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
|
||||
@ -77,6 +77,7 @@ static Fl_Font_Descriptor *gl_fontsize;
|
||||
*/
|
||||
void gl_font(int fontid, int size) {
|
||||
fl_font(fontid, size);
|
||||
Fl_Font_Descriptor *fl_fontsize = fl_graphics_driver->font_descriptor();
|
||||
#if !GL_DRAW_USES_TEXTURES
|
||||
if (!fl_fontsize->listbase) {
|
||||
|
||||
@ -482,7 +483,7 @@ int gl_texture_fifo::compute_texture(const char* str, int n)
|
||||
if (base == NULL) return -1;
|
||||
fl_gc = CGBitmapContextCreate(base, fifo[current].width, fifo[current].height, 8, fifo[current].width*4, lut, kCGImageAlphaPremultipliedLast);
|
||||
CGColorSpaceRelease(lut);
|
||||
fl_fontsize = gl_fontsize;
|
||||
fl_graphics_driver->font_descriptor(gl_fontsize);
|
||||
GLfloat colors[4];
|
||||
glGetFloatv(GL_CURRENT_COLOR, colors);
|
||||
fl_color((uchar)(colors[0]*255), (uchar)(colors[1]*255), (uchar)(colors[2]*255));
|
||||
|
Loading…
Reference in New Issue
Block a user