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 dbd7368023249233216d3c6ce873213833f64940 (commit) via d64d59ffe85c39cc5f1f285226dd75493d236a00 (commit) via 839f3e4ae66a2068ff6059fd14502e6120418c3e (commit) via 77ef6dd38134300845793ff4da8d4ff6aeaa85bd (commit) from b751bfc9b78d8dc25a503efce8582a8f6df10af7 (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/dbd7368023249233216d3c6ce873213833f64...
commit dbd7368023249233216d3c6ce873213833f64940 Author: Cyril Hrubis metan@ucw.cz Date: Sat May 17 21:11:00 2014 +0200
core: MixPixels: Change RGB mix to linear.
Do not use Gamma mixing, this fixes font rendering.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/include/core/GP_MixPixels.gen.h.t b/include/core/GP_MixPixels.gen.h.t index 8067f4be..7333fe9f 100644 --- a/include/core/GP_MixPixels.gen.h.t +++ b/include/core/GP_MixPixels.gen.h.t @@ -75,7 +75,7 @@ Macros to mix two pixels accordingly to percentage.
#define GP_MIX_PIXELS_{{ pt.name }}(pix1, pix2, perc) %% if pt.is_rgb() - GP_MIX_PIXELS_GAMMA_{{ pt.name }}(pix1, pix2, perc) + GP_MIX_PIXELS_LINEAR_{{ pt.name }}(pix1, pix2, perc) %% else GP_MIX_PIXELS_LINEAR_{{ pt.name }}(pix1, pix2, perc) %% endif
http://repo.or.cz/w/gfxprim.git/commit/d64d59ffe85c39cc5f1f285226dd75493d236...
commit d64d59ffe85c39cc5f1f285226dd75493d236a00 Author: Cyril Hrubis metan@ucw.cz Date: Sat May 17 21:09:03 2014 +0200
text: GP_Font.c: Remove useless includes.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/libs/text/GP_Font.c b/libs/text/GP_Font.c index 62a1efd9..ff5f5c20 100644 --- a/libs/text/GP_Font.c +++ b/libs/text/GP_Font.c @@ -16,12 +16,11 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2012 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2014 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
-#include "core/GP_GetPutPixel.h" -#include "core/GP_MixPixels.gen.h" +#include <stdlib.h> #include "GP_Font.h"
#include "GP_DefaultFont.h"
http://repo.or.cz/w/gfxprim.git/commit/839f3e4ae66a2068ff6059fd14502e6120418...
commit 839f3e4ae66a2068ff6059fd14502e6120418c3e Author: Cyril Hrubis metan@ucw.cz Date: Sat May 17 19:56:39 2014 +0200
spiv: Add support for TTF font
Adds two config options for TTF font path and font height.
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/demos/spiv/spiv.1 b/demos/spiv/spiv.1 index 30bd5d9f..69297e20 100644 --- a/demos/spiv/spiv.1 +++ b/demos/spiv/spiv.1 @@ -105,6 +105,12 @@ Shows this help .B -i, --show-info Show image info such as filename, size, etc... .TP +.B --font-path=value +Path to TTF font to be used in GUI +.TP +.B --font-height=value +TTF font height in pixels +.TP .B -p, --show-progress Show progress bar when loading/resampling/... images .TP @@ -178,6 +184,12 @@ by [NameSpace] and continues until next namespace. .B ShowInfo Show image info such as filename, size, etc... .TP +.B FontPath=value +Path to TTF font to be used in GUI +.TP +.B FontHeight=value +TTF font height in pixels +.TP .B ShowProgress Show progress bar when loading/resampling/... images .TP diff --git a/demos/spiv/spiv.c b/demos/spiv/spiv.c index d4785e0a..3cf212c3 100644 --- a/demos/spiv/spiv.c +++ b/demos/spiv/spiv.c @@ -16,7 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2014 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -96,17 +96,17 @@ static int image_loader_callback(GP_ProgressCallback *self)
int align = GP_ALIGN_CENTER|GP_VALIGN_ABOVE;
- size = GP_TextWidth(NULL, buf); + size = GP_TextWidth(config.style, buf);
int start = c->w/2 - size/2 - 10; int end = c->w/2 + size/2 + 10; int middle = start + (end - start) * self->percentage / 100; - int top = c->h - GP_TextHeight(NULL) - 11; + int top = c->h - GP_TextHeight(config.style) - 11;
GP_FillRectXYXY(c, start, c->h - 1, middle, top, gray_pixel); GP_FillRectXYXY(c, middle, c->h - 1, end, top, black_pixel);
- GP_Text(c, NULL, c->w/2, c->h - 5, align, + GP_Text(c, config.style, c->w/2, c->h - 5, align, white_pixel, black_pixel, buf);
GP_BackendUpdateRect(backend, start, c->h - 1, end, top); @@ -154,10 +154,10 @@ static GP_Context *load_image(int elevate) GP_Context *ctx = backend->context;
GP_Fill(ctx, black_pixel); - GP_Print(ctx, NULL, ctx->w/2, ctx->h/2 - 10, + GP_Print(ctx, config.style, ctx->w/2, ctx->h/2 - 10, GP_ALIGN_CENTER|GP_VALIGN_CENTER, white_pixel, black_pixel, "'%s'", image_loader_img_path()); - GP_Print(ctx, NULL, ctx->w/2, ctx->h/2 + 10, + GP_Print(ctx, config.style, ctx->w/2, ctx->h/2 + 10, GP_ALIGN_CENTER|GP_VALIGN_CENTER, white_pixel, black_pixel, "Failed to load image :( (%s)", strerror(errno)); GP_BackendFlip(backend); @@ -203,11 +203,11 @@ static void info_printf(GP_Context *ctx, GP_Coord x, GP_Coord y, va_start(va, fmt);
va_copy(vac, va); - GP_VPrint(ctx, NULL, x-1, y-1, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM, + GP_VPrint(ctx, config.style, x-1, y-1, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM|GP_TEXT_NOBG, black_pixel, white_pixel, fmt, vac); va_end(vac);
- GP_VPrint(ctx, NULL, x, y, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM, + GP_VPrint(ctx, config.style, x, y, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM|GP_TEXT_NOBG, white_pixel, black_pixel, fmt, va);
va_end(va); @@ -224,7 +224,7 @@ static void show_info(struct loader_params *params, GP_Context *img, if (!config.show_info) return;
- GP_Size th = GP_TextHeight(NULL), y = 10; + GP_Size th = GP_TextHeight(config.style), y = 10;
info_printf(context, 10, y, "%ux%u (%ux%u) 1:%3.3f %3.1f%% %s", img->w, img->h, orig_img->w, orig_img->h, params->zoom_rat, diff --git a/demos/spiv/spiv_config.c b/demos/spiv/spiv_config.c index 166a28c5..6fa95f4b 100644 --- a/demos/spiv/spiv_config.c +++ b/demos/spiv/spiv_config.c @@ -16,7 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2014 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -41,6 +41,9 @@ struct spiv_config config = { .full_screen = 0, .max_win_w = 1024, .max_win_h = 768, + + .font_path = NULL, + .font_height = 12, };
static int set_zoom_strategy(struct cfg_opt *self, unsigned int lineno) @@ -200,6 +203,60 @@ static int set_emulation(struct cfg_opt *self, unsigned int lineno) return 0; }
+int load_font_face(GP_TextStyle *style, const char *path, unsigned int height, + unsigned int lineno) +{ + GP_FontFace *font; + static GP_FontFace *old_font = NULL; + + font = GP_FontFaceLoad(path, 0, height); + + if (!font) { + fprintf(stderr, "ERROR: %u: Failed to load font '%s'n", + lineno, path); + return 1; + } + + GP_FontFaceFree(old_font); + style->font = old_font = font; + + return 0; +} + +static int set_font(struct cfg_opt *self, unsigned int lineno) +{ + static GP_TextStyle style = {NULL, 0, 0, 1, 1, 0}; + + if (load_font_face(&style, self->val, config.font_height, lineno)) + return 1; + + free(config.font_path); + config.font_path = strdup(self->val); + config.style = &style; + + return 0; +} + +static int set_font_height(struct cfg_opt *self, unsigned int lineno) +{ + int height = atoi(self->val); + + if (height <= 0) { + fprintf(stderr, "ERROR: %u: Wrong font height '%s'n", + lineno, self->val); + return 1; + } + + config.font_height = height; + + if (config.style) { + return load_font_face(config.style, config.font_path, + config.font_height, lineno); + } + + return 0; +} + static int help(struct cfg_opt *self, unsigned int lineno) { (void) self; @@ -237,6 +294,20 @@ struct cfg_opt spiv_opts[] = { .help = "Show image info such as filename, size, etc...", }, {.name_space = "Gui", + .key = "FontPath", + .opt_long = "font-path", + .opt_has_value = 1, + .set = set_font, + .help = "Path to TTF font to be used in GUI", + }, + {.name_space = "Gui", + .key = "FontHeight", + .opt_long = "font-height", + .opt_has_value = 1, + .set = set_font_height, + .help = "TTF font height in pixels", + }, + {.name_space = "Gui", .key = "ShowProgress", .opt = 'p', .opt_long = "show-progress", diff --git a/demos/spiv/spiv_config.h b/demos/spiv/spiv_config.h index e4a5c124..144ec6ea 100644 --- a/demos/spiv/spiv_config.h +++ b/demos/spiv/spiv_config.h @@ -16,7 +16,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, * * Boston, MA 02110-1301 USA * * * - * Copyright (C) 2009-2013 Cyril Hrubis metan@ucw.cz * + * Copyright (C) 2009-2014 Cyril Hrubis metan@ucw.cz * * * *****************************************************************************/
@@ -60,6 +60,11 @@ struct spiv_config { int full_screen:1; char backend_init[128]; GP_PixelType emul_type; + + /* Font information */ + GP_TextStyle *style; + char *font_path; + unsigned int font_height; };
extern struct spiv_config config; diff --git a/demos/spiv/spiv_help.c b/demos/spiv/spiv_help.c index 9d018872..ef1f0c58 100644 --- a/demos/spiv/spiv_help.c +++ b/demos/spiv/spiv_help.c @@ -230,6 +230,8 @@ void print_man(void) puts(man_tail); }
+static int last_line; + static int redraw_help(GP_Backend *backend, unsigned int loff, GP_Coord xoff) { GP_Context *c = backend->context; @@ -237,19 +239,32 @@ static int redraw_help(GP_Backend *backend, unsigned int loff, GP_Coord xoff) GP_Pixel white = GP_ColorToContextPixel(GP_COL_WHITE, c); int i;
+ int spacing = GP_TextHeight(config.style)/10 + 2; + int height = GP_TextHeight(config.style); + GP_Fill(c, black);
- GP_Print(c, NULL, 20 + 10 * xoff, 2, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM, + GP_Print(c, config.style, 20 + 10 * xoff, 2, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM, white, black, "%s", "Keyboard Controls:");
+ unsigned int max = 0; + + for (i = 0; i < help_keys_len; i++) + max = GP_MAX(max, GP_TextWidth(config.style, help_keys[i].keys)); + for (i = loff; i < help_keys_len; i++) { - GP_Coord h = 2 + (i - loff + 1) * 15; + GP_Coord h = spacing + (i - loff + 1) * (height + spacing);
- if (h + 2 >= (GP_Coord)c->h) + if (h + height + spacing > (GP_Coord)c->h) { + last_line = 0; goto out; + }
- GP_Print(c, NULL, 20 + 10 * xoff, h, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM, - white, black, "%-"KEYS_MAX"s - %s", help_keys[i].keys, help_keys[i].desc); + GP_Print(c, config.style, 20 + 10 * xoff, h, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM, + white, black, "%s", help_keys[i].keys); + GP_Print(c, config.style, 20 + 10 * xoff + max, h, GP_ALIGN_RIGHT|GP_VALIGN_BOTTOM, + white, black, " - %s", help_keys[i].desc); + last_line = 1; }
out: @@ -257,11 +272,6 @@ out: return i; }
-static int max_lines(GP_Backend *backend) -{ - return (backend->context->h - 4) / 15; -} - void draw_help(GP_Backend *backend) { int loff = 0, last, xoff = 0; @@ -294,17 +304,16 @@ void draw_help(GP_Backend *backend) break; case GP_KEY_PAGE_DOWN: if (last < help_keys_len) { - if (loff + max_lines(backend) >= help_keys_len) + if (last_line) break;
- loff += max_lines(backend); - + loff += last - loff; last = redraw_help(backend, loff, xoff); } break; case GP_KEY_PAGE_UP: if (loff > 0) { - loff -= max_lines(backend); + loff -= last - loff; if (loff < 0) loff = 0; last = redraw_help(backend, loff, xoff);
http://repo.or.cz/w/gfxprim.git/commit/77ef6dd38134300845793ff4da8d4ff6aeaa8...
commit 77ef6dd38134300845793ff4da8d4ff6aeaa85bd Author: Cyril Hrubis metan@ucw.cz Date: Sat May 17 19:52:33 2014 +0200
text: GP_FontFaceFree(): Do not SegFault on NULL
Signed-off-by: Cyril Hrubis metan@ucw.cz
diff --git a/doc/text.txt b/doc/text.txt index 3f3a5e70..8a4a4cb4 100644 --- a/doc/text.txt +++ b/doc/text.txt @@ -218,8 +218,9 @@ GP_FontFace *GP_FontFaceLoad(const char *path, uint32_t width, uint32_t height); void GP_FontFaceFree(GP_FontFace *self); --------------------------------------------------------------------------------
-Renders TrueType font using link:http://www.freetype.org%5BFreeType] (currently -printable ASCII only) into GFXprim font structures. +The 'GP_FontFaceLoad()' renders TrueType font using +link:http://www.freetype.org%5BFreeType] (currently printable ASCII only) into +GFXprim font structures.
One of the 'width' or 'height' may be zero, which means that the second value should be computed accordingly. @@ -227,5 +228,7 @@ should be computed accordingly. NOTE: If you pass both 'width' and 'height' non-zero the resulting font may look strange as this action forced unnatural aspect ratio.
+The 'GP_FontFaceFree()' frees memory taken up by the rendered font. If self is +NULL no operation is done.
TIP: For Font and TextStyle handling see link:example_fonts.html[examples]. diff --git a/libs/text/GP_Font.c b/libs/text/GP_Font.c index d7232393..62a1efd9 100644 --- a/libs/text/GP_Font.c +++ b/libs/text/GP_Font.c @@ -63,6 +63,9 @@ GP_GlyphBitmap *GP_GetGlyphBitmap(const GP_FontFace *font, int c)
void GP_FontFaceFree(GP_FontFace *self) { + if (!self) + return; + free(self->glyphs); free(self); }
-----------------------------------------------------------------------
Summary of changes: demos/spiv/spiv.1 | 12 ++++++ demos/spiv/spiv.c | 18 +++++----- demos/spiv/spiv_config.c | 73 ++++++++++++++++++++++++++++++++++++- demos/spiv/spiv_config.h | 7 +++- demos/spiv/spiv_help.c | 37 ++++++++++++------- doc/text.txt | 7 +++- include/core/GP_MixPixels.gen.h.t | 2 +- libs/text/GP_Font.c | 8 +++-- 8 files changed, 133 insertions(+), 31 deletions(-)
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.