summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-07-24 12:36:21 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-07-24 12:36:21 +0000
commite79139d4ea59a424356d0b6695a2ce841267817d (patch)
tree0512e2feaf79a5248eb302ddc58180a04712bb6a
parent778bce2d8d383f434863845a4230c1a63ad11860 (diff)
downloadnuttx-e79139d4ea59a424356d0b6695a2ce841267817d.tar.gz
nuttx-e79139d4ea59a424356d0b6695a2ce841267817d.tar.bz2
nuttx-e79139d4ea59a424356d0b6695a2ce841267817d.zip
Update BDF converter
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3815 42af7a65-404d-4744-a932-0658087f49c3
-rw-r--r--apps/examples/README.txt51
-rw-r--r--nuttx/Documentation/NXGraphicsSubsystem.html7
-rw-r--r--nuttx/TODO34
-rwxr-xr-xnuttx/configs/stm3210e-eval/README.txt52
-rw-r--r--nuttx/tools/Makefile.host2
-rw-r--r--nuttx/tools/bdf-converter.c193
6 files changed, 289 insertions, 50 deletions
diff --git a/apps/examples/README.txt b/apps/examples/README.txt
index 8e6f05b98..b241b8f75 100644
--- a/apps/examples/README.txt
+++ b/apps/examples/README.txt
@@ -1,16 +1,34 @@
examples
^^^^^^^^
- The examples directory contains several sample applications that
- can be linked with NuttX. The specific example is selected in the
- configs/<board-name>/appconfig file via the CONFIGURED_APPS setting.
- This setting provides the path to the directory containing the
- application Makefile (this path is a relative to the apps/ top-
- level directory). For example,
+ appconfig and CONFIG_APPS
+
+ The examples directory contains several sample applications that
+ can be linked with NuttX. The specific example is selected in the
+ configs/<board-name>/appconfig file via the CONFIGURED_APPS setting.
+ This setting provides the path to the directory containing the
+ application Makefile (this path is a relative to the apps/ top-
+ level directory). For example,
+
+ CONFIGURE_APPS += examples/ostest
+
+ Selects the examples/ostest example.
+
+ Built-In functions
- CONFIGURE_APPS += examples/ostest
+ Some of the examples may be built as "built-in" functions that
+ can be executed at run time (rather than as NuttX "main" programs).
+ These "built-in" examples can be also be executed from the NuttShell
+ (NSH) command line. In order to configure these built-in NSH
+ functions, you have to set up the following:
- Selects the examples/ostest example.
+ - CONFIG_NSH_BUILTIN_APPS - Enable support for external registered,
+ "named" applications that can be executed from the NSH
+ command line (see apps/README.txt for more information).
+ - CONFIG_EXAMPLES_XYZ_BUILTIN -- Build the XYZ example as a "built-in"
+ that can be executed from the NSH command line (where XYZ is
+ the specific example. See the following for examples that
+ support this option).
examples/buttons
^^^^^^^^^^^^^^^^
@@ -838,7 +856,22 @@ examples/usbstorage
Error results are always shown in the trace output
- NOTE: This test exercises internal USB device driver interfaces. As such,
+ NOTE 1: When built as an NSH add-on command (CONFIG_EXAMPLES_USBSTRG_BUILTIN=y),
+ Caution should be used to assure that the SD drive (or other storage device) is
+ not in use when the USB storage device is configured. Specifically, the SD
+ driver should be unmounted like:
+
+ nsh> mount -t vfat /dev/mmcsd0 /mnt/sdcard # Card is mounted in NSH
+ ...
+ nsh> umount /mnd/sdcard # Unmount before connecting USB!!!
+ nsh> msconn # Connect the USB storage device
+ ...
+ nsh> msdis # Disconnect USB storate device
+ nsh> mount -t vfat /dev/mmcsd0 /mnt/sdcard # Restore the mount
+
+ Failure to do this could result in corruption of the SD card format.
+
+ NOTE 2: This test exercises internal USB device driver interfaces. As such,
it relies on internal OS interfaces that are not normally available to a
user-space program. As a result, this example cannot be used if a
NuttX is built as a protected, supervisor kernel (CONFIG_NUTTX_KERNEL).
diff --git a/nuttx/Documentation/NXGraphicsSubsystem.html b/nuttx/Documentation/NXGraphicsSubsystem.html
index 0b0c69ce3..99ffda846 100644
--- a/nuttx/Documentation/NXGraphicsSubsystem.html
+++ b/nuttx/Documentation/NXGraphicsSubsystem.html
@@ -2439,7 +2439,7 @@ FAR const struct nx_font_s *nxf_getfontset(NXHANDLE handle);
<b>Input Parameters:</b>
<ul><dl>
<dt><code>handle</code>
- <dd>A font handle previously returned by <code>nxf_getfonthandle()</code>.
+ <dd>A font handle previously returned by <a href="#nxfgetfonthandle"><code>nxf_getfonthandle()</code></a>.
</dl></ul>
</p>
<p>
@@ -2465,7 +2465,7 @@ FAR const struct nx_fontbitmap_s *nxf_getbitmap(NXHANDLE handle, uint16_t ch);
<dt><code>ch</code>
<dd>The char code for the requested bitmap.
<dt><code>handle</code>
- <dd>A font handle previously returned by <code>nxf_getfonthandle()</code>.
+ <dd>A font handle previously returned by <a href="#nxfgetfonthandle"><code>nxf_getfonthandle()</code></a>.
</dl></ul>
</p>
<p>
@@ -2882,7 +2882,8 @@ endif
<li>
<p>
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 <code>NXHANDLE nxf_getfonthandle(enum nx_fontid_e fontid)</code>.
+ The lookup function is <a href="#nxfgetfonthandle"><code>NXHANDLE nxf_getfonthandle(enum nx_fontid_e fontid)</code></a>.
+ Note that the lookup is based on the font ID that was defined in step 4.
The new font information needs to be added to data structures used by that function:
</p>
<ul><pre>
diff --git a/nuttx/TODO b/nuttx/TODO
index 88a86e06d..f9fc8614a 100644
--- a/nuttx/TODO
+++ b/nuttx/TODO
@@ -42,7 +42,7 @@ apps/
(5) Network Utilities (apps/netutils/)
(5) NuttShell (NSH) (apps/nshlib)
- (3) Other Applications & Tests (apps/examples/)
+ (6) Other Applications & Tests (apps/examples/)
o Task/Scheduler (sched/)
^^^^^^^^^^^^^^^^^^^^^^^
@@ -1310,4 +1310,34 @@ o Other Applications & Tests (apps/examples/)
Priority: Low. This is not really a problem becauses examples/nx works
fine with its bogus font caching.
-
+ Description: examples/nxtext. Artifacts when the pop-up window is opened.
+ There are some artifacts that appear in the upper left hand
+ corner. These seems to be related to window creation. At
+ tiny artifact would not be surprising (the initial window
+ should like at (0,0) and be of size (1,1)), but sometimes
+ the artifact is larger.
+ Status: Open
+ Priority: Medium.
+
+ Description: USB Mass Storage Memory Leak. When examples/usbstorage is
+ built as an NuttShell (NSH) built-in, there appears to be a
+ memory leak that occurs when a USB mass storage connection is
+ established and then torn down. This leak is 608 bytes each
+ time:
+
+ NuttShell (NSH) NuttX-6.6
+ nsh> free
+ total used free largest
+ Mem: 59360 9536 49824 49824
+ nsh> msconn
+ total used free largest
+ Mem: 59360 15296 44064 41712
+ nsh> msdis
+ nsh> free
+ total used free largest
+ Mem: 59360 10144 49216 41712 <-- Leaked 608 bytes
+ Status: Open
+ Priority: Medium. Obviously, this must be fixed. However the USB
+ Mass storage example is fine for supporting most development
+ needs even thought it does leak.
+
diff --git a/nuttx/configs/stm3210e-eval/README.txt b/nuttx/configs/stm3210e-eval/README.txt
index bf35141c9..f6b8a1c1c 100755
--- a/nuttx/configs/stm3210e-eval/README.txt
+++ b/nuttx/configs/stm3210e-eval/README.txt
@@ -455,13 +455,13 @@ Where <subdir> is one of the following:
=========== ======================= ================================
nsh nsh2
=========== ======================= ================================
- Toolchain: NuttX buildroot for Codesourcery for Windows *
- Linux or Cygwin *,**
+ Toolchain: NuttX buildroot for Codesourcery for Windows (1)
+ Linux or Cygwin (1,2)
----------- ----------------------- --------------------------------
Loader: DfuSe DfuSe
----------- ----------------------- --------------------------------
Serial Debug output: USART1 Debug output: USART1
- Console: NSH output: USART1 NSH output: USART1 ***
+ Console: NSH output: USART1 NSH output: USART1 (3)
----------- ----------------------- --------------------------------
I2C1 Disabled Enabled
----------- ----------------------- --------------------------------
@@ -469,7 +469,7 @@ Where <subdir> is one of the following:
Support
----------- ----------------------- --------------------------------
FAT FS CONFIG_FAT_LCNAME=y CONFIG_FAT_LCNAME=y
- Config CONFIG_FAT_LFN=n CONFIG_FAT_LFN=y ****
+ Config CONFIG_FAT_LFN=n CONFIG_FAT_LFN=y (4)
----------- ----------------------- --------------------------------
Support for No Yes
Built-in
@@ -477,23 +477,37 @@ Where <subdir> is one of the following:
----------- ----------------------- --------------------------------
Built-in None apps/examples/nx
Apps apps/examples/nxhello
- apps/examples/usbstorage
+ apps/examples/usbstorage (5)
=========== ======================= ================================
- * You will probably need to modify nsh/setenv.sh or nsh2/setenv.sh
- to set up the correct PATH variable for whichever toolchain you
- may use.
- ** Since DfuSe is assumed, this configuration may only work under
- Cygwin without modification.
- *** When any other device other than /dev/console is used for a user
- interface, (1) linefeeds (\n) will not be expanded to carriage return
- / linefeeds \r\n). You will need to configure your terminal program
- to account for this. And (2) input is not automatically echoed so
- you will have to turn local echo on.
- **** Microsoft holds several patents related to the design of
- long file names in the FAT file system. Please refer to the
- details in the top-level COPYING file. Please do not use FAT
- long file name unless you are familiar with these patent issues.
+ (1) You will probably need to modify nsh/setenv.sh or nsh2/setenv.sh
+ to set up the correct PATH variable for whichever toolchain you
+ may use.
+ (2) Since DfuSe is assumed, this configuration may only work under
+ Cygwin without modification.
+ (3) When any other device other than /dev/console is used for a user
+ interface, (1) linefeeds (\n) will not be expanded to carriage return
+ / linefeeds \r\n). You will need to configure your terminal program
+ to account for this. And (2) input is not automatically echoed so
+ you will have to turn local echo on.
+ (4) Microsoft holds several patents related to the design of
+ long file names in the FAT file system. Please refer to the
+ details in the top-level COPYING file. Please do not use FAT
+ long file name unless you are familiar with these patent issues.
+ (5) When built as an NSH add-on command (CONFIG_EXAMPLES_USBSTRG_BUILTIN=y),
+ Caution should be used to assure that the SD drive is not in use when
+ the USB storage device is configured. Specifically, the SD driver
+ should be unmounted like:
+
+ nsh> mount -t vfat /dev/mmcsd0 /mnt/sdcard # Card is mounted in NSH
+ ...
+ nsh> umount /mnd/sdcard # Unmount before connecting USB!!!
+ nsh> msconn # Connect the USB storage device
+ ...
+ nsh> msdis # Disconnect USB storate device
+ nsh> mount -t vfat /dev/mmcsd0 /mnt/sdcard # Restore the mount
+
+ Failure to do this could result in corruption of the SD card format.
nx:
---
diff --git a/nuttx/tools/Makefile.host b/nuttx/tools/Makefile.host
index fc8762480..2384697b2 100644
--- a/nuttx/tools/Makefile.host
+++ b/nuttx/tools/Makefile.host
@@ -56,7 +56,7 @@ mkversion: mkconfig.c cfgparser.c
mksyscall: mksyscall.c
@gcc $(CFLAGS) -o mksyscall mksyscall.c
-# mksyscall - Convert a CSV file into syscall stubs and proxies
+# bdf-converter - Converts a BDF font to the NuttX font format
bdf-converter: bdf-converter.c
@gcc $(CFLAGS) -o bdf-converter bdf-converter.c
diff --git a/nuttx/tools/bdf-converter.c b/nuttx/tools/bdf-converter.c
index 94d00b8ee..773922428 100644
--- a/nuttx/tools/bdf-converter.c
+++ b/nuttx/tools/bdf-converter.c
@@ -33,6 +33,12 @@
*
****************************************************************************/
+/*
+ * Based one the "Glyph Bitmap Distribution Format (BDF) Specification",
+ * Version 2.2, by Adobe Systems Incorporated.
+ *
+ */
+
/****************************************************************************
* Included Files
****************************************************************************/
@@ -70,15 +76,15 @@
typedef struct glyphinfo_s
{
- char *name; /* Name for they glyph */
- int encoding; /* The Adobe Standard Encoding value */
- int bb_w; /* The width of the black pixels in x */
- int bb_h; /* The height of the black pixels in y */
- int bb_x_off; /* X displacement of the lower left corner
- * of the bitmap from origin 0 */
- int bb_y_off; /* Y displacement of the lower left corner
- * of the bitmap from origin 0 */
- uint32_t *bitmap; /* Hexadecimal data for the */
+ char *name; /* Name for they glyph */
+ int encoding; /* The Adobe Standard Encoding value */
+ int bb_w; /* The width of the black pixels in x */
+ int bb_h; /* The height of the black pixels in y */
+ int bb_x_off; /* X displacement of the lower left corner
+ * of the bitmap from origin 0 */
+ int bb_y_off; /* Y displacement of the lower left corner
+ * of the bitmap from origin 0 */
+ uint32_t *bitmap; /* Hexadecimal data for the character bitmap */
} glyphinfo_t;
/* This structures provides the metrics for one glyph */
@@ -97,6 +103,17 @@ typedef struct nx_fontmetric_s
* Private Functions
****************************************************************************/
+/****************************************************************************
+ * Name: trimLine
+ *
+ * Description:
+ * Trims the line removing space characters at the front and at the end
+ * of the line.
+ *
+ * Input Parameters:
+ * line - The line to trim
+ *
+ ****************************************************************************/
static void trimLine(char *line)
{
char *str;
@@ -143,6 +160,17 @@ static void bdf_parseintline(char *line, unsigned int count, int *info)
}
}
+/****************************************************************************
+ * Name: bdf_printflyphinfo
+ *
+ * Description:
+ * Prints the information available for a glyph.
+ *
+ * Input Parameters:
+ * ginfo - A glyphinfo_t struct with the glyph's information.
+ *
+ ****************************************************************************/
+#ifdef DBG
static void bdf_printglyphinfo(const glyphinfo_t *ginfo)
{
printf("NAME = %s\n", ginfo->name);
@@ -157,7 +185,20 @@ static void bdf_printglyphinfo(const glyphinfo_t *ginfo)
printf("BITMAP[%d] = %x\n", i, ginfo->bitmap[i]);
}
}
+#endif /* DBG */
+/****************************************************************************
+ * Name: bdf_printnxmetricinfo
+ *
+ * Description:
+ * Prints the information available for a glyph's metric in the NX
+ * graphics system.
+ *
+ * Input Parameters:
+ * info - A nx_fontmetric_t struct with the glyph's information.
+ *
+ ****************************************************************************/
+#ifdef DBG
static void bdf_printnxmetricinfo(const nx_fontmetric_t *info)
{
printf("STRIDE = %d\n", info->stride);
@@ -166,7 +207,29 @@ static void bdf_printnxmetricinfo(const nx_fontmetric_t *info)
printf("XOFFSET = %d\n", info->xoffset);
printf("YOFFSET = %d\n", info->yoffset);
}
+#endif /* DBG */
+/****************************************************************************
+ * Name: bdf_getglyphinfo
+ *
+ * Description:
+ * Obtains the information for an individual glyph. The BDF properties
+ * taken into account are:
+ * - ENCODING
+ * - BBX
+ * BDF properties ignored:
+ * - SWIDTH
+ * - DWIDTH
+ * - SWIDTH1
+ * - DWIDTH1
+ * - VVECTOR
+ *
+ * Input Parameters:
+ * file - The input file stream pointing to the first line of the
+ * glyph's information (right after STARTCHAR).
+ * ginfo - A glyphinfo_t struct to fill with the glyph's information.
+ *
+ ****************************************************************************/
static void bdf_getglyphinfo(FILE *file, glyphinfo_t *ginfo)
{
char line[BDF_MAX_LINE_LENGTH];
@@ -215,6 +278,18 @@ static void bdf_getglyphinfo(FILE *file, glyphinfo_t *ginfo)
}
}
+/****************************************************************************
+ * Name: bdf_getglyphbitmap
+ *
+ * Description:
+ * Obtains the character bitmap information for an individual glyph.
+ *
+ * Input Parameters:
+ * file - The input file stream pointing to the first line of the
+ * glyph's bitmap (right after BITMAP).
+ * ginfo - A glyphinfo_t struct to fill with the glyph's bitmap.
+ *
+ ****************************************************************************/
static void bdf_getglyphbitmap(FILE *file, glyphinfo_t *ginfo)
{
char line[BDF_MAX_LINE_LENGTH];
@@ -252,11 +327,37 @@ static void bdf_getglyphbitmap(FILE *file, glyphinfo_t *ginfo)
}
}
+/****************************************************************************
+ * Name: bdf_getstride
+ *
+ * Description:
+ * Obtains the stride for an individual glyph. The stride is the width
+ * of one glyph's bitmap row in bytes.
+ *
+ * Input Parameters:
+ * ginfo - A glyphinfo_t struct with the glyph's information.
+ * stride - A pointer to memory provided by the caller in which to
+ * return the stride.
+ *
+ ****************************************************************************/
static void bdf_getstride(glyphinfo_t *ginfo, uint32_t *stride)
{
- *stride = (ginfo->bb_w % 8 == 0) ? ginfo->bb_w / 8 : ginfo->bb_w / 8 + 1 ;
+ *stride = (ginfo->bb_w % 8 == 0) ? ginfo->bb_w / 8 : ginfo->bb_w / 8 + 1;
}
+/****************************************************************************
+ * Name: bdf_printoutput
+ *
+ * Description:
+ * Prints to the output stream the information of an individual glyph in
+ * the NuttX font format.
+ *
+ * Input Parameters:
+ * out - The output stream.
+ * ginfo - A glyphinfo_t struct with the glyph's information.
+ * nxmetric - A nx_fontmetric_t struct with the glyph's information.
+ *
+ ****************************************************************************/
static void bdf_printoutput(FILE *out,
glyphinfo_t *ginfo,
nx_fontmetric_t *nxmetric)
@@ -310,22 +411,57 @@ int main(int argc, char **argv)
char line[BDF_MAX_LINE_LENGTH];
char lineCopy[BDF_MAX_LINE_LENGTH];
char *str, *token, *saveptr1;
+ char *input, *output;
/* FONTBOUNDINGBOX properties*/
- int fbb_x, fbb_y, fbb_x_off, fbb_y_off;
- file = fopen("8x13.bdf", "r");
- out = fopen("out.txt", "w");
+ int fbb_x = 0;
+ int fbb_y = 0;
+ int fbb_x_off = 0;
+ int fbb_y_off = 0;
+
+ /* Input BDF file */
+
+ input = argv[1];
+
+ if (input == NULL)
+ {
+ printf("%s: no input file\n", argv[0]);
+ exit(0);
+ }
+
+ file = fopen(input, "r");
if (file == NULL)
{
- perror("Error opening file");
+ printf("%s: error opening file %s\n", argv[0], input);
+ exit(0);
+ }
+ else
+ {
+#ifdef VERBOSE
+ printf("Opening \"%s\"\n", input);
+#endif /* VERBOSE */
+ }
+
+ /* Output file */
+ output = "out.txt";
+ out = fopen(output, "w");
+
+ if (out == NULL)
+ {
+ printf("%s: error opening file %s\n", argv[0], output);
+ fclose(file);
+ exit(0);
}
else
{
while (fgets(line, BDF_MAX_LINE_LENGTH, file) != NULL)
{
+
+#ifdef DBG
printf("--\n");
+#endif /* DBG */
// Save a copy of the line
@@ -349,6 +485,13 @@ int main(int argc, char **argv)
fbb_y = fbbinfo[1];
fbb_x_off = fbbinfo[2];
fbb_y_off = fbbinfo[3];
+
+ /* Print FONTBOUNDINGBOX information */
+
+ fprintf(out, "/* Maximum height and width of any");
+ fprintf(out, " glyph in the set */\n\n");
+ fprintf(out, "#define NXFONT_MAXHEIGHT %d\n", fbb_y);
+ fprintf(out, "#define NXFONT_MAXWIDTH %d\n\n", fbb_x);
}
/* STARTCHAR - Individual glyph information */
@@ -360,12 +503,20 @@ int main(int argc, char **argv)
/* Glyph name */
ginfo.name = (char *)strtok_r(NULL, " ", &saveptr1);
+
+#ifdef VERBOSE
+ printf("Processing glyph: %s\n", ginfo.name);
+#endif /* VERBOSE */
/* Glyph information:
* ENCODING
* BBX
*/
-
+ ginfo.encoding = 0;
+ ginfo.bb_w = 0;
+ ginfo.bb_h = 0;
+ ginfo.bb_x_off = 0;
+ ginfo.bb_y_off = 0;
bdf_getglyphinfo(file, &ginfo);
/* Glyph bitmap */
@@ -373,7 +524,9 @@ int main(int argc, char **argv)
ginfo.bitmap = malloc(sizeof(uint32_t) * ginfo.bb_h);
bdf_getglyphbitmap(file, &ginfo);
+#ifdef DBG
bdf_printglyphinfo(&ginfo);
+#endif /* DBG */
/* Convert to nxfonts */
@@ -385,8 +538,11 @@ int main(int argc, char **argv)
nxmetric.height = ginfo.bb_h;
nxmetric.xoffset = (-fbb_x_off) + ginfo.bb_x_off;
nxmetric.yoffset = fbb_y + fbb_y_off - ginfo.bb_y_off;
+
+#ifdef DBG
bdf_printnxmetricinfo(&nxmetric);
-
+#endif /* DBG */
+
bdf_printoutput(out, &ginfo, &nxmetric);
/* Free memory */
@@ -401,6 +557,11 @@ int main(int argc, char **argv)
}
fclose(file);
fclose(out);
+
+ /* The End */
+
+ printf("Generated \"%s\"\n", output);
+
}
return EXIT_SUCCESS;