summaryrefslogtreecommitdiff
path: root/src/drivers/Quartz
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers/Quartz')
-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
3 files changed, 27 insertions, 61 deletions
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;