@@ -30,6 +30,7 @@ public override void Draw(ZplElementBase element, DrawerOptions options)
30
30
{
31
31
float x = textField . PositionX ;
32
32
float y = textField . PositionY ;
33
+ var fieldJustification = Label . FieldJustification . None ;
33
34
34
35
var font = textField . Font ;
35
36
@@ -84,6 +85,7 @@ public override void Draw(ZplElementBase element, DrawerOptions options)
84
85
case Label . FieldOrientation . Normal :
85
86
break ;
86
87
}
88
+ fieldJustification = textField . FieldOrigin . FieldJustification ;
87
89
}
88
90
else
89
91
{
@@ -101,6 +103,7 @@ public override void Draw(ZplElementBase element, DrawerOptions options)
101
103
case Label . FieldOrientation . Normal :
102
104
break ;
103
105
}
106
+ fieldJustification = textField . FieldTypeset . FieldJustification ;
104
107
}
105
108
106
109
if ( matrix != SKMatrix . Empty )
@@ -118,7 +121,27 @@ public override void Draw(ZplElementBase element, DrawerOptions options)
118
121
skPaint . BlendMode = SKBlendMode . Xor ;
119
122
}
120
123
124
+ if ( fieldJustification == Label . FieldJustification . Left )
125
+ {
126
+ skPaint . TextAlign = SKTextAlign . Left ;
127
+ }
128
+ else if ( fieldJustification == Label . FieldJustification . Right )
129
+ {
130
+ skPaint . TextAlign = SKTextAlign . Right ;
131
+ }
132
+ else if ( fieldJustification == Label . FieldJustification . Auto )
133
+ {
134
+ var buffer = new HarfBuzzSharp . Buffer ( ) ;
135
+ buffer . AddUtf16 ( displayText ) ;
136
+ buffer . GuessSegmentProperties ( ) ;
137
+ if ( buffer . Direction == HarfBuzzSharp . Direction . RightToLeft )
138
+ {
139
+ skPaint . TextAlign = SKTextAlign . Right ;
140
+ }
141
+ }
142
+
121
143
this . _skCanvas . DrawShapedText ( displayText , x , y , skPaint ) ;
144
+
122
145
}
123
146
}
124
147
}
0 commit comments