public async Task UnsettingSingleLineBreakModeResetsMaxLines(LineBreakMode newMode) { var label = new LabelStub() { Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit", MaxLines = 3, LineBreakMode = LineBreakMode.WordWrap, }; var handler = await CreateHandlerAsync(label); var nativeLabel = GetNativeLabel(handler); await InvokeOnMainThreadAsync(() => { Assert.Equal(3, GetNativeMaxLines(handler)); Assert.Equal(LineBreakMode.WordWrap.ToNative(), GetNativeLineBreakMode(handler)); label.LineBreakMode = newMode; nativeLabel.UpdateLineBreakMode(label); Assert.Equal(1, GetNativeMaxLines(handler)); Assert.Equal(newMode.ToNative(), GetNativeLineBreakMode(handler)); label.LineBreakMode = LineBreakMode.WordWrap; nativeLabel.UpdateLineBreakMode(label); Assert.Equal(3, GetNativeMaxLines(handler)); Assert.Equal(LineBreakMode.WordWrap.ToNative(), GetNativeLineBreakMode(handler)); }); }
/* private Style CreateStyle ( * Color textColor, * double fontSize, * string fontFamily, * LineBreakMode breakmode = LineBreakMode.WordWrap) * { * return new Style(typeof(Label)) * { * Setters = { * new Setter { Property = Label.TextColorProperty, Value = textColor }, * new Setter { Property = Label.FontSizeProperty, Value = fontSize }, * new Setter { Property = Label.FontFamilyProperty, Value = fontFamily }, * new Setter { Property = Label.LineBreakModeProperty, Value = breakmode } * } * }; * } */ private Style CreateStyle( Color textColor, double fontSize, string fontFamily, LineBreakMode breakmode = LineBreakMode.WordWrap) { Type t = typeof(T); return(new Style(t) { Setters = { new Setter { Property = t.GetStatic <BindableProperty>("TextColorProperty"), Value = textColor }, new Setter { Property = t.GetStatic <BindableProperty>("FontSizeProperty"), Value = fontSize }, new Setter { Property = t.GetStatic <BindableProperty>("FontFamilyProperty"), Value = fontFamily }, new Setter { Property = t.GetStatic <BindableProperty>("LineBreakModeProperty"), Value = breakmode } } }); }
public async Task UnsettingSingleLineBreakModeResetsMaxLines(LineBreakMode newMode) { var label = new Label() { Text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit", MaxLines = 3, LineBreakMode = LineBreakMode.WordWrap, }; var handler = await CreateHandlerAsync <LabelHandler>(label); var platformLabel = GetPlatformLabel(handler); await InvokeOnMainThreadAsync((System.Action)(() => { Assert.Equal(3, GetPlatformMaxLines(handler)); Assert.Equal(LineBreakMode.WordWrap.ToPlatform(), GetPlatformLineBreakMode(handler)); label.LineBreakMode = newMode; platformLabel.UpdateLineBreakMode(label); Assert.Equal(1, GetPlatformMaxLines(handler)); Assert.Equal(newMode.ToPlatform(), GetPlatformLineBreakMode(handler)); label.LineBreakMode = LineBreakMode.WordWrap; platformLabel.UpdateLineBreakMode(label); Assert.Equal(3, GetPlatformMaxLines(handler)); Assert.Equal(LineBreakMode.WordWrap.ToPlatform(), GetPlatformLineBreakMode(handler)); })); }
internal static void SetLineBreakMode(this TextView textView, LineBreakMode lineBreakMode, int?maxLines = null) { if (!maxLines.HasValue || maxLines <= 0) { maxLines = int.MaxValue; } bool singleLine = false; bool shouldSetSingleLine = !OperatingSystem.IsAndroidVersionAtLeast(23); switch (lineBreakMode) { case LineBreakMode.NoWrap: maxLines = 1; textView.Ellipsize = null; break; case LineBreakMode.WordWrap: textView.Ellipsize = null; break; case LineBreakMode.CharacterWrap: textView.Ellipsize = null; break; case LineBreakMode.HeadTruncation: maxLines = 1; // If maxLines is anything greater than 1, the truncation will be ignored: https://developer.android.com/reference/android/widget/TextView#setEllipsize(android.text.TextUtils.TruncateAt) if (shouldSetSingleLine) { singleLine = true; // Workaround for bug in older Android API versions (https://issuetracker.google.com/issues/36950033) (https://bugzilla.xamarin.com/show_bug.cgi?id=49069) } textView.Ellipsize = TextUtils.TruncateAt.Start; break; case LineBreakMode.TailTruncation: // Leaving this in for now to preserve existing behavior // Technically, we don't _need_ this for Labels; they will handle Ellipsization at the end just fine, even with multiple lines // But we don't have a mechanism for setting MaxLines on other controls (e.g., Button) right now, so we need to force it here or // they will potentially exceed a single line. Also, changing this behavior the for Labels would technically be breaking (though // possibly less surprising than what happens currently). maxLines = 1; textView.Ellipsize = TextUtils.TruncateAt.End; break; case LineBreakMode.MiddleTruncation: maxLines = 1; // If maxLines is anything greater than 1, the truncation will be ignored: https://developer.android.com/reference/android/widget/TextView#setEllipsize(android.text.TextUtils.TruncateAt) textView.Ellipsize = TextUtils.TruncateAt.Middle; break; } if (shouldSetSingleLine) // Save ourselves this trip across the bridge if we're on an API level that doesn't need it { textView.SetSingleLine(singleLine); } textView.SetMaxLines(maxLines.Value); }
public static string ToText(this LineBreakMode mode) { switch (mode) { case LineBreakMode.CharacterWrap: return(nameof(LineBreakMode.CharacterWrap)); case LineBreakMode.HeadTruncation: return(nameof(LineBreakMode.HeadTruncation)); case LineBreakMode.MiddleTruncation: return(nameof(LineBreakMode.MiddleTruncation)); case LineBreakMode.NoWrap: return(nameof(LineBreakMode.NoWrap)); case LineBreakMode.TailTruncation: return(nameof(LineBreakMode.TailTruncation)); case LineBreakMode.WordWrap: return(nameof(LineBreakMode.WordWrap)); default: throw new NotSupportedException(); } }
private Style CreateStyle( Color textColor, double fontSize, string fontFamily, LineBreakMode breakmode = LineBreakMode.TailTruncation) { return(new Style(typeof(Label)) { Setters = { new Setter { Property = Label.TextColorProperty, Value = textColor }, new Setter { Property = Label.FontSizeProperty, Value = fontSize }, new Setter { Property = Label.FontFamilyProperty, Value = fontFamily }, new Setter { Property = Label.LineBreakModeProperty, Value = breakmode }, } }); }
static Button MakeLineBreakModeButton (string buttonText, Label label, LineBreakMode lineBreakMode) { var button = new Button { Text = buttonText, Command = new Command (() => label.LineBreakMode = lineBreakMode) }; return button; }
private static StackLayout GetStackLayout(string Text, LineBreakMode breakMode) { return(new StackLayout { Orientation = StackOrientation.Horizontal, HorizontalOptions = LayoutOptions.FillAndExpand, Children = { new Label { HorizontalOptions = LayoutOptions.FillAndExpand, FontSize = 14, Text = Text, LineBreakMode = breakMode }, new Image { HorizontalOptions = LayoutOptions.End, Source = ImageSource.FromFile(caret_image), HeightRequest = 20, Aspect = Aspect.AspectFit, BackgroundColor = Colors.Green } }, }); }
partial void Init(StringAlignment horizontalAlignment, StringAlignment verticalAlignment, LineBreakMode lineBreakMode) { this.horizontalAlignment = horizontalAlignment; this.verticalAlignment = verticalAlignment; this.lineBreakMode = lineBreakMode; }
static Button MakeLineBreakModeButton(string buttonText, Label label, LineBreakMode lineBreakMode) { var button = new Button { Text = buttonText, Command = new Command(() => label.LineBreakMode = lineBreakMode) }; return(button); }
static UILineBreakMode ConvertLineBreakMode(LineBreakMode lineBreakMode) { switch (lineBreakMode) { case LineBreakMode.TailTruncation: return(UILineBreakMode.TailTruncation); case LineBreakMode.WordWrap: return(UILineBreakMode.WordWrap); default: return(UILineBreakMode.Clip); } }
public static IControl Create( Text text = default(Text), Font font = null, TextAlignment textAlignment = TextAlignment.Left, Brush color = default(Brush), LineBreakMode lineBreakMode = LineBreakMode.Clip) { return(Implementation.Factory( font ?? Font.Default, text, Observable.Return(textAlignment), color | new Color(1, 1, 1, 1), lineBreakMode)); }
public static IControl FormattedText( IObservable <IEnumerable <TextPart> > textParts, Font font = null, TextAlignment textAlignment = TextAlignment.Left, Brush color = default(Brush), LineBreakMode lineBreakMode = LineBreakMode.Clip) { return(Implementation.Formatted( textParts, font ?? Font.Default, Observable.Return(textAlignment), color | Color.FromBytes(255, 0, 0), lineBreakMode)); }
public ControlState(ControlState source) { _textFormatted = source._textFormatted; _text = source._text; _javaText = source._javaText; Typeface = source.Typeface; TextColor = source.TextColor; AvailWidth = source.AvailWidth; AvailHeight = source.AvailHeight; TextSize = source.TextSize; Lines = source.Lines; AutoFit = source.AutoFit; LineBreakMode = source.LineBreakMode; SyncFontSize = source.SyncFontSize; }
static void OnTextPropertyChanged(BindableObject bindable, object oldvalue, object newvalue) { var label = (Label)bindable; LineBreakMode breakMode = label.LineBreakMode; bool isVerticallyFixed = (label.Constraint & LayoutConstraint.VerticallyFixed) != 0; bool isSingleLine = !(breakMode == LineBreakMode.CharacterWrap || breakMode == LineBreakMode.WordWrap); if (!isVerticallyFixed || !isSingleLine) { ((Label)bindable).InvalidateMeasureInternal(InvalidationTrigger.MeasureChanged); } if (newvalue != null) { ((Label)bindable).FormattedText = null; } }
static StackLayout GetLayout(LineBreakMode lineBreakMode) { var text = ""; switch (lineBreakMode) { default: case LineBreakMode.NoWrap: text = "This is a long sentence that should NOT wrap. If this sentence has wrapped, then this test has failed."; break; case LineBreakMode.WordWrap: text = "This is a long sentence that should word wrap. If this sentence has NOT wrapped, then this test has failed."; break; case LineBreakMode.CharacterWrap: text = "This is a long sentence that should character wrap. If this sentence has NOT wrapped, then this test has failed."; break; case LineBreakMode.HeadTruncation: text = "This is a long sentence that should truncate at the beginning. If this sentence has NOT truncated, then this test has failed."; break; case LineBreakMode.TailTruncation: text = "This is a long sentence that should truncate at the end. If this sentence has NOT truncated, then this test has failed."; break; case LineBreakMode.MiddleTruncation: text = "This is a long sentence that should truncate at the middle. If this sentence has NOT truncated, then this test has failed."; break; } var label = new Label { LineBreakMode = lineBreakMode, Text = text, }; var layout = new StackLayout { Children = { label }, Orientation = StackOrientation.Horizontal }; return(layout); }
public static void UpdateLineBreakMode(this TextBlock textBlock, LineBreakMode lineBreakMode) { if (textBlock == null) { return; } switch (lineBreakMode) { case LineBreakMode.NoWrap: textBlock.TextTrimming = TextTrimming.Clip; textBlock.TextWrapping = TextWrapping.NoWrap; break; case LineBreakMode.WordWrap: textBlock.TextTrimming = TextTrimming.None; textBlock.TextWrapping = TextWrapping.Wrap; break; case LineBreakMode.CharacterWrap: textBlock.TextTrimming = TextTrimming.WordEllipsis; textBlock.TextWrapping = TextWrapping.Wrap; break; case LineBreakMode.HeadTruncation: // TODO: This truncates at the end. textBlock.TextTrimming = TextTrimming.WordEllipsis; DetermineTruncatedTextWrapping(textBlock); break; case LineBreakMode.TailTruncation: textBlock.TextTrimming = TextTrimming.CharacterEllipsis; DetermineTruncatedTextWrapping(textBlock); break; case LineBreakMode.MiddleTruncation: // TODO: This truncates at the end. textBlock.TextTrimming = TextTrimming.WordEllipsis; DetermineTruncatedTextWrapping(textBlock); break; default: throw new ArgumentOutOfRangeException(); } }
protected override UILabel CreateView() { var label = new UILabel(); // todo: answer the question of whether or not these should be default or not. if (DefaultColor == null) { DefaultFont = label.Font.ToFont(); DefaultColor = label.TextColor.ToColor(); } if (DefaultLineBreakMode == null) { DefaultLineBreakMode = LineBreakMode.NoWrap; } return(label); }
public static int SetLineBreak(TextView textView, LineBreakMode lineBreakMode) { int maxLines = Int32.MaxValue; bool singleLine = false; switch (lineBreakMode) { case LineBreakMode.NoWrap: maxLines = 1; singleLine = true; textView.Ellipsize = null; break; case LineBreakMode.WordWrap: textView.Ellipsize = null; break; case LineBreakMode.CharacterWrap: textView.Ellipsize = null; break; case LineBreakMode.HeadTruncation: maxLines = 1; singleLine = true; // Workaround for bug in older Android API versions (https://bugzilla.xamarin.com/show_bug.cgi?id=49069) textView.Ellipsize = TextUtils.TruncateAt.Start; break; case LineBreakMode.TailTruncation: maxLines = 1; singleLine = true; textView.Ellipsize = TextUtils.TruncateAt.End; break; case LineBreakMode.MiddleTruncation: maxLines = 1; singleLine = true; // Workaround for bug in older Android API versions (https://bugzilla.xamarin.com/show_bug.cgi?id=49069) textView.Ellipsize = TextUtils.TruncateAt.Middle; break; } textView.SetSingleLine(singleLine); return(maxLines); }
private void UpdateLineBreakMode(TextView view, LineBreakMode lineBreakMode) { if (view == null) { return; } switch (lineBreakMode) { case LineBreakMode.NoWrap: view.SetSingleLine(true); view.Ellipsize = null; break; case LineBreakMode.WordWrap: view.SetSingleLine(false); view.Ellipsize = null; view.SetMaxLines(100); break; case LineBreakMode.CharacterWrap: view.SetSingleLine(false); view.Ellipsize = null; view.SetMaxLines(100); break; case LineBreakMode.HeadTruncation: view.SetSingleLine(true); view.Ellipsize = TextUtils.TruncateAt.Start; break; case LineBreakMode.TailTruncation: view.SetSingleLine(true); view.Ellipsize = TextUtils.TruncateAt.End; break; case LineBreakMode.MiddleTruncation: view.SetSingleLine(true); view.Ellipsize = TextUtils.TruncateAt.Middle; break; } }
public static NSLineBreakMode ToNSLineBreakMode(this LineBreakMode lineBreakMode) { switch (lineBreakMode) { case LineBreakMode.Clip: return(NSLineBreakMode.Clipping); case LineBreakMode.Wrap: return(NSLineBreakMode.ByWordWrapping); case LineBreakMode.TruncateHead: return(NSLineBreakMode.TruncatingHead); case LineBreakMode.TruncateTail: return(NSLineBreakMode.TruncatingTail); default: throw new InvalidEnumArgumentException("lineBreakMode", (int)lineBreakMode, typeof(LineBreakMode)); } }
public static void SetLineBreakMode(this TextView textView, LineBreakMode lineBreakMode) { switch (lineBreakMode) { case LineBreakMode.NoWrap: textView.SetMaxLines(1); textView.SetSingleLine(true); textView.Ellipsize = null; break; case LineBreakMode.WordWrap: textView.Ellipsize = null; textView.SetMaxLines(100); textView.SetSingleLine(false); break; case LineBreakMode.CharacterWrap: textView.Ellipsize = null; textView.SetMaxLines(100); textView.SetSingleLine(false); break; case LineBreakMode.HeadTruncation: textView.SetMaxLines(1); textView.SetSingleLine(true); textView.Ellipsize = TextUtils.TruncateAt.Start; break; case LineBreakMode.TailTruncation: textView.SetMaxLines(1); textView.SetSingleLine(true); textView.Ellipsize = TextUtils.TruncateAt.End; break; case LineBreakMode.MiddleTruncation: textView.SetMaxLines(1); textView.SetSingleLine(true); textView.Ellipsize = TextUtils.TruncateAt.Middle; break; } }
private void UpdateLineBreakMode(UILabel label, LineBreakMode lineBreakMode) { if (label == null) { return; } switch (lineBreakMode) { case LineBreakMode.NoWrap: label.LineBreakMode = UILineBreakMode.Clip; label.Lines = 1; break; case LineBreakMode.WordWrap: label.LineBreakMode = UILineBreakMode.WordWrap; label.Lines = 0; break; case LineBreakMode.CharacterWrap: label.LineBreakMode = UILineBreakMode.CharacterWrap; label.Lines = 0; break; case LineBreakMode.HeadTruncation: label.LineBreakMode = UILineBreakMode.HeadTruncation; label.Lines = 1; break; case LineBreakMode.MiddleTruncation: label.LineBreakMode = UILineBreakMode.MiddleTruncation; label.Lines = 1; break; case LineBreakMode.TailTruncation: label.LineBreakMode = UILineBreakMode.TailTruncation; label.Lines = 1; break; } }
Native.LineBreakMode ConvertToNativeLineBreakMode(LineBreakMode mode) { switch (mode) { case LineBreakMode.CharacterWrap: return(Native.LineBreakMode.CharacterWrap); case LineBreakMode.HeadTruncation: return(Native.LineBreakMode.HeadTruncation); case LineBreakMode.MiddleTruncation: return(Native.LineBreakMode.MiddleTruncation); case LineBreakMode.NoWrap: return(Native.LineBreakMode.NoWrap); case LineBreakMode.TailTruncation: return(Native.LineBreakMode.TailTruncation); case LineBreakMode.WordWrap: default: return(Native.LineBreakMode.WordWrap); } }
public static UILineBreakMode ToUILineBreakMode(this LineBreakMode mode) { switch (mode) { case LineBreakMode.CharacterWrap: return(UILineBreakMode.CharacterWrap); case LineBreakMode.HeadTruncation: return(UILineBreakMode.HeadTruncation); case LineBreakMode.MiddleTruncation: return(UILineBreakMode.MiddleTruncation); case LineBreakMode.TailTruncation: return(UILineBreakMode.TailTruncation); case LineBreakMode.WordWrap: return(UILineBreakMode.WordWrap); case LineBreakMode.NoWrap: default: return(UILineBreakMode.Clip); } }
public void DrawString(string s, float x, float y, float width, float height, LineBreakMode lineBreak, TextAlignment align) { if (string.IsNullOrWhiteSpace (s)) return; if (align == TextAlignment.Left || align == TextAlignment.Justified) { DrawString (s, x, y); } else if (align == TextAlignment.Right) { var stringWidth = GetFontMetrics ().StringWidth (s); DrawString (s, x + width - stringWidth, y); } else { var stringWidth = GetFontMetrics ().StringWidth (s); DrawString (s, x + (width - stringWidth) / 2, y); } }
public void DrawString(string s, float x, float y, float width, float height, LineBreakMode lineBreak, TextAlignment align) { if (string.IsNullOrWhiteSpace (s)) return; DrawString (s, x, y); }
public void DrawString(string s, float x, float y, float width, float height, LineBreakMode lineBreak, TextAlignment align) { }
public static void DrawString(this IGraphics g, string s, RectangleF p, Font f, LineBreakMode lineBreak, TextAlignment align) { g.SetFont (f); g.DrawString (s, p.Left, p.Top, p.Width, p.Height, lineBreak, align); }
public void DrawString(string s, float x, float y, float width, float height, LineBreakMode lineBreak, TextAlignment align) { _eshape.DrawString(s, x, y, width, height, lineBreak, align); }
public void DrawString(string s, float x, float y, float width, float height, LineBreakMode lineBreak, TextAlignment align) { WriteLine("<text x=\"{0}\" y=\"{1}\" font-family=\"sans-serif\" font-size=\"{2}\">{3}</text>", x, y + _fontMetrics.Height, _fontMetrics.Height * 3 / 2, s.Replace("&", "&").Replace("<", "<").Replace(">", ">")); }
public void DrawString(string s, float x, float y, float width, float height, LineBreakMode lineBreak, TextAlignment align) { if (_lastFont == null) { return; } var fm = GetFontMetrics(); var xx = x; var yy = y; if (align == TextAlignment.Center) { xx = (x + width / 2) - (fm.StringWidth(s) / 2); } else if (align == TextAlignment.Right) { xx = (x + width) - fm.StringWidth(s); } DrawString(s, xx, yy); }
public void DrawString(string s, float x, float y, float width, float height, LineBreakMode lineBreak, TextAlignment align) { if (_lastFont == null) return; var fm = GetFontMetrics (); var fix = FixupString (s); var xx = x; var yy = y; if (align == TextAlignment.Center) { xx = (x + width / 2) - (fm.StringWidth (s) / 2); } else if (align == TextAlignment.Right) { xx = (x + width) - fm.StringWidth (s); } if (fix == null) { _c.ShowTextAtPoint (xx, yy + fm.Height, s); } else { _c.ShowTextAtPoint (xx, yy + fm.Height, fix); } }
static public UnityEngine.HorizontalWrapMode ToUnityHorizontalWrapMode(this LineBreakMode mode) { return(mode == LineBreakMode.CharacterWrap || mode == LineBreakMode.WordWrap ? UnityEngine.HorizontalWrapMode.Wrap : UnityEngine.HorizontalWrapMode.Overflow); }
public static void DrawString(this IGraphics g, string s, RectangleF p, Font f, LineBreakMode lineBreak, TextAlignment align) { g.SetFont(f); g.DrawString(s, p.Left, p.Top, p.Width, p.Height, lineBreak, align); }
public void DrawString(string str, float x, float y, float width = 0, float height = 0, LineBreakMode lineBreak = LineBreakMode.None, TextAlignment align = TextAlignment.Left) { var s = GetNextShape(TypeId.Text); var e = (TextBlock)s.Element; //var b = s.Element as Border; //var e = b.Child as TextBlock; //if (e == null) { // e = new TextBlock(); // b.Child = e; //} if (s.TextAlignment != align) { switch (align) { case TextAlignment.Center: e.TextAlignment = NativeTextAlignment.Center; e.Width = width; e.Height = height; break; default: e.TextAlignment = NativeTextAlignment.Left; break; } s.TextAlignment = align; } if (s.X != x) { s.X = x; Canvas.SetLeft(e, x); } if (s.Y != y) { s.Y = y; Canvas.SetTop(e, y); } if (s.Text != str) { s.Text = str; e.Text = str; //b.Background = new SolidColorBrush(System.Windows.Media.Colors.Red); } if (s.Color != _currentColor) { s.Color = _currentColor; e.Foreground = _currentColor.GetBrush(); } if (s.Font != CurrentFont) { s.Font = CurrentFont; e.Padding = new Thickness(0); e.RenderTransform = new TranslateTransform() { X = 0, Y = -0.333 * CurrentFont.Size, }; e.FontSize = CurrentFont.Size; //e.Height = CurrentFont.Size; } }
partial void Init(StringAlignment horizontalAlignment, StringAlignment verticalAlignment, LineBreakMode lineBreakMode) { format = new System.Drawing.StringFormat() { Alignment = horizontalAlignment, LineAlignment = verticalAlignment, FormatFlags = StringFormatFlags.LineLimit | StringFormatFlags.NoFontFallback }; if (lineBreakMode == LineBreakMode.WrapChars) { format.Trimming = StringTrimming.Character; } else if (lineBreakMode == LineBreakMode.WrapWords) { format.Trimming = StringTrimming.Word; } else if (lineBreakMode == LineBreakMode.SingleLineEndEllipsis) { format.Trimming = StringTrimming.EllipsisCharacter; } }
public void DrawString(string s, float x, float y, float width, float height, LineBreakMode lineBreak, TextAlignment align) { _tw.WriteLine("<text x=\"{0}\" y=\"{1}\" font-family=\"sans-serif\">{2}</text>", x, y + _fontMetrics.Height, s.Replace("&", "&").Replace("<", "<").Replace(">", ">")); }
private Style CreateStyle( Color textColor, double fontSize, string fontFamily, LineBreakMode breakmode = LineBreakMode.TailTruncation) { return new Style (typeof(Label)) { Setters = { new Setter { Property = Label.TextColorProperty, Value = textColor }, new Setter { Property = Label.FontSizeProperty, Value = fontSize }, new Setter { Property = Label.FontFamilyProperty, Value = fontFamily }, new Setter { Property = Label.LineBreakModeProperty, Value = breakmode }, } }; }
public void DrawString (string s, float x, float y, float width, float height, LineBreakMode lineBreak, TextAlignment align) { if (_lastFont == null) return; var fm = GetFontMetrics (); var xx = x; var yy = y; if (align == TextAlignment.Center) { xx = (x + width / 2) - (fm.StringWidth (s) / 2); } else if (align == TextAlignment.Right) { xx = (x + width) - fm.StringWidth (s); } DrawString (s, xx, yy); }