This commit is contained in:
Joel Bodenmann 2013-05-20 19:15:20 +02:00
parent fefdd42d7d
commit 8d5fa39dd9
8 changed files with 82 additions and 64 deletions

View file

@ -4,64 +4,65 @@
* *
* http://chibios-gfx.com/license.html * http://chibios-gfx.com/license.html
*/ */
/** /**
* @file include/gdisp/fonts.h * @file include/gdisp/fonts.h
* @brief GDISP internal font definitions. * @brief GDISP internal font definitions.
* @details This is not generally needed by an application. It is used * @details This is not generally needed by an application. It is used
* by the low level drivers that need to understand a font. * by the low level drivers that need to understand a font.
* *
* @addtogroup GDISP * @addtogroup GDISP
* @{ *
*/ * @{
*/
#ifndef _GDISP_FONTS_H
#define _GDISP_FONTS_H #ifndef _GDISP_FONTS_H
#define _GDISP_FONTS_H
/* Don't test against GFX_USE_GDISP as we may want to use this in other non-GDISP utilities. */
/* Don't test against GFX_USE_GDISP as we may want to use this in other non-GDISP utilities. */
/**
* @brief The type of a font column. /**
* @note Set by defining @p GDISP_MAX_FNT_HEIGHT appropriately. * @brief The type of a font column.
*/ * @note Set by defining @p GDISP_MAX_FNT_HEIGHT appropriately.
#if GDISP_MAX_FONT_HEIGHT == 16 */
typedef uint16_t fontcolumn_t; #if GDISP_MAX_FONT_HEIGHT == 16
#elif GDISP_MAX_FONT_HEIGHT == 32 typedef uint16_t fontcolumn_t;
typedef uint32_t fontcolumn_t; #elif GDISP_MAX_FONT_HEIGHT == 32
#else typedef uint32_t fontcolumn_t;
#error "GDISP: GDISP_MAX_FONT_HEIGHT must be either 16 or 32" #else
#endif #error "GDISP: GDISP_MAX_FONT_HEIGHT must be either 16 or 32"
#endif
/**
* @brief Internal font structure. /**
* @note This structure is followed by: * @brief Internal font structure.
* 1. An array of character widths (uint8_t) * @note This structure is followed by:
* 2. An array of column data offsets (relative to the font structure) * 1. An array of character widths (uint8_t)
* 3. Each characters array of column data (fontcolumn_t) * 2. An array of column data offsets (relative to the font structure)
* Each sub-structure must be padded to a multiple of 8 bytes * 3. Each characters array of column data (fontcolumn_t)
* to allow the tables to work across many different compilers. * Each sub-structure must be padded to a multiple of 8 bytes
*/ * to allow the tables to work across many different compilers.
struct font { */
const char * name; struct font {
uint8_t height; const char * name;
uint8_t charPadding; uint8_t height;
uint8_t lineSpacing; uint8_t charPadding;
uint8_t descenderHeight; uint8_t lineSpacing;
uint8_t minWidth; uint8_t descenderHeight;
uint8_t maxWidth; uint8_t minWidth;
char minChar; uint8_t maxWidth;
char maxChar; char minChar;
uint8_t xscale; char maxChar;
uint8_t yscale; uint8_t xscale;
const uint8_t *widthTable; uint8_t yscale;
const uint16_t *offsetTable; const uint8_t *widthTable;
const fontcolumn_t *dataTable; const uint16_t *offsetTable;
}; const fontcolumn_t *dataTable;
};
#define _getCharWidth(f,c) (((c) < (f)->minChar || (c) > (f)->maxChar) ? 0 : (f)->widthTable[(c) - (f)->minChar])
#define _getCharOffset(f,c) ((f)->offsetTable[(c) - (f)->minChar]) #define _getCharWidth(f,c) (((c) < (f)->minChar || (c) > (f)->maxChar) ? 0 : (f)->widthTable[(c) - (f)->minChar])
#define _getCharData(f,c) (&(f)->dataTable[_getCharOffset(f, c)]) #define _getCharOffset(f,c) ((f)->offsetTable[(c) - (f)->minChar])
#define _getCharData(f,c) (&(f)->dataTable[_getCharOffset(f, c)])
#endif /* _GDISP_FONTS_H */
/** @} */ #endif /* _GDISP_FONTS_H */
/** @} */

View file

@ -9,7 +9,8 @@
* @file include/gdisp/image.h * @file include/gdisp/image.h
* @brief GDISP image header file. * @brief GDISP image header file.
* *
* @addtogroup GDISP * @defgroup Image Image
* @ingroup GDISP
* @{ * @{
*/ */

View file

@ -10,6 +10,7 @@
* @brief GDISP Font Handling. * @brief GDISP Font Handling.
* *
* @addtogroup GDISP * @addtogroup GDISP
*
* @{ * @{
*/ */

View file

@ -8,6 +8,9 @@
/** /**
* @file src/gdisp/image.c * @file src/gdisp/image.c
* @brief GDISP generic image code. * @brief GDISP generic image code.
*
* @defgroup Image Image
* @ingroup GDISP
*/ */
#include "ch.h" #include "ch.h"
#include "hal.h" #include "hal.h"

View file

@ -8,6 +8,9 @@
/** /**
* @file src/gdisp/image_bmp.c * @file src/gdisp/image_bmp.c
* @brief GDISP native image code. * @brief GDISP native image code.
*
* @defgroup Image Image
* @ingroup GDISP
*/ */
#include "ch.h" #include "ch.h"
#include "hal.h" #include "hal.h"

View file

@ -8,7 +8,10 @@
/** /**
* @file src/gdisp/image_gif.c * @file src/gdisp/image_gif.c
* @brief GDISP native image code. * @brief GDISP native image code.
*/ *
* @defgroup Image Image
* @ingroup GDISP
*/
#include "ch.h" #include "ch.h"
#include "hal.h" #include "hal.h"
#include "gfx.h" #include "gfx.h"

View file

@ -8,6 +8,9 @@
/** /**
* @file src/gdisp/image_native.c * @file src/gdisp/image_native.c
* @brief GDISP native image code. * @brief GDISP native image code.
*
* @defgroup Image Image
* @ingroup GDISP
*/ */
#include "ch.h" #include "ch.h"
#include "hal.h" #include "hal.h"

View file

@ -8,7 +8,10 @@
/** /**
* @file src/gdisp/image_png.c * @file src/gdisp/image_png.c
* @brief GDISP native image code. * @brief GDISP native image code.
*/ *
* @defgroup Image Image
* @ingroup GDISP
*/
#include "ch.h" #include "ch.h"
#include "hal.h" #include "hal.h"
#include "gfx.h" #include "gfx.h"