Re: gtk-i18n-list Digest, Vol 111, Issue 6



The attachment is .tar.gz file. After downloading the attachment, rename attachment.gz to attachment.tar.gz.


2013/7/13 <gtk-i18n-list-request gnome org>
Send gtk-i18n-list mailing list submissions to
        gtk-i18n-list gnome org

To subscribe or unsubscribe via the World Wide Web, visit
        https://mail.gnome.org/mailman/listinfo/gtk-i18n-list
or, via email, send a message with subject or body 'help' to
        gtk-i18n-list-request gnome org

You can reach the person managing the list at
        gtk-i18n-list-owner gnome org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of gtk-i18n-list digest..."


Today's Topics:

   1. segmentation fault when using pango inside evince backend
      (Hodong Kim)


----------------------------------------------------------------------

Message: 1
Date: Sat, 13 Jul 2013 00:27:31 +0900
From: Hodong Kim <cogniti gmail com>
To: gtk-i18n-list gnome org
Subject: segmentation fault when using pango inside evince backend
Message-ID:
        <CAFBu8hXo59Ga7xqYndz+ARH0PdC_wBmdqL2fLQ6V8FAWB9_f1Q mail gmail com>
Content-Type: text/plain; charset="utf-8"

Hello.

I am developing evince backend for hwp document file.
I want to apply pango layout to evince hwp backend.

so, I tried to apply "Example 1. Using Pango with Cairo"
(https://developer.gnome.org/pango/stable/pango-Cairo-Rendering.html)
to SAMPLE evince backend and EXAMPLE library.

/* Example 1. Using Pango with Cairo */
/* https://developer.gnome.org/pango/1.34/pango-Cairo-Rendering.html */
#include <math.h>
#include <pango/pangocairo.h>
static void
draw_text (cairo_t *cr)
{
#define RADIUS 150
#define N_WORDS 10
#define FONT "Sans Bold 27"
  PangoLayout *layout;
  PangoFontDescription *desc;
  int i;
  /* Center coordinates on the middle of the region we are drawing
   */
  cairo_translate (cr, RADIUS, RADIUS);
  /* Create a PangoLayout, set the font and text */
  layout = pango_cairo_create_layout (cr);
  pango_layout_set_text (layout, "Text", -1);
  desc = pango_font_description_from_string (FONT);
  pango_layout_set_font_description (layout, desc);
  pango_font_description_free (desc);
  /* Draw the layout N_WORDS times in a circle */
  for (i = 0; i < N_WORDS; i++)
    {
      int width, height;
      double angle = (360. * i) / N_WORDS;
      double red;
      cairo_save (cr);
      /* Gradient from red at angle == 60 to blue at angle == 240 */
      red   = (1 + cos ((angle - 60) * G_PI / 180.)) / 2;
      cairo_set_source_rgb (cr, red, 0, 1.0 - red);
      cairo_rotate (cr, angle * G_PI / 180.);
      /* Inform Pango to re-layout the text with the new transformation */
      pango_cairo_update_layout (cr, layout);
      pango_layout_get_size (layout, &width, &height);
      cairo_move_to (cr, - ((double)width / PANGO_SCALE) / 2, - RADIUS);
      pango_cairo_show_layout (cr, layout);
      cairo_restore (cr);
    }
  /* free the layout object */
  g_object_unref (layout);
}

gboolean example_page_render (ExamplePage *page, cairo_t *cr)
{
    g_return_val_if_fail (EXAMPLE_IS_PAGE (page), FALSE);
    draw_text (cr);
    return TRUE;
}

then opened the sample text file from the terminal with evince
but segmentation fault occurred intermittently.

I cannot understand the behavior that when I use cairo it works fine
but when I use pango segmentation fault occurs.

Is it because of pango_cairo_font_map_get_default() or thread ?
but considering ev_job_render_run (EvJob *job) in libview/ev-jobs.c

    ev_document_fc_mutex_lock ()
    ...
    job_render->surface = ev_document_render (job->document, rc);
    ...
    ev_document_fc_mutex_unlock ()

Although pango is thread-safe since 1.32.6
when I tested in pango 1.30.0 / 1.32.5 / 1.34.1 / 1.35.0
segmentation fault alse occurred in all cases.

I don't know why.
Please advise me how to do.

To test libexample and evince-sample-backend please follow the below steps.

Step 1. Downloads the attachment and extract.

evince-sample-backend and libexample will be created.

Step 2. compile and install libexample

cd libexample
./autogen.sh
make
sudo make install
sudo ldconfig
cd ..

Step 3. compile and install evince-sample-backend

cd evince-sample-backend
./autogen.sh
make
sudo make install
sudo ldconfig

Step 4. open the any text file from the terminal with evince many times.

$ evince any.txt


My current environment:
debian wheezy
evince          3.4.0-3.1
libpango1.0-0   1.30.0-1
libcairo2       1.12.2-3
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.gnome.org/archives/gtk-i18n-list/attachments/20130713/0a7d09c9/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: projects.tar.gz
Type: application/x-gzip
Size: 23386 bytes
Desc: not available
URL: <https://mail.gnome.org/archives/gtk-i18n-list/attachments/20130713/0a7d09c9/attachment.gz>

------------------------------

Subject: Digest Footer

_______________________________________________
gtk-i18n-list mailing list
gtk-i18n-list gnome org
https://mail.gnome.org/mailman/listinfo/gtk-i18n-list


------------------------------

End of gtk-i18n-list Digest, Vol 111, Issue 6
*********************************************



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]