Ok lets try another approach. I am not sure if I undestood the advices correctly.
Right now I run my configure --with-included-modules=yes , so by default pango choses one of the modules already installed based on language script? pango_module_register() requires PangoIncludedModule. How should I "link" my code to PangoIncludedModule object, does that require creating another PangoEngine? 2012/3/7 Behdad Esfahbod <[email protected]> > On 03/07/2012 10:50 AM, Mindaugas Jaunius wrote: > > Would it be possible for somebody to provide an example or a link to > > example of how to use pango_module_register()? I tried looking for any > > example, but was not able to find one. I am new at using pango and > > from very beginning I see a lack of any examples of how to actualy use > > it. > > The only example I know of is Pango source code itself. > > behdad > > > > > 2012/3/6 Behdad Esfahbod <[email protected]>: > >> You have a better luck just copying basic-fc.c and modifying it, and > either > >> installing your module on the system or register it using > pango_module_register(). > >> > >> behdad > >> > >> On 03/01/2012 08:28 AM, Mindaugas Jaunius wrote: > >>> Hi, > >>> > >>> To be able to fully control open type font features (liga, smcp, ssup) > >>> I ended up using PangoOTBuffer not just PangoLayout. No the problem I > >>> run into is that the output of PangoOTBuffer is PangoGlyphString. The > >>> only function I found to show it is pango_cairo_show_glyph_string(cr, > >>> font, glyphString), but this function shows the full PangoGlyphString > >>> in one line and does not create a wraping paragraph on PangoLayout. No > >>> is there a way to give my PangoGlyphString from PangoOTBuffer to > >>> PangoLayout? > >>> > >>> Below is some code of how I am using PangoOTBuffer now. Mainly I used > >>> code from pango modules class basic-fc.c as an example. Any comments > >>> and critiques on the code are welcomed. > >>> > >>> const char foo[] = "ffi ff fl Wa VA"; > >>> > >>> static const PangoOTFeatureMap gsub_features[] = > >>> { > >>> {"ccmp", PANGO_OT_ALL_GLYPHS}, > >>> {"locl", PANGO_OT_ALL_GLYPHS}, > >>> {"liga", PANGO_OT_ALL_GLYPHS}, > >>> {"clig", PANGO_OT_ALL_GLYPHS} > >>> }; > >>> > >>> static const PangoOTFeatureMap gpos_features[] = > >>> { > >>> {"kern", PANGO_OT_ALL_GLYPHS}, > >>> {"mark", PANGO_OT_ALL_GLYPHS}, > >>> {"mkmk", PANGO_OT_ALL_GLYPHS} > >>> }; > >>> > >>> cairo_t *cr = cairo_create(surface); > >>> cairo_set_source_rgb(cr, 1.0, 1.0, 1.0); // sets the background color > to white > >>> cairo_paint(cr); > >>> > >>> PangoLayout *layout; // layout for a paragraph of text > >>> layout = pango_cairo_create_layout(cr); > >>> > >>> PangoFontDescription *descFont; > >>> pango_layout_set_text(layout, foo, -1); > >>> pango_layout_set_width(layout, width * PANGO_SCALE); > >>> descFont = pango_font_description_from_string("Fedra Serif Pro A Book > 20"); > >>> pango_layout_set_font_description(layout, descFont); > >>> pango_font_description_free(descFont); > >>> > >>> cairo_move_to(cr, 20, 40); > >>> cairo_set_line_width(cr, 1.0); // sets the line width, default is 2.0 > >>> > >>> cairo_set_source_rgb(cr, 0.0, 0.0, 0.0); // set the colour to black > >>> > >>> pango_cairo_update_layout(cr, layout); // update layout > >>> > >>> PangoLayoutIter *iter = NULL; > >>> iter = pango_layout_get_iter(layout); > >>> > >>> PangoLayoutRun *run = NULL; > >>> run = pango_layout_iter_get_run_readonly(iter); > >>> > >>> PangoFont *font = run->item->analysis.font; // get PangoFont of Fedra > Serif > >>> > >>> PangoFcFont *fc_font = PANGO_FC_FONT(font); > >>> > >>> PangoOTBuffer *otBuffer; > >>> otBuffer = pango_ot_buffer_new(fc_font); > >>> > >>> glong n_chars = g_utf8_strlen(foo, strlen(foo)); > >>> PangoGlyphString *glyphs = pango_glyph_string_new(); > >>> > >>> const char *p = foo; > >>> int cluster = 0; > >>> int i; > >>> FT_Face face; > >>> PangoOTRulesetDescription desc; > >>> const PangoOTRuleset *ruleset; > >>> > >>> face = pango_fc_font_lock_face(fc_font); > >>> if (!face) { > >>> LOGE("Can not lock fc font face"); > >>> } > >>> > >>> // add all glyphs to otBuffer > >>> for (i = 0; i < n_chars; i++) { > >>> gunichar wc; > >>> PangoGlyph glyph; > >>> > >>> wc = g_utf8_get_char(p); > >>> > >>> if (g_unichar_type(wc) != G_UNICODE_NON_SPACING_MARK) > >>> cluster = p - foo1; > >>> > >>> if (pango_is_zero_width(wc)) > >>> glyph = PANGO_GLYPH_EMPTY; > >>> else { > >>> gunichar c = wc; > >>> > >>> if (run->item->analysis.level % 2) > >>> g_unichar_get_mirror_char(c, &c); > >>> > >>> glyph = pango_fc_font_get_glyph(fc_font, c); > >>> } > >>> > >>> if (!glyph) > >>> glyph = PANGO_GET_UNKNOWN_GLYPH(wc); > >>> > >>> pango_ot_buffer_add_glyph(otBuffer, glyph, 0, cluster); > >>> > >>> p = g_utf8_next_char(p); > >>> } > >>> > >>> // apply open type features > >>> desc.script = run->item->analysis.script; > >>> desc.language = run->item->analysis.language; > >>> desc.n_static_gsub_features = G_N_ELEMENTS(gsub_features); > >>> desc.static_gsub_features = gsub_features; > >>> desc.n_static_gpos_features = G_N_ELEMENTS(gpos_features); > >>> desc.static_gpos_features = gpos_features; > >>> desc.n_other_features = 0; > >>> desc.other_features = NULL; > >>> > >>> ruleset = > pango_ot_ruleset_get_for_description(pango_ot_info_get(face), &desc); > >>> > >>> pango_ot_ruleset_substitute(ruleset, otBuffer); > >>> pango_ot_ruleset_position(ruleset, otBuffer); > >>> > >>> // output from otBuffer to PangoGlyphString > >>> pango_ot_buffer_output(otBuffer, glyphs); > >>> > >>> pango_cairo_show_glyph_string(cr, font, glyphs); > >>> > >>> -mindaugas > >>> _______________________________________________ > >>> gtk-i18n-list mailing list > >>> [email protected] > >>> http://mail.gnome.org/mailman/listinfo/gtk-i18n-list > >>> > > >
_______________________________________________ gtk-i18n-list mailing list [email protected] http://mail.gnome.org/mailman/listinfo/gtk-i18n-list
