From 63e33b1be3e2af253cd8adf10a5eac7e72a5fc7e Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Fri, 23 Sep 2016 07:47:57 +0000 Subject: Fl_Quartz_Graphics_Driver: separate CoreText- and ATSU-based code using new, derived classes. FLTK for the Mac OS platform draws text using 2 distinct system APIs depending on the version of the running OS. Classes Fl_CoreText_Graphics_Driver and Fl_ATSU_Graphics_Driver are defined and implement the same virtual functions of class Fl_Quartz_Graphics_Driver using CoreText and ATSU, respectively. The app allocates an object of one of these derived classes according to the running OS version. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11967 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx') diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx index 8d5cff37b..fd31e7030 100644 --- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx @@ -19,6 +19,7 @@ #include "../../config_lib.h" #include "Fl_Quartz_Graphics_Driver.H" +#include "../Darwin/Fl_Darwin_System_Driver.H" #include /* @@ -27,7 +28,20 @@ */ Fl_Graphics_Driver *Fl_Graphics_Driver::newMainGraphicsDriver() { - return new Fl_Quartz_Graphics_Driver(); +#if HAS_ATSU + static int option = 0; // 0: not initialized, 1: use CoreText, 2: use ATSU + if (!option) { + option = 2; + if (Fl_Darwin_System_Driver::calc_mac_os_version() >= Fl_Quartz_Graphics_Driver::CoreText_threshold) { + option = 1; + } + } + if (option == 2) return new Fl_ATSU_Graphics_Driver(); +#endif // HAS_ATSU +#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5 + return new Fl_CoreText_Graphics_Driver(); +#endif + return NULL; // should not happen } char Fl_Quartz_Graphics_Driver::can_do_alpha_blending() { -- cgit v1.2.3