public FormattedTextImpl( Pango.Context context, string text, string fontFamily, double fontSize, FontStyle fontStyle, TextAlignment textAlignment, FontWeight fontWeight) { Contract.Requires <ArgumentNullException>(context != null); Contract.Requires <ArgumentNullException>(text != null); Layout = new Pango.Layout(context); _text = text; Layout.SetText(text); Layout.FontDescription = new Pango.FontDescription { Family = fontFamily, Size = Pango.Units.FromDouble(CorrectScale(fontSize)), Style = (Pango.Style)fontStyle, Weight = fontWeight.ToCairo() }; Layout.Alignment = textAlignment.ToCairo(); Layout.Attributes = new Pango.AttrList(); }
public FormattedTextImpl( Pango.Context context, string text, string fontFamily, double fontSize, FontStyle fontStyle, TextAlignment textAlignment, FontWeight fontWeight) { Contract.Requires<ArgumentNullException>(context != null); Contract.Requires<ArgumentNullException>(text != null); Layout = new Pango.Layout(context); _text = text; Layout.SetText(text); Layout.FontDescription = new Pango.FontDescription { Family = fontFamily, Size = Pango.Units.FromDouble(CorrectScale(fontSize)), Style = (Pango.Style)fontStyle, Weight = fontWeight.ToCairo() }; Layout.Alignment = textAlignment.ToCairo(); Layout.Attributes = new Pango.AttrList(); }
public FormattedTextImpl( Pango.Context context, string text, Typeface typeface, TextAlignment textAlignment, TextWrapping wrapping, Size constraint, IReadOnlyList <FormattedTextStyleSpan> spans) { Contract.Requires <ArgumentNullException>(context != null); Contract.Requires <ArgumentNullException>(text != null); Layout = new Pango.Layout(context); Layout.SetText(text); Layout.FontDescription = new Pango.FontDescription { Family = typeface?.FontFamilyName ?? "monospace", Size = Pango.Units.FromDouble(CorrectScale(typeface?.FontSize ?? 12)), Style = (Pango.Style)(typeface?.Style ?? FontStyle.Normal), Weight = (typeface?.Weight ?? FontWeight.Normal).ToCairo(), }; Layout.Alignment = textAlignment.ToCairo(); Layout.Attributes = new Pango.AttrList(); Layout.Width = double.IsPositiveInfinity(constraint.Width) ? -1 : Pango.Units.FromDouble(constraint.Width); if (spans != null) { foreach (var span in spans) { if (span.ForegroundBrush is SolidColorBrush scb) { var color = new Pango.Color(); color.Parse(string.Format("#{0}", scb.Color.ToString().Substring(3))); var brushAttr = new Pango.AttrForeground(color); brushAttr.StartIndex = (uint)TextIndexToPangoIndex(span.StartIndex); brushAttr.EndIndex = (uint)TextIndexToPangoIndex(span.StartIndex + span.Length); this.Layout.Attributes.Insert(brushAttr); } } } Size = Measure(); }
public FormattedTextImpl( string text, string fontFamily, double fontSize, FontStyle fontStyle, TextAlignment textAlignment, FontWeight fontWeight) { var context = Locator.Current.GetService<Pango.Context>(); this.Layout = new Pango.Layout(context); this.Layout.SetText(text); this.Layout.FontDescription = new Pango.FontDescription { Family = fontFamily, Size = Pango.Units.FromDouble(fontSize * 0.73), Style = (Pango.Style)fontStyle, Weight = fontWeight.ToCairo() }; this.Layout.Alignment = textAlignment.ToCairo(); }
public FormattedTextImpl( string text, string fontFamily, double fontSize, FontStyle fontStyle, TextAlignment textAlignment, FontWeight fontWeight) { var context = Locator.Current.GetService <Pango.Context>(); Layout = new Pango.Layout(context); Layout.SetText(text); Layout.FontDescription = new Pango.FontDescription { Family = fontFamily, Size = Pango.Units.FromDouble(fontSize * 0.73), Style = (Pango.Style)fontStyle, Weight = fontWeight.ToCairo() }; Layout.Alignment = textAlignment.ToCairo(); }