-
-#if wxUSE_PANGO
- int ps_dpi = 72;
- int pango_dpi = 600;
- PangoContext *context = pango_ft2_get_context ( pango_dpi, pango_dpi );
-
- double scale = (double)pango_dpi / (double)ps_dpi;
- scale /= m_userScaleY;
-
- pango_context_set_language (context, pango_language_from_string ("en_US"));
- pango_context_set_base_dir (context, PANGO_DIRECTION_LTR );
-
- pango_context_set_font_description (context, m_font.GetNativeFontInfo()->description );
-
- PangoLayout *layout = pango_layout_new (context);
-#if wxUSE_UNICODE
- wxCharBuffer buffer = wxConvUTF8.cWC2MB( text );
-#else
- wxCharBuffer buffer = wxConvUTF8.cWC2MB( wxConvLocal.cWX2WC( text ) );
-#endif
- pango_layout_set_text( layout, (const char*) buffer, strlen(buffer) );
-
- fprintf( m_pstream, "%%%% %s\n", (const char*)buffer );
-
- PangoRectangle rect;
- pango_layout_get_extents(layout, NULL, &rect);
-
- int xx = LogicalToDeviceX( x );
- int yy = LogicalToDeviceY( y );
-
- int xxx = xx * PANGO_SCALE;
- int yyy = yy * PANGO_SCALE - (int)(rect.height * 0.66 / scale); // Move down by estimated baseline. HACK.
-
-#define ps_kludge_factor 2.8
-
- // Loop over lines in layout
- int num_lines = pango_layout_get_line_count( layout );
- for (int i = 0; i < num_lines; i++)
- {
- PangoLayoutLine *line = pango_layout_get_line( layout, i );
-
- // width of glyphs already printed
- int all_width = 0;
-
- // Loop over runs in line
- GSList *runs_list = line->runs;
- while (runs_list)
- {
- PangoLayoutRun *run = (PangoLayoutRun*) runs_list->data;
- PangoItem *item = run->item;
- PangoGlyphString *glyphs = run->glyphs;
- PangoAnalysis *analysis = &item->analysis;
- PangoFont *font = analysis->font;
- FT_Face ft_face = pango_ft2_font_get_face(font);
-
- int num_glyphs = glyphs->num_glyphs;
- for (int glyph_idx = 0; glyph_idx < num_glyphs; glyph_idx++)
- {
- PangoGlyphGeometry geometry = glyphs->glyphs[glyph_idx].geometry;
- int pos_x = xxx + (int)((double)(all_width+geometry.x_offset) / scale);
- int pos_y = yyy + (int)((double)geometry.y_offset / scale );
- all_width += geometry.width;
-
- draw_bezier_outline( m_pstream, ft_face,
- (FT_UInt)(glyphs->glyphs[glyph_idx].glyph),
- pos_x / PANGO_SCALE,
- pos_y / PANGO_SCALE,
- 1.0/(ps_kludge_factor * scale * 26.6),
- 1.0/(ps_kludge_factor * scale * 26.6) );
- }
- runs_list = runs_list->next;
- }
- }