From 5259bbe81c526cc1b6be6e1a70d7b50794ed87dc Mon Sep 17 00:00:00 2001 From: Jose Medrano Date: Tue, 27 Nov 2018 20:15:42 +0100 Subject: [PATCH] Adds font Size handling in span tag over GTK backend --- Xwt.Gtk/Xwt.GtkBackend/GtkInterop.cs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Xwt.Gtk/Xwt.GtkBackend/GtkInterop.cs b/Xwt.Gtk/Xwt.GtkBackend/GtkInterop.cs index edcf3030..8d2f9bd5 100644 --- a/Xwt.Gtk/Xwt.GtkBackend/GtkInterop.cs +++ b/Xwt.Gtk/Xwt.GtkBackend/GtkInterop.cs @@ -61,6 +61,8 @@ namespace Xwt.GtkBackend /// internal class FastPangoAttrList : IDisposable { + const float PangoScale = 1024; + IntPtr list; public Gdk.Color DefaultLinkColor = Toolkit.CurrentEngine.Defaults.FallbackLinkColor.ToGtkValue (); @@ -91,7 +93,11 @@ namespace Xwt.GtkBackend else if (attr is FontWeightTextAttribute) { var xa = (FontWeightTextAttribute)attr; AddWeightAttribute ((Pango.Weight)(int)xa.Weight, start, end); - } + } + else if (attr is FontSizeTextAttribute) { + var xa = (FontSizeTextAttribute)attr; + AddFontSizeAttribute ((int) (xa.Size * PangoScale), start, end); + } else if (attr is FontStyleTextAttribute) { var xa = (FontStyleTextAttribute)attr; AddStyleAttribute ((Pango.Style)(int)xa.Style, start, end); @@ -149,6 +155,11 @@ namespace Xwt.GtkBackend Add (pango_attr_strikethrough_new (strikethrough), start, end); } + public void AddFontSizeAttribute (int size, uint start, uint end) + { + Add (pango_attr_size_new_absolute (size), start, end); + } + public void AddFontAttribute (Pango.FontDescription font, uint start, uint end) { Add (pango_attr_font_desc_new (font.Handle), start, end); @@ -164,6 +175,9 @@ namespace Xwt.GtkBackend pango_attr_list_insert (list, attribute); } + [DllImport (GtkInterop.LIBPANGO, CallingConvention = CallingConvention.Cdecl)] + static extern IntPtr pango_attr_size_new_absolute (int size); + [DllImport (GtkInterop.LIBPANGO, CallingConvention=CallingConvention.Cdecl)] static extern IntPtr pango_attr_style_new (Pango.Style style);