Gfxprim
Threads by month
- ----- 2026 -----
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- 929 discussions
[repo.or.cz] gfxprim.git branch master updated: 4d91a70e678339b10b0ed4b35ba9a18ccc84fa67
by metan 24 Dec '11
by metan 24 Dec '11
24 Dec '11
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 4d91a70e678339b10b0ed4b35ba9a18ccc84fa67 (commit)
from 584415285129a73670aa799560d765a94707850e (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/4d91a70e678339b10b0ed4b35ba9a18ccc84…
commit 4d91a70e678339b10b0ed4b35ba9a18ccc84fa67
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sat Dec 24 23:52:50 2011 +0100
Text: Fix FreeType font loading.
The font metadata are not correct
compute the text ascender and descender
from the glyphs while we load them.
diff --git a/libs/text/GP_FreeType.c b/libs/text/GP_FreeType.c
index a041a45..a66999a 100644
--- a/libs/text/GP_FreeType.c
+++ b/libs/text/GP_FreeType.c
@@ -85,8 +85,6 @@ GP_FontFace *GP_FontFaceLoad(const char *path, uint32_t width, uint32_t height)
font->glyph_bitmap_format = GP_FONT_BITMAP_8BPP;
font->charset = GP_CHARSET_7BIT;
- font->ascend = face->ascender>>6;
- font->descend = -(face->descender>>6);
/* Count glyph data size */
unsigned int i;
@@ -134,6 +132,8 @@ GP_FontFace *GP_FontFaceLoad(const char *path, uint32_t width, uint32_t height)
font->max_glyph_width = 0;
font->max_glyph_advance = 0;
+ font->ascend = 0;
+ font->descend = 0;
for (i = 0x20; i < 0x7f; i++) {
FT_UInt glyph_idx = FT_Get_Char_Index(face, i);
@@ -163,11 +163,21 @@ GP_FontFace *GP_FontFaceLoad(const char *path, uint32_t width, uint32_t height)
glyph_bitmap->bearing_y = glyph->bitmap_top;
glyph_bitmap->advance_x = (glyph->advance.x + 32)>>6;
+ int16_t width = glyph_bitmap->bearing_x + glyph_bitmap->width;
+ int16_t ascend = glyph_bitmap->bearing_y;
+ int16_t descend = glyph_bitmap->height - ascend;
+
+ if (font->ascend < ascend)
+ font->ascend = ascend;
+
+ if (font->descend < descend)
+ font->descend = descend;
+
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;
+ if (font->max_glyph_width < width)
+ font->max_glyph_width = width;
int x, y;
diff --git a/libs/text/GP_Text.gen.c.t b/libs/text/GP_Text.gen.c.t
index b76b345..286d3a7 100644
--- a/libs/text/GP_Text.gen.c.t
+++ b/libs/text/GP_Text.gen.c.t
@@ -44,10 +44,12 @@ static void text_draw_1BPP_{{ pt.name }}(GP_Context *context, GP_TextStyle *styl
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);
+ if (!bit)
+ continue;
+
+ 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;
@@ -105,6 +107,9 @@ static void text_draw_8BPP_{{ pt.name }}(GP_Context *context, GP_TextStyle *styl
uint8_t gray = glyph->bitmap[i + j * glyph->width];
unsigned int x_start = x + (i + glyph->bearing_x) * x_mul;
+
+ if (!gray)
+ continue;
for (k = 0; k < style->pixel_ymul; k++)
GP_HLine(context, x_start, x_start + style->pixel_xmul - 1,
diff --git a/tests/SDL/fileview.c b/tests/SDL/fileview.c
index db23a72..f468750 100644
--- a/tests/SDL/fileview.c
+++ b/tests/SDL/fileview.c
@@ -215,7 +215,7 @@ int main(int argc, char *argv[])
if (argc > 2)
- font = GP_FontFaceLoad(argv[2], 17, 23);
+ font = GP_FontFaceLoad(argv[2], 12, 17);
if (!read_file_head(argv[1]))
return 1;
diff --git a/tests/SDL/fonttest.c b/tests/SDL/fonttest.c
index fdcf622..ef1b39d 100644
--- a/tests/SDL/fonttest.c
+++ b/tests/SDL/fonttest.c
@@ -137,7 +137,7 @@ void redraw_screen(void)
16, SPACING*i + 16,
GP_TextWidth(&style, test_string),
GP_FontHeight(style.font),
- red_pixel);
+ dark_gray_pixel);
GP_RectXYWH(&context,
15, SPACING*i + 15,
@@ -146,7 +146,7 @@ void redraw_screen(void)
blue_pixel);
GP_Text(&context, &style, 16, SPACING*i + 16, align,
- white_pixel, red_pixel, test_string);
+ white_pixel, dark_gray_pixel, test_string);
style.pixel_xmul = 2;
style.pixel_ymul = 2;
@@ -229,7 +229,7 @@ int main(int argc, char *argv[])
if (argc > 1) {
fprintf(stderr, "nLoading font '%s'n", argv[1]);
- font = GP_FontFaceLoad(argv[1], 13, 19);
+ font = GP_FontFaceLoad(argv[1], 12, 16);
}
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER) != 0) {
diff --git a/tests/SDL/textaligntest.c b/tests/SDL/textaligntest.c
index b3cead6..26c3028 100644
--- a/tests/SDL/textaligntest.c
+++ b/tests/SDL/textaligntest.c
@@ -30,21 +30,19 @@
#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 black_pixel, red_pixel, yellow_pixel, green_pixel, blue_pixel,
darkgray_pixel;
-/* draw using proportional font? */
-static int flag_proportional = 0;
+static int font_flag = 0;
-/* center of the screen */
static int X = 640;
static int Y = 480;
+GP_FontFace *font = NULL;
+
void redraw_screen(void)
{
SDL_LockSurface(display);
@@ -57,19 +55,17 @@ void redraw_screen(void)
GP_TextStyle style = GP_DEFAULT_TEXT_STYLE;
- if (flag_proportional)
+ switch (font_flag) {
+ case 0:
style.font = &GP_DefaultProportionalFont;
- else
+ break;
+ case 1:
style.font = &GP_DefaultConsoleFont;
-
- style.pixel_xspace = 4;
- style.pixel_yspace = 4;
-
- //GP_BoxCenteredText(&context, &style, 0, 0, X, Y,
- // "Hello world!", darkgray_pixel);
-
- style.pixel_xspace = 0;
- style.pixel_yspace = 0;
+ break;
+ case 2:
+ style.font = font;
+ break;
+ }
GP_Text(&context, &style, X/2, Y/2, GP_ALIGN_LEFT|GP_VALIGN_BELOW,
yellow_pixel, black_pixel, "bottom left");
@@ -98,7 +94,15 @@ void event_loop(void)
case SDL_KEYDOWN:
switch (event.key.keysym.sym) {
case SDLK_SPACE:
- flag_proportional = !flag_proportional;
+ font_flag += 1;
+
+ if (font) {
+ if (font_flag >= 3)
+ font_flag = 0;
+ } else {
+ if (font_flag >= 2)
+ font_flag = 0;
+ }
break;
case SDLK_x:
context.x_swap = !context.x_swap;
@@ -134,15 +138,18 @@ void print_instructions(void)
printf(" R ................... reverse X and Yn");
}
-int main(void)
+int main(int argc, char *argv[])
{
- /* Initialize SDL */
+ GP_SetDebugLevel(10);
+
+ if (argc > 1)
+ font = GP_FontFaceLoad(argv[1], 12, 16);
+
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(X, Y, 0, SDL_SWSURFACE);
if (display == NULL) {
fprintf(stderr, "Could not open display: %sn", SDL_GetError());
@@ -151,14 +158,11 @@ int main(void)
print_instructions();
- /* Set up a clipping rectangle to test proper clipping of pixels */
SDL_Rect clip_rect = {10, 10, X-10, Y-10};
SDL_SetClipRect(display, &clip_rect);
- /* Initialize a GP context from the SDL display */
GP_SDL_ContextFromSurface(&context, display);
- /* Load colors suitable for the display */
black_pixel = GP_ColorToContextPixel(GP_COL_BLACK, &context);
red_pixel = GP_ColorToContextPixel(GP_COL_RED, &context);
blue_pixel = GP_ColorToContextPixel(GP_COL_BLUE, &context);
-----------------------------------------------------------------------
Summary of changes:
libs/text/GP_FreeType.c | 18 ++++++++++++---
libs/text/GP_Text.gen.c.t | 13 ++++++++---
tests/SDL/fileview.c | 2 +-
tests/SDL/fonttest.c | 6 ++--
tests/SDL/textaligntest.c | 50 ++++++++++++++++++++++++--------------------
5 files changed, 54 insertions(+), 35 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 584415285129a73670aa799560d765a94707850e
by metan 24 Dec '11
by metan 24 Dec '11
24 Dec '11
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/584415285129a73670aa799560d765a94707…
commit 584415285129a73670aa799560d765a94707850e
Author: Cyril Hrubis <metan(a)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(a)gmail.com> *
- * *
* Copyright (C) 2009-2011 Cyril Hrubis <metan(a)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(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)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(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)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(a)gmail.com> *
- * *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)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(a)gmail.com> *
* *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)ucw.cz> *
+ * Copyright (C) 2009-2011 Cyril Hrubis <metan(a)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(a)gmail.com> *
- * *
- * Copyright (C) 2009-2010 Cyril Hrubis <metan(a)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(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 9743963133809d6610a4986dbe1514e333e87589
by metan 13 Dec '11
by metan 13 Dec '11
13 Dec '11
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 9743963133809d6610a4986dbe1514e333e87589 (commit)
via d9e3b063bae380e838bf4ae99ddc5ca387b73877 (commit)
from 25e3933b27e047c26e4eefd3024d51bd44fca741 (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/9743963133809d6610a4986dbe1514e333e8…
commit 9743963133809d6610a4986dbe1514e333e87589
Merge: d9e3b06 25e3933
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Dec 13 20:35:44 2011 +0100
Merge ssh://repo.or.cz/srv/git/gfxprim
http://repo.or.cz/w/gfxprim.git/commit/d9e3b063bae380e838bf4ae99ddc5ca387b7…
commit d9e3b063bae380e838bf4ae99ddc5ca387b73877
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Tue Dec 13 18:39:46 2011 +0100
text: First badly hacked support for freetype.
* The text is rendered in 1bpp mode
and not really nice
* Changes to gfxprim font rendering
would be needed before we got
anything better.
diff --git a/configure b/configure
index 36b0418..bb7c7cb 100755
--- a/configure
+++ b/configure
@@ -167,7 +167,7 @@ if __name__ == '__main__':
[header_exists, "jpeglib.h"], "", "-ljpeg"],
["freetype",
"A high-quality and portable font engine",
- [header_exists, "ft2build.h"], "", ""]], cfg)
+ [header_exists, "ft2build.h"], "", "`freetype-config --libs`"]], cfg)
parser = OptionParser();
diff --git a/include/text/GP_FreeType.h b/include/text/GP_FreeType.h
new file mode 100644
index 0000000..954096f
--- /dev/null
+++ b/include/text/GP_FreeType.h
@@ -0,0 +1,30 @@
+/*****************************************************************************
+ * 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-2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#ifndef TEXT_GP_FREE_TYPE_H
+#define TEXT_GP_FREE_TYPE_H
+
+#include "GP_TextStyle.h"
+#include "GP_TextMetric.h"
+
+
+#endif /* TEXT_GP_FREE_TYPE_H */
diff --git a/libs/text/GP_Font.c b/libs/text/GP_Font.c
index 8778ce3..b3b8681 100644
--- a/libs/text/GP_Font.c
+++ b/libs/text/GP_Font.c
@@ -126,13 +126,12 @@ GP_RetCode GP_FontLoad(GP_Font **pfont, const char *filename)
if (pfont == NULL || filename == NULL)
return GP_ENULLPTR;
- /* allocate the font metadata structure */
- GP_Font *font = (GP_Font *) calloc(1, sizeof(*font));
+ GP_Font *font = malloc(sizeof(*font));
if (font == NULL)
return GP_ENOMEM;
- /* open the font file */
FILE *f = fopen(filename, "r");
+
if (f == NULL) {
result = GP_ENOENT;
goto bad;
diff --git a/libs/text/GP_FreeType.c b/libs/text/GP_FreeType.c
new file mode 100644
index 0000000..35b98e1
--- /dev/null
+++ b/libs/text/GP_FreeType.c
@@ -0,0 +1,190 @@
+/*****************************************************************************
+ * 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-2011 Cyril Hrubis <metan(a)ucw.cz> *
+ * *
+ *****************************************************************************/
+
+#include <ft2build.h>
+#include FT_FREETYPE_H
+
+#include "core/GP_Debug.h"
+#include "GP_FreeType.h"
+
+GP_Font *GP_FontFreeTypeLoad(const char *path, uint32_t width, uint32_t height)
+{
+ int err;
+
+ FT_Library library;
+ FT_Face face;
+
+ err = FT_Init_FreeType(&library);
+
+ if (err) {
+ GP_DEBUG(1, "Failed to initalize Free Type");
+ return NULL;
+ }
+
+ err = FT_New_Face(library, path, 0, &face);
+
+ if (err) {
+ //TODO: FT_Exit_FreeType() ?
+ GP_DEBUG(1, "Failed to open font '%s'", path);
+ return NULL;
+ }
+
+ GP_DEBUG(1, "Opened font '%s'", path);
+ GP_DEBUG(2, "Font family_name='%s' style_name='%s' num_glyphs=%li",
+ face->family_name, face->style_name,
+ (long)face->num_glyphs);
+ GP_DEBUG(2, "Font ascender=%i descender=%i height=%i",
+ (int)face->ascender, (int)face->descender, (int)face->height);
+
+ //TODO: not scalable fonts?
+ err = FT_Set_Pixel_Sizes(face, width, height);
+
+ if (err) {
+ GP_DEBUG(1, "Failed to set pixel size");
+ return NULL;
+ }
+
+ GP_Font *font = malloc(sizeof(GP_Font));
+
+ 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");
+
+ font->charset = GP_CHARSET_7BIT;
+ font->version = 0;
+
+ unsigned int i;
+
+ font->height = 0;
+ font->bytes_per_line = 0;
+ font->max_bounding_width = 0;
+ font->baseline = 0;
+
+ int32_t baseline = 0;
+
+ for (i = 0x21; i < 0x7f; i++) {
+ FT_UInt glyph_idx = FT_Get_Char_Index(face, i);
+
+ err = FT_Load_Glyph(face, glyph_idx, FT_LOAD_DEFAULT);
+
+ if (err) {
+ GP_DEBUG(1, "Failed to load glyph '%c'", i);
+ goto err2;
+ }
+
+ err = FT_Render_Glyph(face->glyph, FT_RENDER_MODE_MONO);
+
+ if (err) {
+ GP_DEBUG(1, "Failed to render glyph '%c'", i);
+ goto err2;
+ }
+
+ FT_Bitmap *bitmap = &face->glyph->bitmap;
+
+ GP_DEBUG(2, "Glyph '%c' bitmap rows=%i width=%i pitch=%i",
+ i, bitmap->rows, bitmap->width, bitmap->pitch);
+
+ 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;
+ }
+
+ size_t font_data_size = GP_GetFontDataSize(font);
+ font->data = malloc(font_data_size);
+
+ if (font->data == NULL) {
+ GP_DEBUG(1, "Malloc failed :(");
+ goto err2;
+ }
+
+ memset(font->data, 0, font_data_size);
+
+ for (i = 0x21; i < 0x7f; i++) {
+ FT_UInt glyph_idx = FT_Get_Char_Index(face, i);
+
+ err = FT_Load_Glyph(face, glyph_idx, FT_LOAD_DEFAULT);
+
+ if (err) {
+ GP_DEBUG(1, "Failed to load glyph '%c'", i);
+ goto err2;
+ }
+
+ err = FT_Render_Glyph(face->glyph, FT_RENDER_MODE_MONO);
+
+ if (err) {
+ GP_DEBUG(1, "Failed to render glyph '%c'", i);
+ goto err2;
+ }
+
+ FT_Bitmap *bitmap = &face->glyph->bitmap;
+
+ 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;
+
+ char_data->bitmap[addr] = bitmap->buffer[y*bitmap->pitch + x];
+ }
+ }
+ }
+
+ return font;
+err2:
+ free(font);
+err1:
+ //TODO FREETYPE CLEANUP
+ return NULL;
+}
diff --git a/libs/text/Makefile b/libs/text/Makefile
index 300ad6e..448c8fb 100644
--- a/libs/text/Makefile
+++ b/libs/text/Makefile
@@ -1,5 +1,9 @@
TOPDIR=../..
CSOURCES=$(shell ls *.c)
LIBNAME=text
+
include $(TOPDIR)/include.mk
include $(TOPDIR)/lib.mk
+
+GP_FreeType.dep: CFLAGS+=`freetype-config --cflags`
+GP_FreeType.o: CFLAGS+=`freetype-config --cflags`
diff --git a/pylib/templates/common.c.t b/pylib/templates/common.c.t
index b4af2f8..d3fcbd8 100644
--- a/pylib/templates/common.c.t
+++ b/pylib/templates/common.c.t
@@ -9,3 +9,8 @@
* Maybe opts, adds comma on the right side.
*/
{% macro maybe_opts_r(opts) %}{% if opts %}{{ opts }}, {% endif %}{% endmacro %}
+
+/*
+ * Converts channels to params
+ */
+{% macro expand_chanslist(chlist) %} {{ chlist[0][0] }}{% for i in chlist %}, {{ i[0] }}{% endfor %}{% endmacro %}
diff --git a/tests/SDL/fonttest.c b/tests/SDL/fonttest.c
index 4bfa945..4dd232c 100644
--- a/tests/SDL/fonttest.c
+++ b/tests/SDL/fonttest.c
@@ -197,9 +197,9 @@ int main(int argc, char *argv[])
if (argc > 1) {
GP_RetCode err;
fprintf(stderr, "nLoading font '%s'n", argv[1]);
- err = GP_FontLoad(&font, argv[1]);
+ font = GP_FontFreeTypeLoad(argv[1], 17, 20);
- if (err) {
+ if (font == NULL) {
fprintf(stderr, "Error: %sn", GP_RetCodeName(err));
return 1;
}
-----------------------------------------------------------------------
Summary of changes:
configure | 2 +-
.../histogram.h => include/text/GP_FreeType.h | 10 +-
libs/text/GP_Font.c | 5 +-
libs/text/GP_FreeType.c | 190 ++++++++++++++++++++
libs/text/Makefile | 4 +
pylib/templates/common.c.t | 5 +
tests/SDL/fonttest.c | 4 +-
7 files changed, 209 insertions(+), 11 deletions(-)
copy demos/grinder/histogram.h => include/text/GP_FreeType.h (91%)
create mode 100644 libs/text/GP_FreeType.c
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch generate updated: 1e00e08031c90d4f8d1b987d4908c9d2c938671a
by Kristen Eisenberg 13 Dec '11
by Kristen Eisenberg 13 Dec '11
13 Dec '11
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.
Kristen Eisenberg
Billige Flüge
Marketing GmbH
Emanuelstr. 3,
10317 Berlin
Deutschland
Telefon: +49 (33)
5310967
Email:
utebachmeier at
gmail.com
Site:
http://flug.airego.de
- Billige Flüge vergleichen
1
0
[repo.or.cz] gfxprim.git branch master updated: 25e3933b27e047c26e4eefd3024d51bd44fca741
by bluebear 12 Dec '11
by bluebear 12 Dec '11
12 Dec '11
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 25e3933b27e047c26e4eefd3024d51bd44fca741 (commit)
from 69614535beec61f64ac9b3d5c5016896d0a27beb (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/25e3933b27e047c26e4eefd3024d51bd44fc…
commit 25e3933b27e047c26e4eefd3024d51bd44fca741
Author: BlueBear <jiri.bluebear.dluhos(a)gmail.com>
Date: Mon Dec 12 00:34:17 2011 +0100
Simplified GP_ArcSegment() and extended it to two quadrants.
diff --git a/include/gfx/GP_Arc.h b/include/gfx/GP_Arc.h
index ed4147b..2989489 100644
--- a/include/gfx/GP_Arc.h
+++ b/include/gfx/GP_Arc.h
@@ -30,29 +30,13 @@
#include <math.h>
-/*
- * Bits for quadrant mask used with GP_ArcSegment().
- * Quadrants are ordered using the standard mathematical order, i.e.
- * the top right quadrant (where x > 0 and y < 0) is the first (#0),
- * then the top left, then the bottom left, and then the bottom right.
- */
-#define GP_QUADRANT_0 1
-#define GP_QUADRANT_1 2
-#define GP_QUADRANT_2 4
-#define GP_QUADRANT_3 8
-#define GP_QUADRANT_MINUSMINUS GP_QUADRANT_2
-#define GP_QUADRANT_PLUSMINUS GP_QUADRANT_0
-#define GP_QUADRANT_MINUSPLUS GP_QUADRANT_1
-#define GP_QUADRANT_PLUSPLUS GP_QUADRANT_3
-#define GP_QUADRANT_ALL 15
-
void GP_ArcSegment(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
- GP_Size a, GP_Size b, int quadrant_mask,
+ GP_Size a, GP_Size b, int direction,
double start, double end,
GP_Pixel pixel);
void GP_ArcSegment_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
- GP_Size a, GP_Size b, int quadrant_mask,
+ GP_Size a, GP_Size b, int direction,
double start, double end,
GP_Pixel pixel);
diff --git a/libs/gfx/GP_Arc.c b/libs/gfx/GP_Arc.c
index bd28a74..094497d 100644
--- a/libs/gfx/GP_Arc.c
+++ b/libs/gfx/GP_Arc.c
@@ -32,20 +32,19 @@
GP_DEF_DRAW_FN_PER_BPP(GP_ArcSegment_Raw, DEF_ARCSEGMENT_FN)
void GP_ArcSegment_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
- GP_Size a, GP_Size b, int quadrant_mask,
+ GP_Size a, GP_Size b, int direction,
double start, double end,
GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
GP_FN_PER_BPP_CONTEXT(GP_ArcSegment_Raw, context, context,
- xcenter, ycenter, a, b, quadrant_mask,
- start, end,
- pixel);
+ xcenter, ycenter, a, b, direction,
+ start, end, pixel);
}
void GP_ArcSegment(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
- GP_Size a, GP_Size b, int quadrant_mask,
+ GP_Size a, GP_Size b, int direction,
double start, double end,
GP_Pixel pixel)
{
@@ -55,7 +54,6 @@ void GP_ArcSegment(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_TRANSFORM_POINT(context, xcenter, ycenter);
GP_TRANSFORM_SWAP(context, a, b);
- GP_ArcSegment_Raw(context, xcenter, ycenter, a, b, quadrant_mask,
- start, end,
- pixel);
+ GP_ArcSegment_Raw(context, xcenter, ycenter, a, b, direction,
+ start, end, pixel);
}
diff --git a/libs/gfx/algo/Arc.algo.h b/libs/gfx/algo/Arc.algo.h
index 215fb77..fe94302 100644
--- a/libs/gfx/algo/Arc.algo.h
+++ b/libs/gfx/algo/Arc.algo.h
@@ -30,8 +30,13 @@
*/
/*
- * This macro defines a function that draws a single-quadrant
- * (optionally mirrored) segment of an arc.
+ * This macro defines a function that draws a segment of an arc within
+ * two horizontal quadrants. For a larger arc, two calls are needed.
+ *
+ * The 'direction' parameter specifies which two quadrants to work in:
+ * if <0, the top two quadrants (y < 0) are used, if >0, the bottom two
+ * (y > 0) are used.
+ *
* Arguments:
* CONTEXT_T - user-defined type of drawing context (passed to PUTPIXEL)
* PIXVAL_T - user-defined pixel value type (passed to PUTPIXEL)
@@ -40,19 +45,18 @@
*/
#define DEF_ARCSEGMENT_FN(FN_NAME, CONTEXT_T, PIXVAL_T, PUTPIXEL) void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, - unsigned int a, unsigned int b, int quadrant_mask, + unsigned int a, unsigned int b, int direction, double start, double end, PIXVAL_T pixval) { /* Precompute quadratic terms. */ int a2 = a*a; int b2 = b*b; - double phi_min = GP_MIN(start, end); - double phi_max = GP_MAX(start, end); - int xmin = (int)(cos(start)*a); - int ymin = (int)(sin(start)*b); - int xmax = (int)(cos(end)*a); - int ymax = (int)(sin(end)*b); + /* Compute minimum and maximum value of X from the angles. */ + int x1 = (int)(cos(start)*a); + int x2 = (int)(cos(end)*a); + int xmin = GP_MIN(x1, x2); + int xmax = GP_MAX(x1, x2); int x, y, error; for (x = 0, error = -b2*a, y = b; y >= 0; y--) { @@ -62,42 +66,42 @@ void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, error += 2*x*b2 + b2; x++; - if (quadrant_mask & GP_QUADRANT_MINUSMINUS && - (-x+1) >=
xmin && (-x+1) <= xmax) { - PUTPIXEL(context, xcenter-x+1, ycenter-y, pixval); - } - if (quadrant_mask & GP_QUADRANT_PLUSMINUS && - (x-1) >= xmin && (x-1) <= xmax) { - PUTPIXEL(context, xcenter+x-1, ycenter-y, pixval); - } - if (quadrant_mask & GP_QUADRANT_MINUSPLUS && - (-x+1) >= xmin && (-x+1) <= xmax) { - PUTPIXEL(context, xcenter-x+1, ycenter+y, pixval); + if (direction < 0) { + if ((-x+1) >= xmin && (-x+1) <= xmax) { + PUTPIXEL(context, xcenter-x+1, ycenter-y, pixval); + } + if ((x-1) >= xmin && (x-1) <= xmax) { + PUTPIXEL(context, xcenter+x-1, ycenter-y, pixval); + } } - if (quadrant_mask & GP_QUADRANT_PLUSPLUS && - (x-1) >= xmin && (x-1) <= xmax) { - PUTPIXEL(context, xcenter+x-1, ycenter+y, pixval); + if (direction > 0) { + if ((-x+1) >= xmin && (-x+1) <= xmax) { + PUTPIXEL(context, xcenter-x+1, ycenter+y, pixval); + } + if ((x-1) >= xmin && (x-1) <= xmax) { + PUTPIXEL(context, xcenter+x-1
, ycenter+y, pixval); + } } } /* Calculate error(y-1) from error(y). */ error += -2*y*a2 + a2; - if (quadrant_mask & GP_QUADRANT_MINUSMINUS && - (-x+1) >= xmin && (-x+1) <= xmax) { - PUTPIXEL(context, xcenter-x+1, ycenter-y, pixval); - } - if (quadrant_mask & GP_QUADRANT_PLUSMINUS && - (x-1) >= xmin && (x-1) <= xmax) { - PUTPIXEL(context, xcenter+x-1, ycenter-y, pixval); - } - if (quadrant_mask & GP_QUADRANT_MINUSPLUS && - (-x+1) >= xmin && (-x+1) <= xmax) { - PUTPIXEL(context, xcenter-x+1, ycenter+y, pixval); + if (direction < 0) { + if ((-x+1) >= xmin && (-x+1) <= xmax) { + PUTPIXEL(context, xcenter-x+1, ycenter-y, pixval); + } + if ((x-1) >= xmin && (x-1) <= xmax) { + PUTPIXEL(context, xcenter+x-1, ycenter-y, pixval); + } } - if (quadrant_mask & GP_QUADRANT_PLUSPLUS && - (x-1) >= xmin && (x-1) <= xmax) { - PUTPIXEL(context, xcenter+x-1, ycenter+y, pixval); + if (direction > 0) { + if ((-x+1) >= xmin && (-x+1
) <= xmax) { + PUTPIXEL(context, xcenter-x+1, ycenter+y, pixval); + } + if ((x-1) >= xmin && (x-1) <= xmax) { + PUTPIXEL(context, xcenter+x-1, ycenter+y, pixval); + } } } }
diff --git a/tests/SDL/shapetest.c b/tests/SDL/shapetest.c
index aebd83d..9e40d33 100644
--- a/tests/SDL/shapetest.c
+++ b/tests/SDL/shapetest.c
@@ -189,8 +189,8 @@ void draw_testing_ellipse(int x, int y, int xradius, int yradius)
void draw_testing_arc(int x, int y, int xradius, int yradius)
{
- GP_ArcSegment(&context, x, y, xradius, yradius, GP_QUADRANT_ALL,
- M_PI/3, 0, red);
+ GP_ArcSegment(&context, x, y, xradius, yradius, -1,
+ M_PI - M_PI/8.0, M_PI/4.0, red);
}
void draw_testing_rectangle(int x, int y, int xradius, int yradius)
-----------------------------------------------------------------------
Summary of changes:
include/gfx/GP_Arc.h | 20 +----------
libs/gfx/GP_Arc.c | 14 +++-----
libs/gfx/algo/Arc.algo.h | 78 ++++++++++++++++++++++++----------------------
tests/SDL/shapetest.c | 4 +-
4 files changed, 51 insertions(+), 65 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 69614535beec61f64ac9b3d5c5016896d0a27beb
by metan 11 Dec '11
by metan 11 Dec '11
11 Dec '11
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 69614535beec61f64ac9b3d5c5016896d0a27beb (commit)
from d05b5939892335e58f0f578928a89a05df78f2a0 (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/69614535beec61f64ac9b3d5c5016896d0a2…
commit 69614535beec61f64ac9b3d5c5016896d0a27beb
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Dec 11 21:20:50 2011 +0100
gfx: Fix megre.
diff --git a/include/gfx/GP_Gfx.h b/include/gfx/GP_Gfx.h
index ef5a77c..5e54131 100644
--- a/include/gfx/GP_Gfx.h
+++ b/include/gfx/GP_Gfx.h
@@ -46,7 +46,6 @@
#include "GP_Triangle.h"
#include "GP_Tetragon.h"
#include "GP_Circle.h"
-#include "GP_Arc.h"
#include "GP_Ellipse.h"
#include "GP_Arc.h"
#include "GP_Polygon.h"
-----------------------------------------------------------------------
Summary of changes:
include/gfx/GP_Gfx.h | 1 -
1 files changed, 0 insertions(+), 1 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: d05b5939892335e58f0f578928a89a05df78f2a0
by metan 11 Dec '11
by metan 11 Dec '11
11 Dec '11
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
discards a2ab269a2f82b1cb6e30c5b9afdddded7f307659 (commit)
This update discarded existing revisions and left the branch pointing at
a previous point in the repository history.
* -- * -- N (d05b5939892335e58f0f578928a89a05df78f2a0)
O -- O -- O (a2ab269a2f82b1cb6e30c5b9afdddded7f307659)
The removed revisions are not necessarilly gone - if another reference
still refers to them they will stay in the repository.
No new revisions were added by this update.
Summary of changes:
configure | 2 +-
include/gfx/GP_Gfx.h | 1 +
libs/text/GP_Font.c | 5 +++--
libs/text/Makefile | 4 ----
pylib/templates/common.c.t | 5 -----
tests/SDL/fonttest.c | 4 ++--
6 files changed, 7 insertions(+), 14 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: a2ab269a2f82b1cb6e30c5b9afdddded7f307659
by metan 11 Dec '11
by metan 11 Dec '11
11 Dec '11
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 a2ab269a2f82b1cb6e30c5b9afdddded7f307659 (commit)
from d05b5939892335e58f0f578928a89a05df78f2a0 (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/a2ab269a2f82b1cb6e30c5b9afdddded7f30…
commit a2ab269a2f82b1cb6e30c5b9afdddded7f307659
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Dec 11 21:05:35 2011 +0100
gfx: Fix merge.
diff --git a/configure b/configure
index 36b0418..bb7c7cb 100755
--- a/configure
+++ b/configure
@@ -167,7 +167,7 @@ if __name__ == '__main__':
[header_exists, "jpeglib.h"], "", "-ljpeg"],
["freetype",
"A high-quality and portable font engine",
- [header_exists, "ft2build.h"], "", ""]], cfg)
+ [header_exists, "ft2build.h"], "", "`freetype-config --libs`"]], cfg)
parser = OptionParser();
diff --git a/include/gfx/GP_Gfx.h b/include/gfx/GP_Gfx.h
index ef5a77c..3c36bf0 100644
--- a/include/gfx/GP_Gfx.h
+++ b/include/gfx/GP_Gfx.h
@@ -48,7 +48,6 @@
#include "GP_Circle.h"
#include "GP_Arc.h"
#include "GP_Ellipse.h"
-#include "GP_Arc.h"
#include "GP_Polygon.h"
#include "GP_Symbol.h"
diff --git a/libs/text/GP_Font.c b/libs/text/GP_Font.c
index 8778ce3..b3b8681 100644
--- a/libs/text/GP_Font.c
+++ b/libs/text/GP_Font.c
@@ -126,13 +126,12 @@ GP_RetCode GP_FontLoad(GP_Font **pfont, const char *filename)
if (pfont == NULL || filename == NULL)
return GP_ENULLPTR;
- /* allocate the font metadata structure */
- GP_Font *font = (GP_Font *) calloc(1, sizeof(*font));
+ GP_Font *font = malloc(sizeof(*font));
if (font == NULL)
return GP_ENOMEM;
- /* open the font file */
FILE *f = fopen(filename, "r");
+
if (f == NULL) {
result = GP_ENOENT;
goto bad;
diff --git a/libs/text/Makefile b/libs/text/Makefile
index 300ad6e..448c8fb 100644
--- a/libs/text/Makefile
+++ b/libs/text/Makefile
@@ -1,5 +1,9 @@
TOPDIR=../..
CSOURCES=$(shell ls *.c)
LIBNAME=text
+
include $(TOPDIR)/include.mk
include $(TOPDIR)/lib.mk
+
+GP_FreeType.dep: CFLAGS+=`freetype-config --cflags`
+GP_FreeType.o: CFLAGS+=`freetype-config --cflags`
diff --git a/pylib/templates/common.c.t b/pylib/templates/common.c.t
index b4af2f8..d3fcbd8 100644
--- a/pylib/templates/common.c.t
+++ b/pylib/templates/common.c.t
@@ -9,3 +9,8 @@
* Maybe opts, adds comma on the right side.
*/
{% macro maybe_opts_r(opts) %}{% if opts %}{{ opts }}, {% endif %}{% endmacro %}
+
+/*
+ * Converts channels to params
+ */
+{% macro expand_chanslist(chlist) %} {{ chlist[0][0] }}{% for i in chlist %}, {{ i[0] }}{% endfor %}{% endmacro %}
diff --git a/tests/SDL/fonttest.c b/tests/SDL/fonttest.c
index 4bfa945..feefc73 100644
--- a/tests/SDL/fonttest.c
+++ b/tests/SDL/fonttest.c
@@ -197,9 +197,9 @@ int main(int argc, char *argv[])
if (argc > 1) {
GP_RetCode err;
fprintf(stderr, "nLoading font '%s'n", argv[1]);
- err = GP_FontLoad(&font, argv[1]);
+ font = GP_FontFreeTypeLoad(argv[1], 20, 30);
- if (err) {
+ if (font == NULL) {
fprintf(stderr, "Error: %sn", GP_RetCodeName(err));
return 1;
}
-----------------------------------------------------------------------
Summary of changes:
configure | 2 +-
include/gfx/GP_Gfx.h | 1 -
libs/text/GP_Font.c | 5 ++---
libs/text/Makefile | 4 ++++
pylib/templates/common.c.t | 5 +++++
tests/SDL/fonttest.c | 4 ++--
6 files changed, 14 insertions(+), 7 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: d05b5939892335e58f0f578928a89a05df78f2a0
by bluebear 11 Dec '11
by bluebear 11 Dec '11
11 Dec '11
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 d05b5939892335e58f0f578928a89a05df78f2a0 (commit)
via 5f476be6ba4492daf8d71abb03656c7dcefec959 (commit)
from 91989ac6cef96d62797a104a2f99cca17f6151de (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/d05b5939892335e58f0f578928a89a05df78…
commit d05b5939892335e58f0f578928a89a05df78f2a0
Merge: 5f476be 91989ac
Author: BlueBear <jiri.bluebear.dluhos(a)gmail.com>
Date: Sun Dec 11 20:53:46 2011 +0100
Merge branch 'master' of git://repo.or.cz/gfxprim
diff --cc include/gfx/GP_Gfx.h
index 5e54131,3c36bf0..ef5a77c
--- a/include/gfx/GP_Gfx.h
+++ b/include/gfx/GP_Gfx.h
@@@ -46,8 -46,8 +46,9 @@@
#include "GP_Triangle.h"
#include "GP_Tetragon.h"
#include "GP_Circle.h"
+ #include "GP_Arc.h"
#include "GP_Ellipse.h"
+#include "GP_Arc.h"
#include "GP_Polygon.h"
#include "GP_Symbol.h"
http://repo.or.cz/w/gfxprim.git/commit/5f476be6ba4492daf8d71abb03656c7dcefe…
commit 5f476be6ba4492daf8d71abb03656c7dcefec959
Author: BlueBear <jiri.bluebear.dluhos(a)gmail.com>
Date: Sun Dec 11 20:52:11 2011 +0100
Arcs, version 2; still strange and doubtful.
diff --git a/include/gfx/GP_Arc.h b/include/gfx/GP_Arc.h
index dfec46e..ed4147b 100644
--- a/include/gfx/GP_Arc.h
+++ b/include/gfx/GP_Arc.h
@@ -28,21 +28,32 @@
#include "core/GP_Context.h"
-#define GP_QUADRANT_MINUSMINUS 1
-#define GP_QUADRANT_PLUSMINUS 2
-#define GP_QUADRANT_MINUSPLUS 4
-#define GP_QUADRANT_PLUSPLUS 8
+#include <math.h>
-void GP_Arc(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+/*
+ * Bits for quadrant mask used with GP_ArcSegment().
+ * Quadrants are ordered using the standard mathematical order, i.e.
+ * the top right quadrant (where x > 0 and y < 0) is the first (#0),
+ * then the top left, then the bottom left, and then the bottom right.
+ */
+#define GP_QUADRANT_0 1
+#define GP_QUADRANT_1 2
+#define GP_QUADRANT_2 4
+#define GP_QUADRANT_3 8
+#define GP_QUADRANT_MINUSMINUS GP_QUADRANT_2
+#define GP_QUADRANT_PLUSMINUS GP_QUADRANT_0
+#define GP_QUADRANT_MINUSPLUS GP_QUADRANT_1
+#define GP_QUADRANT_PLUSPLUS GP_QUADRANT_3
+#define GP_QUADRANT_ALL 15
+
+void GP_ArcSegment(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_Size a, GP_Size b, int quadrant_mask,
- int low_dx, int low_dy,
- int high_dx, int high_dy,
+ double start, double end,
GP_Pixel pixel);
-void GP_Arc_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+void GP_ArcSegment_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_Size a, GP_Size b, int quadrant_mask,
- int low_dx, int low_dy,
- int high_dx, int high_dy,
+ double start, double end,
GP_Pixel pixel);
#endif /* GP_ARC_H */
diff --git a/include/gfx/GP_Gfx.h b/include/gfx/GP_Gfx.h
index 5ab2f03..5e54131 100644
--- a/include/gfx/GP_Gfx.h
+++ b/include/gfx/GP_Gfx.h
@@ -47,6 +47,7 @@
#include "GP_Tetragon.h"
#include "GP_Circle.h"
#include "GP_Ellipse.h"
+#include "GP_Arc.h"
#include "GP_Polygon.h"
#include "GP_Symbol.h"
diff --git a/libs/gfx/GP_Arc.c b/libs/gfx/GP_Arc.c
index c64d94d..bd28a74 100644
--- a/libs/gfx/GP_Arc.c
+++ b/libs/gfx/GP_Arc.c
@@ -29,26 +29,24 @@
#include "algo/Arc.algo.h"
/* Generate drawing functions for various bit depths. */
-GP_DEF_DRAW_FN_PER_BPP(GP_Arc_Raw, DEF_ARC_FN)
+GP_DEF_DRAW_FN_PER_BPP(GP_ArcSegment_Raw, DEF_ARCSEGMENT_FN)
-void GP_Arc_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+void GP_ArcSegment_Raw(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_Size a, GP_Size b, int quadrant_mask,
- int low_dx, int low_dy,
- int high_dx, int high_dy,
+ double start, double end,
GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
- GP_FN_PER_BPP_CONTEXT(GP_Arc_Raw, context, context,
+ GP_FN_PER_BPP_CONTEXT(GP_ArcSegment_Raw, context, context,
xcenter, ycenter, a, b, quadrant_mask,
- low_dx, low_dy, high_dx, high_dy,
+ start, end,
pixel);
}
-void GP_Arc(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
+void GP_ArcSegment(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_Size a, GP_Size b, int quadrant_mask,
- int low_dx, int low_dy,
- int high_dx, int high_dy,
+ double start, double end,
GP_Pixel pixel)
{
GP_CHECK_CONTEXT(context);
@@ -57,7 +55,7 @@ void GP_Arc(GP_Context *context, GP_Coord xcenter, GP_Coord ycenter,
GP_TRANSFORM_POINT(context, xcenter, ycenter);
GP_TRANSFORM_SWAP(context, a, b);
- GP_Arc_Raw(context, xcenter, ycenter, a, b, quadrant_mask,
- low_dx, low_dy, high_dx, high_dy,
+ GP_ArcSegment_Raw(context, xcenter, ycenter, a, b, quadrant_mask,
+ start, end,
pixel);
}
diff --git a/libs/gfx/algo/Arc.algo.h b/libs/gfx/algo/Arc.algo.h
index 1681ce8..215fb77 100644
--- a/libs/gfx/algo/Arc.algo.h
+++ b/libs/gfx/algo/Arc.algo.h
@@ -30,23 +30,30 @@
*/
/*
- * This macro defines an elliptic arc drawing function.
+ * This macro defines a function that draws a single-quadrant
+ * (optionally mirrored) segment of an arc.
* Arguments:
* CONTEXT_T - user-defined type of drawing context (passed to PUTPIXEL)
* PIXVAL_T - user-defined pixel value type (passed to PUTPIXEL)
* PUTPIXEL - a pixel drawing function f(context, x, y, pixval)
* FN_NAME - name of the function to be defined
*/
-#define DEF_ARC_FN(FN_NAME, CONTEXT_T, PIXVAL_T, PUTPIXEL) +#define DEF_ARCSEGMENT_FN(FN_NAME, CONTEXT_T, PIXVAL_T, PUTPIXEL) void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, unsigned int a, unsigned int b, int quadrant_mask, - int low_dx, int low_dy, int high_dx, int high_dy, - PIXVAL_T pixval) + double start, double end, PIXVAL_T pixval) { /* Precompute quadratic terms. */ int a2 = a*a; int b2 = b*b; + double phi_min = GP_MIN(start, end); + double phi_max = GP_MAX(start, end); + int xmin = (int)(cos(start)*a); + int ymin = (int)(sin(start)*b); + int xmax = (int)(cos(end)*a); + int ymax = (int)(sin(end)*b); + int x, y, error; for (x = 0, error = -b2*a, y = b; y >= 0; y--) { while (error < 0) { @@ -55,30 +62,42 @@ void FN_NAME(CONTEXT_T context, int xcenter, int ycenter, error += 2*x*b2 + b2; x++; - if ((x*low_dy >= y*low_dx) && (x*high_dy <= y*high_dx)) { - if (quadrant_mask & GP_QUADRANT_MINUSMINUS) - PUTPIXEL(context, xcenter-x+
1, ycenter-y, pixval); - if (quadrant_mask & GP_QUADRANT_PLUSMINUS) - PUTPIXEL(context, xcenter+x-1, ycenter-y, pixval); - if (quadrant_mask & GP_QUADRANT_MINUSPLUS) - PUTPIXEL(context, xcenter-x+1, ycenter+y, pixval); - if (quadrant_mask & GP_QUADRANT_PLUSPLUS) - PUTPIXEL(context, xcenter+x-1, ycenter+y, pixval); + if (quadrant_mask & GP_QUADRANT_MINUSMINUS && + (-x+1) >= xmin && (-x+1) <= xmax) { + PUTPIXEL(context, xcenter-x+1, ycenter-y, pixval); + } + if (quadrant_mask & GP_QUADRANT_PLUSMINUS && + (x-1) >= xmin && (x-1) <= xmax) { + PUTPIXEL(context, xcenter+x-1, ycenter-y, pixval); + } + if (quadrant_mask & GP_QUADRANT_MINUSPLUS && + (-x+1) >= xmin && (-x+1) <= xmax) { + PUTPIXEL(context, xcenter-x+1, ycenter+y, pixval); + } + if (quadrant_mask & GP_QUADRANT_PLUSPLUS && + (x-1) >= xmin && (x-1) <= xmax) { + PUTPIXEL(context, xcenter+x-1, ycenter+y, pixval); } } /* Calculate error(y-1) from error(
y). */ error += -2*y*a2 + a2; - if ((x*low_dy >= y*low_dx) && (x*high_dy <= y*high_dx)) { - if (quadrant_mask & GP_QUADRANT_MINUSMINUS) - PUTPIXEL(context, xcenter-x+1, ycenter-y, pixval); - if (quadrant_mask & GP_QUADRANT_PLUSMINUS) - PUTPIXEL(context, xcenter+x-1, ycenter-y, pixval); - if (quadrant_mask & GP_QUADRANT_MINUSPLUS) - PUTPIXEL(context, xcenter-x+1, ycenter+y, pixval); - if (quadrant_mask & GP_QUADRANT_PLUSPLUS) - PUTPIXEL(context, xcenter+x-1, ycenter+y, pixval); + if (quadrant_mask & GP_QUADRANT_MINUSMINUS && + (-x+1) >= xmin && (-x+1) <= xmax) { + PUTPIXEL(context, xcenter-x+1, ycenter-y, pixval); + } + if (quadrant_mask & GP_QUADRANT_PLUSMINUS && + (x-1) >= xmin && (x-1) <= xmax) { + PUTPIXEL(context, xcenter+x-1, ycenter-y, pixval); + } + if (quadrant_mask & GP_QUADRANT_MINUSPLUS && + (-x+1) >= xmin && (-x+1) <= xmax) { + PUTPIXEL(context, xcenter-x+1, ycenter+y, pixval); + } + if (quadrant_mask & GP_QUADRANT_P
LUSPLUS && + (x-1) >= xmin && (x-1) <= xmax) { + PUTPIXEL(context, xcenter+x-1, ycenter+y, pixval); } } }
diff --git a/tests/SDL/shapetest.c b/tests/SDL/shapetest.c
index 8435e10..aebd83d 100644
--- a/tests/SDL/shapetest.c
+++ b/tests/SDL/shapetest.c
@@ -72,7 +72,8 @@ static int show_axes = 1;
#define SHAPE_ELLIPSE 4
#define SHAPE_RECTANGLE 5
#define SHAPE_TETRAGON 6
-#define SHAPE_LAST 6
+#define SHAPE_ARC 7
+#define SHAPE_LAST 7
static int shape = SHAPE_FIRST;
/* Variants in coordinates, if applicable */
@@ -186,6 +187,12 @@ void draw_testing_ellipse(int x, int y, int xradius, int yradius)
GP_Ellipse(&context, x, y, xradius, yradius, white);
}
+void draw_testing_arc(int x, int y, int xradius, int yradius)
+{
+ GP_ArcSegment(&context, x, y, xradius, yradius, GP_QUADRANT_ALL,
+ M_PI/3, 0, red);
+}
+
void draw_testing_rectangle(int x, int y, int xradius, int yradius)
{
int x0 = x - xradius, y0 = y - yradius;
@@ -270,6 +277,10 @@ void redraw_screen(void)
draw_testing_tetragon(center_x, center_y, xradius, yradius);
title = "TETRAGON";
break;
+ case SHAPE_ARC:
+ draw_testing_arc(center_x, center_y, xradius, yradius);
+ title = "ARC";
+ break;
}
GP_Text(&context, &style, 16, 16, GP_ALIGN_RIGHT|GP_VALIGN_BELOW,
-----------------------------------------------------------------------
Summary of changes:
include/gfx/GP_Arc.h | 31 +++++++++++++++-------
include/gfx/GP_Gfx.h | 1 +
libs/gfx/GP_Arc.c | 20 ++++++--------
libs/gfx/algo/Arc.algo.h | 63 ++++++++++++++++++++++++++++++----------------
tests/SDL/shapetest.c | 13 ++++++++-
5 files changed, 84 insertions(+), 44 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0
[repo.or.cz] gfxprim.git branch master updated: 91989ac6cef96d62797a104a2f99cca17f6151de
by metan 11 Dec '11
by metan 11 Dec '11
11 Dec '11
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 91989ac6cef96d62797a104a2f99cca17f6151de (commit)
from d10318c0369619faa73b93abe840ea8e67cb5a52 (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/91989ac6cef96d62797a104a2f99cca17f61…
commit 91989ac6cef96d62797a104a2f99cca17f6151de
Author: Cyril Hrubis <metan(a)ucw.cz>
Date: Sun Dec 11 19:27:59 2011 +0100
core: Add more tests for GP_MIX_PIXELS.
diff --git a/include/core/GP_MixPixels.gen.h.t b/include/core/GP_MixPixels.gen.h.t
index ab611aa..2ad33a8 100644
--- a/include/core/GP_MixPixels.gen.h.t
+++ b/include/core/GP_MixPixels.gen.h.t
@@ -20,8 +20,8 @@ Macros to mix two pixels accordingly to percentage.
%% for c in pt.chanslist
GP_Pixel {{ c[0] }}; - {{ c[0] }} = GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix1) * perc; - {{ c[0] }} += GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix2) * (255 - perc); + {{ c[0] }} = GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix1) * (perc); + {{ c[0] }} += GP_Pixel_GET_{{ c[0] }}_{{ pt.name }}(pix2) * (255 - (perc)); {{ c[0] }} = ({{ c[0] }} + 128) / 255; %% endfor
diff --git a/tests/core/GP_MixPixels.test.gen.c.t b/tests/core/GP_MixPixels.test.gen.c.t
index ffb9d6d..cb2a6fb 100644
--- a/tests/core/GP_MixPixels.test.gen.c.t
+++ b/tests/core/GP_MixPixels.test.gen.c.t
@@ -34,4 +34,18 @@ GP_SUITE(GP_MixPixels)
}
%% endcall
+%% call(pt) test_for_all_pixeltypes("MixPixelsSymmetry_via",
+ opts="loop_start=0, loop_end=4",
+ palette=False)
+ GP_Pixel p1 = GP_RGBToPixel(0, 124, 12, GP_PIXEL_{{ pt.name }});
+ GP_Pixel p2 = GP_RGBToPixel(255, 99, 0, GP_PIXEL_{{ pt.name }});
+ GP_Pixel p3, p4;
+ int i;
+ for (i = 0; i < 256; i++) {
+ p3 = GP_MIX_PIXELS_{{ pt.name }}(p1, p2, i);
+ p4 = GP_MIX_PIXELS_{{ pt.name }}(p2, p1, 255 - i);
+ GP_CHECK_EqualColors(p3, GP_PIXEL_{{ pt.name }}, p4, GP_PIXEL_{{ pt.name }});
+ }
+%% endcall
+
%% endblock body
-----------------------------------------------------------------------
Summary of changes:
include/core/GP_MixPixels.gen.h.t | 4 ++--
tests/core/GP_MixPixels.test.gen.c.t | 14 ++++++++++++++
2 files changed, 16 insertions(+), 2 deletions(-)
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos(a)gmail.com
if you want to unsubscribe, or site admin admin(a)repo.or.cz if you receive
no reply.
--
gfxprim.git ("A simple 2D graphics library with emphasis on correctness and well-defined operation.")
1
0