@@ -35,7 +35,7 @@ public final class Label: View {
3535 internal var texture : Texture {
3636 if needsUpdateTexture {
3737 needsUpdateTexture = false
38- _texture = font. texture ( forPointSize: UInt ( actualPointSize. rounded ( ) ) , style: style)
38+ _texture = font. texture ( forPointSize: actualPointSize, style: style)
3939 }
4040 return _texture
4141 }
@@ -76,7 +76,7 @@ public final class Label: View {
7676 fromString: text,
7777 font: font,
7878 pointSize: actualPointSize,
79- style: style,
79+ style: font . effectiveStyle ( for : style) ,
8080 paragraphWidth: paragraphWidth
8181 )
8282 _geometry. rawGeometry = values. 0
@@ -110,8 +110,8 @@ public final class Label: View {
110110 }
111111 }
112112 }
113- internal var actualPointSize : Float {
114- return Float ( fontSize) * interfaceScale
113+ internal var actualPointSize : UInt {
114+ return UInt ( ( Float ( fontSize) * interfaceScale) . rounded ( . awayFromZero ) )
115115 }
116116 public var style : Font . Style {
117117 didSet {
@@ -161,14 +161,14 @@ public final class Label: View {
161161 let yOffset : Float
162162 switch textAlignment {
163163 case . leading:
164- xOffset = 4
165- yOffset = 4
164+ xOffset = 4 * self . interfaceScale
165+ yOffset = ( rect . height / 2 ) - ( ( size . height / 2 ) * self . interfaceScale )
166166 case . centered:
167167 xOffset = ( rect. width / 2 ) - ( ( size. width / 2 ) * self . interfaceScale)
168168 yOffset = ( rect. height / 2 ) - ( ( size. height / 2 ) * self . interfaceScale)
169169 case . trailing:
170- xOffset = rect. width - ( size. width * self . interfaceScale) - 4
171- yOffset = rect. height - ( size. height * self . interfaceScale) - 4
170+ xOffset = rect. width - ( size. width * self . interfaceScale) - ( 4 * self . interfaceScale )
171+ yOffset = rect. height - ( size. height * self . interfaceScale) - ( 4 * self . interfaceScale )
172172 }
173173
174174 canvas. insert (
@@ -187,7 +187,7 @@ public final class Label: View {
187187 private static func rawGeometry(
188188 fromString string: String ,
189189 font: Font ,
190- pointSize: Float ,
190+ pointSize: UInt ,
191191 style: Font . Style ,
192192 paragraphWidth: Float ?
193193 ) -> ( RawGeometry , Size2 ) {
@@ -198,8 +198,6 @@ public final class Label: View {
198198 case wordComponent
199199 }
200200
201- let roundedPointSize = UInt ( pointSize. rounded ( ) )
202-
203201 var triangles : [ Triangle ] = [ ]
204202 triangles. reserveCapacity ( string. count)
205203
@@ -213,7 +211,7 @@ public final class Label: View {
213211 var currentWord : [ Triangle ] = [ ]
214212
215213 func newLine( ) {
216- yPosition += pointSize
214+ yPosition += Float ( pointSize)
217215 lineCount += 1
218216 }
219217
@@ -261,7 +259,7 @@ public final class Label: View {
261259 func processCharacter( _ char: Character ) {
262260 let quad = font. alignedCharacter (
263261 forCharacter: char,
264- pointSize: roundedPointSize ,
262+ pointSize: pointSize ,
265263 style: style,
266264 origin: Position2 ( xPosition, yPosition) ,
267265 xAdvance: & xAdvance
@@ -292,7 +290,7 @@ public final class Label: View {
292290 var xAdvance : Float = . nan
293291 let quad = font. alignedCharacter (
294292 forCharacter: char,
295- pointSize: roundedPointSize ,
293+ pointSize: pointSize ,
296294 style: style,
297295 origin: Position2 ( xPosition, yPosition) ,
298296 xAdvance: & xAdvance
0 commit comments