This is an automated email from the git hooks/post-receive script. It was generated because a ref change was pushed to the repository containing the project gfxprim.git.
The branch, master has been updated via 584415285129a73670aa799560d765a94707850e (commit) from 9743963133809d6610a4986dbe1514e333e87589 (commit)
Those revisions listed above that are new to this repository have not appeared on any other notification email; so we list those revisions in full, below.
- Log ----------------------------------------------------------------- http://repo.or.cz/w/gfxprim.git/commit/584415285129a73670aa799560d765a947078...
commit 584415285129a73670aa799560d765a94707850e Author: Cyril Hrubis metan@ucw.cz Date: Sat Dec 24 21:53:29 2011 +0100
Text: Text core rewrite + freetype support.
* Text core rendering was rewritten to support differnt glyph pixel format.
* Basic support for 8BPP freetype fonts. - there are some small bugs yet to be catched
diff --git a/include/text/GP_FreeType.h b/include/text/GP_DefaultFont.h similarity index 88% rename from include/text/GP_FreeType.h rename to include/text/GP_DefaultFont.h index 954096f..e91c670 100644 --- a/include/text/GP_FreeType.h +++ b/include/text/GP_DefaultFont.h @@ -20,11 +20,13 @@ * * *****************************************************************************/
-#ifndef TEXT_GP_FREE_TYPE_H -#define TEXT_GP_FREE_TYPE_H +#ifndef TEXT_GP_DEFAULT_FONT_H +#define TEXT_GP_DEFAULT_FONT_H
-#include "GP_TextStyle.h" -#include "GP_TextMetric.h" +#include "GP_Font.h"
+extern const GP_FontFace GP_DefaultConsoleFont;
-#endif /* TEXT_GP_FREE_TYPE_H */ +extern const GP_FontFace GP_DefaultProportionalFont; + +#endif /* TEXT_GP_DEFAULT_FONT_H */ diff --git a/include/text/GP_Font.h b/include/text/GP_Font.h index a3cd434..201595e 100644 --- a/include/text/GP_Font.h +++ b/include/text/GP_Font.h @@ -16,9 +16,6 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * - * jiri.bluebear.dluhos@gmail.com * - * * * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/ @@ -28,135 +25,167 @@
#include <stdint.h>
-/* The smallest charset, covering only the 7-bit ASCII (0x20 .. 0x7f). */ -typedef enum GP_Charset { - GP_CHARSET_7BIT = 1, -} GP_Charset; - -/* Maximum length of the font name, author, etc. (Note: these values are - * used by the on-disc font format.) - */ -#define GP_FONT_FAMILY_MAX 63 -#define GP_FONT_NAME_MAX 63 -#define GP_FONT_AUTHOR_MAX 63 -#define GP_FONT_LICENSE_MAX 15 - -/* The current version of the on-disc font format. */ -#define GP_FONT_FORMAT_VMAJOR 1 -#define GP_FONT_FORMAT_VMINOR 0 - -/* Magic string starting the on-disc font file. */ -#define GP_FONT_MAGIC "# gfxprim font file" - -/* - * Contains font metadata. +#define GP_FONT_NAME_MAX 64 + +/* + * Data describing single Glyph. + * + * Note that glyph do not necessarily correspond to one character (for example + * ligature is a glyph but corresponds to at least two characters). + * + * The glyphs are rendered to horizontal baseline, vertical rendering is not + * supported. + * + * The structure could contain glyphs of different BPP and information about + * the bitmap format is stored in the font structure. The bitmap lines are byte + * aligned. */ -typedef struct GP_Font { - - /* Name of the font family. */ - char family[GP_FONT_NAME_MAX + 1]; - - /* Font name. */ - char name[GP_FONT_NAME_MAX + 1]; +typedef struct GP_GlyphBitmap { + /* + * Bitmap width in pixels. + */ + uint8_t width;
- /* Name of the font author. */ - char author[GP_FONT_AUTHOR_MAX + 1]; + /* + * Bitmap heigth in pixels. + */ + uint8_t height;
- /* Font license (default is "GPL2"). */ - char license[GP_FONT_LICENSE_MAX + 1]; + /* + * X offset to be applied before we start drawing. + */ + int8_t bearing_x;
- /* Font version (incremented by font author when modifying the font data, - * do not confuse with format version). + /* + * Y offset from baseline to the top of the bitmap. */ - unsigned int version; + int8_t bearing_y;
- /* The charset specifies which characters are defined by the font. */ - uint8_t charset; + /* + * Offset to be applied after drawing, defines + * basepoint for next glyph. + */ + uint8_t advance_x;
+ /* + * Character bitmap, byte aligned bitmap. + */ + uint8_t bitmap[]; +} GP_GlyphBitmap;
- /* Height of every character in pixels. */ - uint8_t height; +typedef enum GP_CharSet { + GP_CHARSET_7BIT, +} GP_CharSet;
- /* Height of the baseline (number of pixels from the bottom). */ - uint8_t baseline; +/* + * Glyph bitmap data format. + * + * The bitmap is byte aligned and for 1BPP the number of bytes per row is + * rounted to bytes. + * + */ +typedef enum GP_FontBitmapFormat { + GP_FONT_BITMAP_1BPP, + GP_FONT_BITMAP_8BPP, +} GP_FontBitmapFormat;
+/* + * Font face + */ +typedef struct GP_FontFace { /* - * Number of bytes for each pixel line in the character data - * (typically 1/8 of char_width, rounded upwards). + * Font family name - eg. Sans, Serif ... */ - uint8_t bytes_per_line; + char family_name[GP_FONT_NAME_MAX];
- /* Maximum width of the character bounding box (including empty areas - * that are not drawn but cause other characters to shift). + /* + * Font style name - Medium, Bold, Italic ... */ - uint8_t max_bounding_width; + char style_name[GP_FONT_NAME_MAX];
/* - * Array of GP_CharData structures, packed together sequentially - * without padding. - * - * Characters are stored in encoding order. The first encoded character - * is 0x20 (space). A font must, at a minimum, encode all characters - * of the 7-bit ASCII set (0x20 .. 0x7F, inclusive). + * Enum for supported charsets. */ - uint8_t *data; -} GP_Font; - -#define GP_CHECK_FONT(font) do { - GP_CHECK(font->data, "invalid font: NULL font data"); - GP_CHECK(font->height > 0, "invalid font: height == 0"); - GP_CHECK(font->baseline <= font->height, "invalid font: baseline exceeds height"); - GP_CHECK(font->bytes_per_line > 0, "invalid font: bytes_per_line == 0"); -} while(0) - -/* Data describing a single character. */ -typedef struct GP_CharData { + uint8_t charset;
- /* Width of the character in pixels. This is the area that is drawn - * onto, but the real area occupied by the character can be different - * and is defined by pre_offset and post_offset. + /* + * Maximal height of font glyph from baseline to the top. */ - uint8_t char_width; + uint16_t ascend; + + /* + * Maximal length of font glyph from baseline to the bottom. + */ + uint16_t descend;
- /* X offset to be applied to the current position *before* - * drawing the character. + /* + * Maximal width of font glyph. + * + * (basically max from glyph->width + glyph->bearing_x) */ - int8_t pre_offset; + uint16_t max_glyph_width;
- /* X offset to be applied to the current position *after* - * the character is drawn. + /* + * Maximal glyph advance. */ - int8_t post_offset; + uint16_t max_glyph_advance;
- /* Character bitmap (size depends on width and height). */ - uint8_t bitmap[]; + /* + * Bitmap format for all glyphs + */ + GP_FontBitmapFormat glyph_bitmap_format;
-} GP_CharData; + /* + * Pointer to glyph bitmap buffer. + */ + void *glyphs;
-/* The default font, which is hardcoded and always available. */ -extern struct GP_Font GP_default_console_font; -extern struct GP_Font GP_default_proportional_font; + /* + * Offsets to the glyph data. + * + * If glyph_offset[0] == 0, the table glyph_offsets holds + * offsets for all characters in glyphs. Otherwise the + * glyph_offset[0] defines step in the glyph table. + */ + uint16_t glyph_offsets[]; +} GP_FontFace;
-/* Returns the number of bytes occupied by the GP_CharData structure - * for this font. (Currently, all characters occupy the same space - * regardless of proportionality.) +/* + * Returns font height eg. ascend + descend */ -unsigned int GP_GetCharDataSize(const GP_Font *font); +static inline unsigned int GP_FontHeight(const GP_FontFace *font) +{ + return font->ascend + font->descend; +} + +static inline unsigned int GP_FontAscend(const GP_FontFace *font) +{ + return font->ascend; +} + +static inline unsigned int GP_FontDescend(const GP_FontFace *font) +{ + return font->descend; +} + +static inline unsigned int GP_FontMaxWidth(const GP_FontFace *font) +{ + return font->max_glyph_width; +}
-/* Returns a pointer to the character data (which start by the header) - * of the specified character in the font data area. +/* + * Returns glyph count for charset. */ -const GP_CharData *GP_GetCharData(const GP_Font *font, int c); +uint32_t GP_GetGlyphCount(GP_CharSet charset);
-/* Returns the overall size (in bytes) occupied by all characters - * of the font (the font metadata do not count into this value; - * add sizeof(GP_Font) to get the complete size of the font in memory.) +/* + * Returns glyph mapping */ -unsigned int GP_GetFontDataSize(const GP_Font *font); +GP_GlyphBitmap *GP_GetGlyphBitmap(const GP_FontFace *font, int c);
-#include "core/GP_RetCode.h" - -GP_RetCode GP_FontLoad(GP_Font **font, const char *filename); -GP_RetCode GP_FontSave(const GP_Font *font, const char *filename); +/* + * Loads font face from file. + */ +GP_FontFace *GP_FontFaceLoad(const char *path, uint32_t width, uint32_t height);
#endif /* TEXT_GP_FONT_H */ diff --git a/include/text/GP_Text.h b/include/text/GP_Text.h index 9cfdb7d..86627e6 100644 --- a/include/text/GP_Text.h +++ b/include/text/GP_Text.h @@ -30,6 +30,7 @@
#include "GP_TextStyle.h" #include "GP_TextMetric.h" +#include "GP_DefaultFont.h"
/* How the rendered text should be aligned. * For GP_Text(), the alignment is relative to the specified point: @@ -54,9 +55,13 @@ typedef enum GP_TextAttr { GP_VALIGN_BOTTOM = GP_VALIGN_BELOW, } GP_TextAttr;
+/* + * Raw version, doesn't use Text aligment. + */ void GP_Text_Raw(GP_Context *context, const GP_TextStyle *style, - GP_Coord x, GP_Coord y, int align, - GP_Pixel fg_color, GP_Pixel bg_color, const char *str); + GP_Coord x, GP_Coord y, + GP_Pixel fg_color, GP_Pixel bg_color, + const char *str);
/* * Draws a string. diff --git a/include/text/GP_TextStyle.h b/include/text/GP_TextStyle.h index 58b6886..4510fbd 100644 --- a/include/text/GP_TextStyle.h +++ b/include/text/GP_TextStyle.h @@ -19,7 +19,7 @@ * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * * jiri.bluebear.dluhos@gmail.com * * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -27,16 +27,14 @@ #define TEXT_GP_TEXTSTYLE_H
#include "GP_Font.h" -#include "core/GP_RetCode.h" +#include "GP_DefaultFont.h"
/* * This structure describes how a text should be rendered. * It includes a font, and its various variants and transformations. */ -typedef struct { - - /* Font to use. */ - struct GP_Font *font; +typedef struct GP_TextStyle { + const struct GP_FontFace *font;
/* Spacing between pixels (0 is the default, no spacing). */ int pixel_xspace, pixel_yspace; @@ -49,23 +47,13 @@ typedef struct {
} GP_TextStyle;
-/* - * Static initializer for initializing a GP_TextStyle structure to default - * values. - * Note that at least the colors should always be changed afterwards, - * as there is no sensible default (they are initialized to 0). - */ -#define GP_DEFAULT_TEXT_STYLE { &GP_default_console_font, 0, 0, 1, 1, 0 } - -/* - * Initalize text style to the default values. - */ -void GP_DefaultTextStyle(GP_TextStyle *style); - -#define GP_CHECK_TEXT_STYLE(style) do { - GP_CHECK(style, "NULL style specified"); - GP_CHECK(style->font, "invalid text style: font is NULL"); - GP_CHECK_FONT(style->font); -} while(0) +#define GP_DEFAULT_TEXT_STYLE { + .font = &GP_DefaultConsoleFont, + .pixel_xspace = 0, + .pixel_yspace = 0, + .pixel_xmul = 1, + .pixel_ymul = 1, + .char_xspace = 0 +}
#endif /* TEXT_GP_TEXTSTYLE_H */ diff --git a/libs/text/GP_DefaultFont.c b/libs/text/GP_DefaultFont.c index bb4b1de..d2faa49 100644 --- a/libs/text/GP_DefaultFont.c +++ b/libs/text/GP_DefaultFont.c @@ -19,233 +19,420 @@ * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * * jiri.bluebear.dluhos@gmail.com * * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
#include "GP_Font.h"
-static uint8_t GP_default_console_font_data[] = { - /* ' ' */ 7, 0, 8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* '!' */ 7, 0, 8, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x08, 0x00, 0x00, - /* '"' */ 7, 0, 8, 0x24, 0x24, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* '#' */ 7, 0, 8, 0x00, 0x14, 0x14, 0x7e, 0x28, 0x28, 0xfc, 0x50, 0x50, 0x00, 0x00, - /* '$' */ 7, 0, 8, 0x10, 0x7c, 0x92, 0x90, 0x7c, 0x12, 0x92, 0x7c, 0x10, 0x00, 0x00, - /* '%' */ 7, 0, 8, 0x61, 0x92, 0x94, 0x68, 0x10, 0x2c, 0x52, 0x92, 0x0c, 0x00, 0x00, - /* '&' */ 7, 0, 8, 0x30, 0x48, 0x48, 0x30, 0x56, 0x88, 0x88, 0x88, 0x76, 0x00, 0x00, - /* ''' */ 7, 0, 8, 0x0c, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* '(' */ 7, 0, 8, 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x00, 0x00, - /* ')' */ 7, 0, 8, 0x10, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x10, 0x00, 0x00, - /* '*' */ 7, 0, 8, 0x00, 0x10, 0x54, 0x54, 0x38, 0x54, 0x54, 0x10, 0x00, 0x00, 0x00, - /* '+' */ 7, 0, 8, 0x00, 0x10, 0x10, 0x10, 0xfe, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, - /* ',' */ 7, 0, 8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x10, 0x00, - /* '-' */ 7, 0, 8, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* '.' */ 7, 0, 8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - /* '/' */ 7, 0, 8, 0x00, 0x04, 0x04, 0x08, 0x08, 0x10, 0x10, 0x20, 0x20, 0x00, 0x00, - /* '0' */ 7, 0, 8, 0x78, 0x84, 0x8c, 0x94, 0xb4, 0xa4, 0xc4, 0x84, 0x78, 0x00, 0x00, - /* '1' */ 7, 0, 8, 0x10, 0x30, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x7c, 0x00, 0x00, - /* '2' */ 7, 0, 8, 0x78, 0x84, 0x84, 0x04, 0x18, 0x60, 0x80, 0x80, 0xfc, 0x00, 0x00, - /* '3' */ 7, 0, 8, 0x78, 0x84, 0x84, 0x04, 0x18, 0x04, 0x84, 0x84, 0x78, 0x00, 0x00, - /* '4' */ 7, 0, 8, 0x18, 0x28, 0x48, 0x48, 0x88, 0xfc, 0x08, 0x08, 0x08, 0x00, 0x00, - /* '5' */ 7, 0, 8, 0xfc, 0x80, 0x80, 0xf8, 0x04, 0x04, 0x84, 0x84, 0x78, 0x00, 0x00, - /* '6' */ 7, 0, 8, 0x78, 0x80, 0x80, 0xf8, 0x84, 0x84, 0x84, 0x84, 0x78, 0x00, 0x00, - /* '7' */ 7, 0, 8, 0xfc, 0x04, 0x04, 0x08, 0x08, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, - /* '8' */ 7, 0, 8, 0x78, 0x84, 0x84, 0x84, 0x78, 0x84, 0x84, 0x84, 0x78, 0x00, 0x00, - /* '9' */ 7, 0, 8, 0x78, 0x84, 0x84, 0x84, 0x84, 0x7c, 0x04, 0x04, 0x78, 0x00, 0x00, - /* ':' */ 7, 0, 8, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, - /* ';' */ 7, 0, 8, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x08, 0x10, 0x00, - /* '<' */ 7, 0, 8, 0x00, 0x08, 0x10, 0x20, 0x40, 0x20, 0x10, 0x08, 0x00, 0x00, 0x00, - /* '=' */ 7, 0, 8, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, - /* '>' */ 7, 0, 8, 0x00, 0x10, 0x08, 0x04, 0x02, 0x04, 0x08, 0x10, 0x00, 0x00, 0x00, - /* '?' */ 7, 0, 8, 0x7c, 0x82, 0x82, 0x02, 0x0c, 0x10, 0x10, 0x00, 0x10, 0x00, 0x00, - /* '@' */ 8, 0, 8, 0x3e, 0x41, 0x9d, 0xa5, 0xa5, 0xa5, 0x9e, 0x41, 0x3e, 0x00, 0x00, - /* 'A' */ 7, 0, 8, 0x7c, 0x82, 0x82, 0x82, 0xfe, 0x82, 0x82, 0x82, 0x82, 0x00, 0x00, - /* 'B' */ 7, 0, 8, 0xfc, 0x82, 0x82, 0x82, 0xfc, 0x82, 0x82, 0x82, 0xfc, 0x00, 0x00, - /* 'C' */ 7, 0, 8, 0x7c, 0x82, 0x80, 0x80, 0x80, 0x80, 0x80, 0x82, 0x7c, 0x00, 0x00, - /* 'D' */ 7, 0, 8, 0xf8, 0x84, 0x82, 0x82, 0x82, 0x82, 0x82, 0x84, 0xf8, 0x00, 0x00, - /* 'E' */ 7, 0, 8, 0xfe, 0x80, 0x80, 0x80, 0xfc, 0x80, 0x80, 0x80, 0xfe, 0x00, 0x00, - /* 'F' */ 7, 0, 8, 0xfe, 0x80, 0x80, 0x80, 0xf8, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, - /* 'G' */ 7, 0, 8, 0x7c, 0x82, 0x80, 0x80, 0x80, 0x9e, 0x82, 0x82, 0x7c, 0x00, 0x00, - /* 'H' */ 7, 0, 8, 0x82, 0x82, 0x82, 0x82, 0xfe, 0x82, 0x82, 0x82, 0x82, 0x00, 0x00, - /* 'I' */ 7, 0, 8, 0x7c, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x7c, 0x00, 0x00, - /* 'J' */ 7, 0, 8, 0x7e, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x82, 0x7c, 0x00, 0x00, - /* 'K' */ 7, 0, 8, 0x82, 0x84, 0x88, 0x90, 0xe0, 0x90, 0x88, 0x84, 0x82, 0x00, 0x00, - /* 'L' */ 7, 0, 8, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xfe, 0x00, 0x00, - /* 'M' */ 7, 0, 8, 0x82, 0xc6, 0xaa, 0x92, 0x82, 0x82, 0x82, 0x82, 0x82, 0x00, 0x00, - /* 'N' */ 7, 0, 8, 0x82, 0xc2, 0xa2, 0xa2, 0x92, 0x8a, 0x8a, 0x86, 0x82, 0x00, 0x00, - /* 'O' */ 7, 0, 8, 0x7c, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x7c, 0x00, 0x00, - /* 'P' */ 7, 0, 8, 0xfc, 0x82, 0x82, 0x82, 0x82, 0xfc, 0x80, 0x80, 0x80, 0x00, 0x00, - /* 'Q' */ 7, 0, 8, 0x7c, 0x82, 0x82, 0x82, 0x82, 0x82, 0x9a, 0x84, 0x7a, 0x00, 0x00, - /* 'R' */ 7, 0, 8, 0xfc, 0x82, 0x82, 0x82, 0x82, 0xfc, 0x88, 0x84, 0x82, 0x00, 0x00, - /* 'S' */ 7, 0, 8, 0x7c, 0x82, 0x80, 0x80, 0x7c, 0x02, 0x02, 0x82, 0x7c, 0x00, 0x00, - /* 'T' */ 7, 0, 8, 0xfe, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, - /* 'U' */ 7, 0, 8, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x7c, 0x00, 0x00, - /* 'V' */ 7, 0, 8, 0x82, 0x82, 0x82, 0x44, 0x44, 0x28, 0x28, 0x10, 0x10, 0x00, 0x00, - /* 'W' */ 7, 0, 8, 0x82, 0x82, 0x82, 0x82, 0x92, 0x92, 0x92, 0xaa, 0x44, 0x00, 0x00, - /* 'X' */ 7, 0, 8, 0x82, 0x82, 0x44, 0x28, 0x10, 0x28, 0x44, 0x82, 0x82, 0x00, 0x00, - /* 'Y' */ 7, 0, 8, 0x82, 0x82, 0x44, 0x28, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, - /* 'Z' */ 7, 0, 8, 0xfe, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0xfe, 0x00, 0x00, - /* '[' */ 7, 0, 8, 0x3c, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x00, 0x00, - /* '' */ 7, 0, 8, 0x00, 0x20, 0x20, 0x10, 0x10, 0x08, 0x08, 0x04, 0x04, 0x00, 0x00, - /* ']' */ 7, 0, 8, 0x1e, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x1e, 0x00, 0x00, - /* '^' */ 7, 0, 8, 0x08, 0x14, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* '_' */ 7, 0, 8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, - /* '`' */ 7, 0, 8, 0x30, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 'a' */ 7, 0, 8, 0x00, 0x00, 0x3c, 0x02, 0x02, 0x3e, 0x42, 0x42, 0x3e, 0x00, 0x00, - /* 'b' */ 7, 0, 8, 0x40, 0x40, 0x7c, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7c, 0x00, 0x00, - /* 'c' */ 7, 0, 8, 0x00, 0x00, 0x3c, 0x42, 0x40, 0x40, 0x40, 0x42, 0x3c, 0x00, 0x00, - /* 'd' */ 7, 0, 8, 0x02, 0x02, 0x3e, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3e, 0x00, 0x00, - /* 'e' */ 7, 0, 8, 0x00, 0x00, 0x3c, 0x42, 0x42, 0x7e, 0x40, 0x40, 0x3e, 0x00, 0x00, - /* 'f' */ 7, 0, 8, 0x1e, 0x20, 0x20, 0xfc, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, - /* 'g' */ 7, 0, 8, 0x00, 0x00, 0x3e, 0x42, 0x42, 0x42, 0x42, 0x3e, 0x02, 0x02, 0x3c, - /* 'h' */ 7, 0, 8, 0x40, 0x40, 0x7c, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00, - /* 'i' */ 7, 0, 8, 0x08, 0x00, 0x38, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3e, 0x00, 0x00, - /* 'j' */ 7, 0, 8, 0x08, 0x00, 0x78, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x70, - /* 'k' */ 7, 0, 8, 0x40, 0x40, 0x42, 0x44, 0x48, 0x70, 0x48, 0x44, 0x42, 0x00, 0x00, - /* 'l' */ 7, 0, 8, 0x70, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x0e, 0x00, 0x00, - /* 'm' */ 7, 0, 8, 0x00, 0x00, 0xfc, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x00, 0x00, - /* 'n' */ 7, 0, 8, 0x00, 0x00, 0x5c, 0x62, 0x42, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00, - /* 'o' */ 7, 0, 8, 0x00, 0x00, 0x3c, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3c, 0x00, 0x00, - /* 'p' */ 7, 0, 8, 0x00, 0x00, 0x7c, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7c, 0x40, 0x40, - /* 'q' */ 7, 0, 8, 0x00, 0x00, 0x3e, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3e, 0x02, 0x02, - /* 'r' */ 7, 0, 8, 0x00, 0x00, 0x5e, 0x60, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00, - /* 's' */ 7, 0, 8, 0x00, 0x00, 0x7c, 0x80, 0x80, 0x7c, 0x02, 0x02, 0x7c, 0x00, 0x00, - /* 't' */ 7, 0, 8, 0x00, 0x10, 0x7c, 0x10, 0x10, 0x10, 0x10, 0x10, 0x0e, 0x00, 0x00, - /* 'u' */ 7, 0, 8, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3e, 0x00, 0x00, - /* 'v' */ 7, 0, 8, 0x00, 0x00, 0x42, 0x42, 0x42, 0x24, 0x24, 0x24, 0x18, 0x00, 0x00, - /* 'w' */ 7, 0, 8, 0x00, 0x00, 0x82, 0x82, 0x92, 0x92, 0x92, 0x92, 0x6c, 0x00, 0x00, - /* 'x' */ 7, 0, 8, 0x00, 0x00, 0x42, 0x42, 0x24, 0x18, 0x24, 0x42, 0x42, 0x00, 0x00, - /* 'y' */ 7, 0, 8, 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3e, 0x02, 0x02, 0x3c, - /* 'z' */ 7, 0, 8, 0x00, 0x00, 0x7e, 0x04, 0x08, 0x10, 0x20, 0x40, 0x7e, 0x00, 0x00, - /* '{' */ 7, 0, 8, 0x0c, 0x10, 0x10, 0x10, 0x60, 0x10, 0x10, 0x10, 0x0c, 0x00, 0x00, - /* '|' */ 7, 0, 8, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, - /* '}' */ 7, 0, 8, 0x30, 0x08, 0x08, 0x08, 0x06, 0x08, 0x08, 0x08, 0x30, 0x00, 0x00, - /* '~' */ 7, 0, 8, 0x32, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +static int8_t default_console_glyphs[] = { + /* ' ' */ 7, 11, 0, 9, 8, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* '!' */ 7, 11, 0, 9, 8, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x08, 0x00, 0x00, + /* '"' */ 7, 11, 0, 9, 8, + 0x24, 0x24, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* '#' */ 7, 11, 0, 9, 8, + 0x00, 0x14, 0x14, 0x7e, 0x28, 0x28, 0xfc, 0x50, 0x50, 0x00, 0x00, + /* '$' */ 7, 11, 0, 9, 8, + 0x10, 0x7c, 0x92, 0x90, 0x7c, 0x12, 0x92, 0x7c, 0x10, 0x00, 0x00, + /* '%' */ 7, 11, 0, 9, 8, + 0x61, 0x92, 0x94, 0x68, 0x10, 0x2c, 0x52, 0x92, 0x0c, 0x00, 0x00, + /* '&' */ 7, 11, 0, 9, 8, + 0x30, 0x48, 0x48, 0x30, 0x56, 0x88, 0x88, 0x88, 0x76, 0x00, 0x00, + /* ''' */ 7, 11, 0, 9, 8, + 0x0c, 0x08, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* '(' */ 7, 11, 0, 9, 8, + 0x08, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x08, 0x00, 0x00, + /* ')' */ 7, 11, 0, 9, 8, + 0x10, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x10, 0x00, 0x00, + /* '*' */ 7, 11, 0, 9, 8, + 0x00, 0x10, 0x54, 0x54, 0x38, 0x54, 0x54, 0x10, 0x00, 0x00, 0x00, + /* '+' */ 7, 11, 0, 9, 8, + 0x00, 0x10, 0x10, 0x10, 0xfe, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, + /* ',' */ 7, 11, 0, 9, 8, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x08, 0x10, 0x00, + /* '-' */ 7, 11, 0, 9, 8, + 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* '.' */ 7, 11, 0, 9, 8, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, + /* '/' */ 7, 11, 0, 9, 8, + 0x00, 0x04, 0x04, 0x08, 0x08, 0x10, 0x10, 0x20, 0x20, 0x00, 0x00, + /* '0' */ 7, 11, 0, 9, 8, + 0x78, 0x84, 0x8c, 0x94, 0xb4, 0xa4, 0xc4, 0x84, 0x78, 0x00, 0x00, + /* '1' */ 7, 11, 0, 9, 8, + 0x10, 0x30, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x7c, 0x00, 0x00, + /* '2' */ 7, 11, 0, 9, 8, + 0x78, 0x84, 0x84, 0x04, 0x18, 0x60, 0x80, 0x80, 0xfc, 0x00, 0x00, + /* '3' */ 7, 11, 0, 9, 8, + 0x78, 0x84, 0x84, 0x04, 0x18, 0x04, 0x84, 0x84, 0x78, 0x00, 0x00, + /* '4' */ 7, 11, 0, 9, 8, + 0x18, 0x28, 0x48, 0x48, 0x88, 0xfc, 0x08, 0x08, 0x08, 0x00, 0x00, + /* '5' */ 7, 11, 0, 9, 8, + 0xfc, 0x80, 0x80, 0xf8, 0x04, 0x04, 0x84, 0x84, 0x78, 0x00, 0x00, + /* '6' */ 7, 11, 0, 9, 8, + 0x78, 0x80, 0x80, 0xf8, 0x84, 0x84, 0x84, 0x84, 0x78, 0x00, 0x00, + /* '7' */ 7, 11, 0, 9, 8, + 0xfc, 0x04, 0x04, 0x08, 0x08, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, + /* '8' */ 7, 11, 0, 9, 8, + 0x78, 0x84, 0x84, 0x84, 0x78, 0x84, 0x84, 0x84, 0x78, 0x00, 0x00, + /* '9' */ 7, 11, 0, 9, 8, + 0x78, 0x84, 0x84, 0x84, 0x84, 0x7c, 0x04, 0x04, 0x78, 0x00, 0x00, + /* ':' */ 7, 11, 0, 9, 8, + 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, + /* ';' */ 7, 11, 0, 9, 8, + 0x00, 0x00, 0x00, 0x18, 0x18, 0x00, 0x00, 0x18, 0x08, 0x10, 0x00, + /* '<' */ 7, 11, 0, 9, 8, + 0x00, 0x08, 0x10, 0x20, 0x40, 0x20, 0x10, 0x08, 0x00, 0x00, 0x00, + /* '=' */ 7, 11, 0, 9, 8, + 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x00, + /* '>' */ 7, 11, 0, 9, 8, + 0x00, 0x10, 0x08, 0x04, 0x02, 0x04, 0x08, 0x10, 0x00, 0x00, 0x00, + /* '?' */ 7, 11, 0, 9, 8, + 0x7c, 0x82, 0x82, 0x02, 0x0c, 0x10, 0x10, 0x00, 0x10, 0x00, 0x00, + /* '@' */ 8, 11, 0, 9, 8, + 0x3e, 0x41, 0x9d, 0xa5, 0xa5, 0xa5, 0x9e, 0x41, 0x3e, 0x00, 0x00, + /* 'A' */ 7, 11, 0, 9, 8, + 0x7c, 0x82, 0x82, 0x82, 0xfe, 0x82, 0x82, 0x82, 0x82, 0x00, 0x00, + /* 'B' */ 7, 11, 0, 9, 8, + 0xfc, 0x82, 0x82, 0x82, 0xfc, 0x82, 0x82, 0x82, 0xfc, 0x00, 0x00, + /* 'C' */ 7, 11, 0, 9, 8, + 0x7c, 0x82, 0x80, 0x80, 0x80, 0x80, 0x80, 0x82, 0x7c, 0x00, 0x00, + /* 'D' */ 7, 11, 0, 9, 8, + 0xf8, 0x84, 0x82, 0x82, 0x82, 0x82, 0x82, 0x84, 0xf8, 0x00, 0x00, + /* 'E' */ 7, 11, 0, 9, 8, + 0xfe, 0x80, 0x80, 0x80, 0xfc, 0x80, 0x80, 0x80, 0xfe, 0x00, 0x00, + /* 'F' */ 7, 11, 0, 9, 8, + 0xfe, 0x80, 0x80, 0x80, 0xf8, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, + /* 'G' */ 7, 11, 0, 9, 8, + 0x7c, 0x82, 0x80, 0x80, 0x80, 0x9e, 0x82, 0x82, 0x7c, 0x00, 0x00, + /* 'H' */ 7, 11, 0, 9, 8, + 0x82, 0x82, 0x82, 0x82, 0xfe, 0x82, 0x82, 0x82, 0x82, 0x00, 0x00, + /* 'I' */ 7, 11, 0, 9, 8, + 0x7c, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x7c, 0x00, 0x00, + /* 'J' */ 7, 11, 0, 9, 8, + 0x7e, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x82, 0x7c, 0x00, 0x00, + /* 'K' */ 7, 11, 0, 9, 8, + 0x82, 0x84, 0x88, 0x90, 0xe0, 0x90, 0x88, 0x84, 0x82, 0x00, 0x00, + /* 'L' */ 7, 11, 0, 9, 8, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xfe, 0x00, 0x00, + /* 'M' */ 7, 11, 0, 9, 8, + 0x82, 0xc6, 0xaa, 0x92, 0x82, 0x82, 0x82, 0x82, 0x82, 0x00, 0x00, + /* 'N' */ 7, 11, 0, 9, 8, + 0x82, 0xc2, 0xa2, 0xa2, 0x92, 0x8a, 0x8a, 0x86, 0x82, 0x00, 0x00, + /* 'O' */ 7, 11, 0, 9, 8, + 0x7c, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x7c, 0x00, 0x00, + /* 'P' */ 7, 11, 0, 9, 8, + 0xfc, 0x82, 0x82, 0x82, 0x82, 0xfc, 0x80, 0x80, 0x80, 0x00, 0x00, + /* 'Q' */ 7, 11, 0, 9, 8, + 0x7c, 0x82, 0x82, 0x82, 0x82, 0x82, 0x9a, 0x84, 0x7a, 0x00, 0x00, + /* 'R' */ 7, 11, 0, 9, 8, + 0xfc, 0x82, 0x82, 0x82, 0x82, 0xfc, 0x88, 0x84, 0x82, 0x00, 0x00, + /* 'S' */ 7, 11, 0, 9, 8, + 0x7c, 0x82, 0x80, 0x80, 0x7c, 0x02, 0x02, 0x82, 0x7c, 0x00, 0x00, + /* 'T' */ 7, 11, 0, 9, 8, + 0xfe, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, + /* 'U' */ 7, 11, 0, 9, 8, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x7c, 0x00, 0x00, + /* 'V' */ 7, 11, 0, 9, 8, + 0x82, 0x82, 0x82, 0x44, 0x44, 0x28, 0x28, 0x10, 0x10, 0x00, 0x00, + /* 'W' */ 7, 11, 0, 9, 8, + 0x82, 0x82, 0x82, 0x82, 0x92, 0x92, 0x92, 0xaa, 0x44, 0x00, 0x00, + /* 'X' */ 7, 11, 0, 9, 8, + 0x82, 0x82, 0x44, 0x28, 0x10, 0x28, 0x44, 0x82, 0x82, 0x00, 0x00, + /* 'Y' */ 7, 11, 0, 9, 8, + 0x82, 0x82, 0x44, 0x28, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, + /* 'Z' */ 7, 11, 0, 9, 8, + 0xfe, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0xfe, 0x00, 0x00, + /* '[' */ 7, 11, 0, 9, 8, + 0x3c, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x3c, 0x00, 0x00, + /* '' */ 7, 11, 0, 9, 8, + 0x00, 0x20, 0x20, 0x10, 0x10, 0x08, 0x08, 0x04, 0x04, 0x00, 0x00, + /* ']' */ 7, 11, 0, 9, 8, + 0x1e, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x1e, 0x00, 0x00, + /* '^' */ 7, 11, 0, 9, 8, + 0x08, 0x14, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* '_' */ 7, 11, 0, 9, 8, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, + /* '`' */ 7, 11, 0, 9, 8, + 0x30, 0x10, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 'a' */ 7, 11, 0, 9, 8, + 0x00, 0x00, 0x3c, 0x02, 0x02, 0x3e, 0x42, 0x42, 0x3e, 0x00, 0x00, + /* 'b' */ 7, 11, 0, 9, 8, + 0x40, 0x40, 0x7c, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7c, 0x00, 0x00, + /* 'c' */ 7, 11, 0, 9, 8, + 0x00, 0x00, 0x3c, 0x42, 0x40, 0x40, 0x40, 0x42, 0x3c, 0x00, 0x00, + /* 'd' */ 7, 11, 0, 9, 8, + 0x02, 0x02, 0x3e, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3e, 0x00, 0x00, + /* 'e' */ 7, 11, 0, 9, 8, + 0x00, 0x00, 0x3c, 0x42, 0x42, 0x7e, 0x40, 0x40, 0x3e, 0x00, 0x00, + /* 'f' */ 7, 11, 0, 9, 8, + 0x1e, 0x20, 0x20, 0xfc, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, + /* 'g' */ 7, 11, 0, 9, 8, + 0x00, 0x00, 0x3e, 0x42, 0x42, 0x42, 0x42, 0x3e, 0x02, 0x02, 0x3c, + /* 'h' */ 7, 11, 0, 9, 8, + 0x40, 0x40, 0x7c, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00, + /* 'i' */ 7, 11, 0, 9, 8, + 0x08, 0x00, 0x38, 0x08, 0x08, 0x08, 0x08, 0x08, 0x3e, 0x00, 0x00, + /* 'j' */ 7, 11, 0, 9, 8, + 0x08, 0x00, 0x78, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x70, + /* 'k' */ 7, 11, 0, 9, 8, + 0x40, 0x40, 0x42, 0x44, 0x48, 0x70, 0x48, 0x44, 0x42, 0x00, 0x00, + /* 'l' */ 7, 11, 0, 9, 8, + 0x70, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x0e, 0x00, 0x00, + /* 'm' */ 7, 11, 0, 9, 8, + 0x00, 0x00, 0xfc, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x00, 0x00, + /* 'n' */ 7, 11, 0, 9, 8, + 0x00, 0x00, 0x5c, 0x62, 0x42, 0x42, 0x42, 0x42, 0x42, 0x00, 0x00, + /* 'o' */ 7, 11, 0, 9, 8, + 0x00, 0x00, 0x3c, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3c, 0x00, 0x00, + /* 'p' */ 7, 11, 0, 9, 8, + 0x00, 0x00, 0x7c, 0x42, 0x42, 0x42, 0x42, 0x42, 0x7c, 0x40, 0x40, + /* 'q' */ 7, 11, 0, 9, 8, + 0x00, 0x00, 0x3e, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3e, 0x02, 0x02, + /* 'r' */ 7, 11, 0, 9, 8, + 0x00, 0x00, 0x5e, 0x60, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00, + /* 's' */ 7, 11, 0, 9, 8, + 0x00, 0x00, 0x7c, 0x80, 0x80, 0x7c, 0x02, 0x02, 0x7c, 0x00, 0x00, + /* 't' */ 7, 11, 0, 9, 8, + 0x00, 0x10, 0x7c, 0x10, 0x10, 0x10, 0x10, 0x10, 0x0e, 0x00, 0x00, + /* 'u' */ 7, 11, 0, 9, 8, + 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3e, 0x00, 0x00, + /* 'v' */ 7, 11, 0, 9, 8, + 0x00, 0x00, 0x42, 0x42, 0x42, 0x24, 0x24, 0x24, 0x18, 0x00, 0x00, + /* 'w' */ 7, 11, 0, 9, 8, + 0x00, 0x00, 0x82, 0x82, 0x92, 0x92, 0x92, 0x92, 0x6c, 0x00, 0x00, + /* 'x' */ 7, 11, 0, 9, 8, + 0x00, 0x00, 0x42, 0x42, 0x24, 0x18, 0x24, 0x42, 0x42, 0x00, 0x00, + /* 'y' */ 7, 11, 0, 9, 8, + 0x00, 0x00, 0x42, 0x42, 0x42, 0x42, 0x42, 0x3e, 0x02, 0x02, 0x3c, + /* 'z' */ 7, 11, 0, 9, 8, + 0x00, 0x00, 0x7e, 0x04, 0x08, 0x10, 0x20, 0x40, 0x7e, 0x00, 0x00, + /* '{' */ 7, 11, 0, 9, 8, + 0x0c, 0x10, 0x10, 0x10, 0x60, 0x10, 0x10, 0x10, 0x0c, 0x00, 0x00, + /* '|' */ 7, 11, 0, 9, 8, + 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x00, 0x00, + /* '}' */ 7, 11, 0, 9, 8, + 0x30, 0x08, 0x08, 0x08, 0x06, 0x08, 0x08, 0x08, 0x30, 0x00, 0x00, + /* '~' */ 7, 11, 0, 9, 8, + 0x32, 0x4c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
-struct GP_Font GP_default_console_font = { - .family = "gfxprim", - .name = "console", - .author = "gfxprim authors", - .license = "GPL2", - .version = 1, +struct GP_FontFace GP_DefaultConsoleFont = { + .family_name = "gfxprim", + .style_name = "mono", .charset = GP_CHARSET_7BIT, - .height = 11, - .baseline = 2, - .bytes_per_line = 1, - .max_bounding_width = 8, - .data = GP_default_console_font_data, + .ascend = 9, + .descend = 2, + .max_glyph_width = 8, + .max_glyph_advance = 8, + .glyph_bitmap_format = GP_FONT_BITMAP_1BPP, + .glyphs = default_console_glyphs, + .glyph_offsets = {16}, };
-static uint8_t GP_default_proportional_font_data[] = { - /* ' ' */ 6, 0, 7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* '!' */ 4, 0, 6, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x20, 0x00, 0x00, - /* '"' */ 8, 0, 9, 0x24, 0x24, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* '#' */ 8, 0, 9, 0x00, 0x12, 0x12, 0x7f, 0x24, 0x24, 0xfe, 0x48, 0x48, 0x00, 0x00, - /* '$' */ 7, 0, 8, 0x10, 0x7c, 0x92, 0x90, 0x7c, 0x12, 0x92, 0x7c, 0x10, 0x00, 0x00, - /* '%' */ 7, 0, 8, 0x61, 0x92, 0x94, 0x68, 0x10, 0x2c, 0x52, 0x92, 0x0c, 0x00, 0x00, - /* '&' */ 7, 0, 8, 0x30, 0x48, 0x48, 0x30, 0x56, 0x88, 0x88, 0x88, 0x76, 0x00, 0x00, - /* ''' */ 4, 0, 5, 0x30, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* '(' */ 2, 1, 4, 0x40, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x40, 0x00, 0x00, - /* ')' */ 2, 1, 4, 0x80, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x80, 0x00, 0x00, - /* '*' */ 5, 0, 6, 0x00, 0x20, 0xa8, 0xa8, 0x70, 0xa8, 0xa8, 0x20, 0x00, 0x00, 0x00, - /* '+' */ 7, 0, 8, 0x00, 0x10, 0x10, 0x10, 0xfe, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, - /* ',' */ 4, 0, 6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x40, 0x00, - /* '-' */ 4, 0, 6, 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* '.' */ 4, 0, 6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, - /* '/' */ 5, 0, 6, 0x08, 0x08, 0x10, 0x10, 0x20, 0x40, 0x40, 0x80, 0x80, 0x00, 0x00, - /* '0' */ 6, 0, 7, 0x78, 0x84, 0x8c, 0x94, 0xb4, 0xa4, 0xc4, 0x84, 0x78, 0x00, 0x00, - /* '1' */ 6, 0, 7, 0x20, 0x60, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xf8, 0x00, 0x00, - /* '2' */ 6, 0, 7, 0x78, 0x84, 0x84, 0x04, 0x18, 0x60, 0x80, 0x80, 0xfc, 0x00, 0x00, - /* '3' */ 6, 0, 7, 0x78, 0x84, 0x84, 0x04, 0x18, 0x04, 0x84, 0x84, 0x78, 0x00, 0x00, - /* '4' */ 6, 0, 7, 0x18, 0x28, 0x48, 0x48, 0x88, 0xfc, 0x08, 0x08, 0x08, 0x00, 0x00, - /* '5' */ 6, 0, 7, 0xfc, 0x80, 0x80, 0xf8, 0x04, 0x04, 0x84, 0x84, 0x78, 0x00, 0x00, - /* '6' */ 6, 0, 7, 0x78, 0x80, 0x80, 0xf8, 0x84, 0x84, 0x84, 0x84, 0x78, 0x00, 0x00, - /* '7' */ 6, 0, 7, 0xfc, 0x04, 0x04, 0x08, 0x08, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, - /* '8' */ 6, 0, 7, 0x78, 0x84, 0x84, 0x84, 0x78, 0x84, 0x84, 0x84, 0x78, 0x00, 0x00, - /* '9' */ 6, 0, 7, 0x78, 0x84, 0x84, 0x84, 0x84, 0x7c, 0x04, 0x04, 0x78, 0x00, 0x00, - /* ':' */ 4, 0, 5, 0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, - /* ';' */ 4, 0, 5, 0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x60, 0x20, 0x40, 0x00, - /* '<' */ 4, 0, 6, 0x00, 0x10, 0x20, 0x40, 0x80, 0x40, 0x20, 0x10, 0x00, 0x00, 0x00, - /* '=' */ 5, 0, 6, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, - /* '>' */ 4, 0, 6, 0x00, 0x80, 0x40, 0x20, 0x10, 0x20, 0x40, 0x80, 0x00, 0x00, 0x00, - /* '?' */ 7, 0, 8, 0x7c, 0x82, 0x82, 0x02, 0x0c, 0x10, 0x10, 0x00, 0x10, 0x00, 0x00, - /* '@' */ 8, 0, 9, 0x3e, 0x41, 0x9d, 0xa5, 0xa5, 0xa5, 0x9e, 0x41, 0x3e, 0x00, 0x00, - /* 'A' */ 7, 0, 8, 0x7c, 0x82, 0x82, 0x82, 0xfe, 0x82, 0x82, 0x82, 0x82, 0x00, 0x00, - /* 'B' */ 7, 0, 8, 0xfc, 0x82, 0x82, 0x82, 0xfc, 0x82, 0x82, 0x82, 0xfc, 0x00, 0x00, - /* 'C' */ 7, 0, 8, 0x7c, 0x82, 0x80, 0x80, 0x80, 0x80, 0x80, 0x82, 0x7c, 0x00, 0x00, - /* 'D' */ 7, 0, 8, 0xf8, 0x84, 0x82, 0x82, 0x82, 0x82, 0x82, 0x84, 0xf8, 0x00, 0x00, - /* 'E' */ 7, 0, 8, 0xfe, 0x80, 0x80, 0x80, 0xfc, 0x80, 0x80, 0x80, 0xfe, 0x00, 0x00, - /* 'F' */ 7, 0, 8, 0xfe, 0x80, 0x80, 0x80, 0xf8, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, - /* 'G' */ 7, 0, 8, 0x7c, 0x82, 0x80, 0x80, 0x80, 0x9e, 0x82, 0x82, 0x7c, 0x00, 0x00, - /* 'H' */ 7, 0, 8, 0x82, 0x82, 0x82, 0x82, 0xfe, 0x82, 0x82, 0x82, 0x82, 0x00, 0x00, - /* 'I' */ 1, 0, 2, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, - /* 'J' */ 7, 0, 8, 0x7e, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x82, 0x7c, 0x00, 0x00, - /* 'K' */ 7, 0, 8, 0x82, 0x84, 0x88, 0x90, 0xe0, 0x90, 0x88, 0x84, 0x82, 0x00, 0x00, - /* 'L' */ 6, 0, 7, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xfc, 0x00, 0x00, - /* 'M' */ 7, 0, 8, 0x82, 0xc6, 0xaa, 0x92, 0x82, 0x82, 0x82, 0x82, 0x82, 0x00, 0x00, - /* 'N' */ 7, 0, 8, 0x82, 0xc2, 0xa2, 0xa2, 0x92, 0x8a, 0x8a, 0x86, 0x82, 0x00, 0x00, - /* 'O' */ 7, 0, 8, 0x7c, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x7c, 0x00, 0x00, - /* 'P' */ 7, 0, 8, 0xfc, 0x82, 0x82, 0x82, 0x82, 0xfc, 0x80, 0x80, 0x80, 0x00, 0x00, - /* 'Q' */ 7, 0, 8, 0x7c, 0x82, 0x82, 0x82, 0x82, 0x82, 0x9a, 0x84, 0x7a, 0x00, 0x00, - /* 'R' */ 7, 0, 8, 0xfc, 0x82, 0x82, 0x82, 0x82, 0xfc, 0x88, 0x84, 0x82, 0x00, 0x00, - /* 'S' */ 7, 0, 8, 0x7c, 0x82, 0x80, 0x80, 0x7c, 0x02, 0x02, 0x82, 0x7c, 0x00, 0x00, - /* 'T' */ 7, 0, 8, 0xfe, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, - /* 'U' */ 7, 0, 8, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x7c, 0x00, 0x00, - /* 'V' */ 7, 0, 8, 0x82, 0x82, 0x82, 0x44, 0x44, 0x28, 0x28, 0x10, 0x10, 0x00, 0x00, - /* 'W' */ 7, 0, 8, 0x82, 0x82, 0x82, 0x82, 0x92, 0x92, 0x92, 0xaa, 0x44, 0x00, 0x00, - /* 'X' */ 7, 0, 8, 0x82, 0x82, 0x44, 0x28, 0x10, 0x28, 0x44, 0x82, 0x82, 0x00, 0x00, - /* 'Y' */ 7, 0, 8, 0x82, 0x82, 0x44, 0x28, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, - /* 'Z' */ 7, 0, 8, 0xfe, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0xfe, 0x00, 0x00, - /* '[' */ 3, 0, 4, 0xe0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xe0, 0x00, 0x00, - /* '' */ 5, 0, 6, 0x80, 0x80, 0x40, 0x40, 0x20, 0x10, 0x10, 0x08, 0x08, 0x00, 0x00, - /* ']' */ 3, 0, 4, 0xe0, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xe0, 0x00, 0x00, - /* '^' */ 8, 0, 9, 0x08, 0x14, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* '_' */ 8, 0, 9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, - /* '`' */ 2, 0, 3, 0xc0, 0x40, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - /* 'a' */ 6, 0, 7, 0x00, 0x00, 0x78, 0x04, 0x04, 0x7c, 0x84, 0x84, 0x7c, 0x00, 0x00, - /* 'b' */ 6, 0, 7, 0x80, 0x80, 0xf8, 0x84, 0x84, 0x84, 0x84, 0x84, 0xf8, 0x00, 0x00, - /* 'c' */ 6, 0, 7, 0x00, 0x00, 0x78, 0x84, 0x80, 0x80, 0x80, 0x84, 0x78, 0x00, 0x00, - /* 'd' */ 6, 0, 7, 0x04, 0x04, 0x7c, 0x84, 0x84, 0x84, 0x84, 0x84, 0x7c, 0x00, 0x00, - /* 'e' */ 6, 0, 7, 0x00, 0x00, 0x78, 0x84, 0x84, 0xfc, 0x80, 0x80, 0x7c, 0x00, 0x00, - /* 'f' */ 6, 0, 7, 0x1e, 0x20, 0x20, 0xfc, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, - /* 'g' */ 6, 0, 7, 0x00, 0x00, 0x7c, 0x84, 0x84, 0x84, 0x84, 0x7c, 0x04, 0x04, 0x78, - /* 'h' */ 6, 0, 7, 0x80, 0x80, 0xf8, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x00, 0x00, - /* 'i' */ 2, 0, 4, 0x40, 0x00, 0xc0, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00, - /* 'j' */ 3, 0, 4, 0x20, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xc0, - /* 'k' */ 7, 0, 8, 0x40, 0x40, 0x42, 0x44, 0x48, 0x70, 0x48, 0x44, 0x42, 0x00, 0x00, - /* 'l' */ 4, 0, 5, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x30, 0x00, 0x00, - /* 'm' */ 7, 0, 8, 0x00, 0x00, 0xfc, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x00, 0x00, - /* 'n' */ 6, 0, 7, 0x00, 0x00, 0xf8, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x00, 0x00, - /* 'o' */ 6, 0, 7, 0x00, 0x00, 0x78, 0x84, 0x84, 0x84, 0x84, 0x84, 0x78, 0x00, 0x00, - /* 'p' */ 6, 0, 7, 0x00, 0x00, 0xf8, 0x84, 0x84, 0x84, 0x84, 0x84, 0xf8, 0x80, 0x80, - /* 'q' */ 6, 0, 7, 0x00, 0x00, 0x7c, 0x84, 0x84, 0x84, 0x84, 0x84, 0x7c, 0x04, 0x04, - /* 'r' */ 5, 0, 6, 0x00, 0x00, 0xb8, 0xc0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, - /* 's' */ 7, 0, 8, 0x00, 0x00, 0x7c, 0x80, 0x80, 0x7c, 0x02, 0x02, 0x7c, 0x00, 0x00, - /* 't' */ 6, 0, 7, 0x00, 0x20, 0xf8, 0x20, 0x20, 0x20, 0x20, 0x20, 0x1c, 0x00, 0x00, - /* 'u' */ 6, 0, 7, 0x00, 0x00, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x7c, 0x00, 0x00, - /* 'v' */ 6, 0, 7, 0x00, 0x00, 0x84, 0x84, 0x84, 0x48, 0x48, 0x48, 0x30, 0x00, 0x00, - /* 'w' */ 7, 0, 8, 0x00, 0x00, 0x82, 0x82, 0x92, 0x92, 0x92, 0x92, 0x6c, 0x00, 0x00, - /* 'x' */ 6, 0, 7, 0x00, 0x00, 0x84, 0x84, 0x48, 0x30, 0x48, 0x84, 0x84, 0x00, 0x00, - /* 'y' */ 6, 0, 7, 0x00, 0x00, 0x84, 0x84, 0x84, 0x84, 0x84, 0x7c, 0x04, 0x04, 0x78, - /* 'z' */ 6, 0, 7, 0x00, 0x00, 0xfc, 0x08, 0x10, 0x20, 0x40, 0x80, 0xfc, 0x00, 0x00, - /* '{' */ 5, 0, 6, 0x18, 0x20, 0x20, 0x20, 0xc0, 0x20, 0x20, 0x20, 0x18, 0x00, 0x00, - /* '|' */ 1, 0, 2, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, - /* '}' */ 5, 0, 6, 0xc0, 0x20, 0x20, 0x20, 0x18, 0x20, 0x20, 0x20, 0xc0, 0x00, 0x00, - /* '~' */ 6, 0, 7, 0x64, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, +static uint8_t default_proportional_glyphs[] = { + /* ' ' */ 6, 11, 0, 9, 7, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* '!' */ 4, 11, 0, 9, 6, + 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x20, 0x00, 0x00, + /* '"' */ 8, 11, 0, 9, 9, + 0x24, 0x24, 0x48, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* '#' */ 8, 11, 0, 9, 9, + 0x00, 0x12, 0x12, 0x7f, 0x24, 0x24, 0xfe, 0x48, 0x48, 0x00, 0x00, + /* '$' */ 7, 11, 0, 9, 8, + 0x10, 0x7c, 0x92, 0x90, 0x7c, 0x12, 0x92, 0x7c, 0x10, 0x00, 0x00, + /* '%' */ 7, 11, 0, 9, 8, + 0x61, 0x92, 0x94, 0x68, 0x10, 0x2c, 0x52, 0x92, 0x0c, 0x00, 0x00, + /* '&' */ 7, 11, 0, 9, 8, + 0x30, 0x48, 0x48, 0x30, 0x56, 0x88, 0x88, 0x88, 0x76, 0x00, 0x00, + /* ''' */ 4, 11, 0, 9, 5, + 0x30, 0x20, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* '(' */ 2, 11, 0, 9, 4, + 0x40, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x40, 0x00, + /* ')' */ 2, 11, 0, 9, 4, + 0x80, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x80, 0x00, + /* '*' */ 5, 11, 0, 9, 6, + 0x00, 0x20, 0xa8, 0xa8, 0x70, 0xa8, 0xa8, 0x20, 0x00, 0x00, 0x00, + /* '+' */ 7, 11, 0, 9, 8, + 0x00, 0x10, 0x10, 0x10, 0xfe, 0x10, 0x10, 0x10, 0x00, 0x00, 0x00, + /* ',' */ 4, 11, 0, 9, 6, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x20, 0x40, 0x00, + /* '-' */ 4, 11, 0, 9, 6, + 0x00, 0x00, 0x00, 0x00, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* '.' */ 4, 11, 0, 9, 6, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, + /* '/' */ 5, 11, 0, 9, 6, + 0x08, 0x08, 0x10, 0x10, 0x20, 0x40, 0x40, 0x80, 0x80, 0x00, 0x00, + /* '0' */ 6, 11, 0, 9, 7, + 0x78, 0x84, 0x8c, 0x94, 0xb4, 0xa4, 0xc4, 0x84, 0x78, 0x00, 0x00, + /* '1' */ 6, 11, 0, 9, 7, + 0x20, 0x60, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xf8, 0x00, 0x00, + /* '2' */ 6, 11, 0, 9, 7, + 0x78, 0x84, 0x84, 0x04, 0x18, 0x60, 0x80, 0x80, 0xfc, 0x00, 0x00, + /* '3' */ 6, 11, 0, 9, 7, + 0x78, 0x84, 0x84, 0x04, 0x18, 0x04, 0x84, 0x84, 0x78, 0x00, 0x00, + /* '4' */ 6, 11, 0, 9, 7, + 0x18, 0x28, 0x48, 0x48, 0x88, 0xfc, 0x08, 0x08, 0x08, 0x00, 0x00, + /* '5' */ 6, 11, 0, 9, 7, + 0xfc, 0x80, 0x80, 0xf8, 0x04, 0x04, 0x84, 0x84, 0x78, 0x00, 0x00, + /* '6' */ 6, 11, 0, 9, 7, + 0x78, 0x80, 0x80, 0xf8, 0x84, 0x84, 0x84, 0x84, 0x78, 0x00, 0x00, + /* '7' */ 6, 11, 0, 9, 7, + 0xfc, 0x04, 0x04, 0x08, 0x08, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, + /* '8' */ 6, 11, 0, 9, 7, + 0x78, 0x84, 0x84, 0x84, 0x78, 0x84, 0x84, 0x84, 0x78, 0x00, 0x00, + /* '9' */ 6, 11, 0, 9, 7, + 0x78, 0x84, 0x84, 0x84, 0x84, 0x7c, 0x04, 0x04, 0x78, 0x00, 0x00, + /* ':' */ 4, 11, 0, 9, 5, + 0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, + /* ';' */ 4, 11, 0, 9, 5, + 0x00, 0x00, 0x00, 0x60, 0x60, 0x00, 0x00, 0x60, 0x20, 0x40, 0x00, + /* '<' */ 4, 11, 0, 9, 6, + 0x00, 0x10, 0x20, 0x40, 0x80, 0x40, 0x20, 0x10, 0x00, 0x00, 0x00, + /* '=' */ 5, 11, 0, 9, 6, + 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0xfc, 0x00, 0x00, 0x00, 0x00, + /* '>' */ 4, 11, 0, 9, 6, + 0x00, 0x80, 0x40, 0x20, 0x10, 0x20, 0x40, 0x80, 0x00, 0x00, 0x00, + /* '?' */ 7, 11, 0, 9, 8, + 0x7c, 0x82, 0x82, 0x02, 0x0c, 0x10, 0x10, 0x00, 0x10, 0x00, 0x00, + /* '@' */ 8, 11, 0, 9, 9, + 0x3e, 0x41, 0x9d, 0xa5, 0xa5, 0xa5, 0x9e, 0x41, 0x3e, 0x00, 0x00, + /* 'A' */ 7, 11, 0, 9, 8, + 0x7c, 0x82, 0x82, 0x82, 0xfe, 0x82, 0x82, 0x82, 0x82, 0x00, 0x00, + /* 'B' */ 7, 11, 0, 9, 8, + 0xfc, 0x82, 0x82, 0x82, 0xfc, 0x82, 0x82, 0x82, 0xfc, 0x00, 0x00, + /* 'C' */ 7, 11, 0, 9, 8, + 0x7c, 0x82, 0x80, 0x80, 0x80, 0x80, 0x80, 0x82, 0x7c, 0x00, 0x00, + /* 'D' */ 7, 11, 0, 9, 8, + 0xf8, 0x84, 0x82, 0x82, 0x82, 0x82, 0x82, 0x84, 0xf8, 0x00, 0x00, + /* 'E' */ 7, 11, 0, 9, 8, + 0xfe, 0x80, 0x80, 0x80, 0xfc, 0x80, 0x80, 0x80, 0xfe, 0x00, 0x00, + /* 'F' */ 7, 11, 0, 9, 8, + 0xfe, 0x80, 0x80, 0x80, 0xf8, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, + /* 'G' */ 7, 11, 0, 9, 8, + 0x7c, 0x82, 0x80, 0x80, 0x80, 0x9e, 0x82, 0x82, 0x7c, 0x00, 0x00, + /* 'H' */ 7, 11, 0, 9, 8, + 0x82, 0x82, 0x82, 0x82, 0xfe, 0x82, 0x82, 0x82, 0x82, 0x00, 0x00, + /* 'I' */ 1, 11, 0, 9, 2, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, + /* 'J' */ 7, 11, 0, 9, 8, + 0x7e, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x82, 0x7c, 0x00, 0x00, + /* 'K' */ 7, 11, 0, 9, 8, + 0x82, 0x84, 0x88, 0x90, 0xe0, 0x90, 0x88, 0x84, 0x82, 0x00, 0x00, + /* 'L' */ 6, 11, 0, 9, 7, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xfc, 0x00, 0x00, + /* 'M' */ 7, 11, 0, 9, 8, + 0x82, 0xc6, 0xaa, 0x92, 0x82, 0x82, 0x82, 0x82, 0x82, 0x00, 0x00, + /* 'N' */ 7, 11, 0, 9, 8, + 0x82, 0xc2, 0xa2, 0xa2, 0x92, 0x8a, 0x8a, 0x86, 0x82, 0x00, 0x00, + /* 'O' */ 7, 11, 0, 9, 8, + 0x7c, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x7c, 0x00, 0x00, + /* 'P' */ 7, 11, 0, 9, 8, + 0xfc, 0x82, 0x82, 0x82, 0x82, 0xfc, 0x80, 0x80, 0x80, 0x00, 0x00, + /* 'Q' */ 7, 11, 0, 9, 8, + 0x7c, 0x82, 0x82, 0x82, 0x82, 0x82, 0x9a, 0x84, 0x7a, 0x00, 0x00, + /* 'R' */ 7, 11, 0, 9, 8, + 0xfc, 0x82, 0x82, 0x82, 0x82, 0xfc, 0x88, 0x84, 0x82, 0x00, 0x00, + /* 'S' */ 7, 11, 0, 9, 8, + 0x7c, 0x82, 0x80, 0x80, 0x7c, 0x02, 0x02, 0x82, 0x7c, 0x00, 0x00, + /* 'T' */ 7, 11, 0, 9, 8, + 0xfe, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, + /* 'U' */ 7, 11, 0, 9, 8, + 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x82, 0x7c, 0x00, 0x00, + /* 'V' */ 7, 11, 0, 9, 8, + 0x82, 0x82, 0x82, 0x44, 0x44, 0x28, 0x28, 0x10, 0x10, 0x00, 0x00, + /* 'W' */ 7, 11, 0, 9, 8, + 0x82, 0x82, 0x82, 0x82, 0x92, 0x92, 0x92, 0xaa, 0x44, 0x00, 0x00, + /* 'X' */ 7, 11, 0, 9, 8, + 0x82, 0x82, 0x44, 0x28, 0x10, 0x28, 0x44, 0x82, 0x82, 0x00, 0x00, + /* 'Y' */ 7, 11, 0, 9, 8, + 0x82, 0x82, 0x44, 0x28, 0x10, 0x10, 0x10, 0x10, 0x10, 0x00, 0x00, + /* 'Z' */ 7, 11, 0, 9, 8, + 0xfe, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0xfe, 0x00, 0x00, + /* '[' */ 3, 11, 0, 9, 4, + 0xe0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0xe0, 0x00, 0x00, + /* '' */ 5, 11, 0, 9, 6, + 0x80, 0x80, 0x40, 0x40, 0x20, 0x10, 0x10, 0x08, 0x08, 0x00, 0x00, + /* ']' */ 3, 11, 0, 9, 4, + 0xe0, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xe0, 0x00, 0x00, + /* '^' */ 8, 11, 0, 9, 9, + 0x08, 0x14, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* '_' */ 8, 11, 0, 9, 9, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, + /* '`' */ 2, 11, 0, 9, 3, + 0xc0, 0x40, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + /* 'a' */ 6, 11, 0, 9, 7, + 0x00, 0x00, 0x78, 0x04, 0x04, 0x7c, 0x84, 0x84, 0x7c, 0x00, 0x00, + /* 'b' */ 6, 11, 0, 9, 7, + 0x80, 0x80, 0xf8, 0x84, 0x84, 0x84, 0x84, 0x84, 0xf8, 0x00, 0x00, + /* 'c' */ 6, 11, 0, 9, 7, + 0x00, 0x00, 0x78, 0x84, 0x80, 0x80, 0x80, 0x84, 0x78, 0x00, 0x00, + /* 'd' */ 6, 11, 0, 9, 7, + 0x04, 0x04, 0x7c, 0x84, 0x84, 0x84, 0x84, 0x84, 0x7c, 0x00, 0x00, + /* 'e' */ 6, 11, 0, 9, 7, + 0x00, 0x00, 0x78, 0x84, 0x84, 0xfc, 0x80, 0x80, 0x7c, 0x00, 0x00, + /* 'f' */ 6, 11, 0, 9, 7, + 0x1e, 0x20, 0x20, 0xfc, 0x20, 0x20, 0x20, 0x20, 0x20, 0x00, 0x00, + /* 'g' */ 6, 11, 0, 9, 7, + 0x00, 0x00, 0x7c, 0x84, 0x84, 0x84, 0x84, 0x7c, 0x04, 0x04, 0x78, + /* 'h' */ 6, 11, 0, 9, 7, + 0x80, 0x80, 0xf8, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x00, 0x00, + /* 'i' */ 2, 11, 0, 9, 4, + 0x40, 0x00, 0xc0, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x00, 0x00, + /* 'j' */ 3, 11, 0, 9, 4, + 0x20, 0x00, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0xc0, + /* 'k' */ 7, 11, 0, 9, 8, + 0x40, 0x40, 0x42, 0x44, 0x48, 0x70, 0x48, 0x44, 0x42, 0x00, 0x00, + /* 'l' */ 4, 11, 0, 9, 5, + 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x30, 0x00, 0x00, + /* 'm' */ 7, 11, 0, 9, 8, + 0x00, 0x00, 0xfc, 0x92, 0x92, 0x92, 0x92, 0x92, 0x92, 0x00, 0x00, + /* 'n' */ 6, 11, 0, 9, 7, + 0x00, 0x00, 0xf8, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x00, 0x00, + /* 'o' */ 6, 11, 0, 9, 7, + 0x00, 0x00, 0x78, 0x84, 0x84, 0x84, 0x84, 0x84, 0x78, 0x00, 0x00, + /* 'p' */ 6, 11, 0, 9, 7, + 0x00, 0x00, 0xf8, 0x84, 0x84, 0x84, 0x84, 0x84, 0xf8, 0x80, 0x80, + /* 'q' */ 6, 11, 0, 9, 7, + 0x00, 0x00, 0x7c, 0x84, 0x84, 0x84, 0x84, 0x84, 0x7c, 0x04, 0x04, + /* 'r' */ 5, 11, 0, 9, 6, + 0x00, 0x00, 0xb8, 0xc0, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, + /* 's' */ 7, 11, 0, 9, 8, + 0x00, 0x00, 0x7c, 0x80, 0x80, 0x7c, 0x02, 0x02, 0x7c, 0x00, 0x00, + /* 't' */ 6, 11, 0, 9, 7, + 0x00, 0x20, 0xf8, 0x20, 0x20, 0x20, 0x20, 0x20, 0x1c, 0x00, 0x00, + /* 'u' */ 6, 11, 0, 9, 7, + 0x00, 0x00, 0x84, 0x84, 0x84, 0x84, 0x84, 0x84, 0x7c, 0x00, 0x00, + /* 'v' */ 6, 11, 0, 9, 7, + 0x00, 0x00, 0x84, 0x84, 0x84, 0x48, 0x48, 0x48, 0x30, 0x00, 0x00, + /* 'w' */ 7, 11, 0, 9, 8, + 0x00, 0x00, 0x82, 0x82, 0x92, 0x92, 0x92, 0x92, 0x6c, 0x00, 0x00, + /* 'x' */ 6, 11, 0, 9, 7, + 0x00, 0x00, 0x84, 0x84, 0x48, 0x30, 0x48, 0x84, 0x84, 0x00, 0x00, + /* 'y' */ 6, 11, 0, 9, 7, + 0x00, 0x00, 0x84, 0x84, 0x84, 0x84, 0x84, 0x7c, 0x04, 0x04, 0x78, + /* 'z' */ 6, 11, 0, 9, 7, + 0x00, 0x00, 0xfc, 0x08, 0x10, 0x20, 0x40, 0x80, 0xfc, 0x00, 0x00, + /* '{' */ 5, 11, 0, 9, 6, + 0x18, 0x20, 0x20, 0x20, 0xc0, 0x20, 0x20, 0x20, 0x18, 0x00, 0x00, + /* '|' */ 1, 11, 0, 9, 2, + 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x00, 0x00, + /* '}' */ 5, 11, 0, 9, 6, + 0xc0, 0x20, 0x20, 0x20, 0x18, 0x20, 0x20, 0x20, 0xc0, 0x00, 0x00, + /* '~' */ 6, 11, 0, 9, 7, + 0x64, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, };
-struct GP_Font GP_default_proportional_font = { - .family = "gfxprim", - .name = "proportional", - .author = "gfxprim authors", - .license = "GPL2", - .version = 1, +struct GP_FontFace GP_DefaultProportionalFont = { + .family_name = "gfxprim", + .style_name = "proportional", .charset = GP_CHARSET_7BIT, - .height = 11, - .baseline = 2, - .bytes_per_line = 1, - .max_bounding_width = 9, - .data = GP_default_proportional_font_data, + .ascend = 9, + .descend = 2, + .max_glyph_width = 9, + .max_glyph_advance = 9, + .glyph_bitmap_format = GP_FONT_BITMAP_1BPP, + .glyphs = default_proportional_glyphs, + .glyph_offsets = {16}, }; - diff --git a/libs/text/GP_Font.c b/libs/text/GP_Font.c index b3b8681..a4439f9 100644 --- a/libs/text/GP_Font.c +++ b/libs/text/GP_Font.c @@ -16,199 +16,47 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * - * jiri.bluebear.dluhos@gmail.com * - * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
+#include "core/GP_GetPutPixel.h" +#include "core/GP_MixPixels.gen.h" #include "GP_Font.h" -#include "core/GP_Common.h"
-#include <stdio.h> +#include "GP_DefaultFont.h"
-unsigned int GP_GetCharDataSize(const GP_Font *font) +uint32_t GP_GetGlyphCount(GP_CharSet charset) { - GP_CHECK(font, "NULL font specified"); - - return sizeof(GP_CharData) + font->bytes_per_line * font->height; + switch (charset) { + case GP_CHARSET_7BIT: + return 0x7f - 0x20 + 1; + break; + default: + return 0; + } }
-const GP_CharData *GP_GetCharData(const GP_Font *font, int c) +GP_GlyphBitmap *GP_GetGlyphBitmap(const GP_FontFace *font, int c) { - GP_CHECK(font, "NULL font specified"); + int i;
- /* characters before space are not encoded */ switch (font->charset) { case GP_CHARSET_7BIT: if (c < 0x20 || c > 0x7f) return NULL; + i = c - ' '; break; default: return NULL; }
- int encoded_character = c - ' '; - - /* NOTE: The character header is placed directly in the byte stream - * of character data without any alignment. If this makes problems - * on any machine, we will have to introduce appropriate padding. - */ - return (GP_CharData *)(font->data + - GP_GetCharDataSize(font) * encoded_character); -} - -int GP_GetCharCount(unsigned int charset) -{ - switch (charset) { - case GP_CHARSET_7BIT: - return 96; - } - - GP_ABORT("Unrecognized font character set"); -} - -unsigned int GP_GetFontDataSize(const GP_Font *font) -{ - GP_CHECK(font, "NULL font specified"); - - return GP_GetCharCount(font->charset) * GP_GetCharDataSize(font); -} - -GP_RetCode GP_FontSave(const struct GP_Font *font, const char *filename) -{ - int retval; - - if (font == NULL || filename == NULL) - return GP_ENULLPTR; - - FILE *f; - - f = fopen(filename, "w"); - if (f == NULL) - return GP_EBADFILE; - - /* write file header */ - retval = fprintf(f, - "%snFORMAT_VERSION %d.%dnFAMILY %snNAME %snAUTHOR %sn" - "LICENSE %snVERSION %dnGEOMETRY %d %d %d %d %dn", - GP_FONT_MAGIC, - GP_FONT_FORMAT_VMAJOR, GP_FONT_FORMAT_VMINOR, - font->family, font->name, font->author, font->license, font->version, - font->charset, font->height, font->baseline, - font->bytes_per_line, font->max_bounding_width); - if (retval < 0) - goto io_error; - - /* write character data */ - unsigned int char_data_size = GP_GetFontDataSize(font); - retval = fwrite(font->data, char_data_size, 1, f); - if (retval != 1) - goto io_error; - - /* commit and close */ - if (fclose(f) != 0) - return GP_EBADFILE; - - return GP_ESUCCESS; - -io_error: - fclose(f); - return GP_EBADFILE; -} - -GP_RetCode GP_FontLoad(GP_Font **pfont, const char *filename) -{ - int retval; - int result = GP_EINVAL; - - if (pfont == NULL || filename == NULL) - return GP_ENULLPTR; - - GP_Font *font = malloc(sizeof(*font)); - if (font == NULL) - return GP_ENOMEM; - - FILE *f = fopen(filename, "r"); - - if (f == NULL) { - result = GP_ENOENT; - goto bad; - } - - /* check file magic and version */ - int format_vmajor, format_vminor; - retval = fscanf(f, GP_FONT_MAGIC "nFORMAT_VERSION %d.%d%*[n]", - &format_vmajor, &format_vminor); - if (retval != 2) { - fprintf(stderr, "gfxprim: error loading font: bad magic or versionn"); - result = GP_EBADFILE; - goto bad; - } - - /* read the header and fill the font metadata */ - retval = fscanf(f, "FAMILY %63[a-zA-Z0-9_ ]%*[n]" - "NAME %63[a-zA-Z0-9_ ]%*[n]" - "AUTHOR %63[a-zA-Z0-9_ ]%*[n]", - font->family, font->name, font->author); - if (retval != 3) { - fprintf(stderr, "gfxprim: error loading font: bad family, name, or authorn"); - result = GP_EBADFILE; - goto bad; - } - - retval = fscanf(f, "LICENSE %15s%*[n]" - "VERSION %u%*[n]", - font->license, &font->version); - if (retval != 2) { - if (retval == 0) - fprintf(stderr, "gfxprim: error loading font: bad license stringn"); - else - fprintf(stderr, "gfxprim: error loading font: bad version stringn"); - result = GP_EBADFILE; - goto bad; - } - - retval = fscanf(f, "GEOMETRY %hhu %hhu %hhu %hhu %hhu%*[n]", - &font->charset, &font->height, - &font->baseline, &font->bytes_per_line, - &font->max_bounding_width); - if (retval != 5) { - fprintf(stderr, "gfxprim: error loading font: bad geometry (item #%d)n", - retval); - result = GP_EBADFILE; - goto bad; - } - - /* allocate memory for character data */ - unsigned int char_data_size = GP_GetFontDataSize(font); - font->data = malloc(char_data_size); - if (font->data == NULL) { - fprintf(stderr, "gfxprim: error loading font: cannot allocate %u bytesn", - char_data_size); - result = GP_ENOMEM; - goto bad; - } - - /* load character data */ - retval = fread(font->data, char_data_size, 1, f); - if (retval != 1) { - fprintf(stderr, "gfxprim: error loading font: premature end of character datan"); - result = GP_EBADFILE; - goto bad; - } + uint16_t offset;
- fclose(f); - *pfont = font; - return GP_ESUCCESS; + if (font->glyph_offsets[0] == 0) + offset = font->glyph_offsets[i]; + else + offset = font->glyph_offsets[0] * i;
-bad: - if (f) - fclose(f); - if (font) { - free(font->data); - free(font); - } - return result; + return (GP_GlyphBitmap*)(font->glyphs + offset); } diff --git a/libs/text/GP_FreeType.c b/libs/text/GP_FreeType.c index 35b98e1..a041a45 100644 --- a/libs/text/GP_FreeType.c +++ b/libs/text/GP_FreeType.c @@ -24,14 +24,13 @@ #include FT_FREETYPE_H
#include "core/GP_Debug.h" -#include "GP_FreeType.h" +#include "GP_Font.h"
-GP_Font *GP_FontFreeTypeLoad(const char *path, uint32_t width, uint32_t height) +GP_FontFace *GP_FontFaceLoad(const char *path, uint32_t width, uint32_t height) { - int err; - FT_Library library; FT_Face face; + int err;
err = FT_Init_FreeType(&library);
@@ -63,33 +62,37 @@ GP_Font *GP_FontFreeTypeLoad(const char *path, uint32_t width, uint32_t height) return NULL; }
- GP_Font *font = malloc(sizeof(GP_Font)); + /* Allocate font face structure */ + unsigned int font_face_size;
+ font_face_size = sizeof(GP_FontFace) + + sizeof(uint16_t) * GP_GetGlyphCount(GP_CHARSET_7BIT); + + GP_FontFace *font = malloc(font_face_size); + if (font == NULL) { GP_DEBUG(1, "Malloc failed :("); goto err1; } - - strncpy(font->family, face->family_name, sizeof(font->family)); - font->family[GP_FONT_NAME_MAX] = '0'; - strncpy(font->name, face->style_name, sizeof(font->name)); - font->name[GP_FONT_NAME_MAX] = '0'; - strcpy(font->author, "Unknown"); - strcpy(font->license, "Unknown"); - + + /* Copy font metadata */ + strncpy(font->family_name, face->family_name, + sizeof(font->family_name)); + font->family_name[GP_FONT_NAME_MAX - 1] = '0'; + strncpy(font->style_name, face->style_name, + sizeof(font->style_name)); + font->style_name[GP_FONT_NAME_MAX - 1] = '0'; + + font->glyph_bitmap_format = GP_FONT_BITMAP_8BPP; font->charset = GP_CHARSET_7BIT; - font->version = 0; + font->ascend = face->ascender>>6; + font->descend = -(face->descender>>6);
+ /* Count glyph data size */ unsigned int i; - - font->height = 0; - font->bytes_per_line = 0; - font->max_bounding_width = 0; - font->baseline = 0; - - int32_t baseline = 0; + unsigned int glyph_table_size = 0;
- for (i = 0x21; i < 0x7f; i++) { + for (i = 0x20; i < 0x7f; i++) { FT_UInt glyph_idx = FT_Get_Char_Index(face, i); err = FT_Load_Glyph(face, glyph_idx, FT_LOAD_DEFAULT); @@ -99,7 +102,7 @@ GP_Font *GP_FontFreeTypeLoad(const char *path, uint32_t width, uint32_t height) goto err2; } - err = FT_Render_Glyph(face->glyph, FT_RENDER_MODE_MONO); + err = FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL);
if (err) { GP_DEBUG(1, "Failed to render glyph '%c'", i); @@ -114,74 +117,72 @@ GP_Font *GP_FontFreeTypeLoad(const char *path, uint32_t width, uint32_t height) GP_DEBUG(2, " bitmap top=%i left=%i", face->glyph->bitmap_top, face->glyph->bitmap_left);
- width = (face->glyph->metrics.width>>6); - - if (font->max_bounding_width < width) - font->max_bounding_width = width; - - if (font->bytes_per_line < bitmap->pitch) - font->bytes_per_line = bitmap->pitch; - - height = face->glyph->metrics.height>>6; - - if (font->height < height) - font->height = height; - - baseline = bitmap->rows - face->glyph->bitmap_top; - - if (font->baseline < baseline) - font->baseline = baseline; + /* count glyph table size and fill offset table */ + font->glyph_offsets[i - 0x20] = glyph_table_size; + glyph_table_size += sizeof(GP_GlyphBitmap) + + bitmap->rows * bitmap->pitch; }
- size_t font_data_size = GP_GetFontDataSize(font); - font->data = malloc(font_data_size); + GP_DEBUG(2, "Glyph table size %u bytes", glyph_table_size); + + font->glyphs = malloc(glyph_table_size);
- if (font->data == NULL) { + if (font->glyphs == NULL) { GP_DEBUG(1, "Malloc failed :("); goto err2; } - - memset(font->data, 0, font_data_size); - for (i = 0x21; i < 0x7f; i++) { + font->max_glyph_width = 0; + font->max_glyph_advance = 0; + + for (i = 0x20; i < 0x7f; i++) { FT_UInt glyph_idx = FT_Get_Char_Index(face, i); err = FT_Load_Glyph(face, glyph_idx, FT_LOAD_DEFAULT); + + GP_DEBUG(2, "Loading and rendering glyph '%c'", i);
if (err) { GP_DEBUG(1, "Failed to load glyph '%c'", i); - goto err2; + goto err3; } - err = FT_Render_Glyph(face->glyph, FT_RENDER_MODE_MONO); + err = FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL);
if (err) { GP_DEBUG(1, "Failed to render glyph '%c'", i); - goto err2; + goto err3; }
- FT_Bitmap *bitmap = &face->glyph->bitmap; + GP_GlyphBitmap *glyph_bitmap = GP_GetGlyphBitmap(font, i); + FT_GlyphSlot glyph = face->glyph; + + glyph_bitmap->width = glyph->bitmap.width; + glyph_bitmap->height = glyph->bitmap.rows; + glyph_bitmap->bearing_x = glyph->bitmap_left; + glyph_bitmap->bearing_y = glyph->bitmap_top; + glyph_bitmap->advance_x = (glyph->advance.x + 32)>>6; + + if (font->max_glyph_advance < glyph_bitmap->advance_x) + font->max_glyph_advance = glyph_bitmap->advance_x; + + if (font->max_glyph_width < glyph_bitmap->bearing_x + glyph_bitmap->width) + font->max_glyph_width = glyph_bitmap->bearing_x + glyph_bitmap->width;
- GP_CharData *char_data = (GP_CharData*)GP_GetCharData(font, i); - - char_data->pre_offset = face->glyph->bitmap_left; - char_data->post_offset = face->glyph->advance.x>>6; - - char_data->char_width = bitmap->width; - int x, y; - for (y = 0; y < bitmap->rows; y++) { - for (x = 0; x < bitmap->pitch; x++) { - uint8_t trans_y = y + font->height - font->baseline - face->glyph->bitmap_top; - uint8_t addr = font->bytes_per_line * trans_y + x; + for (y = 0; y < glyph_bitmap->height; y++) { + for (x = 0; x < glyph_bitmap->width; x++) { + uint8_t addr = glyph_bitmap->width * y + x;
- char_data->bitmap[addr] = bitmap->buffer[y*bitmap->pitch + x]; + glyph_bitmap->bitmap[addr] = glyph->bitmap.buffer[y * glyph->bitmap.pitch + x]; } } }
return font; +err3: + free(font->glyphs); err2: free(font); err1: diff --git a/libs/text/GP_Text.c b/libs/text/GP_Text.c index 56033d2..a5d5776 100644 --- a/libs/text/GP_Text.c +++ b/libs/text/GP_Text.c @@ -24,7 +24,6 @@ *****************************************************************************/
#include <stdarg.h> -#include "algo/Text.algo.h" #include "gfx/GP_Gfx.h" #include "core/GP_FnPerBpp.h" #include "core/GP_Debug.h" @@ -61,7 +60,7 @@ static int do_align(GP_Coord *topleft_x, GP_Coord *topleft_y, int align, *topleft_y = y - height/2; break; case GP_VALIGN_BASELINE: - *topleft_y = y - height + style->font->baseline; + // *topleft_y = y - height + style->font->baseline; break; case GP_VALIGN_BELOW: *topleft_y = y; @@ -74,44 +73,11 @@ static int do_align(GP_Coord *topleft_x, GP_Coord *topleft_y, int align, return 0; }
-/* Generate drawing functions for various bit depths. */ -GP_DEF_FILL_FN_PER_BPP(GP_Text_Raw, DEF_TEXT_FN) - -void GP_Text_Raw(GP_Context *context, const GP_TextStyle *style, - GP_Coord x, GP_Coord y, int align, - GP_Pixel fg_color, GP_Pixel bg_color, const char *str) -{ - (void) bg_color; - - GP_CHECK_CONTEXT(context); - - if (str == NULL) - return; - - if (style == NULL) - style = &GP_DefaultStyle; - - GP_CHECK_TEXT_STYLE(style); - - GP_Coord topleft_x, topleft_y; - GP_Size w = GP_TextWidth(style, str); - - GP_ASSERT(do_align(&topleft_x, &topleft_y, align, x, y, style, w) == 0, - "Invalid aligment flags"); - - GP_FN_PER_BPP_CONTEXT(GP_Text_Raw, context, context, style, - topleft_x, topleft_y, str, fg_color); -} - -DEF_TEXT_FN(GP_Text_internal, GP_Context *, GP_Pixel, GP_HLine) - void GP_Text(GP_Context *context, const GP_TextStyle *style, GP_Coord x, GP_Coord y, int align, GP_Pixel fg_color, GP_Pixel bg_color, const char *str) { - (void) bg_color; - GP_CHECK_CONTEXT(context);
if (str == NULL) @@ -120,15 +86,14 @@ void GP_Text(GP_Context *context, const GP_TextStyle *style, if (style == NULL) style = &GP_DefaultStyle; - GP_CHECK_TEXT_STYLE(style); - GP_Coord topleft_x, topleft_y; GP_Size w = GP_TextWidth(style, str);
GP_ASSERT(do_align(&topleft_x, &topleft_y, align, x, y, style, w) == 0, "Invalid aligment flags");
- GP_Text_internal(context, style, topleft_x, topleft_y, str, fg_color); + GP_Text_Raw(context, style, topleft_x, topleft_y, + fg_color, bg_color, str); }
diff --git a/libs/text/GP_Text.gen.c.t b/libs/text/GP_Text.gen.c.t new file mode 100644 index 0000000..b76b345 --- /dev/null +++ b/libs/text/GP_Text.gen.c.t @@ -0,0 +1,159 @@ +%% extends "base.c.t" + +{% block descr %}Text rendering rutines{% endblock %} + +%% block body + +#include "core/GP_GetPutPixel.h" +#include "core/GP_MixPixels.gen.h" +#include "gfx/GP_HLine.h" +#include "GP_TextStyle.h" +#include "GP_Font.h" + +#define WIDTH_TO_1BPP_BPP(width) ((width)/8 + ((width)%8 != 0)) + +%% for pt in pixeltypes +%% if not pt.is_unknown() + +static void text_draw_1BPP_{{ pt.name }}(GP_Context *context, GP_TextStyle *style, + GP_Coord x, GP_Coord y, + GP_Pixel fg, const char *str) +{ + const char *p; + + GP_Coord y0 = y; + + for (p = str; *p != '0'; p++) { + const GP_GlyphBitmap *glyph = GP_GetGlyphBitmap(style->font, *p); + + if (glyph == NULL) + glyph = GP_GetGlyphBitmap(style->font, ' '); + + int i, j, k; + + unsigned int x_mul = style->pixel_xmul + style->pixel_xspace; + unsigned int y_mul = style->pixel_ymul + style->pixel_yspace; + + unsigned int bpp = WIDTH_TO_1BPP_BPP(glyph->width); + + y = y0; + + for (j = 0; j < glyph->height; j++) { + for (i = 0; i < glyph->width; i++) { + uint8_t bit = (glyph->bitmap[i/8 + j * bpp]) & (0x80>>(i%8)); + + unsigned int x_start = x + (i + glyph->bearing_x) * x_mul; + + if (bit) + for (k = 0; k < style->pixel_ymul; k++) + GP_HLine(context, x_start, x_start + style->pixel_xmul - 1, + y - (glyph->bearing_y - style->font->ascend) * y_mul, fg); + } + + y += style->pixel_ymul + style->pixel_yspace; + } + + x += glyph->advance_x * x_mul + style->char_xspace; + } +} + +%% endif +%% endfor + +static void text_draw_1BPP(GP_Context *context, GP_TextStyle *style, int x, int y, + GP_Pixel fg, const char *str) +{ + switch (context->pixel_type) { +%% for pt in pixeltypes +%% if not pt.is_unknown() + case GP_PIXEL_{{ pt.name }}: + text_draw_1BPP_{{ pt.name }}(context, style, x, y, fg, str); + break; +%% endif +%% endfor + default: + GP_ABORT("Invalid context->pixel_type"); + } +} + +%% for pt in pixeltypes +%% if not pt.is_unknown() + +static void text_draw_8BPP_{{ pt.name }}(GP_Context *context, GP_TextStyle *style, + GP_Coord x, GP_Coord y, + GP_Pixel fg, GP_Pixel bg, const char *str) +{ + const char *p; + + GP_Coord y0 = y; + + for (p = str; *p != '0'; p++) { + const GP_GlyphBitmap *glyph = GP_GetGlyphBitmap(style->font, *p); + + if (glyph == NULL) + glyph = GP_GetGlyphBitmap(style->font, ' '); + + int i, j, k; + + unsigned int x_mul = style->pixel_xmul + style->pixel_xspace; + unsigned int y_mul = style->pixel_ymul + style->pixel_yspace; + + y = y0; + + for (j = 0; j < glyph->height; j++) { + for (i = 0; i < glyph->width; i++) { + uint8_t gray = glyph->bitmap[i + j * glyph->width]; + + unsigned int x_start = x + (i + glyph->bearing_x) * x_mul; + + for (k = 0; k < style->pixel_ymul; k++) + GP_HLine(context, x_start, x_start + style->pixel_xmul - 1, + y - (glyph->bearing_y - style->font->ascend) * y_mul, + GP_MIX_PIXELS_{{ pt.name }}(fg, bg, gray)); + } + + y += style->pixel_ymul + style->pixel_yspace; + } + + x += glyph->advance_x * x_mul + style->char_xspace; + } +} + +%% endif +%% endfor + +static void text_draw_8BPP(GP_Context *context, GP_TextStyle *style, + GP_Coord x, GP_Coord y, + GP_Pixel fg, GP_Pixel bg, const char *str) +{ + switch (context->pixel_type) { +%% for pt in pixeltypes +%% if not pt.is_unknown() + case GP_PIXEL_{{ pt.name }}: + text_draw_8BPP_{{ pt.name }}(context, style, x, y, fg, bg, str); + break; +%% endif +%% endfor + default: + GP_ABORT("Invalid context->pixel_type"); + } +} + + +void GP_Text_Raw(GP_Context *context, GP_TextStyle *style, + GP_Coord x, GP_Coord y, + GP_Pixel fg, GP_Pixel bg, const char *str) +{ + switch (style->font->glyph_bitmap_format) { + case GP_FONT_BITMAP_1BPP: + text_draw_1BPP(context, style, x, y, fg, str); + break; + case GP_FONT_BITMAP_8BPP: + text_draw_8BPP(context, style, x, y, fg, bg, str); + break; + default: + GP_ABORT("Invalid font glyph bitmap format"); + } +} + +%% endblock body diff --git a/libs/text/GP_TextMetric.c b/libs/text/GP_TextMetric.c index d22acc9..ae746df 100644 --- a/libs/text/GP_TextMetric.c +++ b/libs/text/GP_TextMetric.c @@ -28,126 +28,155 @@
extern GP_TextStyle GP_DefaultStyle;
-static unsigned int SpaceWidth(const GP_TextStyle *style) +/* + * Returns glyph width from the basepoint to the end of the glyph bitmap. + */ +static unsigned int glyph_width(const GP_TextStyle *style, char ch) { - //TODO: Does space change with pixel_yspace? - return style->char_xspace * style->pixel_xmul; + unsigned int pixel_multiplier = style->pixel_xmul + style->pixel_xspace; + const GP_GlyphBitmap *glyph = GP_GetGlyphBitmap(style->font, ch); + + if (glyph == NULL) + glyph = GP_GetGlyphBitmap(style->font, ' '); + + return (glyph->width + glyph->bearing_x) * pixel_multiplier; }
-// FIXME: This is not quite right - due to offsets, characters -// can exceed their bounding box and then the reported width will be -// shorter than expected. -static unsigned int CharWidth(const GP_TextStyle *style, char ch) +/* + * Returns space that is added after the glyph. + * + * Eg. the advance minus glyph width. + * + * TODO: kerning + */ +static unsigned int glyph_space(const GP_TextStyle *style, char ch) { unsigned int pixel_multiplier = style->pixel_xmul + style->pixel_xspace; - const GP_CharData *data = GP_GetCharData(style->font, ch); + const GP_GlyphBitmap *glyph = GP_GetGlyphBitmap(style->font, ch); + + if (glyph == NULL) + glyph = GP_GetGlyphBitmap(style->font, ' '); + + return (glyph->advance_x - glyph->width - glyph->bearing_x) + * pixel_multiplier + style->char_xspace; +}
- if (data == NULL) - data = GP_GetCharData(style->font, ' '); +/* + * Returns maximal character width for a given string. + */ +static unsigned int max_glyph_width(const GP_TextStyle *style, const char *str) +{ + unsigned int max = 0, i; + + for (i = 0; str[i] != '0'; i++) + max = GP_MAX(max, glyph_width(style, str[i]));
- return data->pre_offset * pixel_multiplier - + data->post_offset * pixel_multiplier; + return max; }
-static unsigned int MaxCharsWidth(const GP_TextStyle *style, const char *str) +/* + * Return maximal character space after an glyph. + */ +static unsigned int max_glyph_space(const GP_TextStyle *style, const char *str) { unsigned int max = 0, i;
for (i = 0; str[i] != '0'; i++) - max = GP_MAX(max, CharWidth(style, str[i])); + max = GP_MAX(max, glyph_space(style, str[i]));
return max; }
unsigned int GP_TextWidth(const GP_TextStyle *style, const char *str) { - GP_CHECK(str, "NULL string specified"); - unsigned int i, len = 0; - unsigned int space;
if (style == NULL) style = &GP_DefaultStyle;
- space = SpaceWidth(style); - - if (str[0] == '0') + if (str == NULL || str[0] == '0') return 0;
- for (i = 0; str[i] != '0'; i++) - len += CharWidth(style, str[i]); + for (i = 0; str[i] != '0'; i++) { + len += glyph_width(style, str[i]); + + if (str[i+1] != '0') + len += glyph_space(style, str[i]); + }
- return len + (i - 1) * space; + return len; }
-unsigned int GP_TextMaxWidth(const GP_TextStyle *style, unsigned int len) +GP_Size GP_TextMaxWidth(const GP_TextStyle *style, unsigned int len) { - unsigned int space_width = SpaceWidth(style); - unsigned int char_width; - + unsigned int glyph_width; + //TODO: ! + unsigned int space_width = style->char_xspace; + if (style == NULL) style = &GP_DefaultStyle;
- char_width = style->font->max_bounding_width - * (style->pixel_xmul + style->pixel_xspace); + glyph_width = style->font->max_glyph_width + * (style->pixel_xmul + style->pixel_xspace);
if (len == 0) return 0;
- return len * char_width + (len - 1) * space_width; + return len * glyph_width + (len - 1) * space_width; }
-unsigned int GP_TextMaxStrWidth(const GP_TextStyle *style, const char *str, - unsigned int len) +GP_Size GP_TextMaxStrWidth(const GP_TextStyle *style, const char *str, + unsigned int len) { - GP_CHECK(str, "NULL string specified"); - unsigned int space_width; - unsigned int char_width; + unsigned int glyph_width; if (style == NULL) style = &GP_DefaultStyle; - space_width = SpaceWidth(style); + space_width = max_glyph_space(style, str); - if (len == 0) + if (len == 0 || str == NULL) return 0;
- char_width = MaxCharsWidth(style, str); + glyph_width = max_glyph_width(style, str);
- return len * char_width + (len - 1) * space_width; + return len * glyph_width + (len - 1) * space_width; }
-unsigned int GP_TextHeight(const GP_TextStyle *style) +GP_Size GP_TextHeight(const GP_TextStyle *style) { + unsigned int h; + if (style == NULL) style = &GP_DefaultStyle;
- return style->font->height * style->pixel_ymul + - (style->font->height - 1) * style->pixel_yspace; + h = style->font->ascend + style->font->descend; + + return h * style->pixel_ymul + + (h - 1) * style->pixel_yspace; }
-unsigned int GP_TextAscent(const GP_TextStyle *style) +GP_Size GP_TextAscent(const GP_TextStyle *style) { unsigned int h;
if (style == NULL) style = &GP_DefaultStyle;
- h = style->font->height - style->font->baseline; + h = style->font->ascend; return h * style->pixel_ymul + (h - 1) * style->pixel_yspace; }
-unsigned int GP_TextDescent(const GP_TextStyle *style) +GP_Size GP_TextDescent(const GP_TextStyle *style) { unsigned int h; if (style == NULL) style = &GP_DefaultStyle;
- h = style->font->baseline; + h = style->font->descend; return h * style->pixel_ymul + (h - 1) * style->pixel_yspace; } - diff --git a/libs/text/GP_TextStyle.c b/libs/text/GP_TextStyle.c index 4d4d4bd..1622375 100644 --- a/libs/text/GP_TextStyle.c +++ b/libs/text/GP_TextStyle.c @@ -19,7 +19,7 @@ * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * * jiri.bluebear.dluhos@gmail.com * * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2011 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -27,7 +27,7 @@
void GP_DefaultTextStyle(GP_TextStyle *style) { - style->font = &GP_default_console_font; + style->font = &GP_DefaultConsoleFont; style->pixel_xspace = 0; style->pixel_yspace = 0; style->pixel_xmul = 1; diff --git a/libs/text/Makefile b/libs/text/Makefile index 448c8fb..d58db9a 100644 --- a/libs/text/Makefile +++ b/libs/text/Makefile @@ -1,7 +1,9 @@ TOPDIR=../.. -CSOURCES=$(shell ls *.c) +GENSOURCES=GP_Text.gen.c +CSOURCES=$(filter-out $(wildcard *.gen.c),$(wildcard *.c)) LIBNAME=text
+include $(TOPDIR)/gen.mk include $(TOPDIR)/include.mk include $(TOPDIR)/lib.mk
diff --git a/libs/text/algo/Text.algo.h b/libs/text/algo/Text.algo.h deleted file mode 100644 index f9f12de..0000000 --- a/libs/text/algo/Text.algo.h +++ /dev/null @@ -1,83 +0,0 @@ -/***************************************************************************** - * This file is part of gfxprim library. * - * * - * Gfxprim is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Lesser General Public * - * License as published by the Free Software Foundation; either * - * version 2.1 of the License, or (at your option) any later version. * - * * - * Gfxprim is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * - * Lesser General Public License for more details. * - * * - * You should have received a copy of the GNU Lesser General Public * - * License along with gfxprim; if not, write to the Free Software * - * Foundation, Inc., 51 Franklin Street, Fifth Floor, * - * Boston, MA 02110-1301 USA * - * * - * Copyright (C) 2009-2010 Jiri "BlueBear" Dluhos * - * jiri.bluebear.dluhos@gmail.com * - * * - * Copyright (C) 2009-2010 Cyril Hrubis metan@ucw.cz * - * * - *****************************************************************************/ - -/* - * A bitmap text drawing algorithm. - */ - -#define DEF_TEXT_FN(FN_NAME, CONTEXT_T, PIXVAL_T, HLINE) -void FN_NAME(CONTEXT_T context, const GP_TextStyle *style, int x, int y, - const char *str, PIXVAL_T pixval) -{ - /* Remember the original starting height. */ - int y0 = y; -- const char *p; - for (p = str; *p != '0'; p++) { -- /* Calculate the address of the character data. */ - const GP_CharData *data = GP_GetCharData(style->font, *p); - if (data == NULL) { -- /* unencoded character */ - data = GP_GetCharData(style->font, ' '); - } -- /* Starting and final X for each character line. */ - int x0 = x + data->pre_offset * (style->pixel_xmul + style->pixel_xspace); - int x1 = x0 + data->char_width * (style->pixel_xmul + style->pixel_xspace); -- /* Draw the character line by line. */ - const uint8_t *src = data->bitmap; - int line, linerep; - for (line = 0, y = y0; line < style->font->height; line++, y += style->pixel_yspace) { -- /* repeat the line as specified by pixel_ymul */ - for (linerep = 0; lin erep < style->pixel_ymul; linerep++, y++) { - uint8_t const * linesrc = src + line * style->font->bytes_per_line; - uint8_t mask = 0x80; -- /* draw the line of the character bitmap */ - for (x = x0; x < x1; x += style->pixel_xmul + style->pixel_xspace) { - if (*linesrc & mask) { - HLINE(context, - x, x + style->pixel_xmul - 1, - y, pixval); - } - mask >>= 1; - if (mask == 0) { - linesrc++; - mask = 0x80; - } - } - } - } -- /* Update the X position. */ - x = x0 + data->post_offset * (style->pixel_xmul + style->pixel_xspace); - x += style->char_xspace * style->pixel_xmul; /* optional extra spacing */ - } -} - diff --git a/tests/SDL/fileview.c b/tests/SDL/fileview.c index 1899da9..db23a72 100644 --- a/tests/SDL/fileview.c +++ b/tests/SDL/fileview.c @@ -30,26 +30,20 @@ #include "GP.h" #include "GP_SDL.h"
-/* the display */ SDL_Surface *display = NULL; GP_Context context;
-/* precomputed color pixels in display format */ static GP_Pixel white_pixel, gray_pixel, dark_gray_pixel, black_pixel, red_pixel, blue_pixel;
-/* draw using proportional font? */ static int font_flag = 0; - -/* font tracking */ static int tracking = 0;
-/* font to be used */ -GP_Font *font; +static GP_FontFace *font;
struct FileLine { - char *text; /* null-terminated, malloc'd string */ - struct FileLine *next; /* next line or NULL for the last line */ + char *text; + struct FileLine *next; struct FileLine *prev; };
@@ -66,10 +60,10 @@ void redraw_screen(void)
switch (font_flag) { case 0: - style.font = &GP_default_console_font; + style.font = &GP_DefaultConsoleFont; break; case 1: - style.font = &GP_default_proportional_font; + style.font = &GP_DefaultProportionalFont; break; case 2: style.font = font; @@ -89,11 +83,11 @@ void redraw_screen(void)
struct FileLine *line = first_line; unsigned int i; - for (i = 0; i < 30; i++) { + for (i = 0; i < context.h/GP_TextHeight(&style); i++) { if (line == NULL) break; - GP_Text(&context, &style, 16, 16*i + 16, align, - black_pixel, black_pixel, line->text); + GP_Text(&context, &style, 16, 16 + (1.0 * GP_TextHeight(&style))*i, + align, black_pixel, gray_pixel, line->text); line = line->next; }
@@ -218,6 +212,10 @@ int main(int argc, char *argv[]) fprintf(stderr, "No file specifiedn"); return 1; } + + + if (argc > 2) + font = GP_FontFaceLoad(argv[2], 17, 23);
if (!read_file_head(argv[1])) return 1; diff --git a/tests/SDL/fonttest.c b/tests/SDL/fonttest.c index 4dd232c..fdcf622 100644 --- a/tests/SDL/fonttest.c +++ b/tests/SDL/fonttest.c @@ -30,11 +30,9 @@ #include "GP.h" #include "GP_SDL.h"
-/* the display */ SDL_Surface *display = NULL; GP_Context context;
-/* precomputed color pixels in display format */ static GP_Pixel white_pixel, gray_pixel, dark_gray_pixel, black_pixel, red_pixel, blue_pixel;
@@ -45,10 +43,57 @@ static const char *test_strings[] = { "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor..." };
-/* draw using proportional font? */ static int font_flag = 0; static int tracking = 0; -GP_Font *font; +GP_FontFace *font = NULL; + +static const char *glyph_bitmap_format_name(const GP_FontBitmapFormat format) +{ + switch (format) { + case GP_FONT_BITMAP_1BPP: + return "1BPP"; + break; + case GP_FONT_BITMAP_8BPP: + return "8BPP"; + break; + default: + return "Unknown"; + } +} + +static void print_character_metadata(const GP_FontFace *font, int c) +{ + const GP_GlyphBitmap *glyph = GP_GetGlyphBitmap(font, c); + fprintf(stderr, "Properties of the character '%c':n", c); + + if (glyph) { + fprintf(stderr, " bitmap width: %d, height: %dn", + glyph->width, glyph->height); + fprintf(stderr, " bearing_x: %d bearing_y %dn", + glyph->bearing_x, glyph->bearing_y); + fprintf(stderr, " advance_x: %dn", + glyph->advance_x); + } else { + fprintf(stderr, "(null)n"); + } +} + +static void print_font_properties(const GP_FontFace *font) +{ + fprintf(stderr, "Font properties:n"); + fprintf(stderr, " Height: ascend: %d, descend: %dn", + GP_FontAscend(font), GP_FontDescend(font)); + fprintf(stderr, " Glyph bitmap format: %sn", + glyph_bitmap_format_name(font->glyph_bitmap_format)); + fprintf(stderr, " Bounding box width: %d, heigth: %dn", + GP_FontMaxWidth(font), GP_FontHeight(font)); + + print_character_metadata(font, 'a'); + print_character_metadata(font, 'm'); + print_character_metadata(font, '0'); +} + +#define SPACING 120
void redraw_screen(void) { @@ -60,16 +105,18 @@ void redraw_screen(void)
switch (font_flag) { case 0: - style.font = &GP_default_proportional_font; + style.font = &GP_DefaultProportionalFont; break; case 1: - style.font = &GP_default_console_font; + style.font = &GP_DefaultConsoleFont; break; case 2: style.font = font; break; }
+ print_font_properties(style.font); + /* Text alignment (we are always drawing to the right * and below the starting point). */ @@ -87,25 +134,25 @@ void redraw_screen(void) style.char_xspace = tracking;
GP_FillRectXYWH(&context, - 16, 100*i + 16, + 16, SPACING*i + 16, GP_TextWidth(&style, test_string), - style.font->height, + GP_FontHeight(style.font), red_pixel);
GP_RectXYWH(&context, - 15, 100*i + 15, + 15, SPACING*i + 15, GP_TextMaxWidth(&style, strlen(test_string)) + 1, - style.font->height + 1, + GP_FontHeight(style.font) + 1, blue_pixel);
- GP_Text(&context, &style, 16, 100*i + 16, align, - white_pixel, black_pixel, test_string); - + GP_Text(&context, &style, 16, SPACING*i + 16, align, + white_pixel, red_pixel, test_string); + style.pixel_xmul = 2; style.pixel_ymul = 2; style.pixel_yspace = 1;
- GP_Text(&context, &style, 34, 100*i + 38, align, + GP_Text(&context, &style, 34, SPACING*i + 44, align, white_pixel, black_pixel, test_string);
style.pixel_xmul = 4; @@ -113,7 +160,7 @@ void redraw_screen(void) style.pixel_xspace = 1; style.pixel_yspace = 1;
- GP_Text(&context, &style, 64, 100*i + 72, align, + GP_Text(&context, &style, 64, SPACING*i + 88, align, dark_gray_pixel, black_pixel, test_string); }
@@ -174,20 +221,6 @@ void print_instructions(void) printf(" up/down ............. increase/decrease trackingn"); }
-void print_character_metadata(const GP_Font *font, int c) -{ - const GP_CharData *adata = GP_GetCharData(font, c); - fprintf(stderr, "Properties of the character '%c':n", c); - - if (adata) { - fprintf(stderr, " pre_offset: %d, post_offset: %dn", - adata->pre_offset, adata->post_offset); - fprintf(stderr, " width: %dn", adata->char_width); - } else { - fprintf(stderr, "(null)n"); - } -} - int main(int argc, char *argv[]) { print_instructions(); @@ -195,47 +228,23 @@ int main(int argc, char *argv[]) GP_SetDebugLevel(10);
if (argc > 1) { - GP_RetCode err; fprintf(stderr, "nLoading font '%s'n", argv[1]); - font = GP_FontFreeTypeLoad(argv[1], 17, 20); - - if (font == NULL) { - fprintf(stderr, "Error: %sn", GP_RetCodeName(err)); - return 1; - } - - fprintf(stderr, "Font properties:n"); - fprintf(stderr, " Height: total: %d total, baseline: %dn", - font->height, font->baseline); - fprintf(stderr, " Bytes per line: %dn", font->bytes_per_line); - fprintf(stderr, " Max bounding width: %dn", font->max_bounding_width); - - print_character_metadata(font, 'a'); - print_character_metadata(font, 'm'); - print_character_metadata(font, '0'); + font = GP_FontFaceLoad(argv[1], 13, 19); }
- /* Initialize SDL */ if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) { fprintf(stderr, "Could not initialize SDL: %sn", SDL_GetError()); return 1; }
- /* Create a window with a software back surface */ - display = SDL_SetVideoMode(640, 480, 0, SDL_SWSURFACE); + display = SDL_SetVideoMode(640, 500, 0, SDL_SWSURFACE); if (display == NULL) { fprintf(stderr, "Could not open display: %sn", SDL_GetError()); goto fail; }
- /* Set up a clipping rectangle to test proper clipping of pixels */ - SDL_Rect clip_rect = {10, 10, 620, 460}; - SDL_SetClipRect(display, &clip_rect); - - /* Initialize a GP context from the SDL display */ GP_SDL_ContextFromSurface(&context, display);
- /* Load colors suitable for the display */ white_pixel = GP_ColorToContextPixel(GP_COL_WHITE, &context); gray_pixel = GP_ColorToContextPixel(GP_COL_GRAY_LIGHT, &context); dark_gray_pixel = GP_ColorToContextPixel(GP_COL_GRAY_DARK, &context); diff --git a/tests/SDL/shapetest.c b/tests/SDL/shapetest.c index 9e40d33..0bbc4c4 100644 --- a/tests/SDL/shapetest.c +++ b/tests/SDL/shapetest.c @@ -230,7 +230,7 @@ void redraw_screen(void)
/* text style for the label */ GP_TextStyle style = { - .font = &GP_default_console_font, + .font = &GP_DefaultConsoleFont, .pixel_xmul = 2, .pixel_ymul = 1, .pixel_xspace = 0, diff --git a/tests/SDL/textaligntest.c b/tests/SDL/textaligntest.c index b6ac351..b3cead6 100644 --- a/tests/SDL/textaligntest.c +++ b/tests/SDL/textaligntest.c @@ -58,9 +58,9 @@ void redraw_screen(void) GP_TextStyle style = GP_DEFAULT_TEXT_STYLE;
if (flag_proportional) - style.font = &GP_default_proportional_font; + style.font = &GP_DefaultProportionalFont; else - style.font = &GP_default_console_font; + style.font = &GP_DefaultConsoleFont;
style.pixel_xspace = 4; style.pixel_yspace = 4;
-----------------------------------------------------------------------
Summary of changes: include/text/{GP_FreeType.h => GP_DefaultFont.h} | 12 +- include/text/GP_Font.h | 229 +++++---- include/text/GP_Text.h | 9 +- include/text/GP_TextStyle.h | 36 +- libs/text/GP_DefaultFont.c | 619 ++++++++++++++-------- libs/text/GP_Font.c | 194 +------ libs/text/GP_FreeType.c | 125 +++--- libs/text/GP_Text.c | 41 +-- libs/text/GP_Text.gen.c.t | 159 ++++++ libs/text/GP_TextMetric.c | 123 +++-- libs/text/GP_TextStyle.c | 4 +- libs/text/Makefile | 4 +- libs/text/algo/Text.algo.h | 83 --- tests/SDL/fileview.c | 26 +- tests/SDL/fonttest.c | 119 +++-- tests/SDL/shapetest.c | 2 +- tests/SDL/textaligntest.c | 4 +- 17 files changed, 964 insertions(+), 825 deletions(-) rename include/text/{GP_FreeType.h => GP_DefaultFont.h} (88%) create mode 100644 libs/text/GP_Text.gen.c.t delete mode 100644 libs/text/algo/Text.algo.h
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.