From 5873d87ca2185e825f1187eca3bc7f0de7437e69 Mon Sep 17 00:00:00 2001 From: Andrew Hannam Date: Fri, 7 Dec 2012 00:52:01 +1000 Subject: Add GDISP font routines. Fix demo bugs Add GDISP font routines to Open and Close a font by name. Allows wildcard searching for fonts. Old global font variables are now only optionally included (soon to be deprecated). More demo fixing --- include/gdisp/fonts.h | 11 +------ include/gdisp/gdisp.h | 51 ++++++++++++++++++++------------ include/gdisp/options.h | 33 +++++++++++++++++++++ include/gfxconf.example.h | 74 ----------------------------------------------- 4 files changed, 66 insertions(+), 103 deletions(-) delete mode 100644 include/gfxconf.example.h (limited to 'include') diff --git a/include/gdisp/fonts.h b/include/gdisp/fonts.h index e0c7f7de..34a5b89d 100644 --- a/include/gdisp/fonts.h +++ b/include/gdisp/fonts.h @@ -33,16 +33,6 @@ /* Don't test against GFX_USE_GDISP as we may want to use this in other non-GDISP utilities. */ -/** - * @brief The maximum height of a font. - * @details Either 16 or 32. Defaults to 16 - * @note Setting this to 32 causes the font tables to take - * twice the internal program memory. - */ -#ifndef GDISP_MAX_FONT_HEIGHT - #define GDISP_MAX_FONT_HEIGHT 16 -#endif - /** * @brief The type of a font column. * @note Set by defining @p GDISP_MAX_FNT_HEIGHT appropriately. @@ -65,6 +55,7 @@ * to allow the tables to work across many different compilers. */ struct font { + const char * name; uint8_t height; uint8_t charPadding; uint8_t lineSpacing; diff --git a/include/gdisp/gdisp.h b/include/gdisp/gdisp.h index b9434d3f..117f865a 100644 --- a/include/gdisp/gdisp.h +++ b/include/gdisp/gdisp.h @@ -96,25 +96,35 @@ typedef enum fontmetric {fontHeight, fontDescendersHeight, fontLineSpacing, font /* External declarations. */ /*===========================================================================*/ -#if GDISP_NEED_TEXT || defined(__DOXYGEN__) -/** - * @brief Predefined fonts. - */ -extern const struct font fontSmall; -extern const struct font fontSmallDouble; -extern const struct font fontSmallNarrow; -extern const struct font fontLarger; -extern const struct font fontLargerDouble; -extern const struct font fontLargerNarrow; -extern const struct font fontUI1; -extern const struct font fontUI1Double; -extern const struct font fontUI1Narrow; -extern const struct font fontUI2; -extern const struct font fontUI2Double; -extern const struct font fontUI2Narrow; -extern const struct font fontLargeNumbers; -extern const struct font fontLargeNumbersDouble; -extern const struct font fontLargeNumbersNarrow; +#if (GDISP_NEED_TEXT && GDISP_OLD_FONT_DEFINITIONS) || defined(__DOXYGEN__) + /** + * @brief Predefined fonts. + */ + #if GDISP_INCLUDE_FONT_SMALL + extern const struct font fontSmall; + extern const struct font fontSmallDouble; + extern const struct font fontSmallNarrow; + #endif + #if GDISP_INCLUDE_FONT_LARGER + extern const struct font fontLarger; + extern const struct font fontLargerDouble; + extern const struct font fontLargerNarrow; + #endif + #if GDISP_INCLUDE_FONT_UI1 + extern const struct font fontUI1; + extern const struct font fontUI1Double; + extern const struct font fontUI1Narrow; + #endif + #if GDISP_INCLUDE_FONT_UI2 + extern const struct font fontUI2; + extern const struct font fontUI2Double; + extern const struct font fontUI2Narrow; + #endif + #if GDISP_INCLUDE_FONT_LARGENUMBERS + extern const struct font fontLargeNumbers; + extern const struct font fontLargeNumbersDouble; + extern const struct font fontLargeNumbersNarrow; + #endif #endif #ifdef __cplusplus @@ -226,6 +236,9 @@ void gdispDrawBox(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color); coord_t gdispGetFontMetric(font_t font, fontmetric_t metric); coord_t gdispGetCharWidth(char c, font_t font); coord_t gdispGetStringWidth(const char* str, font_t font); + font_t gdispOpenFont(const char *name); + void gdispCloseFont(font_t font); + const char *gdispGetFontName(font_t font); #endif /* Extra Arc Functions */ diff --git a/include/gdisp/options.h b/include/gdisp/options.h index c2163631..b53138ca 100644 --- a/include/gdisp/options.h +++ b/include/gdisp/options.h @@ -149,6 +149,39 @@ #ifndef GDISP_NEED_ASYNC #define GDISP_NEED_ASYNC FALSE #endif +/** + * @} + * + * @name GDISP Fonts + * @{ + */ + /** + * @brief Include the old global font variable definitions + * @details Defaults to FALSE + */ + #ifndef GDISP_OLD_FONT_DEFINITIONS + #define GDISP_OLD_FONT_DEFINITIONS FALSE + #endif + /** + * @brief Predefined built in fonts. + * @note Turning off the ones you are not using can save program size. + */ + #ifndef GDISP_INCLUDE_FONT_SMALL + #define GDISP_INCLUDE_FONT_SMALL TRUE + #endif + #ifndef GDISP_INCLUDE_FONT_LARGER + #define GDISP_INCLUDE_FONT_LARGER TRUE + #endif + #ifndef GDISP_INCLUDE_FONT_UI1 + #define GDISP_INCLUDE_FONT_UI1 TRUE + #endif + #ifndef GDISP_INCLUDE_FONT_UI2 + #define GDISP_INCLUDE_FONT_UI2 TRUE + #endif + #ifndef GDISP_INCLUDE_FONT_LARGENUMBERS + #define GDISP_INCLUDE_FONT_LARGENUMBERS TRUE + #endif + /** * @} * diff --git a/include/gfxconf.example.h b/include/gfxconf.example.h deleted file mode 100644 index 94413237..00000000 --- a/include/gfxconf.example.h +++ /dev/null @@ -1,74 +0,0 @@ -/** - * This file has a different license to the rest of the GFX system. - * You can copy, modify and distribute this file as you see fit. - * You do not need to publish your source modifications to this file. - * The only thing you are not permitted to do is to relicense it - * under a different license. - */ - -/** - * Copy this file into your project directory and rename it as gfxconf.h - * Edit your copy to turn on the GFX features you want to use. - */ - -#ifndef _GFXCONF_H -#define _GFXCONF_H - -/* GFX sub-systems to turn on */ -#define GFX_USE_GDISP FALSE -#define GFX_USE_GWIN FALSE -#define GFX_USE_GEVENT FALSE -#define GFX_USE_GTIMER FALSE -#define GFX_USE_GINPUT FALSE - -/* Features for the GDISP sub-system. */ -#define GDISP_NEED_VALIDATION TRUE -#define GDISP_NEED_CLIP TRUE -#define GDISP_NEED_TEXT TRUE -#define GDISP_NEED_CIRCLE TRUE -#define GDISP_NEED_ELLIPSE TRUE -#define GDISP_NEED_ARC FALSE -#define GDISP_NEED_SCROLL FALSE -#define GDISP_NEED_PIXELREAD FALSE -#define GDISP_NEED_CONTROL FALSE -#define GDISP_NEED_MULTITHREAD FALSE -#define GDISP_NEED_ASYNC FALSE -#define GDISP_NEED_MSGAPI FALSE - -/* Features for the GWIN sub-system. */ -#define GWIN_NEED_BUTTON FALSE -#define GWIN_NEED_CONSOLE FALSE -#define GWIN_NEED_GRAPH FALSE - -/* Features for the GEVENT sub-system. */ -#define GEVENT_ASSERT_NO_RESOURCE FALSE - -/* Features for the GTIMER sub-system. */ -/* NONE */ - -/* Features for the GINPUT sub-system. */ -#define GINPUT_NEED_MOUSE FALSE -#define GINPUT_NEED_KEYBOARD FALSE -#define GINPUT_NEED_TOGGLE FALSE -#define GINPUT_NEED_DIAL FALSE - -/* Optional Parameters for various sub-systems */ -/* - #define GDISP_MAX_FONT_HEIGHT 16 - #define GEVENT_MAXIMUM_SIZE 32 - #define GEVENT_MAX_SOURCE_LISTENERS 32 - #define GTIMER_THREAD_WORKAREA_SIZE 512 -*/ - -/* Optional Low Level Driver Definitions */ -/* - #define GDISP_USE_CUSTOM_BOARD FALSE - #define GDISP_SCREEN_WIDTH 320 - #define GDISP_SCREEN_HEIGHT 240 - #define GDISP_USE_FSMC - #define GDISP_USE_GPIO - #define GDISP_VMT_NAME1(x) x##YourDriver1 - #define GDISP_VMT_NAME2(x) x##YourDriver2 -*/ - -#endif /* _GFXCONF_H */ -- cgit v1.2.3