@@ -2113,30 +2113,20 @@ export class StaticLayout {
2113
2113
}
2114
2114
const fullRange = { location : 0 , length : nsAttributedString . length } ;
2115
2115
nsAttributedString . addAttributeValueRange ( NSParagraphStyleAttributeName , paragraphStyle , fullRange ) ;
2116
+ this . toDraw = nsAttributedString ;
2116
2117
this . nsAttributedString . enumerateAttributesInRangeOptionsUsingBlock ( fullRange , 0 , ( attributes : NSDictionary < string , any > , range : NSRange , p3 : any ) => {
2117
2118
nsAttributedString . addAttributesRange ( attributes , range ) ;
2118
2119
} ) ;
2119
-
2120
- this . toDraw = nsAttributedString ;
2121
- let height ;
2122
- this . toDraw . enumerateAttributeInRangeOptionsUsingBlock ( 'verticalTextAligment' , fullRange , 0 , ( value , range ) => {
2123
- if ( value ) {
2124
- if ( ! height ) {
2125
- height = this . getHeight ( ) ;
2126
- }
2127
- const font : UIFont = this . toDraw . attributeAtIndexEffectiveRange ( NSFontAttributeName , range . location , null ) ;
2128
- const fontHeight = font . lineHeight ;
2129
- this . toDraw . addAttributeValueRange ( NSBaselineOffsetAttributeName , Math . round ( height / 2 - fontHeight / 2 ) , range ) ;
2130
- }
2131
- } ) ;
2132
2120
}
2133
2121
draw ( canvas : Canvas ) {
2122
+ canvas . startApplyPaint ( this . paint ) ;
2134
2123
const ctx = canvas . ctx ;
2135
2124
this . createAttributedStringToDraw ( ) ;
2136
2125
2137
2126
UIGraphicsPushContext ( ctx ) ;
2138
2127
this . toDraw . drawWithRectOptionsContext ( CGRectMake ( 0 , 0 , this . width , Number . MAX_VALUE ) , NSStringDrawingOptions . UsesLineFragmentOrigin , null ) ;
2139
2128
UIGraphicsPopContext ( ) ;
2129
+ canvas . finishApplyPaint ( this . paint ) ;
2140
2130
}
2141
2131
getPaint ( ) {
2142
2132
return this . paint ;
@@ -2149,11 +2139,19 @@ export class StaticLayout {
2149
2139
return this . rect ;
2150
2140
}
2151
2141
getWidth ( ) {
2152
- const result = this . getBounds ( ) . size . width ;
2153
- return Math . round ( isNaN ( result ) ? this . width : result ) ;
2142
+ if ( this . width ) {
2143
+ return this . width ;
2144
+ }
2145
+ let result = this . getBounds ( ) . size . width ;
2146
+ if ( isNaN ( result ) ) {
2147
+ result = this . width ;
2148
+ } else {
2149
+ result = Math . max ( result , this . width ) ;
2150
+ }
2151
+ return result ;
2154
2152
}
2155
2153
getHeight ( ) {
2156
2154
const result = this . getBounds ( ) . size . height ;
2157
- return Math . round ( result ) ;
2155
+ return result ;
2158
2156
}
2159
2157
}
0 commit comments