diff options
Diffstat (limited to 'support/dktools/WxdkdrawFont.cpt')
-rw-r--r-- | support/dktools/WxdkdrawFont.cpt | 650 |
1 files changed, 0 insertions, 650 deletions
diff --git a/support/dktools/WxdkdrawFont.cpt b/support/dktools/WxdkdrawFont.cpt deleted file mode 100644 index 53a2bc4e3f..0000000000 --- a/support/dktools/WxdkdrawFont.cpt +++ /dev/null @@ -1,650 +0,0 @@ -%% options - -copyright owner = Dirk Krause -copyright year = 2019-xxxx -SPDX-License-Identifier: BSD-3-Clause - -%% header - -/** @file WxdkdrawFont.h WXD font structures. -*/ - -#ifndef WXDKDRAWTYPES_H_INCLUDED -#include "WxdkdrawTypes.h" -#endif - -#ifndef WXDENUM_H_INCLUDED -#include "wxdenum.h" -#endif - - -#ifdef __cplusplus -extern "C" { -#endif - -int -wxdfont_compare(const void *l, const void *r, int cr); - -#ifdef __cplusplus -} -#endif - - -/** Create new font structure. - @param find Font index (0 to 34). - @param fsz Font size in pt. - @return Valid pointer to new structure on success, NULL on error. -*/ - -Wxd_font_t * -wxdfont_new(uint8_t find, uint16_t fsz); - - -/** Delete font structure, release memory. - @param ptr Font structure to delete. -*/ - -void -wxdfont_delete(Wxd_font_t *ptr); - - -/** Retrieve wxFont from font structure. - @param ptr Font structure to use. - @return wxFont pointer or NULL. -*/ - -wxFont * -wxdfont_get_font(Wxd_font_t *ptr); - - -/** Create wxFont component. - @param ptr Font structure to modify. - @param zoom Current zoom factor. - @param res Resolution. - @param exf Use exact font. -*/ - -void -wxdfont_find_font(Wxd_font_t *ptr, double zoom, double res, bool exf); - - - -/* vim: set ai sw=4 ts=4 : */ - -%% module - - -#include "WxdkdrawFont.h" - -#include "wxdkdraw.h" - - -$!trace-include - - - -/** Font family names for font 00. -*/ -static wxChar const * const font_families_00[] = { -$!string-table macro=wxT -Times -Nimbus Roman -Nimbus Roman No9 L -ptmr -Times New Roman -Bodoni MT -$!end -}; - - - -/** Font family names for font 04. -*/ -static wxChar const * const font_families_04[] = { -$!string-table macro=wxT -AvantGarde -URW Gothic -URW Gothic L -pagk -Trebuchet MS -Verdana -$!end -}; - - - -/** Font family names for font 08. -*/ -static wxChar const * const font_families_08[] = { -$!string-table macro=wxT -Bookman -URW Bookman -URW Bookman L -pbkl -Bookman Old Style -Times New Roman -$!end -}; - - - -/** Font family names for font 12. -*/ -static wxChar const * const font_families_12[] = { -$!string-table macro=wxT -Courier -Nimbus Mono PS -Nimbus Mono L -pcr -Courier New -$!end -}; - - - -/** Font family names for font 16. -*/ -static wxChar const * const font_families_16[] = { -$!string-table macro=wxT -Helvetica -Nimbus Sans -Nimbus Sans L -phv -Arial -Gill Sans MT -Lucida Sans -Tahoma -$!end -}; - - - -/** Font family names for font 20. -*/ -static wxChar const * const font_families_20[] = { -$!string-table macro=wxT -Helvetica-Narrow -Nimbus Sans Narrow -Nimbus Sans L -phv -Arial Narrow -Arial -$!end -}; - - - -/** Font family names for font 24. -*/ -static wxChar const * const font_families_24[] = { -$!string-table macro=wxT -C059 -Century Schoolbook -Century Schoolbook L -NewCenturySchlbk -pnc -Times New Roman -$!end -}; - - - -/** Font family names for font 28. -*/ -static wxChar const * const font_families_28[] = { -$!string-table macro=wxT -Palatino -P052 -URW Palladio L -Palatino Linotype -ppl -Times New Roman -$!end -}; - - - -/** Font family names for font 32. -*/ -static wxChar const * const font_families_32[] = { -$!string-table macro=wxT -$!end -}; - - -/** Font family names for font 33. -*/ -static wxChar const * const font_families_33[] = { -$!string-table macro=wxT -ZapfChancery -Z003 -URW Chancery L -pzc -Edwardian Script ITC -Blackadder ITC -$!end -}; - - -/** Font family names for font 34. -*/ -static wxChar const * const font_families_34[] = { -$!string-table macro=wxT -ZapfDingbats -D050000L -Dingbats -pzdr -WingDings -$!end -}; - - - -/** Information about one font. -*/ -typedef struct { - wxFontFamily f; /**< Font family. */ - wxFontStyle s; /**< Font style. */ - wxFontWeight w; /**< Font weight. */ - wxChar const * const *n; /**< Font names array. */ -} font_info_t; - - - -/** The 35 fonts. -*/ -static const font_info_t font_info[] = { - { - wxFONTFAMILY_ROMAN, - wxFONTSTYLE_NORMAL, - wxFONTWEIGHT_NORMAL, - font_families_00 - }, - { - wxFONTFAMILY_ROMAN, - wxFONTSTYLE_ITALIC, - wxFONTWEIGHT_NORMAL, - font_families_00 - }, - { - wxFONTFAMILY_ROMAN, - wxFONTSTYLE_NORMAL, - wxFONTWEIGHT_BOLD, - font_families_00 - }, - { - wxFONTFAMILY_ROMAN, - wxFONTSTYLE_ITALIC, - wxFONTWEIGHT_BOLD, - font_families_00 - }, - { - wxFONTFAMILY_SWISS, - wxFONTSTYLE_NORMAL, - wxFONTWEIGHT_NORMAL, - font_families_04 - }, - { - wxFONTFAMILY_SWISS, - wxFONTSTYLE_ITALIC, - wxFONTWEIGHT_NORMAL, - font_families_04 - }, - { - wxFONTFAMILY_SWISS, - wxFONTSTYLE_NORMAL, - wxFONTWEIGHT_BOLD, - font_families_04 - }, - { - wxFONTFAMILY_SWISS, - wxFONTSTYLE_ITALIC, - wxFONTWEIGHT_BOLD, - font_families_04 - }, - { - wxFONTFAMILY_ROMAN, - wxFONTSTYLE_NORMAL, - wxFONTWEIGHT_NORMAL, - font_families_08 - }, - { - wxFONTFAMILY_ROMAN, - wxFONTSTYLE_ITALIC, - wxFONTWEIGHT_NORMAL, - font_families_08 - }, - { - wxFONTFAMILY_ROMAN, - wxFONTSTYLE_NORMAL, - wxFONTWEIGHT_BOLD, - font_families_08 - }, - { - wxFONTFAMILY_ROMAN, - wxFONTSTYLE_ITALIC, - wxFONTWEIGHT_BOLD, - font_families_08 - }, - { - wxFONTFAMILY_TELETYPE, - wxFONTSTYLE_NORMAL, - wxFONTWEIGHT_NORMAL, - font_families_12 - }, - { - wxFONTFAMILY_TELETYPE, - wxFONTSTYLE_ITALIC, - wxFONTWEIGHT_NORMAL, - font_families_12 - }, - { - wxFONTFAMILY_TELETYPE, - wxFONTSTYLE_NORMAL, - wxFONTWEIGHT_BOLD, - font_families_12 - }, - { - wxFONTFAMILY_TELETYPE, - wxFONTSTYLE_ITALIC, - wxFONTWEIGHT_BOLD, - font_families_12 - }, - { - wxFONTFAMILY_SWISS, - wxFONTSTYLE_NORMAL, - wxFONTWEIGHT_NORMAL, - font_families_16 - }, - { - wxFONTFAMILY_SWISS, - wxFONTSTYLE_ITALIC, - wxFONTWEIGHT_NORMAL, - font_families_16 - }, - { - wxFONTFAMILY_SWISS, - wxFONTSTYLE_NORMAL, - wxFONTWEIGHT_BOLD, - font_families_16 - }, - { - wxFONTFAMILY_SWISS, - wxFONTSTYLE_ITALIC, - wxFONTWEIGHT_BOLD, - font_families_16 - }, - { - wxFONTFAMILY_SWISS, - wxFONTSTYLE_NORMAL, - wxFONTWEIGHT_NORMAL, - font_families_20 - }, - { - wxFONTFAMILY_SWISS, - wxFONTSTYLE_ITALIC, - wxFONTWEIGHT_NORMAL, - font_families_20 - }, - { - wxFONTFAMILY_SWISS, - wxFONTSTYLE_NORMAL, - wxFONTWEIGHT_BOLD, - font_families_20 - }, - { - wxFONTFAMILY_SWISS, - wxFONTSTYLE_ITALIC, - wxFONTWEIGHT_BOLD, - font_families_20 - }, - { - wxFONTFAMILY_ROMAN, - wxFONTSTYLE_NORMAL, - wxFONTWEIGHT_NORMAL, - font_families_24 - }, - { - wxFONTFAMILY_ROMAN, - wxFONTSTYLE_ITALIC, - wxFONTWEIGHT_NORMAL, - font_families_24 - }, - { - wxFONTFAMILY_ROMAN, - wxFONTSTYLE_NORMAL, - wxFONTWEIGHT_BOLD, - font_families_24 - }, - { - wxFONTFAMILY_ROMAN, - wxFONTSTYLE_ITALIC, - wxFONTWEIGHT_BOLD, - font_families_24 - }, - { - wxFONTFAMILY_ROMAN, - wxFONTSTYLE_NORMAL, - wxFONTWEIGHT_NORMAL, - font_families_28 - }, - { - wxFONTFAMILY_ROMAN, - wxFONTSTYLE_ITALIC, - wxFONTWEIGHT_NORMAL, - font_families_28 - }, - { - wxFONTFAMILY_ROMAN, - wxFONTSTYLE_NORMAL, - wxFONTWEIGHT_BOLD, - font_families_28 - }, - { - wxFONTFAMILY_ROMAN, - wxFONTSTYLE_ITALIC, - wxFONTWEIGHT_BOLD, - font_families_28 - }, - { - wxFONTFAMILY_DEFAULT, - wxFONTSTYLE_NORMAL, - wxFONTWEIGHT_NORMAL, - font_families_32 - }, - { - wxFONTFAMILY_SCRIPT, - wxFONTSTYLE_NORMAL, - wxFONTWEIGHT_NORMAL, - font_families_33 - }, - { - wxFONTFAMILY_DECORATIVE, - wxFONTSTYLE_NORMAL, - wxFONTWEIGHT_NORMAL, - font_families_34 - } -}; - - - -int -wxdfont_compare(const void *l, const void *r, int DK4_ARG_UNUSED(cr)) -{ - Wxd_font_t const *pl; - Wxd_font_t const *pr; - int back = 0; - $? "+ wxdfont_compare" - DK4_UNUSED_ARG(cr) - if (NULL != l) { - if (NULL != r) { - pl = (Wxd_font_t const *)l; - pr = (Wxd_font_t const *)r; - if (pl->find > pr->find) { $? ". pl->find > pr->find" - back = 1; - } - else { - if (pl->find < pr->find) { $? ". pl->find < pr->find" - back = -1; - } - else { - if (pl->fsz > pr->fsz) { $? ". pl->fsz > pr->fsz" - back = 1; - } - else { - if (pl->fsz < pr->fsz) { $? ". pl->fsz < pr->fsz" - back = -1; - } -#if TRACE_DEBUG - else { $? ". fonts equal" - } -#endif - } - } - } - } - else { $? ". no right font" - back = 1; - } - } - else { - if (NULL != r) { $? ". no left font" - back = -1; - } - } $? "- wxdfont_compare %d", back - return back; -} - - - -Wxd_font_t * -wxdfont_new(uint8_t find, uint16_t fsz) -{ - Wxd_font_t *back = NULL; - $? "+ wxdfont_new %u %u", (unsigned)find, (unsigned)fsz - back = dk4mem_new(Wxd_font_t,1,NULL); - if (NULL != back) { - back->font = NULL; - back->fsz = fsz; - back->find = find; - back->used = false; - back->attempted = false; - } $? "- wxdfont_new %d", TR_IPTR(back) - return back; -} - - - -void -wxdfont_delete(Wxd_font_t *ptr) -{ - $? "+ wxdfont_delete %d", TR_IPTR(ptr) - if (NULL != ptr) { - $? ". delete font=%u size=%u", (unsigned)(ptr->find), (unsigned)(ptr->fsz) - if (NULL != ptr->font) { - delete (ptr->font); - ptr->font = NULL; - } - dk4mem_free(ptr); - } $? "- wxdfont_delete" -} - - - -wxFont * -wxdfont_get_font(Wxd_font_t *ptr) -{ - wxFont *back = NULL; - $? "+ wxdfont_get_font %d", TR_IPTR(ptr) - if (NULL != ptr) { - back = ptr->font; - } $? "- wxdfont_get_font %d", TR_IPTR(back) - return back; -} - - - -void -wxdfont_find_font(Wxd_font_t *ptr, double zoom, double res, bool exf) -{ - wxChar const * const *nptr; /* Traverse names */ - wxFontFamily ffam = wxFONTFAMILY_DEFAULT; /* Font family */ - wxFontStyle fsty = wxFONTSTYLE_NORMAL; /* Font style */ - wxFontWeight fwei = wxFONTWEIGHT_NORMAL; /* Font weight */ - int ifsz; /* Font size as int */ - bool cc; /* Flag: can continue */ - $? "+ wxdfont_find_font %u %u", (unsigned)(ptr->find), (unsigned)(ptr->fsz) - ifsz = (int)dk4ma_rint((zoom * (double)(ptr->fsz) *res) / 72.27); - if (0 < ifsz) { - wxSize fspx(0, ifsz); - ffam = font_info[ptr->find].f; - fsty = font_info[ptr->find].s; - fwei = font_info[ptr->find].w; - nptr = font_info[ptr->find].n; - if (exf) { - /* - Use exact font specified by family and features - */ - cc = true; - while (cc) { - if (NULL != *nptr) { - wxString facename(*nptr); - ptr->font = new wxFont(fspx,ffam,fsty,fwei,false,facename); - if (NULL != ptr->font) { - if (ptr->font->IsOk()) { - cc = false; $? ". success \"%!xs\"", *nptr - } - else { - delete (ptr->font); - ptr->font = NULL; - } - } - } - else { - cc = false; - ptr->font = new wxFont(fspx, ffam, fsty, fwei); - if (NULL != ptr->font) { - if (!(ptr->font->IsOk())) { - delete (ptr->font); - ptr->font = NULL; - } - } - } - } - } - else { - /* - Use font specified by type and features - */ - ptr->font = new wxFont(fspx, ffam, fsty, fwei); - if (NULL != ptr->font) { - if (!(ptr->font->IsOk())) { - delete (ptr->font); - ptr->font = NULL; - } - } - } -#if TRACE_DEBUG - if (NULL != ptr->font) { - wxString facestr = (ptr->font)->GetFaceName(); - wxString userdes = (ptr->font)->GetNativeFontInfoUserDesc(); - wxCStrData facedata = facestr.c_str(); - wxCStrData userdata = userdes.c_str(); - wxChar const *facename = (wxChar const *)facedata; - wxChar const *username = (wxChar const *)userdata; - if (NULL != facename) { - $? ". facename = \"%!xs\"", TR_WXSTR(facename) - $? ". font = \"%!xs\"", TR_WXSTR(username) - } - } - else { $? "! font" - } -#endif - } - $? "- wxdfont_find_font %d", TR_IPTR(ptr->font) -} - - - - -/* vim: set ai sw=4 ts=4 : */ |