diff --git a/src/BinaryKits.Zpl.Label/Elements/ZplFieldOrientation.cs b/src/BinaryKits.Zpl.Label/Elements/ZplFieldOrientation.cs
new file mode 100644
index 0000000..e729089
--- /dev/null
+++ b/src/BinaryKits.Zpl.Label/Elements/ZplFieldOrientation.cs
@@ -0,0 +1,24 @@
+using System.Collections.Generic;
+
+namespace BinaryKits.Zpl.Label.Elements
+{
+ ///
+ /// ^FW - Field Orientation
+ ///
+ public class ZplFieldOrientation : ZplElementBase
+ {
+ public FieldOrientation FieldOrientation { get; private set; }
+
+ public ZplFieldOrientation(FieldOrientation fieldOrientation)
+ {
+ this.FieldOrientation = fieldOrientation;
+ }
+
+ ///
+ public override IEnumerable Render(ZplRenderOptions context)
+ {
+ return new[] { $"^FW{RenderFieldOrientation(this.FieldOrientation)}" };
+ }
+
+ }
+}
diff --git a/src/BinaryKits.Zpl.Viewer.WebApi/Labels/Test/FieldDataText2-102x152.zpl2 b/src/BinaryKits.Zpl.Viewer.WebApi/Labels/Test/FieldDataText2-102x152.zpl2
index aad65db..f7585e6 100644
--- a/src/BinaryKits.Zpl.Viewer.WebApi/Labels/Test/FieldDataText2-102x152.zpl2
+++ b/src/BinaryKits.Zpl.Viewer.WebApi/Labels/Test/FieldDataText2-102x152.zpl2
@@ -1,32 +1,33 @@
^XA
^LH0,0
+^FWI
-^A0N,50,0
+^A0,50,0
^FO10,0
^FDFont1 Demo Text^FS
-^A1N,50,0
+^A1,50,0
^FO10,100
^FDFont2 Demo Text^FS
-^AAN,80,0
+^AA,80,0
^FO10,200
^FDFont3 Demo Text^FS
-^ABN,50,0
+^AB,50,0
^FO10,300
^FDFont4 Demo Text^FS
-^ACN,20,0
+^AC,20,0
^FO10,400
^FDFont5 Demo Text^FS
-^ADN,0,20
+^AD,0,20
^FO10,500
^FDFont6 Demo Text^FS
-^ADN,20,20
+^AD,20,20
^FO10,600
^FDFont7 Demo Text^FS
diff --git a/src/BinaryKits.Zpl.Viewer/CommandAnalyzers/FieldDataZplCommandAnalyzer.cs b/src/BinaryKits.Zpl.Viewer/CommandAnalyzers/FieldDataZplCommandAnalyzer.cs
index 3f0b9f6..1f7406a 100644
--- a/src/BinaryKits.Zpl.Viewer/CommandAnalyzers/FieldDataZplCommandAnalyzer.cs
+++ b/src/BinaryKits.Zpl.Viewer/CommandAnalyzers/FieldDataZplCommandAnalyzer.cs
@@ -206,8 +206,9 @@ private ZplFont GetFontFromVirtualPrinter()
int fontWidth = this.VirtualPrinter.FontWidth;
int fontHeight = this.VirtualPrinter.FontHeight;
string fontName = this.VirtualPrinter.FontName;
+ var fieldOrientation = this.VirtualPrinter.FieldOrientation;
- return new ZplFont(fontWidth, fontHeight, fontName);
+ return new ZplFont(fontWidth, fontHeight, fontName, fieldOrientation);
}
private ZplFont GetNextFontFromVirtualPrinter()
diff --git a/src/BinaryKits.Zpl.Viewer/CommandAnalyzers/FieldOrientationZplCommandAnalyzer.cs b/src/BinaryKits.Zpl.Viewer/CommandAnalyzers/FieldOrientationZplCommandAnalyzer.cs
new file mode 100644
index 0000000..c98a8cb
--- /dev/null
+++ b/src/BinaryKits.Zpl.Viewer/CommandAnalyzers/FieldOrientationZplCommandAnalyzer.cs
@@ -0,0 +1,22 @@
+using BinaryKits.Zpl.Label.Elements;
+
+namespace BinaryKits.Zpl.Viewer.CommandAnalyzers
+{
+ public class FieldOrientationZplCommandAnalyzer : ZplCommandAnalyzerBase
+ {
+ public FieldOrientationZplCommandAnalyzer(VirtualPrinter virtualPrinter) : base("^FW", virtualPrinter) { }
+
+ ///
+ public override ZplElementBase Analyze(string zplCommand)
+ {
+ var zplDataParts = this.SplitCommand(zplCommand);
+ if (zplDataParts.Length > 0)
+ {
+ var fieldOrientation = ConvertFieldOrientation(zplDataParts[0]);
+ this.VirtualPrinter.SetFieldOrientation(fieldOrientation);
+ }
+
+ return null;
+ }
+ }
+}
diff --git a/src/BinaryKits.Zpl.Viewer/CommandAnalyzers/ZplCommandAnalyzerBase.cs b/src/BinaryKits.Zpl.Viewer/CommandAnalyzers/ZplCommandAnalyzerBase.cs
index ac7c7e8..6ad1946 100644
--- a/src/BinaryKits.Zpl.Viewer/CommandAnalyzers/ZplCommandAnalyzerBase.cs
+++ b/src/BinaryKits.Zpl.Viewer/CommandAnalyzers/ZplCommandAnalyzerBase.cs
@@ -37,7 +37,7 @@ protected FieldOrientation ConvertFieldOrientation(string fieldOrientation)
"R" => FieldOrientation.Rotated90,
"I" => FieldOrientation.Rotated180,
"B" => FieldOrientation.Rotated270,
- _ => FieldOrientation.Normal,
+ _ => this.VirtualPrinter.FieldOrientation,
};
}
diff --git a/src/BinaryKits.Zpl.Viewer/VirtualPrinter.cs b/src/BinaryKits.Zpl.Viewer/VirtualPrinter.cs
index 2bfe896..5b11992 100644
--- a/src/BinaryKits.Zpl.Viewer/VirtualPrinter.cs
+++ b/src/BinaryKits.Zpl.Viewer/VirtualPrinter.cs
@@ -10,6 +10,7 @@ public class VirtualPrinter
public LabelPosition NextElementPosition { get; private set; }
public FieldDataBase NextElementFieldData { get; private set; }
public FieldBlock NextElementFieldBlock { get; private set; }
+ public FieldOrientation FieldOrientation { get; private set; } = FieldOrientation.Normal;
public int FontWidth { get; private set; } = 0;
public int FontHeight { get; private set; } = 10;
public string FontName { get; private set; } = "0";
@@ -103,6 +104,14 @@ public void ClearNextElementFieldUseHexadecimalIndicator()
this.NextElementFieldUseHexadecimalIndicator = false;
}
+ public void SetFieldOrientation(FieldOrientation fieldOrientation) {
+ this.FieldOrientation = fieldOrientation;
+ if (this.NextFont != null)
+ {
+ this.SetNextFont(this.NextFont.FontName, fieldOrientation, this.NextFont.FontWidth, this.NextFont.FontHeight);
+ }
+ }
+
public void SetFontWidth(int fontWidth)
{
this.FontWidth = fontWidth;
diff --git a/src/BinaryKits.Zpl.Viewer/ZplAnalyzer.cs b/src/BinaryKits.Zpl.Viewer/ZplAnalyzer.cs
index e816499..fb79d97 100644
--- a/src/BinaryKits.Zpl.Viewer/ZplAnalyzer.cs
+++ b/src/BinaryKits.Zpl.Viewer/ZplAnalyzer.cs
@@ -50,6 +50,7 @@ public AnalyzeInfo Analyze(string zplData)
new DownloadObjectsZplCommandAnaylzer(this._virtualPrinter, this._printerStorage),
new FieldBlockZplCommandAnalyzer(this._virtualPrinter),
new FieldHexadecimalZplCommandAnalyzer(this._virtualPrinter),
+ new FieldOrientationZplCommandAnalyzer(this._virtualPrinter),
new FieldNumberCommandAnalyzer(this._virtualPrinter),
new FieldVariableZplCommandAnalyzer(this._virtualPrinter),
new FieldReversePrintZplCommandAnalyzer(this._virtualPrinter),