[Fwd: Re: [Subsurface] #3: Better layout of localized printout]
Dirk Hohndel
dirk at hohndel.org
Tue Nov 20 08:45:05 PST 2012
Hi Salva,
sorry for being so embarrassingly slow to react to this. I saw it on
trac and didn't get around to apply it - then I saw it here and the same
thing happened again. Just too much other stuff going on...
It's now pushed out to master
Thanks
/D
Salvador Cuñat <salvador.cunat at gmail.com> writes:
> Hellow.
>
> I put this comment and a little patch on track system thinking, don't
> ask me why, it would link with this list.
>
> There was an obvious mistake when I said "I have modified the justify of
> the text from "center" to "left"", I meant I had removed the justify by
> putting it to 0.
>
> There is a very simple solution for the header, trimming the localized
> text in pango_layout_set_text() to the desired size, but we would get
> words cut in a hideous way as (in spanish for Profundidad) "Profundi".
>
> So I still think that limiting the size of the words in de .po file will
> bring better results as it leaves the choice of the abbreviation to the
> translator.
>
> Best regards.
>
> Salva.
>
>
> --------- Mensaje reenviado --------
> De: Subsurface Bug Tracking System <trac at hohndel.org>
> Reply-to: trac at hohndel.org
> Cc: subsurface-trac at hohndel.org
> Asunto: Re: [Subsurface] #3: Better layout of localized printout
> Fecha: Tue, 13 Nov 2012 00:22:51 -0000
>
> #3: Better layout of localized printout
> ----------------------------------+------------------------------
> Reporter: Dirk Hohndel <dirk@…> | Owner: Subsurface Team
> Type: defect | Status: new
> Priority: major | Component: Translations
> Version: 2.1-rc1 | Resolution:
> Keywords: |
> ----------------------------------+------------------------------
>
> Comment (by salvador.cunat@…):
>
> I don't think there is a generic solution, but limiting the size of the
> localized texts, as the width of the columns is finite.
>
> One aproach would be scaling the text but we would get diferent sizes in a
> per column basis, and I'm afraid it would be worse than the first option.
>
> I've attached a patch to this ticket that mainly creates a grid around
> each dive in the table form. In adition I have modified the justify of
> the text from "center" to "left", wich improves slightly the printout of
> the dives, not the header one.
>
> Regards.
>
> Salva.
>
> --
> Ticket URL: <http://trac.hohndel.org/ticket/3#comment:1>
> Subsurface <http://subsurface.hohndel.org>
> Subsurface Dive Log
>
> From dd78f345783cf7c74a5402bfff178c00cb764816 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Salvador=20Cu=C3=B1at?= <salvador.cunat at gmail.com>
> Date: Tue, 13 Nov 2012 00:30:12 +0100
> Subject: [PATCH] Improving table print output.
> MIME-Version: 1.0
> Content-Type: text/plain; charset=UTF-8
> Content-Transfer-Encoding: 8bit
>
> - Create a grid for each dive printed.
> - We change justify "center" to "left" wich contributes to diferentiate each component of the array.
>
> Signed-off-by: Salvador Cuñat <salvador.cunat at gmail.com>
> ---
> print.c | 35 ++++++++++++++++++++++++++---------
> 1 files changed, 26 insertions(+), 9 deletions(-)
>
> diff --git a/print.c b/print.c
> index 9ce3675..d7a97be 100644
> --- a/print.c
> +++ b/print.c
> @@ -191,7 +191,7 @@ static void show_table_header(cairo_t *cr, double w, double h,
> curwidth = curwidth + colwidth;
> }
> pango_layout_set_text(layout, _(headers[i]), -1);
> - pango_layout_set_justify(layout, 1);
> + pango_layout_set_justify(layout, 0);
> pango_cairo_show_layout(cr, layout);
> }
>
> @@ -230,7 +230,7 @@ static void show_dive_table(struct dive *dive, cairo_t *cr, double w,
> snprintf(divenr, sizeof(divenr), "#%d", dive->number);
> pango_layout_set_width(layout, colwidth/ (double) 2);
> pango_layout_set_text(layout, divenr, -1);
> - pango_layout_set_justify(layout, 1);
> + pango_layout_set_justify(layout, 0);
> pango_cairo_show_layout(cr, layout);
> curwidth = curwidth + (colwidth / 2);
>
> @@ -247,7 +247,7 @@ static void show_dive_table(struct dive *dive, cairo_t *cr, double w,
> );
> cairo_move_to(cr, curwidth / PANGO_SCALE, 0);
> pango_layout_set_text(layout, buffer, len);
> - pango_layout_set_justify(layout, 1);
> + pango_layout_set_justify(layout, 0);
> pango_cairo_show_layout(cr, layout);
> curwidth = curwidth + colwidth;
>
> @@ -258,7 +258,7 @@ static void show_dive_table(struct dive *dive, cairo_t *cr, double w,
> cairo_move_to(cr, curwidth / PANGO_SCALE, 0);
> pango_layout_set_width(layout, colwidth/ (double) 2);
> pango_layout_set_text(layout, buffer, len);
> - pango_layout_set_justify(layout, 1);
> + pango_layout_set_justify(layout, 0);
> pango_cairo_show_layout(cr, layout);
> curwidth = curwidth + (colwidth / 2);
>
> @@ -268,7 +268,7 @@ static void show_dive_table(struct dive *dive, cairo_t *cr, double w,
> cairo_move_to(cr, curwidth / PANGO_SCALE, 0);
> pango_layout_set_width(layout, colwidth/ (double) 2);
> pango_layout_set_text(layout, buffer, len);
> - pango_layout_set_justify(layout, 1);
> + pango_layout_set_justify(layout, 0);
> pango_cairo_show_layout(cr, layout);
> curwidth = curwidth + (colwidth / 2);
>
> @@ -276,14 +276,14 @@ static void show_dive_table(struct dive *dive, cairo_t *cr, double w,
> pango_layout_set_width(layout, colwidth);
> cairo_move_to(cr, curwidth / PANGO_SCALE, 0);
> pango_layout_set_text(layout, dive->divemaster ? : " ", -1);
> - pango_layout_set_justify(layout, 1);
> + pango_layout_set_justify(layout, 0);
> pango_cairo_show_layout(cr, layout);
> curwidth = curwidth + colwidth;
>
> // Col 6: Buddy
> cairo_move_to(cr, curwidth / PANGO_SCALE, 0);
> pango_layout_set_text(layout, dive->buddy ? : " ", -1);
> - pango_layout_set_justify(layout, 1);
> + pango_layout_set_justify(layout, 0);
> pango_cairo_show_layout(cr, layout);
> curwidth = curwidth + colwidth;
>
> @@ -291,7 +291,7 @@ static void show_dive_table(struct dive *dive, cairo_t *cr, double w,
> cairo_move_to(cr, curwidth / PANGO_SCALE, 0);
> pango_layout_set_width(layout, maxwidth - curwidth);
> pango_layout_set_text(layout, dive->location ? : " ", -1);
> - pango_layout_set_justify(layout, 1);
> + pango_layout_set_justify(layout, 0);
> pango_cairo_show_layout(cr, layout);
>
> g_object_unref(layout);
> @@ -367,6 +367,8 @@ static void print_table(int divenr, cairo_t *cr, double x, double y,
> double w, double h, PangoFontDescription *font)
> {
> struct dive *dive;
> + double maxwidth, curwidth;
> + int i;
>
> dive = get_dive_for_printing(divenr);
> if (!dive)
> @@ -374,10 +376,25 @@ static void print_table(int divenr, cairo_t *cr, double x, double y,
> cairo_save(cr);
>
> /*Create a frame for each print x,y are provided in draw_page()*/
> - cairo_rectangle(cr, x, y, w, h);
> + maxwidth = w * 0.90;
> + curwidth = w * 0.045;
> + cairo_rectangle(cr, curwidth, y, maxwidth, h);
> cairo_set_line_width(cr, 0.01);
> cairo_set_line_join(cr, CAIRO_LINE_JOIN_MITER);
> cairo_stroke(cr);
> + for (i = 0; i < 6; i++) {
> + if (i == 0 || i == 2 || i == 3 ){
> + // Column 0, 2 and 3 (Dive #, Depth and Time) get 1/2 width
> + curwidth = curwidth + (maxwidth/7/2);
> + } else {
> + curwidth = curwidth + (maxwidth/7);
> + }
> + cairo_move_to(cr, curwidth, y);
> + cairo_line_to(cr, curwidth, y + h);
> + cairo_set_line_width (cr, 0.01);
> + cairo_stroke(cr);
> + }
> +
> cairo_translate(cr, x, y);
>
> /* Plus 5% on all sides */
> --
> 1.7.2.5
>
> _______________________________________________
> subsurface mailing list
> subsurface at hohndel.org
> http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface
--
Dirk Hohndel
Intel Open Source Technology Center
More information about the subsurface
mailing list