Move font-related member functions from Fl_Screen_Driver to Fl_Graphics_Driver.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11968 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
parent
63e33b1be3
commit
0250c5a98a
@ -52,6 +52,7 @@ FL_EXPORT extern Fl_Graphics_Driver *fl_graphics_driver;
|
||||
*/
|
||||
typedef void (*Fl_Draw_Image_Cb)(void* data,int x,int y,int w,uchar* buf);
|
||||
|
||||
struct Fl_Fontdesc;
|
||||
|
||||
#define FL_REGION_STACK_SIZE 10
|
||||
#define FL_MATRIX_STACK_SIZE 32
|
||||
@ -323,6 +324,15 @@ public:
|
||||
virtual void add_rectangle_to_region(Fl_Region r, int x, int y, int w, int h);
|
||||
virtual Fl_Region XRectangleRegion(int x, int y, int w, int h);
|
||||
virtual void XDestroyRegion(Fl_Region r);
|
||||
// font support
|
||||
virtual const char* get_font_name(Fl_Font fnum, int* ap) {return NULL;}
|
||||
virtual int get_font_sizes(Fl_Font fnum, int*& sizep) {return 0;}
|
||||
virtual Fl_Font set_fonts(const char *name) {return 0;}
|
||||
// an implementation which returns NULL may be enough
|
||||
virtual Fl_Fontdesc* calc_fl_fonts(void) {return NULL;}
|
||||
virtual unsigned font_desc_size() {return 0;}
|
||||
virtual const char *font_name(int num) {return NULL;}
|
||||
virtual void font_name(int num, const char *name) {}
|
||||
};
|
||||
|
||||
#endif // FL_GRAPHICS_DRIVER_H
|
||||
|
@ -118,16 +118,6 @@ public:
|
||||
Fl_Text_Editor::Key_Binding *text_editor_extra_key_bindings;
|
||||
// default implementation may be enough
|
||||
virtual int text_display_can_leak() { return 0; }
|
||||
// an implementation which returns NULL may be enough
|
||||
virtual struct Fl_Fontdesc *calc_fl_fonts() {return NULL;}
|
||||
// API to the platform-dependent Fl_Fontdesc structure
|
||||
virtual unsigned font_desc_size() {return 0;}
|
||||
virtual const char *font_name(int num) {return NULL;}
|
||||
virtual void font_name(int num, const char *name) {}
|
||||
// to support Fl::set_fonts(), Fl::get_font_sizes(), Fl::get_font_name()
|
||||
virtual Fl_Font set_fonts(const char *name) {return 0;}
|
||||
virtual int get_font_sizes(Fl_Font fnum, int*& sizep) {return 0;}
|
||||
virtual const char* get_font_name(Fl_Font fnum, int* ap) {return NULL;}
|
||||
|
||||
// read raw image from a window or an offscreen buffer
|
||||
#if defined(FL_PORTING)
|
||||
|
@ -2005,15 +2005,15 @@ void fl_open_callback(void (*cb)(const char *))
|
||||
/** @} */
|
||||
|
||||
Fl_Font Fl::set_fonts(const char* xstarname) {
|
||||
return Fl::screen_driver()->set_fonts(xstarname);
|
||||
return Fl_Graphics_Driver::default_driver().set_fonts(xstarname);
|
||||
}
|
||||
|
||||
const char* Fl::get_font_name(Fl_Font fnum, int* ap) {
|
||||
return Fl::screen_driver()->get_font_name(fnum, ap);
|
||||
return Fl_Graphics_Driver::default_driver().get_font_name(fnum, ap);
|
||||
}
|
||||
|
||||
int Fl::get_font_sizes(Fl_Font fnum, int*& sizep) {
|
||||
return Fl::screen_driver()->get_font_sizes(fnum, sizep);
|
||||
return Fl_Graphics_Driver::default_driver().get_font_sizes(fnum, sizep);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -94,13 +94,6 @@ public:
|
||||
virtual void enable_im();
|
||||
virtual void disable_im();
|
||||
virtual void open_display();
|
||||
virtual Fl_Font set_fonts(const char *name);
|
||||
virtual int get_font_sizes(Fl_Font fnum, int*& sizep);
|
||||
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();
|
||||
virtual struct Fl_Fontdesc *calc_fl_fonts();
|
||||
};
|
||||
|
||||
|
||||
|
@ -279,29 +279,6 @@ int Fl_Cocoa_Screen_Driver::compose(int &del) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned Fl_Cocoa_Screen_Driver::font_desc_size() {
|
||||
return (unsigned)sizeof(Fl_Fontdesc);
|
||||
}
|
||||
|
||||
const char *Fl_Cocoa_Screen_Driver::font_name(int num) {
|
||||
if (!fl_fonts) fl_fonts = calc_fl_fonts();
|
||||
return fl_fonts[num].name;
|
||||
}
|
||||
|
||||
void Fl_Cocoa_Screen_Driver::font_name(int num, const char *name) {
|
||||
Fl_Fontdesc *s = fl_fonts + num;
|
||||
if (s->name) {
|
||||
if (!strcmp(s->name, name)) {s->name = name; return;}
|
||||
for (Fl_Font_Descriptor* f = s->first; f;) {
|
||||
Fl_Font_Descriptor* n = f->next; delete f; f = n;
|
||||
}
|
||||
s->first = 0;
|
||||
}
|
||||
s->name = name;
|
||||
s->fontname[0] = 0;
|
||||
s->first = 0;
|
||||
}
|
||||
|
||||
uchar * // O - Pixel buffer or NULL if failed
|
||||
Fl_Cocoa_Screen_Driver::read_image(uchar *p, // I - Pixel buffer or NULL to allocate
|
||||
int x, // I - Left position
|
||||
|
@ -134,6 +134,12 @@ protected:
|
||||
void free_color(Fl_Color i, int overlay);
|
||||
void set_spot(int font, int size, int X, int Y, int W, int H, Fl_Window *win);
|
||||
void reset_spot();
|
||||
virtual Fl_Font set_fonts(const char *name);
|
||||
virtual int get_font_sizes(Fl_Font fnum, int*& sizep);
|
||||
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();
|
||||
protected:
|
||||
void global_gc();
|
||||
};
|
||||
|
@ -37,7 +37,6 @@
|
||||
|
||||
// Select fonts from the FLTK font table.
|
||||
#include "Fl_GDI_Graphics_Driver.H"
|
||||
#include "../WinAPI/Fl_WinAPI_Screen_Driver.H"
|
||||
#include "../../flstring.h"
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/fl_draw.H>
|
||||
@ -63,7 +62,7 @@
|
||||
#define ENDOFBUFFER 127 // sizeof(Fl_Font.fontname)-1
|
||||
|
||||
// turn a stored font name into a pretty name:
|
||||
const char* Fl_WinAPI_Screen_Driver::get_font_name(Fl_Font fnum, int* ap) {
|
||||
const char* Fl_GDI_Graphics_Driver::get_font_name(Fl_Font fnum, int* ap) {
|
||||
Fl_Fontdesc *f = fl_fonts + fnum;
|
||||
if (!f->fontname[0]) {
|
||||
const char* p = f->name;
|
||||
@ -113,7 +112,7 @@ enumcbw(CONST LOGFONTW *lpelf,
|
||||
return 1;
|
||||
} /* enumcbw */
|
||||
|
||||
Fl_Font Fl_WinAPI_Screen_Driver::set_fonts(const char* xstarname) {
|
||||
Fl_Font Fl_GDI_Graphics_Driver::set_fonts(const char* xstarname) {
|
||||
HDC gc = (HDC)fl_graphics_driver->gc();
|
||||
if (fl_free_font == FL_FREE_FONT) {// if not already been called
|
||||
if (!gc) gc = fl_GetDC(0);
|
||||
@ -164,7 +163,7 @@ EnumSizeCbW(CONST LOGFONTW * /*lpelf*/,
|
||||
}
|
||||
|
||||
|
||||
int Fl_WinAPI_Screen_Driver::get_font_sizes(Fl_Font fnum, int*& sizep) {
|
||||
int Fl_GDI_Graphics_Driver::get_font_sizes(Fl_Font fnum, int*& sizep) {
|
||||
nbSize = 0;
|
||||
Fl_Fontdesc *s = fl_fonts+fnum;
|
||||
if (!s->name) s = fl_fonts; // empty slot in table, use entry 0
|
||||
@ -190,29 +189,28 @@ int Fl_WinAPI_Screen_Driver::get_font_sizes(Fl_Font fnum, int*& sizep) {
|
||||
return nbSize;
|
||||
}
|
||||
|
||||
unsigned Fl_GDI_Graphics_Driver::font_desc_size() {
|
||||
return (unsigned)sizeof(Fl_Fontdesc);
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
||||
//
|
||||
// "$Id$"
|
||||
//
|
||||
// WIN32 font selection routines for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-2016 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
|
||||
// file is missing or damaged, see the license at:
|
||||
//
|
||||
// http://www.fltk.org/COPYING.php
|
||||
//
|
||||
// Please report all bugs and problems on the following page:
|
||||
//
|
||||
// http://www.fltk.org/str.php
|
||||
//
|
||||
const char *Fl_GDI_Graphics_Driver::font_name(int num) {
|
||||
return fl_fonts[num].name;
|
||||
}
|
||||
|
||||
void Fl_GDI_Graphics_Driver::font_name(int num, const char *name) {
|
||||
Fl_Fontdesc *s = fl_fonts + num;
|
||||
if (s->name) {
|
||||
if (!strcmp(s->name, name)) {s->name = name; return;}
|
||||
for (Fl_Font_Descriptor* f = s->first; f;) {
|
||||
Fl_Font_Descriptor* n = f->next; delete f; f = n;
|
||||
}
|
||||
s->first = 0;
|
||||
}
|
||||
s->name = name;
|
||||
s->fontname[0] = 0;
|
||||
s->first = 0;
|
||||
}
|
||||
|
||||
#include <FL/Fl_Printer.H>
|
||||
|
||||
static int fl_angle_ = 0;
|
||||
|
||||
@ -642,6 +640,7 @@ void Fl_GDI_Graphics_Driver::rtl_draw(const char* c, int n, int x, int y) {
|
||||
SetTextColor(gc_, oldColor);
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
//
|
||||
|
@ -140,13 +140,17 @@ protected:
|
||||
int descent();
|
||||
virtual bool high_resolution() { return high_resolution_; }
|
||||
virtual void global_gc();
|
||||
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);
|
||||
// Next group of virtual functions have at least one alternative
|
||||
// CoreText- or ATSU-based implementation.
|
||||
virtual void draw_float(float x, float y, const char *str, int n) {}
|
||||
virtual double width(const UniChar* txt, int n, Fl_Font_Descriptor *fl_fontsize) {return 0;}
|
||||
public:
|
||||
virtual Fl_Font set_fonts(const char* xstarname) {return 0;}
|
||||
virtual Fl_Fontdesc* calc_fl_fonts(void) {return NULL;}
|
||||
virtual void set_fontname_in_fontdesc(Fl_Fontdesc *f);
|
||||
virtual void descriptor_init(const char* name, Fl_Fontsize Size, Fl_Font_Descriptor *d) {}
|
||||
// end of function group
|
||||
@ -157,7 +161,7 @@ class Fl_CoreText_Graphics_Driver : public Fl_Quartz_Graphics_Driver {
|
||||
void text_extents(const char*, int n, int& dx, int& dy, int& w, int& h);
|
||||
virtual void draw_float(float x, float y, const char *str, int n);
|
||||
virtual double width(const UniChar* txt, int n, Fl_Font_Descriptor *fl_fontsize);
|
||||
Fl_Font set_fonts(const char* xstarname);
|
||||
virtual Fl_Font set_fonts(const char* xstarname);
|
||||
virtual Fl_Fontdesc* calc_fl_fonts(void);
|
||||
virtual void set_fontname_in_fontdesc(Fl_Fontdesc *f);
|
||||
virtual void descriptor_init(const char* name, Fl_Fontsize Size, Fl_Font_Descriptor *d);
|
||||
@ -169,7 +173,7 @@ class Fl_ATSU_Graphics_Driver : public Fl_Quartz_Graphics_Driver {
|
||||
void text_extents(const char*, int n, int& dx, int& dy, int& w, int& h);
|
||||
virtual void draw_float(float x, float y, const char *str, int n);
|
||||
virtual double width(const UniChar* txt, int n, Fl_Font_Descriptor *fl_fontsize);
|
||||
Fl_Font set_fonts(const char* xstarname);
|
||||
virtual Fl_Font set_fonts(const char* xstarname);
|
||||
virtual Fl_Fontdesc* calc_fl_fonts(void);
|
||||
virtual void descriptor_init(const char* name, Fl_Fontsize Size, Fl_Font_Descriptor *d);
|
||||
};
|
||||
|
@ -87,12 +87,11 @@ static Fl_Fontdesc built_in_table_full[] = { // full font names used before 10.5
|
||||
#define ENDOFBUFFER sizeof(fl_fonts->fontname)-1
|
||||
|
||||
// turn a stored font name into a pretty name:
|
||||
const char* Fl_Cocoa_Screen_Driver::get_font_name(Fl_Font fnum, int* ap) {
|
||||
const char* Fl_Quartz_Graphics_Driver::get_font_name(Fl_Font fnum, int* ap) {
|
||||
if (!fl_fonts) fl_fonts = calc_fl_fonts();
|
||||
Fl_Fontdesc *f = fl_fonts + fnum;
|
||||
if (!f->fontname[0]) {
|
||||
Fl_Quartz_Graphics_Driver *d = (Fl_Quartz_Graphics_Driver*)Fl_Display_Device::display_device()->driver();
|
||||
d->set_fontname_in_fontdesc(f);
|
||||
this->set_fontname_in_fontdesc(f);
|
||||
const char* p = f->name;
|
||||
if (!p || !*p) {if (ap) *ap = 0; return "";}
|
||||
int type = 0;
|
||||
@ -105,18 +104,7 @@ const char* Fl_Cocoa_Screen_Driver::get_font_name(Fl_Font fnum, int* ap) {
|
||||
}
|
||||
|
||||
|
||||
// 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.
|
||||
|
||||
Fl_Font Fl_Cocoa_Screen_Driver::set_fonts(const char* xstarname) {
|
||||
Fl_Quartz_Graphics_Driver *d = (Fl_Quartz_Graphics_Driver*)Fl_Display_Device::display_device()->driver();
|
||||
return d->set_fonts(xstarname);
|
||||
}
|
||||
|
||||
|
||||
int Fl_Cocoa_Screen_Driver::get_font_sizes(Fl_Font fnum, int*& sizep) {
|
||||
int Fl_Quartz_Graphics_Driver::get_font_sizes(Fl_Font fnum, int*& sizep) {
|
||||
static int array[128];
|
||||
if (!fl_fonts) fl_fonts = calc_fl_fonts();
|
||||
Fl_Fontdesc *s = fl_fonts+fnum;
|
||||
@ -194,14 +182,8 @@ static UniChar *mac_Utf8_to_Utf16(const char *txt, int len, int *new_len)
|
||||
}
|
||||
|
||||
|
||||
Fl_Fontdesc* Fl_Cocoa_Screen_Driver::calc_fl_fonts(void) {
|
||||
Fl_Quartz_Graphics_Driver *d = (Fl_Quartz_Graphics_Driver*)Fl_Display_Device::display_device()->driver();
|
||||
return d->calc_fl_fonts();
|
||||
}
|
||||
|
||||
|
||||
static Fl_Font_Descriptor* find(Fl_Font fnum, Fl_Fontsize size) {
|
||||
if (!fl_fonts) fl_fonts = Fl::screen_driver()->calc_fl_fonts();
|
||||
if (!fl_fonts) fl_fonts = Fl_Graphics_Driver::default_driver().calc_fl_fonts();
|
||||
Fl_Fontdesc* s = fl_fonts+fnum;
|
||||
if (!s->name) s = fl_fonts; // use 0 if fnum undefined
|
||||
Fl_Font_Descriptor* f;
|
||||
@ -289,6 +271,31 @@ void Fl_Quartz_Graphics_Driver::set_fontname_in_fontdesc(Fl_Fontdesc *f) {
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
void Fl_Quartz_Graphics_Driver::font_name(int num, const char *name) {
|
||||
Fl_Fontdesc *s = fl_fonts + num;
|
||||
if (s->name) {
|
||||
if (!strcmp(s->name, name)) {s->name = name; return;}
|
||||
for (Fl_Font_Descriptor* f = s->first; f;) {
|
||||
Fl_Font_Descriptor* n = f->next; delete f; f = n;
|
||||
}
|
||||
s->first = 0;
|
||||
}
|
||||
s->name = name;
|
||||
s->fontname[0] = 0;
|
||||
s->first = 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5
|
||||
/// CoreText-based code
|
||||
|
||||
|
@ -77,12 +77,6 @@ public:
|
||||
virtual void enable_im();
|
||||
virtual void disable_im();
|
||||
virtual void open_display();
|
||||
virtual Fl_Font set_fonts(const char *name);
|
||||
virtual int get_font_sizes(Fl_Font fnum, int*& sizep);
|
||||
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();
|
||||
};
|
||||
|
||||
|
||||
|
@ -511,28 +511,6 @@ int Fl_WinAPI_Screen_Driver::compose(int &del) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
unsigned Fl_WinAPI_Screen_Driver::font_desc_size() {
|
||||
return (unsigned)sizeof(Fl_Fontdesc);
|
||||
}
|
||||
|
||||
const char *Fl_WinAPI_Screen_Driver::font_name(int num) {
|
||||
return fl_fonts[num].name;
|
||||
}
|
||||
|
||||
void Fl_WinAPI_Screen_Driver::font_name(int num, const char *name) {
|
||||
Fl_Fontdesc *s = fl_fonts + num;
|
||||
if (s->name) {
|
||||
if (!strcmp(s->name, name)) {s->name = name; return;}
|
||||
for (Fl_Font_Descriptor* f = s->first; f;) {
|
||||
Fl_Font_Descriptor* n = f->next; delete f; f = n;
|
||||
}
|
||||
s->first = 0;
|
||||
}
|
||||
s->name = name;
|
||||
s->fontname[0] = 0;
|
||||
s->first = 0;
|
||||
}
|
||||
|
||||
|
||||
Fl_RGB_Image * // O - image or NULL if failed
|
||||
Fl_WinAPI_Screen_Driver::read_win_rectangle(uchar *p, // I - Pixel buffer or NULL to allocate
|
||||
|
@ -87,12 +87,6 @@ public:
|
||||
virtual void disable_im();
|
||||
virtual void open_display();
|
||||
virtual void close_display();
|
||||
virtual Fl_Font set_fonts(const char *name);
|
||||
virtual int get_font_sizes(Fl_Font fnum, int*& sizep);
|
||||
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();
|
||||
};
|
||||
|
||||
|
||||
|
@ -694,29 +694,6 @@ int Fl_X11_Screen_Driver::text_display_can_leak() {
|
||||
#endif
|
||||
}
|
||||
|
||||
unsigned Fl_X11_Screen_Driver::font_desc_size() {
|
||||
return (unsigned)sizeof(Fl_Fontdesc);
|
||||
}
|
||||
|
||||
const char *Fl_X11_Screen_Driver::font_name(int num) {
|
||||
return fl_fonts[num].name;
|
||||
}
|
||||
|
||||
void Fl_X11_Screen_Driver::font_name(int num, const char *name) {
|
||||
Fl_Fontdesc *s = fl_fonts + num;
|
||||
if (s->name) {
|
||||
if (!strcmp(s->name, name)) {s->name = name; return;}
|
||||
if (s->xlist && s->n >= 0) XFreeFontNames(s->xlist);
|
||||
for (Fl_Font_Descriptor* f = s->first; f;) {
|
||||
Fl_Font_Descriptor* n = f->next; delete f; f = n;
|
||||
}
|
||||
s->first = 0;
|
||||
}
|
||||
s->name = name;
|
||||
s->fontname[0] = 0;
|
||||
s->xlist = 0;
|
||||
s->first = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// 'fl_subimage_offsets()' - Calculate subimage offsets for an axis
|
||||
|
@ -151,6 +151,12 @@ protected:
|
||||
virtual float scale_bitmap_for_PostScript();
|
||||
virtual void set_spot(int font, int size, int X, int Y, int W, int H, Fl_Window *win);
|
||||
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);
|
||||
virtual unsigned font_desc_size();
|
||||
virtual const char *font_name(int num);
|
||||
virtual void font_name(int num, const char *name);
|
||||
virtual Fl_Font set_fonts(const char* xstarname);
|
||||
protected:
|
||||
virtual void global_gc();
|
||||
};
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
#include "../../config_lib.h"
|
||||
#include "Fl_Xlib_Graphics_Driver.H"
|
||||
#include "Fl_Font.H"
|
||||
#include <FL/fl_draw.H>
|
||||
#include <FL/x.H>
|
||||
|
||||
@ -197,6 +198,29 @@ void Fl_Xlib_Graphics_Driver::set_spot(int font, int size, int X, int Y, int W,
|
||||
XFree(preedit_attr);
|
||||
}
|
||||
|
||||
unsigned Fl_Xlib_Graphics_Driver::font_desc_size() {
|
||||
return (unsigned)sizeof(Fl_Fontdesc);
|
||||
}
|
||||
|
||||
const char *Fl_Xlib_Graphics_Driver::font_name(int num) {
|
||||
return fl_fonts[num].name;
|
||||
}
|
||||
|
||||
void Fl_Xlib_Graphics_Driver::font_name(int num, const char *name) {
|
||||
Fl_Fontdesc *s = fl_fonts + num;
|
||||
if (s->name) {
|
||||
if (!strcmp(s->name, name)) {s->name = name; return;}
|
||||
if (s->xlist && s->n >= 0) XFreeFontNames(s->xlist);
|
||||
for (Fl_Font_Descriptor* f = s->first; f;) {
|
||||
Fl_Font_Descriptor* n = f->next; delete f; f = n;
|
||||
}
|
||||
s->first = 0;
|
||||
}
|
||||
s->name = name;
|
||||
s->fontname[0] = 0;
|
||||
s->xlist = 0;
|
||||
s->first = 0;
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id$".
|
||||
|
@ -19,7 +19,6 @@
|
||||
// Select fonts from the FLTK font table.
|
||||
#include "../../flstring.h"
|
||||
#include "Fl_Xlib_Graphics_Driver.H"
|
||||
#include "../X11/Fl_X11_Screen_Driver.H"
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/fl_draw.H>
|
||||
#include <FL/x.H>
|
||||
@ -94,7 +93,7 @@ static int use_registry(const char *p) {
|
||||
#define ENDOFBUFFER 127 // sizeof(Fl_Font.fontname)-1
|
||||
|
||||
// turn a stored (with *'s) X font name into a pretty name:
|
||||
const char* Fl_X11_Screen_Driver::get_font_name(Fl_Font fnum, int* ap) {
|
||||
const char* Fl_Xlib_Graphics_Driver::get_font_name(Fl_Font fnum, int* ap) {
|
||||
Fl_Fontdesc *f = fl_fonts + fnum;
|
||||
if (!f->fontname[0]) {
|
||||
int type = 0;
|
||||
@ -265,7 +264,12 @@ static int to_canonical(char *to, const char *from, size_t tolen) {
|
||||
|
||||
static unsigned int fl_free_font = FL_FREE_FONT;
|
||||
|
||||
Fl_Font Fl_X11_Screen_Driver::set_fonts(const char* xstarname) {
|
||||
|
||||
// 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.
|
||||
Fl_Font Fl_Xlib_Graphics_Driver::set_fonts(const char* xstarname) {
|
||||
if (fl_free_font > (unsigned)FL_FREE_FONT) // already been here
|
||||
return (Fl_Font)fl_free_font;
|
||||
fl_open_display();
|
||||
@ -318,7 +322,7 @@ Fl_Font Fl_X11_Screen_Driver::set_fonts(const char* xstarname) {
|
||||
return (Fl_Font)fl_free_font;
|
||||
}
|
||||
|
||||
int Fl_X11_Screen_Driver::get_font_sizes(Fl_Font fnum, int*& sizep) {
|
||||
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
|
||||
if (!s->xlist) {
|
||||
|
@ -19,7 +19,6 @@
|
||||
// Select fonts from the FLTK font table.
|
||||
#include "../../flstring.h"
|
||||
#include "Fl_Xlib_Graphics_Driver.H"
|
||||
#include "../X11/Fl_X11_Screen_Driver.H"
|
||||
#include <FL/Fl.H>
|
||||
#include <FL/fl_draw.H>
|
||||
#include <FL/x.H>
|
||||
@ -44,7 +43,7 @@
|
||||
#define USE_OVERLAY 0
|
||||
|
||||
// turn a stored font name in "fltk format" into a pretty name:
|
||||
const char* Fl_X11_Screen_Driver::get_font_name(Fl_Font fnum, int* ap) {
|
||||
const char* Fl_Xlib_Graphics_Driver::get_font_name(Fl_Font fnum, int* ap) {
|
||||
Fl_Fontdesc *f = fl_fonts + fnum;
|
||||
if (!f->fontname[0]) {
|
||||
const char* p = f->name;
|
||||
@ -218,7 +217,7 @@ static int fl_free_font = FL_FREE_FONT;
|
||||
// Also, for now I'm ignoring the "pattern_name" and just getting everything...
|
||||
// AND I don't try and skip the fonts we've already loaded in the defaults.
|
||||
// Blimey! What a hack!
|
||||
Fl_Font Fl_X11_Screen_Driver::set_fonts(const char* pattern_name)
|
||||
Fl_Font Fl_Xlib_Graphics_Driver::set_fonts(const char* pattern_name)
|
||||
{
|
||||
FcFontSet *fnt_set; // Will hold the list of fonts we find
|
||||
FcPattern *fnt_pattern; // Holds the generic "match all names" pattern
|
||||
@ -364,11 +363,11 @@ static int int_sort(const void *aa, const void *bb) {
|
||||
// Return all the point sizes supported by this font:
|
||||
// Suprisingly enough Xft works exactly like fltk does and returns
|
||||
// the same list. Except there is no way to tell if the font is scalable.
|
||||
int Fl_X11_Screen_Driver::get_font_sizes(Fl_Font fnum, int*& sizep) {
|
||||
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
|
||||
|
||||
open_display();
|
||||
fl_open_display();
|
||||
XftFontSet* fs = XftListFonts(fl_display, fl_screen,
|
||||
XFT_FAMILY, XftTypeString, s->name+1,
|
||||
(void *)0,
|
||||
|
@ -35,8 +35,9 @@ static int table_size;
|
||||
the string is not copied, so the string must be in static memory.
|
||||
*/
|
||||
void Fl::set_font(Fl_Font fnum, const char* name) {
|
||||
unsigned width = Fl::screen_driver()->font_desc_size();
|
||||
if (!fl_fonts) fl_fonts = Fl::screen_driver()->calc_fl_fonts();
|
||||
Fl_Graphics_Driver &d = Fl_Graphics_Driver::default_driver();
|
||||
unsigned width = d.font_desc_size();
|
||||
if (!fl_fonts) fl_fonts = d.calc_fl_fonts();
|
||||
while (fnum >= table_size) {
|
||||
int i = table_size;
|
||||
if (!i) { // don't realloc the built-in table
|
||||
@ -53,8 +54,8 @@ void Fl::set_font(Fl_Font fnum, const char* name) {
|
||||
memset((char*)fl_fonts + i * width, 0, width);
|
||||
}
|
||||
}
|
||||
Fl::screen_driver()->font_name(fnum, name);
|
||||
Fl_Display_Device::display_device()->driver()->font(-1, 0);
|
||||
d.font_name(fnum, name);
|
||||
d.font(-1, 0);
|
||||
}
|
||||
|
||||
/** Copies one face to another. */
|
||||
@ -68,7 +69,7 @@ void Fl::set_font(Fl_Font fnum, Fl_Font from) {
|
||||
of this face.
|
||||
*/
|
||||
const char* Fl::get_font(Fl_Font fnum) {
|
||||
return Fl::screen_driver()->font_name(fnum);
|
||||
return Fl_Graphics_Driver::default_driver().font_name(fnum);
|
||||
}
|
||||
|
||||
//
|
||||
|
Loading…
Reference in New Issue
Block a user