aboutsummaryrefslogtreecommitdiffstats
path: root/include/gdisp
diff options
context:
space:
mode:
authorAndrew Hannam <andrewh@inmarket.com.au>2012-12-07 00:52:01 +1000
committerAndrew Hannam <andrewh@inmarket.com.au>2012-12-07 00:52:01 +1000
commit5873d87ca2185e825f1187eca3bc7f0de7437e69 (patch)
treeda1a2f56b60d9495cafef79734082660f39abaf2 /include/gdisp
parentec89b8e82d890066f60c48349da062add76db6cd (diff)
downloaduGFX-5873d87ca2185e825f1187eca3bc7f0de7437e69.tar.gz
uGFX-5873d87ca2185e825f1187eca3bc7f0de7437e69.tar.bz2
uGFX-5873d87ca2185e825f1187eca3bc7f0de7437e69.zip
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
Diffstat (limited to 'include/gdisp')
-rw-r--r--include/gdisp/fonts.h11
-rw-r--r--include/gdisp/gdisp.h51
-rw-r--r--include/gdisp/options.h33
3 files changed, 66 insertions, 29 deletions
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
@@ -34,16 +34,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
@@ -152,6 +152,39 @@
/**
* @}
*
+ * @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
+
+/**
+ * @}
+ *
* @name GDISP Optional Sizing Parameters
* @{
*/