Exemple #1
0
        public Pango.Font GetFont(uint wc)
        {
            IntPtr raw_ret = pango_fontset_get_font(Handle, wc);

            Pango.Font ret = GLib.Object.GetObject(raw_ret) as Pango.Font;
            return(ret);
        }
Exemple #2
0
        public Pango.Font LoadFont(Pango.FontDescription desc)
        {
            IntPtr raw_ret = pango_context_load_font(Handle, desc == null ? IntPtr.Zero : desc.Handle);

            Pango.Font ret = GLib.Object.GetObject(raw_ret) as Pango.Font;
            return(ret);
        }
        public void ExtentsRange(int start, int end, Pango.Font font, Pango.Rectangle ink_rect, Pango.Rectangle logical_rect)
        {
            IntPtr native_ink_rect     = GLib.Marshaller.StructureToPtrAlloc(ink_rect);
            IntPtr native_logical_rect = GLib.Marshaller.StructureToPtrAlloc(logical_rect);

            pango_glyph_string_extents_range(Handle, start, end, font == null ? IntPtr.Zero : font.Handle, native_ink_rect, native_logical_rect);
            Marshal.FreeHGlobal(native_ink_rect);
            Marshal.FreeHGlobal(native_logical_rect);
        }
Exemple #4
0
        private void InternalDrawGlyphs(Pango.Font font, Pango.GlyphString glyphs, int x, int y)
        {
            DrawGlyphsNativeDelegate unmanaged = class_abi.BaseOverride <DrawGlyphsNativeDelegate>(this.LookupGType(), "draw_glyphs");

            if (unmanaged == null)
            {
                return;
            }

            unmanaged(this.Handle, font == null ? IntPtr.Zero : font.Handle, glyphs == null ? IntPtr.Zero : glyphs.Handle, x, y);
        }
Exemple #5
0
        private void InternalDrawGlyph(Pango.Font font, uint glyph, double x, double y)
        {
            DrawGlyphNativeDelegate unmanaged = class_abi.BaseOverride <DrawGlyphNativeDelegate>(this.LookupGType(), "draw_glyph");

            if (unmanaged == null)
            {
                return;
            }

            unmanaged(this.Handle, font == null ? IntPtr.Zero : font.Handle, glyph, x, y);
        }
Exemple #6
0
        private void InternalDrawGlyphs(Pango.Font font, Pango.GlyphString glyphs, int x, int y)
        {
            DrawGlyphsNativeDelegate unmanaged = null;

            unsafe {
                IntPtr *raw_ptr = (IntPtr *)(((long)this.LookupGType().GetThresholdType().GetClassPtr()) + (long)class_abi.GetFieldOffset("draw_glyphs"));
                unmanaged = (DrawGlyphsNativeDelegate)Marshal.GetDelegateForFunctionPointer(*raw_ptr, typeof(DrawGlyphsNativeDelegate));
            }
            if (unmanaged == null)
            {
                return;
            }

            unmanaged(this.Handle, font == null ? IntPtr.Zero : font.Handle, glyphs == null ? IntPtr.Zero : glyphs.Handle, x, y);
        }
Exemple #7
0
 public void DrawGlyphs(Pango.Font font, Pango.GlyphString glyphs, int x, int y)
 {
     pango_renderer_draw_glyphs(Handle, font == null ? IntPtr.Zero : font.Handle, glyphs == null ? IntPtr.Zero : glyphs.Handle, x, y);
 }
Exemple #8
0
 public void DrawGlyph(Pango.Font font, uint glyph, double x, double y)
 {
     pango_renderer_draw_glyph(Handle, font == null ? IntPtr.Zero : font.Handle, glyph, x, y);
 }
Exemple #9
0
 protected virtual void OnDrawGlyphs(Pango.Font font, Pango.GlyphString glyphs, int x, int y)
 {
     InternalDrawGlyphs(font, glyphs, x, y);
 }
Exemple #10
0
 protected virtual void OnDrawGlyph(Pango.Font font, uint glyph, double x, double y)
 {
     InternalDrawGlyph(font, glyph, x, y);
 }
Exemple #11
0
        bool InvokeNative(Pango.Fontset fontset, Pango.Font font)
        {
            bool __result = native_cb(fontset == null ? IntPtr.Zero : fontset.Handle, font == null ? IntPtr.Zero : font.Handle, __data);

            return(__result);
        }
Exemple #12
0
        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;
        }
Exemple #13
0
 public static void GlyphStringPath(Cairo.Context cr, Pango.Font font, Pango.GlyphString glyphs)
 {
     pango_cairo_glyph_string_path(cr == null ? IntPtr.Zero : cr.Handle, font == null ? IntPtr.Zero : font.Handle, glyphs == null ? IntPtr.Zero : glyphs.Handle);
 }