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 hwp backend, #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 ghwp_page_render (GHWPPage *page, cairo_t *cr) { g_return_val_if_fail (page != NULL, FALSE); g_return_val_if_fail (cr != NULL, FALSE); draw_text (cr); return TRUE; } then opened the hwp file from the terminal with evince but segmentation fault occurred intermittently. I cannot understand the behavior that when I use cairo (master branch) it works fine but when I use pango (experimental branch) 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 () Because 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. ----- Please see the below about hwp document. http://en.wikipedia.org/wiki/Hangul_%28word_processor%29 To test libghwp and evince-hwp backend plese follow the below steps. Step 1. install libghwp git clone https://github.com/cogniti/libghwp.git cd libghwp git checkout experimental ./autogen.sh make sudo make install sudo ldconfig Step 2. install evince-hwp git clone https://github.com/cogniti/evince-hwp.git cd evince-hwp git checkout experimental ./autogen.sh make sudo make install sudo ldconfig Step 3. open the sample hwp file (kreg1.hwp) from the terminal with evince. wget https://github.com/cogniti/ruby-hwp/raw/master/samples/kreg1.hwp $ evince kreg1.hwp My current environment: debian wheezy evince 3.4.0-3.1 libpango1.0-0 1.30.0-1 libcairo2 1.12.2-3
Attachment:
kreg1.hwp
Description: Binary data