2013-07-31 06:45:17 +00:00
|
|
|
@@ -, +, @@
|
2012-09-21 07:21:57 +00:00
|
|
|
---
|
|
|
|
src/libpaps.c | 40 +++++++++++++++++++++++++++++-----------
|
|
|
|
1 file changed, 29 insertions(+), 11 deletions(-)
|
2013-07-31 06:45:17 +00:00
|
|
|
--- a/src/libpaps.c
|
|
|
|
+++ a/src/libpaps.c
|
2012-09-21 07:21:57 +00:00
|
|
|
@@ -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)
|
|
|
|
+ {
|
2013-07-31 06:45:17 +00:00
|
|
|
+ double n = ((double)geometry.width) / avg_width;
|
2012-09-21 07:21:57 +00:00
|
|
|
+
|
2013-07-31 06:45:17 +00:00
|
|
|
+ x_pos += n * (1 / paps->cpi * 72.0);
|
2012-09-21 07:21:57 +00:00
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ x_pos += geometry.width * scale * paps->scale_x;
|
|
|
|
+ }
|
|
|
|
|
|
|
|
if (glyphs->glyphs[glyph_idx].glyph == PANGO_GLYPH_EMPTY)
|
|
|
|
continue;
|
|
|
|
--
|