@nativescript-community/text 1.6.7 → 1.6.8
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.8",
|
4
4
|
"description": "Expands the capabilities of NativeScript's text property.",
|
5
5
|
"main": "./index",
|
6
6
|
"sideEffects": false,
|
@@ -37,5 +37,5 @@
|
|
37
37
|
},
|
38
38
|
"license": "Apache-2.0",
|
39
39
|
"readmeFilename": "README.md",
|
40
|
-
"gitHead": "
|
40
|
+
"gitHead": "0810f355bfb768beb536456d570fc36531807fcc"
|
41
41
|
}
|
@@ -362,7 +362,7 @@ public class Font {
|
|
362
362
|
|
363
363
|
}
|
364
364
|
if (!Double.isNaN(fontSize)) {
|
365
|
-
ssb.setSpan(new FontSizeSpan(context, fontSize.floatValue(),
|
365
|
+
ssb.setSpan(new FontSizeSpan(context, fontSize.floatValue(), false), start, end,
|
366
366
|
android.text.Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
|
367
367
|
}
|
368
368
|
Double relativeSize = span.optDouble("relativeSize");
|
@@ -20,6 +20,7 @@ public class FontSizeSpan extends MetricAffectingSpan {
|
|
20
20
|
public FontSizeSpan(Context context, float size) {
|
21
21
|
mContext = context;
|
22
22
|
mSize = size;
|
23
|
+
mDip = false;
|
23
24
|
}
|
24
25
|
|
25
26
|
/**
|
@@ -43,19 +44,23 @@ public class FontSizeSpan extends MetricAffectingSpan {
|
|
43
44
|
static float FONT_SIZE_FACTOR = -1.0f;
|
44
45
|
static float SCREEN_DENSITY = -1.0f;
|
45
46
|
private void setTextPaintSize(TextPaint ds) {
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
47
|
+
if (mDip) {
|
48
|
+
int flags = ds.getFlags();
|
49
|
+
// dont think we can cache this as it would change when display change on the phone
|
50
|
+
if (FONT_SIZE_FACTOR == -1) {
|
51
|
+
android.util.DisplayMetrics metrics = mContext.getResources().getDisplayMetrics();
|
52
|
+
SCREEN_DENSITY = metrics.density;
|
53
|
+
FONT_SIZE_FACTOR = android.util.TypedValue.applyDimension(android.util.TypedValue.COMPLEX_UNIT_SP, 1, metrics);
|
54
|
+
}
|
55
|
+
if (mDip && (flags & 2048) != 2048) {
|
56
|
+
// this case is for use with TextView
|
57
|
+
ds.setTextSize(mSize * FONT_SIZE_FACTOR);
|
58
|
+
} else {
|
59
|
+
// this case is for StaticLayout drawing in canvas
|
60
|
+
ds.setTextSize(mSize * FONT_SIZE_FACTOR / SCREEN_DENSITY);
|
61
|
+
}
|
56
62
|
} else {
|
57
|
-
|
58
|
-
ds.setTextSize(mSize * FONT_SIZE_FACTOR / SCREEN_DENSITY);
|
63
|
+
ds.setTextSize(mSize);
|
59
64
|
}
|
60
65
|
}
|
61
66
|
|