@nativescript-community/text 1.6.0 → 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@nativescript-community/text",
|
3
|
-
"version": "1.6.
|
3
|
+
"version": "1.6.2",
|
4
4
|
"description": "Expands the capabilities of NativeScript's text property.",
|
5
5
|
"main": "./index",
|
6
6
|
"sideEffects": false,
|
@@ -30,5 +30,5 @@
|
|
30
30
|
},
|
31
31
|
"license": "Apache-2.0",
|
32
32
|
"readmeFilename": "README.md",
|
33
|
-
"gitHead": "
|
33
|
+
"gitHead": "b1ccad631cbddb0346b0ceaa73804a4c231045a7"
|
34
34
|
}
|
@@ -7,7 +7,7 @@ import CoreGraphics
|
|
7
7
|
class NSTextUtils: NSObject {
|
8
8
|
class func setTextDecorationAndTransformOn(view:UIView!, text:String!, textDecoration:String!, letterSpacing:CGFloat, lineHeight:CGFloat, color:UIColor!) {
|
9
9
|
let attrDict:NSMutableDictionary! = NSMutableDictionary()
|
10
|
-
|
10
|
+
var paragraphStyle:NSMutableParagraphStyle! = nil
|
11
11
|
let isTextType:Bool = (view is UITextField) || (view is UITextView) || (view is UILabel) || (view is UIButton)
|
12
12
|
let isTextView:Bool = (view is UITextView)
|
13
13
|
|
@@ -23,7 +23,7 @@ class NSTextUtils: NSObject {
|
|
23
23
|
let kern:NSNumber! = NSNumber.init(value: letterSpacing * (view as! UILabel).font.pointSize)
|
24
24
|
attrDict[NSAttributedString.Key.kern] = kern
|
25
25
|
}
|
26
|
-
|
26
|
+
var fLineHeight = lineHeight
|
27
27
|
if fLineHeight >= 0 {
|
28
28
|
if fLineHeight == 0 {
|
29
29
|
fLineHeight = 0.00001
|
@@ -89,7 +89,7 @@ class NSTextUtils: NSObject {
|
|
89
89
|
}
|
90
90
|
}
|
91
91
|
class func computeBaseLineOffset(align:String!, fontAscent:Float, fontDescent:Float, fontBottom:Float, fontTop:Float, fontSize:Float, maxFontSize:Float) -> Float {
|
92
|
-
|
92
|
+
var result:Float = 0
|
93
93
|
if (align == "top") {
|
94
94
|
result = -maxFontSize - fontBottom - fontTop
|
95
95
|
} else if (align == "bottom") {
|
@@ -128,7 +128,7 @@ class NSTextUtils: NSObject {
|
|
128
128
|
attrText.enumerateAttribute(NSAttributedString.Key.link, in: fullRange) { value, range, stop in
|
129
129
|
if (value != nil) {
|
130
130
|
let attributes:NSMutableDictionary! = NSMutableDictionary(dictionary:attrText.attributes(at: range.location, longestEffectiveRange:nil, in:range))
|
131
|
-
|
131
|
+
var sValue:String! = nil
|
132
132
|
if (value is NSURL) {
|
133
133
|
sValue = (value as! NSURL).absoluteString
|
134
134
|
} else {
|
@@ -162,7 +162,7 @@ class NSTextUtils: NSObject {
|
|
162
162
|
if (letterSpacing != nil) && letterSpacing.floatValue != 0 {
|
163
163
|
attrText.addAttribute(NSAttributedString.Key.kern, value:letterSpacing.floatValue * fontSize.floatValue, range:fullRange)
|
164
164
|
}
|
165
|
-
|
165
|
+
var paragraphStyle:NSMutableParagraphStyle! = nil
|
166
166
|
let textAlignment:NSNumber! = data.object(forKey:"textAlignment") as? NSNumber
|
167
167
|
let createParagraphStyle:()->Void = {
|
168
168
|
if (paragraphStyle == nil) {
|
@@ -186,7 +186,7 @@ class NSTextUtils: NSObject {
|
|
186
186
|
let lineHeight:NSNumber! = data.object(forKey:"lineHeight") as? NSNumber
|
187
187
|
if (lineHeight != nil) {
|
188
188
|
createParagraphStyle()
|
189
|
-
|
189
|
+
var fLineHeight:Float = lineHeight.floatValue
|
190
190
|
if fLineHeight == 0.0 {
|
191
191
|
fLineHeight = 0.00001
|
192
192
|
}
|
@@ -264,7 +264,7 @@ class NSTextUtils: NSObject {
|
|
264
264
|
paragraphStyle.alignment = NSTextAlignment.left
|
265
265
|
}
|
266
266
|
if (lineHeight != nil) {
|
267
|
-
|
267
|
+
var fLineHeight:CGFloat = CGFloat(lineHeight.floatValue)
|
268
268
|
if fLineHeight == 0.0 {
|
269
269
|
fLineHeight = 0.00001
|
270
270
|
}
|