From e483d7f639a115aa2f86282cc8500ad6b99cc41d Mon Sep 17 00:00:00 2001 From: primo-ppcg Date: Wed, 17 May 2023 22:15:12 +0700 Subject: [PATCH] Add Support for RTL languages Fixes #162 - Changes both instances of `DrawText` with `DrawShapedText` - Requires an additional dependency (~200kb). --- src/BinaryKits.Zpl.Viewer/BinaryKits.Zpl.Viewer.csproj | 1 + .../ElementDrawers/FieldBlockElementDrawer.cs | 3 ++- .../ElementDrawers/TextFieldElementDrawer.cs | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/src/BinaryKits.Zpl.Viewer/BinaryKits.Zpl.Viewer.csproj b/src/BinaryKits.Zpl.Viewer/BinaryKits.Zpl.Viewer.csproj index 1505e04f..13f8e209 100644 --- a/src/BinaryKits.Zpl.Viewer/BinaryKits.Zpl.Viewer.csproj +++ b/src/BinaryKits.Zpl.Viewer/BinaryKits.Zpl.Viewer.csproj @@ -25,6 +25,7 @@ + diff --git a/src/BinaryKits.Zpl.Viewer/ElementDrawers/FieldBlockElementDrawer.cs b/src/BinaryKits.Zpl.Viewer/ElementDrawers/FieldBlockElementDrawer.cs index 76528f58..d7a5f06b 100644 --- a/src/BinaryKits.Zpl.Viewer/ElementDrawers/FieldBlockElementDrawer.cs +++ b/src/BinaryKits.Zpl.Viewer/ElementDrawers/FieldBlockElementDrawer.cs @@ -2,6 +2,7 @@ using BinaryKits.Zpl.Label.Elements; using BinaryKits.Zpl.Viewer.Helpers; using SkiaSharp; +using SkiaSharp.HarfBuzz; using System; using System.Collections.Generic; using System.Linq; @@ -150,7 +151,7 @@ public override void Draw(ZplElementBase element, DrawerOptions options) break; } - this._skCanvas.DrawText(textLine, x, y, skFont, skPaint); + this._skCanvas.DrawShapedText(textLine, x, y, skPaint); y += lineHeight; } } diff --git a/src/BinaryKits.Zpl.Viewer/ElementDrawers/TextFieldElementDrawer.cs b/src/BinaryKits.Zpl.Viewer/ElementDrawers/TextFieldElementDrawer.cs index f476774d..d709b32a 100644 --- a/src/BinaryKits.Zpl.Viewer/ElementDrawers/TextFieldElementDrawer.cs +++ b/src/BinaryKits.Zpl.Viewer/ElementDrawers/TextFieldElementDrawer.cs @@ -1,6 +1,7 @@ using BinaryKits.Zpl.Label.Elements; using BinaryKits.Zpl.Viewer.Helpers; using SkiaSharp; +using SkiaSharp.HarfBuzz; using System; namespace BinaryKits.Zpl.Viewer.ElementDrawers @@ -116,7 +117,7 @@ public override void Draw(ZplElementBase element, DrawerOptions options) y += textBoundBaseline.Height; } - this._skCanvas.DrawText(displayText, x, y, skFont, skPaint); + this._skCanvas.DrawShapedText(displayText, x, y, skPaint); } } }