summaryrefslogtreecommitdiff
path: root/nuttx/graphics/nxfonts
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-12-04 16:45:06 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2008-12-04 16:45:06 +0000
commit6fd4a801b4330342cfdee6f44a81d64b41785c74 (patch)
tree281112b23ca6848793245604ba590feecc87743c /nuttx/graphics/nxfonts
parent05d31bd06816565ec8af26885ecaa26851851e18 (diff)
downloadpx4-nuttx-6fd4a801b4330342cfdee6f44a81d64b41785c74.tar.gz
px4-nuttx-6fd4a801b4330342cfdee6f44a81d64b41785c74.tar.bz2
px4-nuttx-6fd4a801b4330342cfdee6f44a81d64b41785c74.zip
Add font test
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1413 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/graphics/nxfonts')
-rw-r--r--nuttx/graphics/nxfonts/nxfonts_bitmaps.c28
-rw-r--r--nuttx/graphics/nxfonts/nxfonts_convert.c17
-rw-r--r--nuttx/graphics/nxfonts/nxfonts_getfont.c35
-rw-r--r--nuttx/graphics/nxfonts/nxfonts_internal.h93
4 files changed, 140 insertions, 33 deletions
diff --git a/nuttx/graphics/nxfonts/nxfonts_bitmaps.c b/nuttx/graphics/nxfonts/nxfonts_bitmaps.c
index 60c543100..ff69f786a 100644
--- a/nuttx/graphics/nxfonts/nxfonts_bitmaps.c
+++ b/nuttx/graphics/nxfonts/nxfonts_bitmaps.c
@@ -41,6 +41,8 @@
#include <sys/types.h>
#include <nuttx/nxfonts.h>
+#include "nxfonts_internal.h"
+
/* Pick the fontset */
#ifdef CONFIG_NXFONT_SANS
@@ -1622,26 +1624,28 @@ NXFONT_DEFMETRIC(255),
struct nx_fontset_s g_7bitfonts =
{
- NXFONT_MAXHEIGHT, /* Max. height of a glyph in rows */
- NXFONT_MAXWIDTH, /* Max. width of a glyph in pixels */
- NXFONT_MIN7BIT, /* First font code */
- NXFONT_N7BITFONTS, /* Number of bitmap fonts */
- NXFONT_SPACEWIDTH, /* The width of a space in pixels */
- g_7bitmaps /* List of fonts */
+ NXFONT_MIN7BIT, /* First glyph code */
+ NXFONT_N7BITFONTS, /* Number of bitmap glyphs */
+ g_7bitmaps /* List of glyphs */
};
#if CONFIG_NXFONTS_CHARBITS >= 8
struct nx_fontset_s g_8bitfonts =
{
- NXFONT_MAXHEIGHT, /* Max. height of a glyph in rows */
- NXFONT_MAXWIDTH, /* Max. width of a glyph in pixels */
- NXFONT_MIN8BIT, /* First font code */
- NXFONT_N8BITFONTS, /* Number of bitmap fonts */
- NXFONT_SPACEWIDTH, /* The width of a space in pixels */
- g_8bitmaps /* List of fonts */
+ NXFONT_MIN8BIT, /* First glyph code */
+ NXFONT_N8BITFONTS, /* Number of bitmap glyphs */
+ g_8bitmaps /* List of glyphs */
};
#endif
+struct nx_font_s g_fonts =
+{
+ NXFONT_MAXHEIGHT, /* Max. height of a glyph in rows */
+ NXFONT_MAXWIDTH, /* Max. width of a glyph in pixels */
+ CONFIG_NXFONTS_CHARBITS, /* Max number of bits per character code */
+ NXFONT_SPACEWIDTH, /* The width of a space in pixels */
+};
+
/****************************************************************************
* Private Functions
****************************************************************************/
diff --git a/nuttx/graphics/nxfonts/nxfonts_convert.c b/nuttx/graphics/nxfonts/nxfonts_convert.c
index 85094c4c7..852c9e5af 100644
--- a/nuttx/graphics/nxfonts/nxfonts_convert.c
+++ b/nuttx/graphics/nxfonts/nxfonts_convert.c
@@ -44,6 +44,8 @@
#include <nuttx/nxglib.h>
#include <nuttx/nxfonts.h>
+#include "nxfonts_internal.h"
+
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
@@ -138,7 +140,6 @@ int NXF_FUNCNAME(nxf_convert,NXFONTS_SUFFIX)
(FAR NXF_PIXEL_T *dest, uint16 height, uint16 width, uint16 stride,
uint16 ch, nxgl_mxpixel_t color)
{
- FAR const struct nx_fontset_s *set;
FAR const struct nx_fontbitmap_s *bm;
FAR ubyte *line;
FAR NXF_PIXEL_T *dptr;
@@ -156,16 +157,6 @@ int NXF_FUNCNAME(nxf_convert,NXFONTS_SUFFIX)
int nbits;
#endif
- /* Check if we have the fontset containing this character code */
-
- set = nxf_getfontset(ch);
- if (!set)
- {
- /* No fontset? Nothing to rend, return the width of a 7-bit space */
-
- return g_7bitfonts.spwidth;
- }
-
/* Map the character code to a bitmap font */
bm = nxf_getbitmap(ch);
@@ -173,7 +164,7 @@ int NXF_FUNCNAME(nxf_convert,NXFONTS_SUFFIX)
{
/* No character? Nothing to rend, return the width of a space */
- return set->spwidth;
+ return g_fonts.spwidth;
}
/* Get the starting position */
@@ -285,5 +276,5 @@ int NXF_FUNCNAME(nxf_convert,NXFONTS_SUFFIX)
}
}
#endif
- return bm->metric.width;
+ return bm->metric.width + bm->metric.xoffset;
} \ No newline at end of file
diff --git a/nuttx/graphics/nxfonts/nxfonts_getfont.c b/nuttx/graphics/nxfonts/nxfonts_getfont.c
index 83d8a914d..c8ae4d018 100644
--- a/nuttx/graphics/nxfonts/nxfonts_getfont.c
+++ b/nuttx/graphics/nxfonts/nxfonts_getfont.c
@@ -40,9 +40,11 @@
#include <nuttx/config.h>
#include <sys/types.h>
#include <debug.h>
-#
+
#include <nuttx/nxfonts.h>
+#include "nxfonts_internal.h"
+
/****************************************************************************
* Pre-Processor Definitions
****************************************************************************/
@@ -60,11 +62,7 @@
****************************************************************************/
/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: nxf_getfontset
+ * Name: nxf_getglyphset
*
* Description:
* Return information about the font set containtined he selected
@@ -75,7 +73,7 @@
*
****************************************************************************/
-FAR const struct nx_fontset_s *nxf_getfontset(uint16 ch)
+static inline FAR const struct nx_fontset_s *nxf_getglyphset(uint16 ch)
{
if (ch < 128)
{
@@ -101,6 +99,27 @@ FAR const struct nx_fontset_s *nxf_getfontset(uint16 ch)
{
gdbg("16-bit font not currently supported\n");
}
+ return NULL;
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nxf_getfontset
+ *
+ * Description:
+ * Return information about the current font set
+ *
+ * Input Parameters:
+ * None
+ *
+ ****************************************************************************/
+
+FAR const struct nx_font_s *nxf_getfontset(void)
+{
+ return &g_fonts;
}
/****************************************************************************
@@ -116,7 +135,7 @@ FAR const struct nx_fontset_s *nxf_getfontset(uint16 ch)
FAR const struct nx_fontbitmap_s *nxf_getbitmap(uint16 ch)
{
- FAR const struct nx_fontset_s *set = nxf_getfontset(ch);
+ FAR const struct nx_fontset_s *set = nxf_getglyphset(ch);
FAR struct nx_fontbitmap_s *bm = NULL;
if (set)
diff --git a/nuttx/graphics/nxfonts/nxfonts_internal.h b/nuttx/graphics/nxfonts/nxfonts_internal.h
new file mode 100644
index 000000000..3167f96b1
--- /dev/null
+++ b/nuttx/graphics/nxfonts/nxfonts_internal.h
@@ -0,0 +1,93 @@
+/****************************************************************************
+ * graphics/nxfonts/nxfonts_internal.h
+ *
+ * Copyright (C) 2008 Gregory Nutt. All rights reserved.
+ * Author: Gregory Nutt <spudmonkey@racsa.co.cr>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in
+ * the documentation and/or other materials provided with the
+ * distribution.
+ * 3. Neither the name NuttX nor the names of its contributors may be
+ * used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
+ * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
+ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ *
+ ****************************************************************************/
+
+#ifndef __GRAPHICS_NXFONTS_NXFONTS_INTERNAL_H
+#define __GRAPHICS_NXFONTS_NXFONTS_INTERNAL_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <sys/types.h>
+
+#include <nuttx/nxfonts.h>
+
+/****************************************************************************
+ * Pre-processor definitions
+ ****************************************************************************/
+
+/* Configuration ************************************************************/
+
+#ifndef CONFIG_NXFONTS_CHARBITS
+# define CONFIG_NXFONTS_CHARBITS 7
+#endif
+
+/* Only font supported for now */
+
+#define CONFIG_NXFONT_SANS 1
+
+/****************************************************************************
+ * Public Types
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Data
+ ****************************************************************************/
+
+#undef EXTERN
+#if defined(__cplusplus)
+# define EXTERN extern "C"
+extern "C" {
+#else
+# define EXTERN extern
+#endif
+
+EXTERN struct nx_fontset_s g_7bitfonts;
+#if CONFIG_NXFONTS_CHARBITS >= 8
+EXTERN struct nx_fontset_s g_8bitfonts;
+#endif
+EXTERN struct nx_font_s g_fonts;
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+#undef EXTERN
+#if defined(__cplusplus)
+}
+#endif
+
+#endif /* __GRAPHICS_NXFONTS_NXFONTS_INTERNAL_H */