summaryrefslogtreecommitdiff
path: root/src/drivers
diff options
context:
space:
mode:
authorManolo Gouy <Manolo>2018-02-07 15:34:44 +0000
committerManolo Gouy <Manolo>2018-02-07 15:34:44 +0000
commitdcc82d8926e447e422f200d01e1aa990233bc16a (patch)
treebc0d120f1381e0e8c0ef5c66262289e93d3b9a08 /src/drivers
parent90630409cbe8740d2c8b66823757a4ea5441aa21 (diff)
STR#3450: Draw text with OpenGL using textures on all platforms.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12650 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/drivers')
-rw-r--r--src/drivers/GDI/Fl_Font.H30
-rw-r--r--src/drivers/GDI/Fl_GDI_Graphics_Driver.H3
-rw-r--r--src/drivers/GDI/Fl_GDI_Graphics_Driver_font.cxx31
-rw-r--r--src/drivers/Quartz/Fl_Font.H32
-rw-r--r--src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H11
-rw-r--r--src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx45
-rw-r--r--src/drivers/Xlib/Fl_Font.H28
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H2
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx20
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx53
-rw-r--r--src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx45
11 files changed, 118 insertions, 182 deletions
diff --git a/src/drivers/GDI/Fl_Font.H b/src/drivers/GDI/Fl_Font.H
index fd36aab24..b530ec422 100644
--- a/src/drivers/GDI/Fl_Font.H
+++ b/src/drivers/GDI/Fl_Font.H
@@ -3,7 +3,7 @@
//
// Font definitions for the Fast Light Tool Kit (FLTK).
//
-// Copyright 1998-2011 by Bill Spitzak and others.
+// Copyright 1998-2018 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
@@ -26,39 +26,17 @@
#include <config.h>
-/**
- This a structure for an actual system font, with junk to
- help choose it and info on character sizes. Each Fl_Fontdesc has a
- linked list of these. These are created the first time each system
- font/size combination is used.
-*/
-class Fl_Font_Descriptor {
+class Fl_GDI_Font_Descriptor : public 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.
HFONT fid;
int *width[64];
TEXTMETRIC metr;
int angle;
- FL_EXPORT Fl_Font_Descriptor(const char* fontname, Fl_Fontsize size);
+ FL_EXPORT Fl_GDI_Font_Descriptor(const char* fontname, Fl_Fontsize size);
# if HAVE_GL
- unsigned int listbase;// base of display list, 0 = none
char glok[64];
# endif // HAVE_GL
-
- FL_EXPORT ~Fl_Font_Descriptor();
-
-#endif // FL_DOXYGEN
-};
-
-//extern FL_EXPORT Fl_Font_Descriptor *fl_fontsize; // the currently selected one
-
-struct Fl_Fontdesc {
- const char *name;
- char fontname[128]; // "Pretty" font name
- Fl_Font_Descriptor *first; // linked list of sizes of this style
+ FL_EXPORT ~Fl_GDI_Font_Descriptor();
};
extern FL_EXPORT Fl_Fontdesc *fl_fonts; // the table
diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver.H b/src/drivers/GDI/Fl_GDI_Graphics_Driver.H
index fea0ccac4..8de2a9a1d 100644
--- a/src/drivers/GDI/Fl_GDI_Graphics_Driver.H
+++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver.H
@@ -4,7 +4,7 @@
// Definition of classes Fl_Graphics_Driver, Fl_Surface_Device, Fl_Display_Device
// for the Fast Light Tool Kit (FLTK).
//
-// Copyright 2010-2017 by Bill Spitzak and others.
+// Copyright 2010-2018 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
@@ -146,7 +146,6 @@ protected:
virtual const char* get_font_name(Fl_Font fnum, int* ap);
virtual const char *font_name(int num);
virtual void font_name(int num, const char *name);
- virtual unsigned font_desc_size();
void global_gc();
};
diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver_font.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver_font.cxx
index 360076b0f..c9d74e59e 100644
--- a/src/drivers/GDI/Fl_GDI_Graphics_Driver_font.cxx
+++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver_font.cxx
@@ -189,10 +189,6 @@ int Fl_GDI_Graphics_Driver::get_font_sizes(Fl_Font fnum, int*& sizep) {
return nbSize;
}
-unsigned Fl_GDI_Graphics_Driver::font_desc_size() {
- return (unsigned)sizeof(Fl_Fontdesc);
-}
-
const char *Fl_GDI_Graphics_Driver::font_name(int num) {
return fl_fonts[num].name;
}
@@ -215,7 +211,7 @@ void Fl_GDI_Graphics_Driver::font_name(int num, const char *name) {
static int fl_angle_ = 0;
#ifndef FL_DOXYGEN
-Fl_Font_Descriptor::Fl_Font_Descriptor(const char* name, Fl_Fontsize fsize) {
+Fl_GDI_Font_Descriptor::Fl_GDI_Font_Descriptor(const char* name, Fl_Fontsize fsize) : Fl_Font_Descriptor(name,fsize) {
int weight = FW_NORMAL;
int italic = 0;
switch (*name++) {
@@ -252,13 +248,12 @@ Fl_Font_Descriptor::Fl_Font_Descriptor(const char* name, Fl_Fontsize fsize) {
int i;
memset(width, 0, 64 * sizeof(int*));
#if HAVE_GL
- listbase = 0;
for (i = 0; i < 64; i++) glok[i] = 0;
#endif
size = fsize;
}
-Fl_Font_Descriptor::~Fl_Font_Descriptor() {
+Fl_GDI_Font_Descriptor::~Fl_GDI_Font_Descriptor() {
#if HAVE_GL
// Delete list created by gl_draw(). This is not done by this code
// as it will link in GL unnecessarily. There should be some kind
@@ -296,13 +291,13 @@ static Fl_Fontdesc built_in_table[] = {
Fl_Fontdesc* fl_fonts = built_in_table;
-static Fl_Font_Descriptor* find(Fl_Font fnum, Fl_Fontsize size, int angle) {
+static Fl_GDI_Font_Descriptor* find(Fl_Font fnum, Fl_Fontsize size, int angle) {
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)
+ Fl_GDI_Font_Descriptor* f;
+ for (f = (Fl_GDI_Font_Descriptor*)s->first; f; f = (Fl_GDI_Font_Descriptor*)f->next)
if (f->size == size && f->angle == angle) return f;
- f = new Fl_Font_Descriptor(s->name, size);
+ f = new Fl_GDI_Font_Descriptor(s->name, size);
f->next = s->first;
s->first = f;
return f;
@@ -328,13 +323,13 @@ void Fl_GDI_Graphics_Driver::font_unscaled(Fl_Font fnum, Fl_Fontsize size) {
}
int Fl_GDI_Graphics_Driver::height_unscaled() {
- Fl_Font_Descriptor *fl_fontsize = font_descriptor();
+ Fl_GDI_Font_Descriptor *fl_fontsize = (Fl_GDI_Font_Descriptor*)font_descriptor();
if (fl_fontsize) return (fl_fontsize->metr.tmAscent + fl_fontsize->metr.tmDescent);
else return -1;
}
int Fl_GDI_Graphics_Driver::descent_unscaled() {
- Fl_Font_Descriptor *fl_fontsize = font_descriptor();
+ Fl_GDI_Font_Descriptor *fl_fontsize = (Fl_GDI_Font_Descriptor*)font_descriptor();
if (fl_fontsize) return fl_fontsize->metr.tmDescent;
else return -1;
}
@@ -369,7 +364,7 @@ double Fl_GDI_Graphics_Driver::width_unscaled(const char* c, int n) {
}
double Fl_GDI_Graphics_Driver::width_unscaled(unsigned int c) {
- Fl_Font_Descriptor *fl_fontsize = font_descriptor();
+ Fl_GDI_Font_Descriptor *fl_fontsize = (Fl_GDI_Font_Descriptor*)font_descriptor();
unsigned int r;
SIZE s;
// Special Case Handling of Unicode points over U+FFFF.
@@ -468,7 +463,7 @@ static void on_printer_extents_update(int &dx, int &dy, int &w, int &h, HDC gc)
// Function to determine the extent of the "inked" area of the glyphs in a string
void Fl_GDI_Graphics_Driver::text_extents_unscaled(const char *c, int n, int &dx, int &dy, int &w, int &h) {
- Fl_Font_Descriptor *fl_fontsize = font_descriptor();
+ Fl_GDI_Font_Descriptor *fl_fontsize = (Fl_GDI_Font_Descriptor*)font_descriptor();
if (!fl_fontsize) { // no valid font, nothing to measure
w = 0; h = 0;
dx = dy = 0;
@@ -582,7 +577,7 @@ void Fl_GDI_Graphics_Driver::draw_unscaled(const char* str, int n, int x, int y)
COLORREF oldColor = SetTextColor(gc_, fl_RGB());
// avoid crash if no font has been set yet
if (!font_descriptor()) this->font(FL_HELVETICA, FL_NORMAL_SIZE);
- SelectObject(gc_, font_descriptor()->fid);
+ SelectObject(gc_, ((Fl_GDI_Font_Descriptor*)font_descriptor())->fid);
int wn = fl_utf8toUtf16(str, n, wstr, wstr_len);
if(wn >= wstr_len) {
wstr = (unsigned short*) realloc(wstr, sizeof(unsigned short) * (wn + 1));
@@ -597,7 +592,7 @@ void Fl_GDI_Graphics_Driver::draw_unscaled(int angle, const char* str, int n, in
fl_font(this, Fl_Graphics_Driver::font(), size_unscaled(), angle);
int wn = 0; // count of UTF16 cells to render full string
COLORREF oldColor = SetTextColor(gc_, fl_RGB());
- SelectObject(gc_, font_descriptor()->fid);
+ SelectObject(gc_, ((Fl_GDI_Font_Descriptor*)font_descriptor())->fid);
wn = fl_utf8toUtf16(str, n, wstr, wstr_len);
if(wn >= wstr_len) { // Array too small
wstr = (unsigned short*) realloc(wstr, sizeof(unsigned short) * (wn + 1));
@@ -619,7 +614,7 @@ void Fl_GDI_Graphics_Driver::rtl_draw_unscaled(const char* c, int n, int x, int
}
COLORREF oldColor = SetTextColor(gc_, fl_RGB());
- SelectObject(gc_, font_descriptor()->fid);
+ SelectObject(gc_, ((Fl_GDI_Font_Descriptor*)font_descriptor())->fid);
#ifdef RTL_CHAR_BY_CHAR
int i = 0;
int lx = 0;
diff --git a/src/drivers/Quartz/Fl_Font.H b/src/drivers/Quartz/Fl_Font.H
index 00a96370c..e6c56a75c 100644
--- a/src/drivers/Quartz/Fl_Font.H
+++ b/src/drivers/Quartz/Fl_Font.H
@@ -3,7 +3,7 @@
//
// Font definitions for the Fast Light Tool Kit (FLTK).
//
-// Copyright 1998-2011 by Bill Spitzak and others.
+// Copyright 1998-2018 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
@@ -28,21 +28,10 @@
#include "Fl_Quartz_Graphics_Driver.H"
#include <ApplicationServices/ApplicationServices.h>
-/**
- This a structure for an actual system font, with junk to
- help choose it and info on character sizes. Each Fl_Fontdesc has a
- linked list of these. These are created the first time each system
- font/size combination is used.
-*/
-class Fl_Font_Descriptor {
+class Fl_Quartz_Font_Descriptor : public 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.
- Fl_Font_Descriptor(const char* fontname, Fl_Fontsize size);
- FL_EXPORT ~Fl_Font_Descriptor();
- short ascent, descent, q_width;
+ Fl_Quartz_Font_Descriptor(const char* fontname, Fl_Fontsize size);
+ FL_EXPORT ~Fl_Quartz_Font_Descriptor();
# if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
CTFontRef fontref;
// the unicode span is divided in 512 blocks of 128 characters
@@ -52,19 +41,6 @@ public:
ATSUTextLayout layout;
ATSUStyle style;
# endif
-# if HAVE_GL
- unsigned int listbase;// base of display list, 0 = none
-# endif // HAVE_GL
-
-#endif // FL_DOXYGEN
-};
-
-//extern FL_EXPORT Fl_Font_Descriptor *fl_fontsize; // the currently selected one
-
-struct Fl_Fontdesc {
- const char *name;
- char fontname[128]; // "Pretty" font name
- Fl_Font_Descriptor *first; // linked list of sizes of this style
};
extern FL_EXPORT Fl_Fontdesc *fl_fonts; // the table
diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H
index 7e936c2d3..60a261e94 100644
--- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H
+++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.H
@@ -34,6 +34,7 @@
MAC_OS_X_VERSION_MIN_REQUIRED < MAC_OS_X_VERSION_10_5)
struct Fl_Fontdesc;
+class Fl_Quartz_Font_Descriptor;
/**
\brief The Mac OS X-specific graphics class.
@@ -43,6 +44,7 @@ struct Fl_Fontdesc;
class Fl_Quartz_Graphics_Driver : public Fl_Graphics_Driver {
friend class Fl_Font_Descriptor;
friend class Fl_Cocoa_Printer_Driver;
+ friend class Fl_Quartz_Font_Descriptor;
protected:
CGContextRef gc_;
int p_size;
@@ -146,10 +148,9 @@ protected:
virtual bool high_resolution() { return high_resolution_; }
virtual void global_gc();
void quartz_restore_line_style();
- inline Fl_Font_Descriptor *valid_font_descriptor();
+ inline Fl_Quartz_Font_Descriptor *valid_font_descriptor();
virtual const char* get_font_name(Fl_Font fnum, int* ap);
virtual int get_font_sizes(Fl_Font fnum, int*& sizep);
- virtual unsigned font_desc_size();
virtual const char *font_name(int num);
virtual void font_name(int num, const char *name);
Fl_Fontdesc* calc_fl_fonts(void);
@@ -165,13 +166,13 @@ protected:
static void init_CoreText_or_ATSU();
void draw_CoreText(const char *str, int n, float x, float y);
double width_CoreText(const UniChar* txt, int n);
- void descriptor_init_CoreText(const char* name, Fl_Fontsize Size, Fl_Font_Descriptor *d);
+ void descriptor_init_CoreText(const char* name, Fl_Fontsize Size, Fl_Quartz_Font_Descriptor *d);
void text_extents_CoreText(const char*, int n, int& dx, int& dy, int& w, int& h);
Fl_Font set_fonts_CoreText(const char* xstarname);
void draw_ATSU(const char *str, int n, float x, float y);
double width_ATSU(const UniChar* txt, int n);
- void descriptor_init_ATSU(const char* name, Fl_Fontsize Size, Fl_Font_Descriptor *d);
+ void descriptor_init_ATSU(const char* name, Fl_Fontsize Size, Fl_Quartz_Font_Descriptor *d);
void text_extents_ATSU(const char*, int n, int& dx, int& dy, int& w, int& h);
Fl_Font set_fonts_ATSU(const char* xstarname);
@@ -181,7 +182,7 @@ protected:
static pter_to_draw_member CoreText_or_ATSU_draw;
static pter_to_width_member CoreText_or_ATSU_width;
#else
- void descriptor_init(const char* name, Fl_Fontsize Size, Fl_Font_Descriptor *d);
+ void descriptor_init(const char* name, Fl_Fontsize Size, Fl_Quartz_Font_Descriptor *d);
#endif
};
diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx
index 597c1c1cc..7e1717650 100644
--- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx
+++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver_font.cxx
@@ -179,13 +179,7 @@ int Fl_Quartz_Graphics_Driver::get_font_sizes(Fl_Font fnum, int*& sizep) {
return cnt;
}
-Fl_Font_Descriptor::Fl_Font_Descriptor(const char* name, Fl_Fontsize Size) {
- next = 0;
-# if HAVE_GL
- listbase = 0;
-# endif
- // OpenGL needs those for its font handling
- size = Size;
+Fl_Quartz_Font_Descriptor::Fl_Quartz_Font_Descriptor(const char* name, Fl_Fontsize Size) : Fl_Font_Descriptor(name, Size) {
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
fontref = NULL;
#endif
@@ -205,7 +199,7 @@ Fl_Font_Descriptor::Fl_Font_Descriptor(const char* name, Fl_Fontsize Size) {
}
-Fl_Font_Descriptor::~Fl_Font_Descriptor() {
+Fl_Quartz_Font_Descriptor::~Fl_Quartz_Font_Descriptor() {
/*
#if HAVE_GL
// ++ todo: remove OpenGL font allocations
@@ -257,7 +251,7 @@ static Fl_Font_Descriptor* find(Fl_Font fnum, Fl_Fontsize size) {
Fl_Font_Descriptor* f;
for (f = s->first; f; f = f->next)
if (f->size == size) return f;
- f = new Fl_Font_Descriptor(s->name, size);
+ f = new Fl_Quartz_Font_Descriptor(s->name, size);
f->next = s->first;
s->first = f;
return f;
@@ -273,19 +267,19 @@ void Fl_Quartz_Graphics_Driver::font(Fl_Font fnum, Fl_Fontsize size) {
font_descriptor( find(fnum, size) );
}
-Fl_Font_Descriptor *Fl_Quartz_Graphics_Driver::valid_font_descriptor() {
+Fl_Quartz_Font_Descriptor *Fl_Quartz_Graphics_Driver::valid_font_descriptor() {
// avoid a crash if no font has been selected by user yet
if (!font_descriptor()) font(FL_HELVETICA, FL_NORMAL_SIZE);
- return font_descriptor();
+ return (Fl_Quartz_Font_Descriptor*)font_descriptor();
}
int Fl_Quartz_Graphics_Driver::height() {
- Fl_Font_Descriptor *fl_fontsize = valid_font_descriptor();
+ Fl_Quartz_Font_Descriptor *fl_fontsize = valid_font_descriptor();
return fl_fontsize->ascent + fl_fontsize->descent;
}
int Fl_Quartz_Graphics_Driver::descent() {
- Fl_Font_Descriptor *fl_fontsize = valid_font_descriptor();
+ Fl_Quartz_Font_Descriptor *fl_fontsize = valid_font_descriptor();
return fl_fontsize->descent + 1;
}
@@ -351,11 +345,6 @@ void Fl_Quartz_Graphics_Driver::set_fontname_in_fontdesc(Fl_Fontdesc *f) {
#endif
}
-
-unsigned Fl_Quartz_Graphics_Driver::font_desc_size() {
- return (unsigned)sizeof(Fl_Fontdesc);
-}
-
const char *Fl_Quartz_Graphics_Driver::font_name(int num) {
if (!fl_fonts) fl_fonts = calc_fl_fonts();
return fl_fonts[num].name;
@@ -421,7 +410,7 @@ void Fl_Quartz_Graphics_Driver::text_extents(const char* txt, int n, int& dx, in
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
void Fl_Quartz_Graphics_Driver::ADD_SUFFIX(descriptor_init, _CoreText)(const char* name,
- Fl_Fontsize size, Fl_Font_Descriptor *d)
+ Fl_Fontsize size, Fl_Quartz_Font_Descriptor *d)
{
CFStringRef str = CFStringCreateWithCString(NULL, name, kCFStringEncodingUTF8);
d->fontref = CTFontCreateWithName(str, size, NULL);
@@ -470,7 +459,7 @@ void Fl_Quartz_Graphics_Driver::ADD_SUFFIX(descriptor_init, _CoreText)(const cha
}
// returns width of a pair of UniChar's in the surrogate range
-static CGFloat surrogate_width(const UniChar *txt, Fl_Font_Descriptor *fl_fontsize)
+static CGFloat surrogate_width(const UniChar *txt, Fl_Quartz_Font_Descriptor *fl_fontsize)
{
CTFontRef font2 = fl_fontsize->fontref;
bool must_release = false;
@@ -491,7 +480,7 @@ static CGFloat surrogate_width(const UniChar *txt, Fl_Font_Descriptor *fl_fontsi
return a.width;
}
-static CGFloat variation_selector_width(CFStringRef str16, Fl_Font_Descriptor *fl_fontsize)
+static CGFloat variation_selector_width(CFStringRef str16, Fl_Quartz_Font_Descriptor *fl_fontsize)
{
CGFloat retval;
CFDictionarySetValue(attributes, kCTFontAttributeName, fl_fontsize->fontref);
@@ -508,7 +497,7 @@ double Fl_Quartz_Graphics_Driver::ADD_SUFFIX(width, _CoreText)(const UniChar* tx
double retval = 0;
UniChar uni;
int i;
- Fl_Font_Descriptor *fl_fontsize = valid_font_descriptor();
+ Fl_Quartz_Font_Descriptor *fl_fontsize = valid_font_descriptor();
for (i = 0; i < n; i++) { // loop over txt
uni = txt[i];
if (uni >= 0xD800 && uni <= 0xDBFF) { // handles the surrogate range
@@ -576,7 +565,7 @@ double Fl_Quartz_Graphics_Driver::ADD_SUFFIX(width, _CoreText)(const UniChar* tx
// text extent calculation
void Fl_Quartz_Graphics_Driver::ADD_SUFFIX(text_extents, _CoreText)(const char *str8, int n,
int &dx, int &dy, int &w, int &h) {
- Fl_Font_Descriptor *fl_fontsize = valid_font_descriptor();
+ Fl_Quartz_Font_Descriptor *fl_fontsize = valid_font_descriptor();
UniChar *txt = mac_Utf8_to_Utf16(str8, n, &n);
CFStringRef str16 = CFStringCreateWithCharactersNoCopy(NULL, txt, n, kCFAllocatorNull);
CFDictionarySetValue (attributes, kCTFontAttributeName, fl_fontsize->fontref);
@@ -610,7 +599,7 @@ static CGColorRef flcolortocgcolor(Fl_Color i)
void Fl_Quartz_Graphics_Driver::ADD_SUFFIX(draw, _CoreText)(const char *str, int n, float x, float y)
{
- Fl_Font_Descriptor *fl_fontsize = valid_font_descriptor();
+ Fl_Quartz_Font_Descriptor *fl_fontsize = valid_font_descriptor();
// convert to UTF-16 first
UniChar *uniStr = mac_Utf8_to_Utf16(str, n, &n);
CGContextRef gc = (CGContextRef)this->gc();
@@ -710,7 +699,7 @@ Fl_Font Fl_Quartz_Graphics_Driver::ADD_SUFFIX(set_fonts, _CoreText)(const char*
#if HAS_ATSU
void Fl_Quartz_Graphics_Driver::ADD_SUFFIX(descriptor_init, _ATSU)(const char* name,
- Fl_Fontsize size, Fl_Font_Descriptor *d)
+ Fl_Fontsize size, Fl_Quartz_Font_Descriptor *d)
{
OSStatus err;
// fill our structure with a few default values
@@ -766,7 +755,7 @@ void Fl_Quartz_Graphics_Driver::ADD_SUFFIX(descriptor_init, _ATSU)(const char* n
void Fl_Quartz_Graphics_Driver::ADD_SUFFIX(draw, _ATSU)(const char *str, int n, float x, float y)
{
- Fl_Font_Descriptor *fl_fontsize = valid_font_descriptor();
+ Fl_Quartz_Font_Descriptor *fl_fontsize = valid_font_descriptor();
// convert to UTF-16 first
UniChar *uniStr = mac_Utf8_to_Utf16(str, n, &n);
CGContextRef gc = (CGContextRef)this->gc();
@@ -793,7 +782,7 @@ double Fl_Quartz_Graphics_Driver::ADD_SUFFIX(width, _ATSU)(const UniChar* txt, i
ATSUAttributeTag iTag;
ATSUAttributeValuePtr iValuePtr;
- Fl_Font_Descriptor *fl_fontsize = valid_font_descriptor();
+ Fl_Quartz_Font_Descriptor *fl_fontsize = valid_font_descriptor();
// Here's my ATSU text measuring attempt... This seems to do the Right Thing
// now collect our ATSU resources and measure our text string
layout = fl_fontsize->layout;
@@ -814,7 +803,7 @@ double Fl_Quartz_Graphics_Driver::ADD_SUFFIX(width, _ATSU)(const UniChar* txt, i
void Fl_Quartz_Graphics_Driver::ADD_SUFFIX(text_extents, _ATSU)(const char *str8, int n,
int &dx, int &dy, int &w, int &h)
{
- Fl_Font_Descriptor *fl_fontsize = valid_font_descriptor();
+ Fl_Quartz_Font_Descriptor *fl_fontsize = valid_font_descriptor();
UniChar *txt = mac_Utf8_to_Utf16(str8, n, &n);
OSStatus err;
ATSUTextLayout layout;
diff --git a/src/drivers/Xlib/Fl_Font.H b/src/drivers/Xlib/Fl_Font.H
index 0bc4b200e..49917b6d3 100644
--- a/src/drivers/Xlib/Fl_Font.H
+++ b/src/drivers/Xlib/Fl_Font.H
@@ -3,7 +3,7 @@
//
// Font definitions for the Fast Light Tool Kit (FLTK).
//
-// Copyright 1998-2011 by Bill Spitzak and others.
+// Copyright 1998-2018 by Bill Spitzak and others.
//
// This library is free software. Distribution and use rights are outlined in
// the file "COPYING" which should have been included with this file. If this
@@ -32,18 +32,8 @@ typedef struct _XftFont XftFont;
# include "../../Xutf8.h"
#endif // USE_XFT
-/**
- This a structure for an actual system font, with junk to
- help choose it and info on character sizes. Each Fl_Fontdesc has a
- linked list of these. These are created the first time each system
- font/size combination is used.
-*/
-class Fl_Font_Descriptor {
+class Fl_Xlib_Font_Descriptor : public 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.
# if USE_XFT
# if USE_PANGO
int descent_;
@@ -52,30 +42,28 @@ public:
XftFont* font;
# endif
int angle;
- FL_EXPORT Fl_Font_Descriptor(const char* xfontname, Fl_Fontsize size, int angle);
+ FL_EXPORT Fl_Xlib_Font_Descriptor(const char* xfontname, Fl_Fontsize size, int angle);
# else
XUtf8FontStruct* font; // X UTF-8 font information
- FL_EXPORT Fl_Font_Descriptor(const char* xfontname);
+ FL_EXPORT Fl_Xlib_Font_Descriptor(const char* xfontname);
# endif
# if HAVE_GL
- unsigned int listbase;// base of display list, 0 = none
char glok[64];
# endif // HAVE_GL
-
- FL_EXPORT ~Fl_Font_Descriptor();
-
-#endif // FL_DOXYGEN
+ FL_EXPORT ~Fl_Xlib_Font_Descriptor();
};
//extern FL_EXPORT Fl_Font_Descriptor *fl_fontsize; // the currently selected one
-struct Fl_Fontdesc {
+#if !USE_XFT
+struct Fl_Xlib_Fontdesc { // replaces Fl_Fontdesc
const char *name;
char fontname[128]; // "Pretty" font name
Fl_Font_Descriptor *first; // linked list of sizes of this style
char **xlist; // matched X font names
int n; // size of xlist, negative = don't free xlist!
};
+#endif
extern FL_EXPORT Fl_Fontdesc *fl_fonts; // the table
diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H
index 09f0dd31b..8e44e2371 100644
--- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H
+++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H
@@ -180,7 +180,9 @@ protected:
virtual void reset_spot();
virtual const char* get_font_name(Fl_Font fnum, int* ap);
virtual int get_font_sizes(Fl_Font fnum, int*& sizep);
+#if !USE_XFT
virtual unsigned font_desc_size();
+#endif
virtual const char *font_name(int num);
virtual void font_name(int num, const char *name);
virtual Fl_Font set_fonts(const char* xstarname);
diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx
index fd21de07c..dfae0c006 100644
--- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx
+++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx
@@ -202,22 +202,34 @@ void Fl_Xlib_Graphics_Driver::set_spot(int font, int size, int X, int Y, int W,
XFree(preedit_attr);
}
+#if !USE_XFT
unsigned Fl_Xlib_Graphics_Driver::font_desc_size() {
- return (unsigned)sizeof(Fl_Fontdesc);
+ return (unsigned)sizeof(Fl_Xlib_Fontdesc);
}
+#endif
const char *Fl_Xlib_Graphics_Driver::font_name(int num) {
+#if USE_XFT
return fl_fonts[num].name;
+#else
+ return ((Fl_Xlib_Fontdesc*)fl_fonts)[num].name;
+#endif
}
void Fl_Xlib_Graphics_Driver::font_name(int num, const char *name) {
-#if USE_PANGO
+#if USE_XFT
+# if USE_PANGO
init_built_in_fonts();
-#endif
+# endif
Fl_Fontdesc *s = fl_fonts + num;
+#else
+ Fl_Xlib_Fontdesc *s = ((Fl_Xlib_Fontdesc*)fl_fonts) + num;
+#endif
if (s->name) {
if (!strcmp(s->name, name)) {s->name = name; return;}
+#if !USE_XFT
if (s->xlist && s->n >= 0) XFreeFontNames(s->xlist);
+#endif
for (Fl_Font_Descriptor* f = s->first; f;) {
Fl_Font_Descriptor* n = f->next; delete f; f = n;
}
@@ -225,7 +237,9 @@ void Fl_Xlib_Graphics_Driver::font_name(int num, const char *name) {
}
s->name = name;
s->fontname[0] = 0;
+#if !USE_XFT
s->xlist = 0;
+#endif
s->first = 0;
}
diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx
index dcb209154..377be7c91 100644
--- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx
+++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_x.cxx
@@ -94,7 +94,7 @@ static int use_registry(const char *p) {
// turn a stored (with *'s) X font name into a pretty name:
const char* Fl_Xlib_Graphics_Driver::get_font_name(Fl_Font fnum, int* ap) {
- Fl_Fontdesc *f = fl_fonts + fnum;
+ Fl_Xlib_Fontdesc *f = ((Fl_Xlib_Fontdesc*)fl_fonts) + fnum;
if (!f->fontname[0]) {
int type = 0;
const char* p = f->name;
@@ -312,9 +312,10 @@ Fl_Font Fl_Xlib_Graphics_Driver::set_fonts(const char* xstarname) {
break;
}
}
- if (!fl_fonts[j].xlist) {
- fl_fonts[j].xlist = xlist+first_xlist;
- fl_fonts[j].n = -(i-first_xlist);
+ Fl_Xlib_Fontdesc *s = ((Fl_Xlib_Fontdesc*)fl_fonts)+j;
+ if (!s->xlist) {
+ s->xlist = xlist+first_xlist;
+ s->n = -(i-first_xlist);
used_xlist = 1;
}
}
@@ -323,8 +324,8 @@ Fl_Font Fl_Xlib_Graphics_Driver::set_fonts(const char* xstarname) {
}
int Fl_Xlib_Graphics_Driver::get_font_sizes(Fl_Font fnum, int*& sizep) {
- Fl_Fontdesc *s = fl_fonts+fnum;
- if (!s->name) s = fl_fonts; // empty slot in table, use entry 0
+ Fl_Xlib_Fontdesc *s = ((Fl_Xlib_Fontdesc*)fl_fonts)+fnum;
+ if (!s->name) s = ((Fl_Xlib_Fontdesc*)fl_fonts); // empty slot in table, use entry 0
if (!s->xlist) {
fl_open_display();
s->xlist = XListFonts(fl_display, s->name, 100, &(s->n));
@@ -358,7 +359,7 @@ int Fl_Xlib_Graphics_Driver::get_font_sizes(Fl_Font fnum, int*& sizep) {
#ifndef FL_DOXYGEN
-Fl_Font_Descriptor::Fl_Font_Descriptor(const char* name) {
+Fl_Xlib_Font_Descriptor::Fl_Xlib_Font_Descriptor(const char* name) : Fl_Font_Descriptor(name, 0) {
font = XCreateUtf8FontStruct(fl_display, name);
if (!font) {
Fl::warning("bad font: %s", name);
@@ -372,7 +373,7 @@ Fl_Font_Descriptor::Fl_Font_Descriptor(const char* name) {
Fl_XFont_On_Demand fl_xfont;
-Fl_Font_Descriptor::~Fl_Font_Descriptor() {
+Fl_Xlib_Font_Descriptor::~Fl_Xlib_Font_Descriptor() {
# if HAVE_GL
// Delete list created by gl_draw(). This is not done by this code
// as it will link in GL unnecessarily. There should be some kind
@@ -389,7 +390,7 @@ Fl_Font_Descriptor::~Fl_Font_Descriptor() {
// WARNING: if you add to this table, you must redefine FL_FREE_FONT
// in Enumerations.H & recompile!!
-static Fl_Fontdesc built_in_table[] = {
+static Fl_Xlib_Fontdesc built_in_table[] = {
{"-*-helvetica-medium-r-normal--*"},
{"-*-helvetica-bold-r-normal--*"},
{"-*-helvetica-medium-o-normal--*"},
@@ -408,7 +409,7 @@ static Fl_Fontdesc built_in_table[] = {
{"-*-*zapf dingbats-*"}
};
-Fl_Fontdesc* fl_fonts = built_in_table;
+Fl_Fontdesc* fl_fonts = (Fl_Fontdesc*)built_in_table;
#define MAXSIZE 32767
@@ -554,8 +555,8 @@ static char *put_font_size(const char *n, int size)
char *fl_get_font_xfld(int fnum, int size) {
- Fl_Fontdesc* s = fl_fonts+fnum;
- if (!s->name) s = fl_fonts; // use font 0 if still undefined
+ Fl_Xlib_Fontdesc* s = ((Fl_Xlib_Fontdesc*)fl_fonts)+fnum;
+ if (!s->name) s = (Fl_Xlib_Fontdesc*)fl_fonts; // use font 0 if still undefined
fl_open_display();
return put_font_size(s->name, size);
}
@@ -563,15 +564,15 @@ char *fl_get_font_xfld(int fnum, int size) {
// locate or create an Fl_Font_Descriptor for a given Fl_Fontdesc and size:
static Fl_Font_Descriptor* find(int fnum, int size) {
char *name;
- Fl_Fontdesc* s = fl_fonts+fnum;
- if (!s->name) s = fl_fonts; // use font 0 if still undefined
+ Fl_Xlib_Fontdesc* s = ((Fl_Xlib_Fontdesc*)fl_fonts)+fnum;
+ if (!s->name) s = (Fl_Xlib_Fontdesc*)fl_fonts; // use font 0 if still undefined
Fl_Font_Descriptor* f;
for (f = s->first; f; f = f->next)
if (f->size == size) return f;
fl_open_display();
name = put_font_size(s->name, size);
- f = new Fl_Font_Descriptor(name);
+ f = new Fl_Xlib_Font_Descriptor(name);
f->size = size;
f->next = s->first;
s->first = f;
@@ -597,7 +598,7 @@ void Fl_Xlib_Graphics_Driver::font_unscaled(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);
+ Fl_Xlib_Font_Descriptor* f = (Fl_Xlib_Font_Descriptor*)find(fnum, size);
if (f != this->font_descriptor()) {
this->font_descriptor(f);
fl_xfont = f->font->fonts[0];
@@ -606,12 +607,12 @@ void Fl_Xlib_Graphics_Driver::font_unscaled(Fl_Font fnum, Fl_Fontsize size) {
}
int Fl_Xlib_Graphics_Driver::height_unscaled() {
- if (font_descriptor()) return font_descriptor()->font->ascent + font_descriptor()->font->descent;
+ if (font_descriptor()) return ((Fl_Xlib_Font_Descriptor*)font_descriptor())->font->ascent + ((Fl_Xlib_Font_Descriptor*)font_descriptor())->font->descent;
else return -1;
}
int Fl_Xlib_Graphics_Driver::descent_unscaled() {
- if (font_descriptor()) return font_descriptor()->font->descent;
+ if (font_descriptor()) return ((Fl_Xlib_Font_Descriptor*)font_descriptor())->font->descent;
else return -1;
}
@@ -621,12 +622,12 @@ Fl_Fontsize Fl_Xlib_Graphics_Driver::size_unscaled() {
}
double Fl_Xlib_Graphics_Driver::width_unscaled(const char* c, int n) {
- if (font_descriptor()) return (double) XUtf8TextWidth(font_descriptor()->font, c, n);
+ if (font_descriptor()) return (double) XUtf8TextWidth(((Fl_Xlib_Font_Descriptor*)font_descriptor())->font, c, n);
else return -1;
}
double Fl_Xlib_Graphics_Driver::width_unscaled(unsigned int c) {
- if (font_descriptor()) return (double) XUtf8UcsWidth(font_descriptor()->font, c);
+ if (font_descriptor()) return (double) XUtf8UcsWidth(((Fl_Xlib_Font_Descriptor*)font_descriptor())->font, c);
else return -1;
}
@@ -634,11 +635,11 @@ void Fl_Xlib_Graphics_Driver::text_extents_unscaled(const char *c, int n, int &d
if (font_gc != gc_) {
if (!font_descriptor()) font(FL_HELVETICA, FL_NORMAL_SIZE);
font_gc = gc_;
- XSetFont(fl_display, gc_, font_descriptor()->font->fid);
+ XSetFont(fl_display, gc_, ((Fl_Xlib_Font_Descriptor*)font_descriptor())->font->fid);
}
int xx, yy, ww, hh;
xx = yy = ww = hh = 0;
- if (gc_) XUtf8_measure_extents(fl_display, fl_window, font_descriptor()->font, gc_, &xx, &yy, &ww, &hh, c, n);
+ if (gc_) XUtf8_measure_extents(fl_display, fl_window, ((Fl_Xlib_Font_Descriptor*)font_descriptor())->font, gc_, &xx, &yy, &ww, &hh, c, n);
W = ww; H = hh; dx = xx; dy = yy;
// This is the safe but mostly wrong thing we used to do...
@@ -652,9 +653,9 @@ void Fl_Xlib_Graphics_Driver::draw_unscaled(const char* c, int n, int x, int y)
if (font_gc != gc_) {
if (!font_descriptor()) this->font(FL_HELVETICA, FL_NORMAL_SIZE);
font_gc = gc_;
- XSetFont(fl_display, gc_, font_descriptor()->font->fid);
+ XSetFont(fl_display, gc_, ((Fl_Xlib_Font_Descriptor*)font_descriptor())->font->fid);
}
- if (gc_) XUtf8DrawString(fl_display, fl_window, font_descriptor()->font, gc_, x+offset_x_, y+offset_y_, c, n);
+ if (gc_) XUtf8DrawString(fl_display, fl_window, ((Fl_Xlib_Font_Descriptor*)font_descriptor())->font, gc_, x+offset_x_, y+offset_y_, c, n);
}
void Fl_Xlib_Graphics_Driver::draw_unscaled(int angle, const char *str, int n, int x, int y) {
@@ -673,14 +674,14 @@ void Fl_Xlib_Graphics_Driver::rtl_draw_unscaled(const char* c, int n, int x, int
if (!font_descriptor()) this->font(FL_HELVETICA, FL_NORMAL_SIZE);
font_gc = gc_;
}
- if (gc_) XUtf8DrawRtlString(fl_display, fl_window, font_descriptor()->font, gc_, x+offset_x_, y+offset_y_, c, n);
+ if (gc_) XUtf8DrawRtlString(fl_display, fl_window, ((Fl_Xlib_Font_Descriptor*)font_descriptor())->font, gc_, x+offset_x_, y+offset_y_, c, n);
}
float Fl_Xlib_Graphics_Driver::scale_font_for_PostScript(Fl_Font_Descriptor *desc, int s) {
float ps_size = (float) s;
// Non-Xft fonts can be smaller than required.
// Set the PostScript font size to the display font height
- char *name = desc->font->font_name_list[0];
+ char *name = ((Fl_Xlib_Font_Descriptor*)desc)->font->font_name_list[0];
char *p = strstr(name, "--");
if (p) {
sscanf(p + 2, "%f", &ps_size);
diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx
index 5bda05e5c..e5d62492a 100644
--- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx
+++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx
@@ -695,13 +695,9 @@ puts("Font Opened"); fflush(stdout);
}
} // end of fontopen
-Fl_Font_Descriptor::Fl_Font_Descriptor(const char* name, Fl_Fontsize fsize, int fangle) {
+Fl_Xlib_Font_Descriptor::Fl_Xlib_Font_Descriptor(const char* name, Fl_Fontsize fsize, int fangle) : Fl_Font_Descriptor(name, fsize) {
// encoding = fl_encoding_;
- size = fsize;
angle = fangle;
-#if HAVE_GL
- listbase = 0;
-#endif // HAVE_GL
font = fontopen(name, fsize, false, angle);
}
@@ -729,7 +725,7 @@ static const wchar_t *utf8reformat(const char *str, int& n)
return buffer;
}
-static void utf8extents(Fl_Font_Descriptor *desc, const char *str, int n, XGlyphInfo *extents)
+static void utf8extents(Fl_Xlib_Font_Descriptor *desc, const char *str, int n, XGlyphInfo *extents)
{
memset(extents, 0, sizeof(XGlyphInfo));
const wchar_t *buffer = utf8reformat(str, n);
@@ -741,26 +737,26 @@ static void utf8extents(Fl_Font_Descriptor *desc, const char *str, int n, XGlyph
}
int Fl_Xlib_Graphics_Driver::height_unscaled() {
- if (font_descriptor()) return font_descriptor()->font->ascent + font_descriptor()->font->descent;
+ if (font_descriptor()) return ((Fl_Xlib_Font_Descriptor*)font_descriptor())->font->ascent + ((Fl_Xlib_Font_Descriptor*)font_descriptor())->font->descent;
else return -1;
}
int Fl_Xlib_Graphics_Driver::descent_unscaled() {
- if (font_descriptor()) return font_descriptor()->font->descent;
+ if (font_descriptor()) return ((Fl_Xlib_Font_Descriptor*)font_descriptor())->font->descent;
else return -1;
}
double Fl_Xlib_Graphics_Driver::width_unscaled(const char* str, int n) {
if (!font_descriptor()) return -1.0;
XGlyphInfo i;
- utf8extents(font_descriptor(), str, n, &i);
+ utf8extents((Fl_Xlib_Font_Descriptor*)font_descriptor(), str, n, &i);
return i.xOff;
}
static double fl_xft_width(Fl_Font_Descriptor *desc, FcChar32 *str, int n) {
if (!desc) return -1.0;
XGlyphInfo i;
- XftTextExtents32(fl_display, desc->font, str, n, &i);
+ XftTextExtents32(fl_display, ((Fl_Xlib_Font_Descriptor*)desc)->font, str, n, &i);
return i.xOff;
}
@@ -776,7 +772,7 @@ void Fl_Xlib_Graphics_Driver::text_extents_unscaled(const char *c, int n, int &d
return;
}
XGlyphInfo gi;
- utf8extents(font_descriptor(), c, n, &gi);
+ utf8extents((Fl_Xlib_Font_Descriptor*)font_descriptor(), c, n, &gi);
w = gi.width;
h = gi.height;
@@ -818,9 +814,9 @@ void Fl_Xlib_Graphics_Driver::draw_unscaled(const char *str, int n, int x, int y
const wchar_t *buffer = utf8reformat(str, n);
#ifdef __CYGWIN__
- XftDrawString16(draw_, &color, font_descriptor()->font, x+offset_x_*scale_+line_delta_, y+offset_y_*scale_+line_delta_, (XftChar16 *)buffer, n);
+ XftDrawString16(draw_, &color, ((Fl_Xlib_Font_Descriptor*)font_descriptor())->font, x+offset_x_*scale_+line_delta_, y+offset_y_*scale_+line_delta_, (XftChar16 *)buffer, n);
#else
- XftDrawString32(draw_, &color, font_descriptor()->font, x+offset_x_*scale_+line_delta_, y+offset_y_*scale_+line_delta_, (XftChar32 *)buffer, n);
+ XftDrawString32(draw_, &color, ((Fl_Xlib_Font_Descriptor*)font_descriptor())->font, x+offset_x_*scale_+line_delta_, y+offset_y_*scale_+line_delta_, (XftChar32 *)buffer, n);
#endif
}
}
@@ -862,7 +858,7 @@ void Fl_Xlib_Graphics_Driver::drawUCS4(const void *str, int n, int x, int y) {
color.color.blue = ((int)b)*0x101;
color.color.alpha = 0xffff;
- XftDrawString32(draw_, &color, font_descriptor()->font, x+offset_x_*scale_+line_delta_, y+offset_y_*scale_+line_delta_, (FcChar32 *)str, n);
+ XftDrawString32(draw_, &color, ((Fl_Xlib_Font_Descriptor*)font_descriptor())->font, x+offset_x_*scale_+line_delta_, y+offset_y_*scale_+line_delta_, (FcChar32 *)str, n);
}
@@ -998,7 +994,7 @@ float Fl_Xlib_Graphics_Driver::scale_bitmap_for_PostScript() {
return 2;
}
-Fl_Font_Descriptor::~Fl_Font_Descriptor() {
+Fl_Xlib_Font_Descriptor::~Fl_Xlib_Font_Descriptor() {
if (this == fl_graphics_driver->font_descriptor()) fl_graphics_driver->font_descriptor(NULL);
// XftFontClose(fl_display, font);
}
@@ -1019,18 +1015,18 @@ static void fl_xft_font(Fl_Xlib_Graphics_Driver *driver, Fl_Font fnum, Fl_Fontsi
driver->Fl_Graphics_Driver::font(0, 0);
return;
}
- Fl_Font_Descriptor* f = driver->font_descriptor();
+ Fl_Xlib_Font_Descriptor* f = (Fl_Xlib_Font_Descriptor*)driver->font_descriptor();
if (fnum == driver->Fl_Graphics_Driver::font() && size == driver->size_unscaled() && f && f->angle == angle)
return;
driver->Fl_Graphics_Driver::font(fnum, size);
Fl_Fontdesc *font = fl_fonts + fnum;
// search the fontsizes we have generated already
- for (f = font->first; f; f = f->next) {
+ for (f = (Fl_Xlib_Font_Descriptor*)font->first; f; f = (Fl_Xlib_Font_Descriptor*)f->next) {
if (f->size == size && f->angle == angle)// && !strcasecmp(f->encoding, fl_encoding_))
break;
}
if (!f) {
- f = new Fl_Font_Descriptor(font->name, size, angle);
+ f = new Fl_Xlib_Font_Descriptor(font->name, size, angle);
f->next = font->first;
font->first = f;
}
@@ -1202,6 +1198,7 @@ PangoContext *Fl_Xlib_Graphics_Driver::context() {
return pctxt_;
}
+
void Fl_Xlib_Graphics_Driver::font_unscaled(Fl_Font fnum, Fl_Fontsize size) {
if (!size) return;
if (size < 0) {
@@ -1215,7 +1212,7 @@ void Fl_Xlib_Graphics_Driver::font_unscaled(Fl_Font fnum, Fl_Fontsize size) {
pfd_ = pango_font_description_from_string(Fl::get_font_name(fnum));
pango_font_description_set_absolute_size(pfd_, size*PANGO_SCALE); // 1.8
if (!pctxt_) context();
- Fl_Font_Descriptor *fd = font_descriptor();
+ Fl_Xlib_Font_Descriptor *fd = (Fl_Xlib_Font_Descriptor*)font_descriptor();
if (!fd->height_) {
PangoFont *pfont = pango_font_map_load_font(pfmap_, pctxt_, pfd_);
PangoRectangle logical_rect;
@@ -1339,7 +1336,7 @@ void Fl_Xlib_Graphics_Driver::text_extents_unscaled(const char *str, int n, int
}
int Fl_Xlib_Graphics_Driver::height_unscaled() {
- if (font_descriptor()) return font_descriptor()->height_;
+ if (font_descriptor()) return ((Fl_Xlib_Font_Descriptor*)font_descriptor())->height_;
else return -1;
}
@@ -1350,7 +1347,7 @@ double Fl_Xlib_Graphics_Driver::width_unscaled(unsigned int c) {
}
int Fl_Xlib_Graphics_Driver::descent_unscaled() {
- if (font_descriptor()) return font_descriptor()->descent_;
+ if (font_descriptor()) return ((Fl_Xlib_Font_Descriptor*)font_descriptor())->descent_;
else return -1;
}
@@ -1433,13 +1430,9 @@ int Fl_Xlib_Graphics_Driver::get_font_sizes(Fl_Font fnum, int*& sizep) {
return 1;
}
-Fl_Font_Descriptor::Fl_Font_Descriptor(const char* name, Fl_Fontsize fsize, int fangle) {
+Fl_Xlib_Font_Descriptor::Fl_Xlib_Font_Descriptor(const char* name, Fl_Fontsize fsize, int fangle) : Fl_Font_Descriptor(name, fsize) {
fl_open_display();
- size = fsize;
angle = fangle;
-#if HAVE_GL
- listbase = 0;
-#endif // HAVE_GL
height_ = 0;
descent_ = 0;
}