Fix wrong width for whitespaces when enabling CPI feature. (#857592)
This commit is contained in:
parent
a013fcef35
commit
28dbd1fc7f
86
paps-fix-tab-width.patch
Normal file
86
paps-fix-tab-width.patch
Normal file
@ -0,0 +1,86 @@
|
|||||||
|
From 0b53e86359211b18eb4bb38270324f303920a363 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Akira TAGOH <tagoh@redhat.com>
|
||||||
|
Date: Fri, 21 Sep 2012 16:16:38 +0900
|
||||||
|
Subject: [PATCH] Fix tab width issue when enabling CPI
|
||||||
|
|
||||||
|
---
|
||||||
|
src/libpaps.c | 40 +++++++++++++++++++++++++++++-----------
|
||||||
|
1 file changed, 29 insertions(+), 11 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/libpaps.c b/src/libpaps.c
|
||||||
|
index 1b80257..29d64b0 100644
|
||||||
|
--- a/src/libpaps.c
|
||||||
|
+++ b/src/libpaps.c
|
||||||
|
@@ -251,7 +251,6 @@ gchar *paps_layout_line_to_postscript_strdup(paps_t *paps_,
|
||||||
|
{
|
||||||
|
paps_private_t *paps = (paps_private_t*)paps_;
|
||||||
|
GString *layout_str = g_string_new("");
|
||||||
|
- gchar *ret_str;
|
||||||
|
|
||||||
|
add_line_to_postscript(paps,
|
||||||
|
layout_str,
|
||||||
|
@@ -259,10 +258,7 @@ gchar *paps_layout_line_to_postscript_strdup(paps_t *paps_,
|
||||||
|
pos_y,
|
||||||
|
layout_line);
|
||||||
|
|
||||||
|
- ret_str = layout_str->str;
|
||||||
|
- g_string_free(layout_str, FALSE);
|
||||||
|
-
|
||||||
|
- return ret_str;
|
||||||
|
+ return g_string_free(layout_str, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
@@ -408,9 +404,26 @@ static void draw_contour(paps_private_t *paps,
|
||||||
|
{
|
||||||
|
GSList *runs_list;
|
||||||
|
double scale = 72.0 / PANGO_SCALE / PAPS_DPI;
|
||||||
|
+ PangoGlyphUnit avg_width = 1;
|
||||||
|
|
||||||
|
g_string_append(layout_str, "(");
|
||||||
|
-
|
||||||
|
+
|
||||||
|
+ if (paps->cpi > 0.0L)
|
||||||
|
+ {
|
||||||
|
+ /* calculate approximate width per a character */
|
||||||
|
+ for (runs_list = pango_line->runs; runs_list != NULL; runs_list = g_slist_next(runs_list))
|
||||||
|
+ {
|
||||||
|
+ PangoLayoutRun *run = runs_list->data;
|
||||||
|
+ PangoGlyphString *glyphs = run->glyphs;
|
||||||
|
+ int i;
|
||||||
|
+
|
||||||
|
+ for (i = 0; i < glyphs->num_glyphs; i++)
|
||||||
|
+ {
|
||||||
|
+ if (glyphs->glyphs[i].glyph != PANGO_GLYPH_EMPTY)
|
||||||
|
+ avg_width = MAX (avg_width, glyphs->glyphs[i].geometry.width);
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
/* Loop over the runs and output font info */
|
||||||
|
runs_list = pango_line->runs;
|
||||||
|
double x_pos = line_start_pos_x;
|
||||||
|
@@ -433,11 +446,16 @@ static void draw_contour(paps_private_t *paps,
|
||||||
|
glyph_pos_x = x_pos + 1.0*geometry.x_offset * scale;
|
||||||
|
glyph_pos_y = line_start_pos_y - 1.0*geometry.y_offset * scale;
|
||||||
|
|
||||||
|
- if (paps->cpi > 0.0L) {
|
||||||
|
- x_pos += (1 / paps->cpi * 72.0);
|
||||||
|
- } else {
|
||||||
|
- x_pos += geometry.width * scale * paps->scale_x;
|
||||||
|
- }
|
||||||
|
+ if (paps->cpi > 0.0L)
|
||||||
|
+ {
|
||||||
|
+ int n = geometry.width / avg_width;
|
||||||
|
+
|
||||||
|
+ x_pos += ((double)n) * (1 / paps->cpi * 72.0);
|
||||||
|
+ }
|
||||||
|
+ else
|
||||||
|
+ {
|
||||||
|
+ x_pos += geometry.width * scale * paps->scale_x;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
if (glyphs->glyphs[glyph_idx].glyph == PANGO_GLYPH_EMPTY)
|
||||||
|
continue;
|
||||||
|
--
|
||||||
|
1.7.11.4
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
Name: paps
|
Name: paps
|
||||||
Version: 0.6.8
|
Version: 0.6.8
|
||||||
Release: 20%{?dist}
|
Release: 21%{?dist}
|
||||||
|
|
||||||
License: LGPLv2+
|
License: LGPLv2+
|
||||||
URL: http://paps.sourceforge.net/
|
URL: http://paps.sourceforge.net/
|
||||||
@ -25,6 +25,7 @@ Patch52: paps-dsc-compliant.patch
|
|||||||
Patch53: paps-autoconf262.patch
|
Patch53: paps-autoconf262.patch
|
||||||
Patch54: paps-fix-cpi.patch
|
Patch54: paps-fix-cpi.patch
|
||||||
Patch55: paps-fix-loop-in-split.patch
|
Patch55: paps-fix-loop-in-split.patch
|
||||||
|
Patch56: paps-fix-tab-width.patch
|
||||||
|
|
||||||
Summary: Plain Text to PostScript converter
|
Summary: Plain Text to PostScript converter
|
||||||
Group: Applications/Publishing
|
Group: Applications/Publishing
|
||||||
@ -63,6 +64,7 @@ applications using paps API.
|
|||||||
%patch53 -p1 -b .autoconf262
|
%patch53 -p1 -b .autoconf262
|
||||||
%patch54 -p1 -b .fixcpi
|
%patch54 -p1 -b .fixcpi
|
||||||
%patch55 -p1 -b .loop
|
%patch55 -p1 -b .loop
|
||||||
|
%patch56 -p1 -b .tab
|
||||||
libtoolize -f -c
|
libtoolize -f -c
|
||||||
autoreconf
|
autoreconf
|
||||||
|
|
||||||
@ -113,6 +115,9 @@ rm -rf $RPM_BUILD_ROOT
|
|||||||
%{_libdir}/libpaps.so
|
%{_libdir}/libpaps.so
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Fri Sep 21 2012 Akira TAGOH <tagoh@redhat.com> - 0.6.8-21
|
||||||
|
- Fix wrong width for whitespaces when enabling CPI feature. (#857592)
|
||||||
|
|
||||||
* Thu Sep 6 2012 Akira TAGOH <tagoh@redhat.com> - 0.6.8-20
|
* Thu Sep 6 2012 Akira TAGOH <tagoh@redhat.com> - 0.6.8-20
|
||||||
- Add a missing description of --encoding in manpage. (#854897)
|
- Add a missing description of --encoding in manpage. (#854897)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user