From d81ddbd8b5ecb79087f47a81da93ef19de71981e Mon Sep 17 00:00:00 2001 From: patacongo Date: Sat, 23 Jul 2011 13:53:59 +0000 Subject: [PATCH] Add JP's BDF font conversion program git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3813 42af7a65-404d-4744-a932-0658087f49c3 --- Documentation/NXGraphicsSubsystem.html | 207 +++++++++++++++++++++++-- 1 file changed, 194 insertions(+), 13 deletions(-) diff --git a/Documentation/NXGraphicsSubsystem.html b/Documentation/NXGraphicsSubsystem.html index dd206ed04ca..d37e24ce170 100644 --- a/Documentation/NXGraphicsSubsystem.html +++ b/Documentation/NXGraphicsSubsystem.html @@ -12,7 +12,7 @@

NX Graphics Subsystem

-

Last Updated: July 19, 2011

+

Last Updated: July 23, 2011

@@ -178,14 +178,17 @@

- Appendix C NX Test Coverage + Appendix C Installing New Fonts +

+

+ Appendix D NX Test Coverage

@@ -2729,7 +2732,185 @@ int nxf_convert_32bpp(FAR uint32_t *dest, uint16_t height, + +
-

Appendix C NX Test Coverage

+

Appendix C Installing New Fonts

+
+ +

+ There is a tool called bdf-converter in the directory tools/.. + The bdf-converter program be used to convert fonts in Bitmap Distribution Format (BDF) into fonts that can be used in the NX graphics system. +

+

+ Below are general instructions for creating and installing a new font in the NX graphic system: +

+
    +
  1. +

    + Locate a font in BDF format, +

    +
  2. +
  3. +

    + Use the bdf-converter program to convert the BDF font to the NuttX font format. + This will result in a C header file containing defintions. + That header file should be installed at, for example, graphics/nxfonts/nxfonts_myfont.h. +

    +
  4. +
+

+ Create a new NuttX configuration variable. + For example, suppose you define the following variable: CONFIG_NXFONT_MYFONT. + Then you would need to: +

+
    +
  1. +

    + Define CONFIG_NXFONT_MYFONT=y in your NuttX configuration file. +

    +
  2. +
+

+ A font ID number has to be assigned for each new font. + The font ID is defined in the file include/nuttx/nxfonts.h. + Those definitions have to be extended to support your new font. + Look at how the font ID enabled by CONFIG_NXFONT_SANS23X27 is defined and add an ID for yournew font in a similar fashion: +

+
    +
  1. +

    + include/nuttx/nxfonts.h. Add you new font as a possible system default font: +

    +
      +#if defined(CONFIG_NXFONT_SANS23X27) +# define NXFONT_DEFAULT FONTID_SANS23X27 +#elif defined(CONFIG_NXFONT_MYFONT) +# define NXFONT_DEFAULT FONTID_MYFONT +#endif +
        +

        + Then define the actual font ID. + Make sure that the font ID value is unique: +

        +
          +enum nx_fontid_e
          +{
          +  FONTID_DEFAULT     = 0      /* The default font */
          +#ifdef CONFIG_NXFONT_SANS23X27
          +  , FONTID_SANS23X27 = 1      /* The 23x27 sans serif font */
          +#endif
          +#ifdef CONFIG_NXFONT_MYFONT
          +  , FONTID_MYFONT    = 2      /* My shiny, new font */
          +#endif
          +...
          +
        + +
+

+ New Add the font to the NX build system. + There are several files that you have to modify to to this. + Look how the build system uses the font CONFIG_NXFONT_SANS23X27 for examaples: +

+
    +
  1. +

    + nuttx/graphics/Makefile. + This file needs logic to auto-generate a C source file from the header file that you generated with the the bdf-converter program. + Notice NXFONTS_FONTID=2; this must be set to the same font ID value that you defined in the include/nuttx/nxfonts.h file. +

    +
      +genfontsources:
      +  ifeq ($(CONFIG_NXFONT_SANS23X27),y)
      +      @$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=1 EXTRADEFINES=$(EXTRADEFINES)
      +  endif
      +  ifeq ($(CONFIG_NXFONT_MYFONT),y)
      +      @$(MAKE) -C nxfonts -f Makefile.sources TOPDIR=$(TOPDIR) NXFONTS_FONTID=2 EXTRADEFINES=$(EXTRADEFINES)
      +  endif
      +
    +
  2. +
  3. +

    + nuttx/graphics/nxfonts/Make.defs. + Set the make variable NXFSET_CSRCS. + NXFSET_CSRCS determines the name of the font C file to build when NXFONTS_FONTID=2: +

    +
      +ifeq ($(CONFIG_NXFONT_SANS23X27),y)
      +NXFSET_CSRCS	+= nxfonts_bitmaps_sans23x27.c
      +endif
      +ifeq ($(CONFIG_NXFONT_MYFONT),y)
      +NXFSET_CSRCS	+= nxfonts_bitmaps_myfont.c
      +endif
      +
    +
  4. +
  5. +

    + nuttx/graphics/nxfonts/Makefile.sources. + This is the Makefile used in step 5 that will actually generate the font C file. + So, given your NXFONTS_FONTID=2, it needs to determine a prefix to use for auto-generated variable and function names and (again) the name of the autogenerated file to create (this must be the same name that was used in nuttx/graphics/nxfonts/Make.defs): +

    +
      +ifeq ($(NXFONTS_FONTID),1)
      +NXFONTS_PREFIX	:= g_sans23x27_
      +GEN_CSRC	= nxfonts_bitmaps_sans23x27.c
      +endif
      +ifeq ($(NXFONTS_FONTID),2)
      +NXFONTS_PREFIX	:= g_myfont_
      +GEN_CSRC	= nxfonts_bitmaps_myfont.c
      +endif
      +
    +
  6. +
  7. +

    + graphics/nxfonts/nxfonts_bitmaps.c. + This is the file that contains the generic font structures. + It is used as a "template&qout; file by nuttx/graphics/nxfonts/Makefile.sources to create your customized font data set at build time. +

    +
      +#if NXFONTS_FONTID == 1
      +#  include "nxfonts_sans23x27.h"
      +#elif NXFONTS_FONTID == 2
      +#  include "nxfonts_myfont.h"
      +#else
      +#  error "No font ID specified"
      +#endif
      +
    +

    + Where nxfonts_myfont.h is the NuttX font file that we generated in + step 2 using the bdf-converter tool. +

    +
  8. +

    + Finally, we need to extend the logic that does the run-time font lookups so that can find our new font. + The lookup function is NXHANDLE nxf_getfonthandle(enum nx_fontid_e fontid). + The new font information needs to be added to data structures used by that function: +

    +
      +#ifdef CONFIG_NXFONT_SANS23X27
      +extern const struct nx_fontpackage_s g_sans23x27_package;
      +#endif
      +#ifdef CONFIG_NXFONT_MYFONT
      +extern const struct nx_fontpackage_s g_myfont_package;
      +#endif
      +
      +static FAR const struct nx_fontpackage_s *g_fontpackages[] =
      +{
      +#ifdef CONFIG_NXFONT_SANS23X27
      +  &g_sans23x27_package,
      +#endif
      +#ifdef CONFIG_NXFONT_MYFONT
      +  &g_myfont_package,
      +#endif
      +  NULL
      +};
      +
    +
  9. +
+ + + +
+

Appendix D NX Test Coverage

@@ -2810,7 +2991,7 @@ make The following table describes the testing performed on each NX API:

-

Table C.1: NXGLIB API Test Coverage

+

Table D.1: NXGLIB API Test Coverage

@@ -2910,7 +3091,7 @@ make
Function
-

Table C.2: NX Server Callbacks Test Coverage

+

Table D.2: NX Server Callbacks Test Coverage

@@ -2939,7 +3120,7 @@ make
Function
-

Table C.3: NX API Test Coverage

+

Table D.3: NX API Test Coverage

@@ -3083,7 +3264,7 @@ make
Function
-

Table C.4: NXTK API Test Coverage

+

Table D.4: NXTK API Test Coverage

@@ -3177,7 +3358,7 @@ make
Function
-

Table C.5: NXFONTS API Test Coverage

+

Table D.5: NXFONTS API Test Coverage

Function