void UpdateLayout(string text, double width, double?height, bool forceWidth) { if (text != last_text) { last_formatted_text = GetFormattedText(text) ?? ""; last_text = text; if (TextWrap == TextWrap.None && last_formatted_text.IndexOfAny(lfcr) >= 0) { last_formatted_text = last_formatted_text.Replace("\r\n", "\x20").Replace('\n', '\x20').Replace('\r', '\x20'); } } var wrap = TextWrap; layout.Width = wrap != TextWrap.None || forceWidth ? (int)(Pango.Scale.PangoScale * width) : -1; layout.Wrap = GetPangoWrapMode(wrap); if (height != null && wrap != TextWrap.None) { layout.SetHeight((int)(Pango.Scale.PangoScale * height.Value)); } font_desc.Weight = GetPangoFontWeight(FontWeight); layout.SingleParagraphMode = wrap == TextWrap.None; layout.Ellipsize = EllipsizeMode; if (UseMarkup) { layout.SetMarkup(last_formatted_text); } else { layout.SetText(last_formatted_text); } }