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 cc29e24343c95c5edd528e3567af652fc9b70b7f (commit) via ccfd33d3383ba4de615825d986dbf46805ef8d6a (commit) from 188ea2197a3fdfddccedad25a563c9ee92059abf (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/cc29e24343c95c5edd528e3567af652fc9b70...
commit cc29e24343c95c5edd528e3567af652fc9b70b7f Author: Cyril Hrubis metan@ucw.cz Date: Sat Feb 23 16:08:06 2013 +0100
doc: Edhance text API docs.
diff --git a/doc/example_fonts.txt b/doc/example_fonts.txt new file mode 100644 index 0000000..85a6618 --- /dev/null +++ b/doc/example_fonts.txt @@ -0,0 +1,17 @@ +Font Test Example +----------------- +.A simple program to show all font characters with different styles. + +[source,c] +------------------------------------------------------------------ +include::../demos/c_simple/fonttest.c[] +------------------------------------------------------------------ + +Fileview +-------- +.A simple program to show contents of a file. + +[source,c] +------------------------------------------------------------------ +include::../demos/c_simple/fileview.c[] +------------------------------------------------------------------ diff --git a/doc/images/fonts/default_console_font.png b/doc/images/fonts/default_console_font.png new file mode 100644 index 0000000..badc72a Binary files /dev/null and b/doc/images/fonts/default_console_font.png differ diff --git a/doc/images/fonts/default_console_font_big.png b/doc/images/fonts/default_console_font_big.png new file mode 100644 index 0000000..19d6c03 Binary files /dev/null and b/doc/images/fonts/default_console_font_big.png differ diff --git a/doc/images/fonts/default_console_font_embolding.png b/doc/images/fonts/default_console_font_embolding.png new file mode 100644 index 0000000..795773f Binary files /dev/null and b/doc/images/fonts/default_console_font_embolding.png differ diff --git a/doc/images/fonts/default_proportional_font.png b/doc/images/fonts/default_proportional_font.png new file mode 100644 index 0000000..b436194 Binary files /dev/null and b/doc/images/fonts/default_proportional_font.png differ diff --git a/doc/images/fonts/font_tiny.png b/doc/images/fonts/font_tiny.png new file mode 100644 index 0000000..4865ff2 Binary files /dev/null and b/doc/images/fonts/font_tiny.png differ diff --git a/doc/images/fonts/font_tiny_mono.png b/doc/images/fonts/font_tiny_mono.png new file mode 100644 index 0000000..6cfd5c8 Binary files /dev/null and b/doc/images/fonts/font_tiny_mono.png differ diff --git a/doc/images/fonts/glyph_metrics.png b/doc/images/fonts/glyph_metrics.png new file mode 100644 index 0000000..d2efad3 Binary files /dev/null and b/doc/images/fonts/glyph_metrics.png differ diff --git a/doc/text_api.txt b/doc/text_api.txt index 0f3484c..08cd715 100644 --- a/doc/text_api.txt +++ b/doc/text_api.txt @@ -6,13 +6,17 @@ NOTE: You may want to see the link:coordinate_system.html[coordinate system] fir Text ~~~~
-Text drawing is controlled by the 'GP_TextStyle' structure defined in -'core/GP_TextStyle.h'. This structure carries the information about font, -letter spacing and pixel multiplication and spacing. (If no font is specified, -the default monospace font is used.) +Text drawing is controlled by the <<TextStyle,GP_TextStyle>> structure. This +structure carries the information about font, letter spacing and pixel +multiplication and spacing. (If no font is specified, the default mono-space +font is used.)
[source,c] -------------------------------------------------------------------------------- +#include <GP.h> +/* or */ +#include <text/GP_Text.h> + /* Where the text should be drawn relatively to the specified point */ typedef enum GP_TextAlign { GP_ALIGN_LEFT = 0x01, /* to the left from the point */ @@ -26,49 +30,193 @@ typedef enum GP_TextAlign {
void GP_Text(GP_Context *context, const GP_TextStyle *style, int x, int y, int align, const char *str, GP_Pixel pixel); + + +GP_Size GP_Print(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 *fmt, ...); --------------------------------------------------------------------------------
Draws text at the position x and y; the alignment of the text in relation to the point is specified by alignment flags. + If the 'style' argument is 'NULL', a default style is used.
The text size can be computed by following functions:
[source,c] -------------------------------------------------------------------------------- +#include <GP.h> +/* or */ +#include <text/GP_TextMetric.h> + unsigned int GP_TextWidth(const GP_TextStyle *style, const char *str); --------------------------------------------------------------------------------
Returns the width (in pixels) that would be occupied by the string if rendered using the specified style.
+Computing a length of a given string is more complicated than it appears to +be. The first letter needs 'advance - bearing' pixels, the middle letters +needs 'advance' pixels and the last letter needs 'bearing + width' pixel. See +link:images/fonts/glyph_metrics.png[Glyph Metrics] for a description of the +terms used in this paragraph. + [source,c] -------------------------------------------------------------------------------- +#include <GP.h> +/* or */ +#include <text/GP_TextMetric.h> + unsigned int GP_TextMaxWidth(const GP_TextStyle *style, unsigned int len); --------------------------------------------------------------------------------
-Returns maximum text width, in pixels, for string with 'len' letters. This call -is useful for variable letter size fonts. +Returns maximum text width, in pixels, for string with 'len' letters. + +This call simply computes width of a string rendered with 'len' largest glyphs +(letters) in the font. Because of this the resulting size is often much larger +than needed. + +[source,c] +-------------------------------------------------------------------------------- +#include <GP.h> +/* or */ +#include <text/GP_TextMetric.h> + +GP_Size GP_TextMaxStrWidth(const GP_TextStyle *style, const char *str, + unsigned int len); +-------------------------------------------------------------------------------- + +Returns maximum text width, in pixels, for a string with 'len' letters that +are composed only of letters from 'str'. + +This call simply computes width of a string rendered with largest letter from +'str' and with 'len' characters.
[source,c] -------------------------------------------------------------------------------- +#include <GP.h> +/* or */ +#include <text/GP_TextMetric.h> + unsigned int GP_TextAscent(const GP_TextStyle *style); --------------------------------------------------------------------------------
The Ascent is the height in pixels from the top to the baseline.
+The baseline is imaginary line that letters are positioned upon and the ascent +is usually height of capital letter, but it may be larger for certain fonts. + [source,c] -------------------------------------------------------------------------------- +#include <GP.h> +/* or */ +#include <text/GP_TextMetric.h> + unsigned int GP_TextDescent(const GP_TextStyle *style); --------------------------------------------------------------------------------
The Descent is the height in pixels from baseline to the bottom.
+The baseline is imaginary line that letters are positioned upon and the +descent is usually height of upper part of the letter y that goes under the +baseline, but it may be larger for certain fonts. + [source,c] -------------------------------------------------------------------------------- +#include <GP.h> +/* or */ +#include <text/GP_TextMetric.h> + unsigned int GP_TextHeight(const GP_TextStyle *style); --------------------------------------------------------------------------------
The Height is size of the font from top to the bottom, i.e. equals exactly to the sum of ascent and descent.
+This simply returns height that is needed to draw a line of a text using a +certain font style (without the spacing between the lines). + +[[TextStyle]] +TextStyle +~~~~~~~~~ + +[source,c] +-------------------------------------------------------------------------------- +#include <GP.h> +/* or */ +#include <text/GP_TextStyle.h> + +typedef struct GP_TextStyle { + const struct GP_FontFace *font; + + /* Spacing between pixels (0 is the default, no spacing). */ + int pixel_xspace, pixel_yspace; + + /* Multiplier of pixel width/height (1 is default). */ + int pixel_xmul, pixel_ymul; + + /* Extra spacing (in pixels) between characters. */ + int char_xspace; + +} GP_TextStyle; +-------------------------------------------------------------------------------- + +The TextStyle structure describes the parameters for text rendering. + +The first parameter is font being used. +TODO: link to font format and description. + +The 'xspace' and 'yspace' parameters controls spacing between the pixels and +the 'xmul' and 'ymul' describes pixel multiplication in respective directions. + +The 'char_xspace' is used to add additional space between letters. + +.Default Console Font xmul=ymul=1 xspace=yspace=0 +image::images/fonts/default_console_font.png["Default Console Font"] + +.Default Console Font xmul=ymul=2 xspace=yspace=-1 +image::images/fonts/default_console_font_embolding.png["Default Console Font"] + +.Default Console Font xmul=ymul=2 xspace=yspace=1 +image::images/fonts/default_console_font_big.png["Default Console Font"] + + +Compiled-in Fonts +~~~~~~~~~~~~~~~~~ + +There is a global constant pointer to each compiled-in font structure, see +'include/text/GP_Fonts.h'. + +.Default Console Font +image::images/fonts/default_console_font.png["Default Console Font"] + +.Default Proportional Font +image::images/fonts/default_proportional_font.png["Default Proportional Font"] + +.Font Tiny Mono (GP_FontTinyMono) +image::images/fonts/font_tiny_mono.png["Font Tiny Mono"] + +.Font Tiny (GP_FontTiny) +image::images/fonts/font_tiny.png["Font Tiny"] + +TrueType Fonts +~~~~~~~~~~~~~~ + +[source,c] +-------------------------------------------------------------------------------- +/* + * Load font face from file. + */ +GP_FontFace *GP_FontFaceLoad(const char *path, uint32_t width, uint32_t height); + +/* + * Free the font face. + */ +void GP_FontFaceFree(GP_FontFace *self); +-------------------------------------------------------------------------------- + +Renders TrueType font using link:http://www.freetype.org%5BFreeType] (currently +printable ASCII only) into GFXprim font structures. + +TIP: For Font and TextStyle handling see link:example_fonts.html[examples].
http://repo.or.cz/w/gfxprim.git/commit/ccfd33d3383ba4de615825d986dbf46805ef8...
commit ccfd33d3383ba4de615825d986dbf46805ef8d6a Author: Cyril Hrubis metan@ucw.cz Date: Sat Feb 23 15:44:06 2013 +0100
doc: Fix asciidoc.css
Set the left menu width, otherwise it spans across the whole page and links under are not clickable.
diff --git a/doc/asciidoc.css b/doc/asciidoc.css index 20b466f..c663f2d 100644 --- a/doc/asciidoc.css +++ b/doc/asciidoc.css @@ -120,6 +120,7 @@ div.left-menu { top: 90pt; left: -100pt; height: 0; + width: 100pt; }
div.logo h1 {
-----------------------------------------------------------------------
Summary of changes: doc/asciidoc.css | 1 + doc/{example_v4l2.txt => example_fonts.txt} | 16 +- doc/images/fonts/default_console_font.png | Bin 0 -> 3480 bytes doc/images/fonts/default_console_font_big.png | Bin 0 -> 1509 bytes .../fonts/default_console_font_embolding.png | Bin 0 -> 4125 bytes doc/images/fonts/default_proportional_font.png | Bin 0 -> 3412 bytes doc/images/fonts/font_tiny.png | Bin 0 -> 2763 bytes doc/images/fonts/font_tiny_mono.png | Bin 0 -> 2834 bytes doc/images/fonts/glyph_metrics.png | Bin 0 -> 3418 bytes doc/text_api.txt | 160 +++++++++++++++++++- 10 files changed, 163 insertions(+), 14 deletions(-) copy doc/{example_v4l2.txt => example_fonts.txt} (51%) create mode 100644 doc/images/fonts/default_console_font.png create mode 100644 doc/images/fonts/default_console_font_big.png create mode 100644 doc/images/fonts/default_console_font_embolding.png create mode 100644 doc/images/fonts/default_proportional_font.png create mode 100644 doc/images/fonts/font_tiny.png create mode 100644 doc/images/fonts/font_tiny_mono.png create mode 100644 doc/images/fonts/glyph_metrics.png
repo.or.cz automatic notification. Contact project admin jiri.bluebear.dluhos@gmail.com if you want to unsubscribe, or site admin admin@repo.or.cz if you receive no reply.