Rendering Arabic text with Pango & Cairo VS Pango & FreeType
- From: Nicolas Lacombe <n lacombe gmail com>
- To: gtk-i18n-list gnome org
- Subject: Rendering Arabic text with Pango & Cairo VS Pango & FreeType
- Date: Mon, 30 Nov 2009 15:48:35 +0100
Hi,
I want to use Pango high level functionnality to render arabic tex in a FreeType environnement.
Using Pango with Cairo, it works perfectly, the text is correctly rendered with ligatures typographic ligature.
However, in a freetype environnement, ligature disapear! I can still see the text, but only the original form of each glyph, thus without any contextual interpretation.
Am I doing anything wrong?
PANGO & CAIRO RENDERING (WORKING AS INTENDED)
cairo_surface_t *surface;
cairo_t *cr;
PangoLayout *layout;
surface = cairo_image_surface_create(CAIRO_FORMAT_A8, 512, 512);
cr = cairo_create(surface);
cairo_set_source_rgba(cr, 1., 1., 1., 0.0);
cairo_paint(cr);
layout = pango_cairo_create_layout(cr);
PangoFontDescription *desc;
desc = pango_font_description_from_string("Arial, 20");
pango_layout_set_font_description (layout, desc);
pango_font_description_free(desc);
pango_layout_set_text(layout, txt, -1);
cairo_set_line_width(cr, 0.5);
cairo_set_source_rgba(cr, 0.0, 0.0, 0.0, 1.0);
pango_cairo_update_layout(cr, layout);
pango_cairo_show_layout(cr, layout);
PANGO & FREETYPE RENDERING (no contextual analysis of the arabic text)
PangoContext *context;
PangoFontMap* PFM = pango_ft2_font_map_new();
pango_ft2_font_map_set_resolution(PANGO_FT2_FONT_MAP(PFM), width, height);
context = pango_font_map_create_context(PANGO_FONT_MAP(PFM));
FT_Bitmap* bm;
bm = g_slice_new(FT_Bitmap);
bm->rows = height;
bm->width = width;
bm->pitch = width;
bm->num_grays = 256;
bm->pixel_mode = FT_PIXEL_MODE_GRAY;
bm->buffer = (unsigned char*)g_malloc (bm->pitch * bm->rows);
memset(bm->buffer, 0x00, bm->pitch * bm->rows);
layout = pango_layout_new(context);
static PangoFontDescription *desc;
desc = pango_font_description_from_string("Arial, 20");
pango_layout_set_font_description(layout, desc);
pango_font_description_free(desc);
pango_layout_set_auto_dir (layout, 1);
pango_layout_set_text(layout, txt, -1);
pango_layout_context_changed(layout);
pango_ft2_render_layout(bm, layout, 0, 0);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]