mirror of
https://github.com/apache/nuttx.git
synced 2026-09-23 07:14:28 +08:00
Graphics: Initial separation of font cache from graphics/nxterm. Now in libnx/nxfronts
This commit is contained in:
@@ -51,6 +51,7 @@
|
||||
* Pre-processor definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* Font Definitions *********************************************************/
|
||||
/* Select the default font. If no fonts are selected, then a compilation
|
||||
* error is likely down the road.
|
||||
*/
|
||||
@@ -202,10 +203,16 @@
|
||||
|
||||
#endif
|
||||
|
||||
/* Font Cache Definitions (**************************************************/
|
||||
/* Limit to range of font cache usage count */
|
||||
|
||||
#define MAX_USECNT 255 /* Limit to range of a uint8_t */
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
|
||||
/* Font Types ***************************************************************/
|
||||
/* Font IDs */
|
||||
|
||||
enum nx_fontid_e
|
||||
@@ -453,6 +460,23 @@ struct nx_fontpackage_s
|
||||
#endif
|
||||
};
|
||||
|
||||
/* Font Cache ***************************************************************/
|
||||
/* Opaque handle used to reference a font cache */
|
||||
|
||||
typedef FAR void *FCACHE;
|
||||
|
||||
/* Describes one cached font glyph */
|
||||
|
||||
struct nxfonts_glyph_s
|
||||
{
|
||||
uint8_t code; /* Character code */
|
||||
uint8_t height; /* Height of this glyph (in rows) */
|
||||
uint8_t width; /* Width of this glyph (in pixels) */
|
||||
uint8_t stride; /* Width of the glyph row (in bytes) */
|
||||
uint8_t usecnt; /* Use count */
|
||||
FAR uint8_t *bitmap; /* Allocated bitmap memory */
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
@@ -480,6 +504,9 @@ extern "C"
|
||||
* Input Parameters:
|
||||
* fontid: Identifies the font set to get
|
||||
*
|
||||
* Returned Value:
|
||||
* One success, a non-NULL font handle is returned.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
NXHANDLE nxf_getfonthandle(enum nx_fontid_e fontid);
|
||||
@@ -564,6 +591,83 @@ int nxf_convert_32bpp(FAR uint32_t *dest, uint16_t height,
|
||||
FAR const struct nx_fontbitmap_s *bm,
|
||||
nxgl_mxpixel_t color);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxf_cache_connect
|
||||
*
|
||||
* Description:
|
||||
* Create a new font cache for the provided 'fontid'. If the cache
|
||||
* already, then just increment a reference count return the handler for
|
||||
* the existing font cache.
|
||||
*
|
||||
* Input Parameters:
|
||||
* fontid - Identifies the font supported by this cache
|
||||
*
|
||||
* Returned value:
|
||||
* On success a non-NULL handle is returned that then may sequently be
|
||||
* used with nxf_getglyph() to extract fonts from the font cache. NULL
|
||||
* returned on any failure with the errno value set to indicate the nature
|
||||
* of the error.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FCACHE nxf_cache_connect(enum nx_fontid_e fontid,
|
||||
nxgl_mxpixel_t fgcolor, nxgl_mxpixel_t bgcolor,
|
||||
int bpp);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxf_cache_disconnect
|
||||
*
|
||||
* Description:
|
||||
* Decrement the reference count on the font cache and, if the reference
|
||||
* count goes to zero, free all resources used by the font cache. The
|
||||
* font handler is invalid upon return in either case.
|
||||
*
|
||||
* Input Parameters:
|
||||
* fcache - A font cache handler previously returned by nxf_cache_connect();
|
||||
*
|
||||
* Returned value:
|
||||
* None
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void nxf_cache_disconnect(FCACHE fcache);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxf_cache_getfonthandle
|
||||
*
|
||||
* Description:
|
||||
* Return the handle to the font set used by this instance of the font
|
||||
* cache.
|
||||
*
|
||||
* Input Parameters:
|
||||
* fcache - A font cache handle previously returned by nxf_cache_connect();
|
||||
*
|
||||
* Returned value:
|
||||
* Zero (OK) is returned if the metrics were
|
||||
*
|
||||
* Returned Value:
|
||||
* One success, a non-NULL font handle is returned.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
NXHANDLE nxf_cache_getfonthandle(FCACHE fcache);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: nxf_cache_getglyph
|
||||
*
|
||||
* Description:
|
||||
* Get the font glyph for the character code 'ch' from the font cache. If
|
||||
* the glyph for that character code does not exist in the font cache, it
|
||||
* be rendered.
|
||||
*
|
||||
* Returned Value:
|
||||
* On success, a non-NULL pointer to the rendered glyph in the font cache
|
||||
* is returned. NULL is returned on any failure.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
FAR struct nxfonts_glyph_s *nxf_cache_getglyph(FCACHE fcache, uint8_t ch);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user