public Pango.Fontset LoadFontset(Pango.FontDescription desc, Pango.Language language) { IntPtr raw_ret = pango_context_load_fontset(Handle, desc == null ? IntPtr.Zero : desc.Handle, language == null ? IntPtr.Zero : language.Handle); Pango.Fontset ret = GLib.Object.GetObject(raw_ret) as Pango.Fontset; return(ret); }
public static Pango.Language ScriptGetSampleLanguage(Pango.Script script) { IntPtr raw_ret = pango_script_get_sample_language((int)script); Pango.Language ret = raw_ret == IntPtr.Zero ? null : (Pango.Language)GLib.Opaque.GetOpaque(raw_ret, typeof(Pango.Language), false); return(ret); }
public Pango.FontMetrics GetMetrics(Pango.FontDescription desc, Pango.Language language) { IntPtr raw_ret = pango_context_get_metrics(Handle, desc == null ? IntPtr.Zero : desc.Handle, language == null ? IntPtr.Zero : language.Handle); Pango.FontMetrics ret = raw_ret == IntPtr.Zero ? null : (Pango.FontMetrics)GLib.Opaque.GetOpaque(raw_ret, typeof(Pango.FontMetrics), false); return(ret); }
public Pango.Coverage GetCoverage(Pango.Language language) { IntPtr raw_ret = pango_font_get_coverage(Handle, language == null ? IntPtr.Zero : language.Handle); Pango.Coverage ret = raw_ret == IntPtr.Zero ? null : (Pango.Coverage)GLib.Opaque.GetOpaque(raw_ret, typeof(Pango.Coverage), false); return(ret); }
public Pango.EngineShape FindShaper(Pango.Language language, uint ch) { IntPtr raw_ret = pango_font_find_shaper(Handle, language == null ? IntPtr.Zero : language.Handle, ch); Pango.EngineShape ret = raw_ret == IntPtr.Zero ? null : (Pango.EngineShape)GLib.Opaque.GetOpaque(raw_ret, typeof(Pango.EngineShape), false); return(ret); }
public static Pango.Language FromString(string language) { IntPtr native_language = GLib.Marshaller.StringToPtrGStrdup(language); IntPtr raw_ret = pango_language_from_string(native_language); Pango.Language ret = raw_ret == IntPtr.Zero ? null : (Pango.Language)GLib.Opaque.GetOpaque(raw_ret, typeof(Pango.Language), false); GLib.Marshaller.Free(native_language); return(ret); }
public static void GetLogAttrs(string text, int level, Pango.Language language, Pango.LogAttr log_attrs, int attrs_len) { IntPtr native_text = GLib.Marshaller.StringToPtrGStrdup(text); IntPtr native_log_attrs = GLib.Marshaller.StructureToPtrAlloc(log_attrs); pango_get_log_attrs(native_text, System.Text.Encoding.UTF8.GetByteCount(text), level, language == null ? IntPtr.Zero : language.Handle, native_log_attrs, attrs_len); GLib.Marshaller.Free(native_text); Marshal.FreeHGlobal(native_log_attrs); }
public void GetFont(out Pango.FontDescription desc, out Pango.Language language, out Pango.Attribute[] extra_attrs) { desc = new FontDescription(); IntPtr language_handle, list_handle; pango_attr_iterator_get_font(Handle, desc.Handle, out language_handle, out list_handle); desc.Family = desc.Family; // change static string to allocated one language = language_handle == IntPtr.Zero ? null : new Language(language_handle); if (list_handle == IntPtr.Zero) { extra_attrs = new Pango.Attribute [0]; return; } GLib.SList list = new GLib.SList(list_handle); extra_attrs = new Pango.Attribute [list.Count]; int i = 0; foreach (IntPtr raw_attr in list) { extra_attrs [i++] = Pango.Attribute.GetAttribute(raw_attr); } }
public AttrLanguage(Pango.Language language) : this(pango_attr_language_new(language.Handle)) { }
public void DrawText(int x, int y, String text, TextAlign align) { Pango.FontDescription fd = Pango.FontDescription.FromString(FontFamily); fd.Size = Pango.Units.FromPixels(FontSize); if ((FontStyle & FontStyle.Bold) != 0) { fd.Weight = Pango.Weight.Bold; } if ((FontStyle & FontStyle.Italic) != 0) { fd.Style = Pango.Style.Italic; } Pango.Font font = parent.PangoContext.LoadFont(fd); Pango.Language lang = Pango.Language.FromString("en"); Pango.FontMetrics metrics = font.GetMetrics(lang); int estWidth = text.Length * metrics.ApproximateCharWidth * 3 / 2; Pango.Context pango = parent.PangoContext; Pango.Layout layout = new Pango.Layout(pango) { Width = estWidth, Wrap = Pango.WrapMode.Word, Alignment = Pango.Alignment.Left, FontDescription = fd }; int color = this.Color; ushort cRed = (ushort)((color >> 16) & 0xFF); ushort cGreen = (ushort)((color >> 8) & 0xFF); ushort cBlue = (ushort)(color & 0xFF); layout.Attributes = new Pango.AttrList(); layout.Attributes.Insert(new Pango.AttrForeground(cRed, cGreen, cBlue)); layout.SetText(text); double x0; double y0; double scale = 1.0 / Pango.Scale.PangoScale; Pango.Rectangle dummy; Pango.Rectangle extents; layout.GetExtents(out dummy, out extents); switch ((TextAlign)((int)align & 7)) { case TextAlign.Right: x0 = x - scale * extents.Width; break; case TextAlign.Center: x0 = x - 0.5 * scale * extents.Width; break; default: x0 = x; break; } switch ((TextAlign)((int)align & ~7)) { case TextAlign.Top: y0 = y; break; case TextAlign.Bottom: y0 = y - scale * (metrics.Ascent + metrics.Descent); break; case TextAlign.VCenter: y0 = y - 0.5 * scale * metrics.Ascent; break; default: y0 = y - scale * metrics.Ascent; break; } Matrix srcM = Context.Matrix; Pango.Matrix dstM; dstM.X0 = 0.0; dstM.Xx = srcM.Xx; dstM.Xy = srcM.Xy; dstM.Y0 = 0.0; dstM.Yx = srcM.Yx; dstM.Yy = srcM.Yy; parent.PangoContext.Matrix = dstM; srcM.TransformPoint(ref x0, ref y0); parent.GdkWindow.DrawLayout(parent.Style.TextGC(StateType.Normal), (int)(0.5 + x0), (int)(0.5 + y0), layout); dstM.Xx = 1.0; dstM.Yy = 1.0; parent.PangoContext.Matrix = dstM; }