Problem using Pango with .Net



Hello!

When using Pango in C# (MS Visual Studio), I encountered several strange
problems that I cannot explain. It is 80% sure that I've made some
mistake implementing Pango binding for C#. Does anyone has such experience?

The following code works fine until I try to make some special changes.
In particular, there are two problems.

1) pango_font_description_set_size doesn't work.
Moreover, whenever I try to call this method, boxes appear instead of
letters.
The funny thing is that pango_font_description_from_string works fine.
At present, I change font size by putting needed value into the string
parameter. :-)

2) Whenever I try to call pango_matrix_rotate, boxes appear instead of
letters. Also, pango_context_set_matrix doesn't seem to work.


(The below code is simplified a little bit for readability).

// This is how I implemented some dll bindings
[DllImport(pango)]
public static extern void pango_matrix_rotate(
[In, MarshalAs(UnmanagedType.LPStruct)]
PangoMatrix pango_matrix,
double degrees);

[DllImport(pango)]
public static extern void pango_context_set_matrix(
IntPtr pango_context,
[In, MarshalAs(UnmanagedType.LPStruct)]
PangoMatrix pango_matrix);

[DllImport(pango)]
public static extern void pango_font_description_set_size(IntPtr
font_description, double font_size);
// . . . and so on . . .

// This is how I implemented PangoMatrix object
[StructLayout(LayoutKind.Sequential)]
class PangoMatrix
{
public PangoMatrix()
{
Xx = 1; Xy = 0; Yx = 0;
Yy = 1; X0 = 0; Y0 = 0;
}
public double Xx;
public double Xy;
public double Yx;
public double Yy;
public double X0;
public double Y0;
}

// This is implementation of PangoGravity enum
[Serializable]
public enum PangoGravity
{
South, East, North, West, Auto
}

// Main code from here //

pangoContext = pango_cairo_create_context(cairoContext);
pango_cairo_context_set_font_options(pangoContext, cairoFontOptions);
pangoFont = pango_font_description_from_string("Serif Normal 20");

// This line causes problem
pango_font_description_set_size(pangoFont, newSize)

pangoLayout = pango_layout_new(pangoContext);

// Change the pango gravity to draw vertical text
pango_context_set_base_gravity(pangoContext, PangoGravity.Auto);
PangoMatrix matrix = new PangoMatrix();

// This line also causes problem
pango_matrix_rotate(matrix, 90);

// This line doesn't seem to work
pango_context_set_matrix(pangoContext, matrix);

pango_layout_context_changed(pangoLayout);

pango_layout_set_font_description(pangoLayout, pangoFont);
pango_layout_set_text(pangoLayout, someText, -1);

pango_cairo_show_layout(cairoContext, pangoLayout);

// END of code //


Thanks for any advice.

Evgeny



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]