Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Problem displaying Unicode characters in Pango/Cairo/DirectFB

Posted on 2011-02-23
3
Medium Priority
?
1,224 Views
Last Modified: 2012-05-11
I have an issue while displaying some Japanese characters using Pango. First few times the text comes properly, and after that I see the junk characters. It looks as if the correct characters are displayed, and are overwritten by something else. I have ensured that the string that we are passing to pango_layout_set_markup() is correct. So I am suspecting some internal setting in Pango/Cairo/DirectFB is causing the problem. I may be missing setting something to NULL, freeing something or alike. The sequence of calls I am having is listed below. Can anyone please look at this and see what is wrong with this?

Thanks in advance

/*********** During initialization ***********/
// Initialize DirectFB
DirectFBInit(&argc, &argv);

// Create DirectFB instance
DirectFBCreate(&dfb);

/*********** For each set of texts ***********/
// Get the DirectFB layer
dfb->GetDisplayLayer(dfb, DLID_PRIMARY, &layer);

// Create DirectFB window
layer->CreateWindow(layer, &wDesc, &window);

// Get DirectFB surface
window->GetSurface(window, &surface);

// Create Cairo surface on DirectFB surface.
cairo_surface = cairo_directfb_surface_create(dfb, surface);

// Get Cairo handle
pCrHandle = cairo_create(cairo_surface);

/*********** For each Text information ***********/
// Get Pango Layout using Cairo handle
layout = pango_cairo_create_layout(pCrHandle);

// Set Text
pango_layout_set_markup(layout, string, -1);

// Show the layout
pango_cairo_show_layout(pCrHandle, layout);

// Free the layout
g_object_unref(layout);

/*********** End of Text information ***********/

// Destroy Cairo handle
cairo_destroy(pCrHandle);

// Destroy Cairo surface
cairo_surface_destroy(cairo_surface);

// Release DirectFB surface
surface->Release(surface);

// Destroy DirectFB window
window->Destroy(window);

// Reset DirectFB layer
layer = NULL;

/*********** End of set ***********/

Open in new window

0
Comment
Question by:Harisha M G
  • 2
3 Comments
 
LVL 3

Expert Comment

by:xelous
ID: 35400455
I'm not sure whats going on with your code specifically, however, if the layout engine you are using is written, or derived from, C and it compiled multi-byte everytime a unicode character with a leading byte of zero (0) is encountered it'll ignore that byte and junk the other.

Make sure you are sending two byte cuplets as characters, and further make sure the layout engine supports the unicode correctly.

If in doubt you may need to fudge things over by sending the two bytes of the unicode character (short) together and processing the ones over and above the first page (255) to offset to the correct unicode character yourself...

Failing all that, if you are building [as in compiling from code] your layout engine yourself try to switch the project to "unicode" in the options.  If you're just using an off the shelf library however it can be difficult to work out what byte encoding they're using.

Hope you find the answer out there somewhere, I'm just pointing out the obvious...
0
 
LVL 37

Accepted Solution

by:
Harisha M G earned 0 total points
ID: 35496949
Finally I found that it is a bug in the Pango library itself, and have raised it in the pango bug tracker.
https://bugzilla.gnome.org/show_bug.cgi?id=644716
0
 
LVL 37

Author Closing Comment

by:Harisha M G
ID: 35696329
The problem wasn't solved, and I found that it's a bug with Pango library itself.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
I have written articles previously comparing SARDU and YUMI.  I also included a couple of lines about Easy2boot (easy2boot.com).  I have now been using, and enjoying easy2boot as my sole multiboot utility for some years and realize that it deserves …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
Suggested Courses
Course of the Month11 days, 18 hours left to enroll

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question