public BuilderTextShadow(TextShadow textShadow) { offsetX = new Dimension(textShadow.offset.x, Dimension.Unit.Pixel); offsetY = new Dimension(textShadow.offset.y, Dimension.Unit.Pixel); blurRadius = new Dimension(textShadow.blurRadius, Dimension.Unit.Pixel); color = textShadow.color; }
public override void DrawStringCached(ref CachedRenderString cache, string fontName, float size, string text, float x, float y, Color4 color, bool underline = false, TextShadow shadow = default, TextAlignment alignment = TextAlignment.Left) { UpdateCache(ref cache, fontName, size, text, underline, alignment); var pc = (PangoRenderCache)cache; drawX = (int)x; drawY = (int)y; if (shadow.Enabled) { for (int i = 0; i < pc.quads.Length; i++) { var q = pc.quads[i]; q.Dest.X += drawX + 2; q.Dest.Y += drawY + 2; var t = textures[(int)q.Texture->UserData]; ren.Draw(t, q.Source, q.Dest, shadow.Color); } } for (int i = 0; i < pc.quads.Length; i++) { var q = pc.quads[i]; q.Dest.X += drawX; q.Dest.Y += drawY; var t = textures[(int)q.Texture->UserData]; ren.Draw(t, q.Source, q.Dest, color); } }
public void TextShadowToPropertyValue() { tlog.Debug(tag, $"TextShadowToPropertyValue START"); TextLabel textLabel = new TextLabel() { Text = "TextShadowConstructor", Color = Color.Green, PointSize = 15.0f, }; PropertyMap temp = new PropertyMap(); Tizen.NUI.Object.GetProperty((global::System.Runtime.InteropServices.HandleRef)textLabel.SwigCPtr, TextLabel.Property.SHADOW).Get(temp); using (TextShadow textShadow = new TextShadow(temp)) { var testingTarget = TextShadow.ToPropertyValue(textShadow); Assert.IsNotNull(testingTarget, "Can't create success object PropertyValue"); Assert.IsInstanceOf <PropertyValue>(testingTarget, "Should be an instance of PropertyValue type."); testingTarget.Dispose(); } textLabel.Dispose(); tlog.Debug(tag, $"TextShadowToPropertyValue END (OK)"); }
public void TextShadowCloneWithTextShadow() { tlog.Debug(tag, $"TextShadowCloneWithTextShadow START"); TextLabel textLabel = new TextLabel() { Text = "TextShadowConstructor", Color = Color.Green, PointSize = 15.0f, }; PropertyMap temp = new PropertyMap(); Tizen.NUI.Object.GetProperty((global::System.Runtime.InteropServices.HandleRef)textLabel.SwigCPtr, TextLabel.Property.SHADOW).Get(temp); try { TextShadow.Clone(new TextShadow(temp)); } catch (Exception e) { tlog.Debug(tag, e.Message.ToString()); Assert.Fail("Caught Exception: Failed!"); } textLabel.Dispose(); tlog.Debug(tag, $"TextShadowCloneWithTextShadow END (OK)"); }
public override Result DrawUnderline( object clientDrawingContext, float baselineOriginX, float baselineOriginY, ref Underline underline, ComObject clientDrawingEffect ) { Color4 brushColor = Color4.White; TextShadow shadow = new TextShadow(); if (clientDrawingEffect != null && clientDrawingEffect is ColorDrawingEffect colorFx) { brushColor = colorFx.Color; shadow = colorFx.Shadow; } if (shadow.Enabled) { Quads.Add(new DrawQuad() { Texture = null, Color = shadow.Color, Destination = new Rectangle((int)baselineOriginX + 2, (int)(baselineOriginY + underline.Offset + 2), (int)Math.Ceiling(underline.Width), (int)Math.Ceiling(underline.Thickness)) }); } Quads.Add(new DrawQuad() { Texture = null, Color = brushColor, Destination = new Rectangle((int)baselineOriginX, (int)(baselineOriginY + underline.Offset), (int)Math.Ceiling(underline.Width), (int)Math.Ceiling(underline.Thickness)) }); return(Result.Ok); }
public override Result DrawGlyphRun( object clientDrawingContext, float baselineOriginX, float baselineOriginY, D2D1.MeasuringMode measuringMode, GlyphRun glyphRun, GlyphRunDescription glyphRunDescription, ComObject clientDrawingEffect ) { var fHash = FontHash(glyphRun.FontFace, glyphRun.FontSize); var positionX = (float)Math.Floor(baselineOriginX + 0.5f); var positionY = (float)Math.Floor(baselineOriginY + 0.5f); Color4 brushColor = Color4.White; TextShadow shadow = new TextShadow(); if (clientDrawingEffect != null && clientDrawingEffect is ColorDrawingEffect colorFx) { brushColor = colorFx.Color; shadow = colorFx.Shadow; } for (int i = 0; i < glyphRun.Indices.Length; i++) { var glyph = GetGlyph(fHash, glyphRun.FontFace, glyphRun.Indices[i], glyphRun.FontSize); if (shadow.Enabled) { Quads.Add(new DrawQuad() { Texture = glyph.Texture, Source = glyph.Rectangle, Destination = new Rectangle( (int)(glyph.OffsetX + positionX + 2), (int)(glyph.OffsetY + positionY + 2), glyph.Rectangle.Width, glyph.Rectangle.Height ), Color = shadow.Color }); } var q = new DrawQuad() { Texture = glyph.Texture, Source = glyph.Rectangle, Destination = new Rectangle( (int)(glyph.OffsetX + positionX), (int)(glyph.OffsetY + positionY), glyph.Rectangle.Width, glyph.Rectangle.Height ), Color = brushColor }; Quads.Add(q); positionX += glyphRun.Advances[i]; } return(Result.Ok); }
public void TextShadowCloneWithNullTextShadow() { tlog.Debug(tag, $"TextShadowCloneWithNullTextShadow START"); TextShadow textShadow = null; var testingTarget = TextShadow.Clone(textShadow); Assert.IsNull(testingTarget); tlog.Debug(tag, $"TextShadowCloneWithNullTextShadow END (OK)"); }
public void TextShadowToPropertyValueWithNullInstance() { tlog.Debug(tag, $"TextShadowToPropertyValueWithNullInstance START"); var testingTarget = TextShadow.ToPropertyValue(null); Assert.IsNotNull(testingTarget, "Can't create success object PropertyValue"); Assert.IsInstanceOf <PropertyValue>(testingTarget, "Should be an instance of PropertyValue type."); testingTarget.Dispose(); tlog.Debug(tag, $"TextShadowToPropertyValueWithNullInstance END (OK)"); }
public void TextShadowConstructor() { tlog.Debug(tag, $"TextShadowConstructor START"); using (Vector2 vector = new Vector2(1.5f, 3.0f)) { var testingTarget = new TextShadow(Color.Cyan, vector, 0.3f); Assert.IsNotNull(testingTarget, "Can't create success object TextShadow"); Assert.IsInstanceOf <TextShadow>(testingTarget, "Should be an instance of TextShadow type."); testingTarget.Dispose(); } tlog.Debug(tag, $"TextShadowConstructor END (OK)"); }
private ImageSignOptions GetImageSignOptions(string signImagePath, string signLocation, string signSize) { var options = new ImageSignOptions(signImagePath) { Width = 100, Height = 100, VerticalAlignment = VerticalAlignment.Top, HorizontalAlignment = HorizontalAlignment.Right, Margin = new Padding(10) }; TextShadow shadow = new TextShadow() { Color = Color.DarkGray, Angle = 65, Blur = 3, Distance = 4, Transparency = 0.3 }; options.Extensions.Add(shadow); QrCodeSignOptions locationOptions = GetLocationOptions(signLocation); options.HorizontalAlignment = locationOptions.HorizontalAlignment; options.VerticalAlignment = locationOptions.VerticalAlignment; switch (signSize) { case "small": options.Width = 50; options.Height = 50; break; case "medium": options.Width = 50 * 2; options.Height = 50 * 2; break; case "large": options.Width = 50 * 3; options.Height = 50 * 3; break; } return(options); }
protected override void OnPaint(PaintEventArgs e) { if (Title.Length > 0) { Core.TextShadow ts = new TextShadow(); SizeF szf = e.Graphics.MeasureString(Title, TitleFont); float x = 0; float y = 0; switch (TitleHAlignment) { case StringAlignment.Far: x = this.Width - szf.Width - 10; break; case StringAlignment.Near: x = 0; break; case StringAlignment.Center: x = (this.Width - szf.Width) / 2; break; default: break; } switch (TitleVAlignment) { case StringAlignment.Far: y = this.Height - szf.Height - 10; break; case StringAlignment.Near: break; case StringAlignment.Center: y = (this.Height - szf.Height) / 2; break; default: break; } ts.Draw(e.Graphics, Title, TitleFont, new PointF(x, y)); e.Graphics.DrawString(Title, TitleFont, new SolidBrush(TitleForeColor), new PointF(x, y)); } Draw(e.Graphics); base.OnPaint(e); }
public void TextShadowClone() { tlog.Debug(tag, $"TextShadowClone START"); using (Vector2 vector = new Vector2(1.5f, 3.0f)) { using (TextShadow textShadow = new TextShadow(Color.Cyan, vector, 0.3f)) { try { textShadow.Clone(); } catch (Exception e) { tlog.Debug(tag, e.Message.ToString()); Assert.Fail("Caught Exception: Failed!"); } } } tlog.Debug(tag, $"TextShadowClone END (OK)"); }
public static void TextShadowCloneWithTextShadow() { tlog.Debug(tag, $"TextShadowCloneWithTextShadow START"); using (Vector2 vector = new Vector2(1.5f, 3.0f)) { using (TextShadow textShadow = new TextShadow(new Tizen.NUI.Color("#C3CAD5FF"), vector, 0.3f)) { try { TextShadow.Clone(textShadow); } catch (Exception e) { tlog.Debug(tag, e.Message.ToString()); Assert.Fail("Caught Exception: Failed!"); } } } tlog.Debug(tag, $"TextShadowCloneWithTextShadow END (OK)"); }
public void TextShadowConstructorWithPropertyMap() { tlog.Debug(tag, $"TextShadowConstructorWithPropertyMap START"); TextLabel textLabel = new TextLabel() { Text = "TextShadowConstructor", Color = new Tizen.NUI.Color("#C3CAD5FF"), PointSize = 15.0f, }; PropertyMap temp = new PropertyMap(); Tizen.NUI.Object.GetProperty((global::System.Runtime.InteropServices.HandleRef)textLabel.SwigCPtr, TextLabel.Property.SHADOW).Get(temp); var testingTarget = new TextShadow(temp); Assert.IsNotNull(testingTarget, "Can't create success object TextShadow"); Assert.IsInstanceOf <TextShadow>(testingTarget, "Should be an instance of TextShadow type."); textLabel.Dispose(); testingTarget.Dispose(); tlog.Debug(tag, $"TextShadowConstructorWithPropertyMap END (OK)"); }
public void TextShadowConstructorWithTextShadow() { tlog.Debug(tag, $"TextShadowConstructorWithTextShadow START"); using (Vector2 vector = new Vector2(1.5f, 3.0f)) { using (TextShadow shadow = new TextShadow(Color.Cyan, vector, 0.3f)) { try { var testingTarget = new TextShadow(shadow); testingTarget.Dispose(); } catch (Exception e) { tlog.Debug(tag, e.Message.ToString()); Assert.Fail("Caught Exception: Failed!"); } } } tlog.Debug(tag, $"TextShadowConstructorWithTextShadow END (OK)"); }
public TextShadow ReadTextShadow(int index) { float offsetX = 0.0f; float offsetY = 0.0f; float blurRadius = 0.0f; var color = Color.clear; if (valueCount >= 2) { int i = index; var valueType = GetValueType(i); bool isColorRead = false; if (valueType == StyleValueType.Color || valueType == StyleValueType.Enum) { color = ReadColor(i++); isColorRead = true; } if ((i + 1) < valueCount) { valueType = GetValueType(i); var valueType2 = GetValueType(i + 1); if ((valueType == StyleValueType.Dimension || valueType == StyleValueType.Float) && (valueType2 == StyleValueType.Dimension || valueType2 == StyleValueType.Float)) { var valueX = GetValue(i++); var valueY = GetValue(i++); offsetX = valueX.sheet.ReadDimension(valueX.handle).value; offsetY = valueY.sheet.ReadDimension(valueY.handle).value; } } if (i < valueCount) { valueType = GetValueType(i); if (valueType == StyleValueType.Dimension || valueType == StyleValueType.Float) { var valueBlur = GetValue(i++); blurRadius = valueBlur.sheet.ReadDimension(valueBlur.handle).value; } else if (valueType == StyleValueType.Color || valueType == StyleValueType.Enum) { if (!isColorRead) { color = ReadColor(i); } } } if (i < valueCount) { valueType = GetValueType(i); if (valueType == StyleValueType.Color || valueType == StyleValueType.Enum) { if (!isColorRead) { color = ReadColor(i); } } } } var textShadow = new TextShadow() { offset = new Vector2(offsetX, offsetY), blurRadius = blurRadius, color = color }; return(textShadow); }
private TextSignOptions GetTextSignOptions(string signText, string signLocation, string signSize) { var options = new TextSignOptions(signText) { Width = 100, Height = 30, VerticalAlignment = VerticalAlignment.Top, SignatureImplementation = TextSignatureImplementation.Image, HorizontalAlignment = HorizontalAlignment.Right, Margin = new Padding(10), Border = new Border() { Color = Color.LightGray, DashStyle = DashStyle.Solid, Transparency = 0.9, Visible = true, Weight = 2 }, ForeColor = Color.Black, Font = new SignatureFont { Size = 12, FamilyName = "Comic Sans MS" }, Background = new Background() { Color = Color.Transparent, Transparency = 0.2, Brush = new LinearGradientBrush(Color.White, Color.LightGray, 90) }, TextHorizontalAlignment = TextHorizontalAlignment.Center, TextVerticalAlignment = TextVerticalAlignment.Center }; TextShadow shadow = new TextShadow() { Color = Color.DarkGray, Angle = 65, Blur = 3, Distance = 4, Transparency = 0.3 }; options.Extensions.Add(shadow); QrCodeSignOptions locationOptions = GetLocationOptions(signLocation); options.VerticalAlignment = locationOptions.VerticalAlignment; options.HorizontalAlignment = locationOptions.HorizontalAlignment; switch (signSize) { case "medium": options.Width = options.Width * 2; options.Height = options.Height * 2; break; case "large": options.Width = options.Width * 3; options.Height = options.Height * 3; break; } return(options); }
public override void DrawStringBaseline(string fontName, float size, string text, float x, float y, Color4 color, bool underline = false, TextShadow shadow = default) { if (string.IsNullOrEmpty(fontName)) { throw new InvalidOperationException("fontName null"); } var pixels = size * (96.0f / 72.0f); drawX = int.MaxValue; drawY = int.MaxValue; StringInfo info = new StringInfo() { Underline = underline ? 1 : 0 }; var hash = info.MakeHash(fontName, text); PGQuad[] quads = null; for (int i = 0; i < cachedStrings.Count; i++) { if (cachedStrings[i].Hash == hash && Math.Abs(cachedStrings[i].Size - size) < 0.001f) { quads = cachedStrings[i].Quads; break; } } if (quads == null) { using var textConv = new UTF8ZHelper(stackalloc byte[256], text); using var fontConv = new UTF8ZHelper(stackalloc byte[256], fontName); fixed(byte *tC = &textConv.ToUTF8Z().GetPinnableReference(), tF = &fontConv.ToUTF8Z().GetPinnableReference()) { pg_drawstring(ctx, (IntPtr)tC, (IntPtr)tF, pixels, TextAlignment.Left, underline ? 1 : 0, 1, 1, 1, 1, (Color4 *)0, (float *)0, (float *)0); } quads = lastQuads; lastQuads = null; cachedStrings.Enqueue(new StringResults() { Hash = hash, Size = size, Quads = quads }); } drawX = (int)x; drawY = (int)y; if (shadow.Enabled) { for (int i = 0; i < quads.Length; i++) { var q = quads[i]; q.Dest.X += drawX + 2; q.Dest.Y += drawY + 2; var t = textures[(int)q.Texture->UserData]; ren.Draw(t, q.Source, q.Dest, shadow.Color); } } for (int i = 0; i < quads.Length; i++) { var q = quads[i]; q.Dest.X += drawX; q.Dest.Y += drawY; var t = textures[(int)q.Texture->UserData]; ren.Draw(t, q.Source, q.Dest, color); } }
public override void DrawStringBaseline(string fontName, float size, string text, float x, float y, float start_x, Color4 color, bool underline = false, TextShadow shadow = default) { var pixels = size * (96.0f / 72.0f); drawX = (int)(start_x); drawY = (int)y; int indent = (int)(x - start_x); var textPtr = UnsafeHelpers.StringToHGlobalUTF8(text); var fontPtr = UnsafeHelpers.StringToHGlobalUTF8(fontName); pg_drawstring(ctx, textPtr, fontPtr, pixels, indent, underline ? 1 : 0, color.R, color.G, color.B, color.A, shadow.Enabled ? &shadow.Color : (Color4 *)0); Marshal.FreeHGlobal(textPtr); Marshal.FreeHGlobal(fontPtr); }
protected void DrawText( UiContext context, ref CachedRenderString cache, RectangleF myRectangle, float textSize, string font, InterfaceColor textColor, InterfaceColor shadowColor, HorizontalAlignment horizontalAlign, VerticalAlignment verticalAlign, bool clip, string text ) { if (string.IsNullOrEmpty(text)) { return; } if (myRectangle.Width <= 1 || myRectangle.Height <= 1) { return; } if (string.IsNullOrEmpty(font)) { font = "$Normal"; } if (textSize <= 0) { textSize = 10; } var color = (textColor ?? InterfaceColor.White).GetColor(context.GlobalTime); if (color.A < float.Epsilon) { return; } var fnt = context.Data.GetFont(font); var size = context.TextSize(textSize); var lineHeight = context.RenderContext.Renderer2D.LineHeight(fnt, size); var drawRect = context.PointsToPixels(myRectangle); var sz = context.RenderContext.Renderer2D.MeasureStringCached(ref cache, fnt, size, text, false, CastAlign(horizontalAlign)); //workaround for font substitution causing layout issues - e.g. CJK //TODO: How to get max lineheight of fonts in string? if (sz.Y > lineHeight && sz.Y < (lineHeight * 2)) { lineHeight = sz.Y; } float drawX, drawY; switch (horizontalAlign) { case HorizontalAlignment.Left: drawX = drawRect.X; break; case HorizontalAlignment.Right: { drawX = drawRect.X + drawRect.Width - sz.X; break; } default: // Center { drawX = drawRect.X + (drawRect.Width / 2f) - (sz.X / 2f); break; } } switch (verticalAlign) { case VerticalAlignment.Top: drawY = drawRect.Y; break; case VerticalAlignment.Bottom: drawY = drawRect.Y + drawRect.Height - lineHeight; break; default: //Center drawY = drawRect.Y + (drawRect.Height / 2) - lineHeight / 2; break; } var shadow = new TextShadow(); if (shadowColor != null) { shadow = new TextShadow(shadowColor.Color); } if (clip) { context.RenderContext.ScissorEnabled = true; context.RenderContext.ScissorRectangle = drawRect; } context.RenderContext.Renderer2D.DrawStringCached(ref cache, fnt, size, text, drawX, drawY, color, false, shadow, CastAlign(horizontalAlign)); if (clip) { context.RenderContext.ScissorEnabled = false; } }
protected void DrawText( UiContext context, RectangleF myRectangle, float textSize, string font, InterfaceColor textColor, InterfaceColor shadowColor, HorizontalAlignment horizontalAlign, VerticalAlignment verticalAlign, bool clip, string text ) { if (string.IsNullOrEmpty(text)) { return; } if (myRectangle.Width <= 1 || myRectangle.Height <= 1) { return; } if (string.IsNullOrEmpty(font)) { font = "$Normal"; } if (textSize <= 0) { textSize = 10; } var color = (textColor ?? InterfaceColor.White).GetColor(context.GlobalTime); if (color.A < float.Epsilon) { return; } context.Mode2D(); var fnt = context.Data.GetFont(font); var size = context.TextSize(textSize); var lineHeight = context.Renderer2D.LineHeight(fnt, size); var drawRect = context.PointsToPixels(myRectangle); float drawX, drawY; switch (horizontalAlign) { case HorizontalAlignment.Left: drawX = drawRect.X; break; case HorizontalAlignment.Right: { var sz = context.Renderer2D.MeasureString(fnt, size, text); drawX = drawRect.X + drawRect.Width - sz.X; break; } default: // Center { var sz = context.Renderer2D.MeasureString(fnt, size, text); drawX = drawRect.X + (drawRect.Width / 2f) - (sz.X / 2f); break; } } switch (verticalAlign) { case VerticalAlignment.Top: drawY = drawRect.Y; break; case VerticalAlignment.Bottom: drawY = drawRect.Y + drawRect.Height - lineHeight; break; default: //Center drawY = drawRect.Y + (drawRect.Height / 2) - lineHeight / 2; break; } var shadow = new TextShadow(); if (shadowColor != null) { shadow = new TextShadow(shadowColor.Color); } if (clip) { context.Renderer2D.DrawWithClip(drawRect, () => { context.Renderer2D.DrawStringBaseline(fnt, size, text, drawX, drawY, drawX, color, false, shadow); }); } else { context.Renderer2D.DrawStringBaseline(fnt, size, text, drawX, drawY, drawX, color, false, shadow); } }
/// <summary> /// Sign document with text signature applying specific options /// </summary> public static void Run() { Console.WriteLine("\n--------------------------------------------------------------------------------------------------------------------"); Console.WriteLine("[Example Advanced Usage] # SignWithTextAdvanced : Sign document with text signature applying specific options\n"); // The path to the documents directory. string filePath = Constants.SAMPLE_WORDPROCESSING; string fileName = Path.GetFileName(filePath); string outputFilePath = Path.Combine(Constants.OutputPath, "SignWithTextAdvanced", fileName); using (Signature signature = new Signature(filePath)) { TextSignOptions options = new TextSignOptions("John Smith") { // set signature position Left = 100, Top = 100, // set signature rectangle Width = 100, Height = 30, // set signature alignment // when VerticalAlignment is set the Top coordinate will be ignored. // Use Margin properties Top, Bottom to provide vertical offset VerticalAlignment = Domain.VerticalAlignment.Top, // when HorizontalAlignment is set the Left coordinate will be ignored. // Use Margin properties Left, Right to provide horizontal offset HorizontalAlignment = Domain.HorizontalAlignment.Right, Margin = new Padding() { Top = 20, Right = 20 }, // adjust signature appearance // setup signature border Border = new Border() { Color = Color.IndianRed, DashStyle = DashStyle.DashLongDashDot, Transparency = 0.5, Visible = true, Weight = 2 }, // set text color and Font ForeColor = Color.Red, Font = new SignatureFont { Size = 12, FamilyName = "Comic Sans MS" }, // setup background Background = new Background() { Color = Color.LimeGreen, Transparency = 0.5, Brush = new LinearGradientBrush(Color.LimeGreen, Color.DarkGreen) }, // set rotation RotationAngle = 45, // set alternative signature implementation on document page SignatureImplementation = TextSignatureImplementation.Image }; // set up shadow options for text TextShadow shadow = new TextShadow() { Color = Color.OrangeRed, Angle = 135, Blur = 5, Distance = 4, Transparency = 0.2 }; //add text shadow to signature extensions options.Extensions.Add(shadow); // sign document to file SignResult signResult = signature.Sign(outputFilePath, options); Console.WriteLine($"\nSource document signed successfully with {signResult.Succeeded.Count} signature(s).\nFile saved at {outputFilePath}."); Console.WriteLine("\nList of newly created signatures:"); int number = 1; foreach (BaseSignature temp in signResult.Succeeded) { Console.WriteLine($"Signature #{number++}: Type: {temp.SignatureType} Id:{temp.SignatureId}, Location: {temp.Left}x{temp.Top}. Size: {temp.Width}x{temp.Height}"); } } }
public ColorDrawingEffect(Color4 color, TextShadow shadow) { Color = color; Shadow = shadow; }
public override void DrawStringCached(ref CachedRenderString cache, string fontName, float size, string text, float x, float y, Color4 color, bool underline = false, TextShadow shadow = default, TextAlignment alignment = TextAlignment.Left) { if (string.IsNullOrEmpty(text)) { return; } UpdateCache(ref cache, fontName, size, text, underline, alignment); var pc = (DirectWriteCachedText)cache; if (shadow.Enabled) { foreach (var q in pc.quads) { var d = q.Destination; d.X += (int)x + 2; d.Y += (int)y + 2; if (q.Texture == null) { render2d.FillRectangle(d, shadow.Color); } else { render2d.Draw(q.Texture, q.Source, d, shadow.Color); } } } foreach (var q in pc.quads) { var d = q.Destination; d.X += (int)x; d.Y += (int)y; if (q.Texture == null) { render2d.FillRectangle(d, color); } else { render2d.Draw(q.Texture, q.Source, d, color); } } }
public override void DrawStringBaseline(string fontName, float size, string text, float x, float y, Color4 color, bool underline = false, TextShadow shadow = default) { using (var layout = new TextLayout(dwFactory, text, GetFormat(fontName, ConvertSize(size)), float.MaxValue, float.MaxValue)) { layout.SetDrawingEffect(new ColorDrawingEffect(color, shadow), new TextRange(0, text.Length)); layout.Draw(Renderer, 0, 0); foreach (var q in Renderer.Quads) { var d = q.Destination; d.X += (int)x; d.Y += (int)y; if (q.Texture == null) { render2d.FillRectangle(d, q.Color); } else { render2d.Draw(q.Texture, q.Source, d, q.Color); } } Renderer.Quads = new List <DrawQuad>(); } }