@akylas/nativescript 8.3.5 → 8.4.1
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/accessibility/accessibility-common.js +2 -2
- package/accessibility/accessibility-common.js.map +1 -1
- package/accessibility/accessibility-service-common.js +1 -1
- package/accessibility/accessibility-service-common.js.map +1 -1
- package/accessibility/accessibility-service.android.js +2 -1
- package/accessibility/accessibility-service.android.js.map +1 -1
- package/accessibility/accessibility-service.ios.js +1 -1
- package/accessibility/accessibility-service.ios.js.map +1 -1
- package/accessibility/font-scale.android.js +1 -2
- package/accessibility/font-scale.android.js.map +1 -1
- package/accessibility/index.android.js +8 -8
- package/accessibility/index.android.js.map +1 -1
- package/accessibility/index.ios.js +5 -6
- package/accessibility/index.ios.js.map +1 -1
- package/application/index.android.js +14 -2
- package/application/index.android.js.map +1 -1
- package/application/index.ios.js +4 -5
- package/application/index.ios.js.map +1 -1
- package/application-settings/index.android.js +4 -2
- package/application-settings/index.android.js.map +1 -1
- package/color/color-common.d.ts +5 -2
- package/color/color-common.js +11 -8
- package/color/color-common.js.map +1 -1
- package/color/index.android.d.ts +2 -2
- package/color/index.android.js +2 -2
- package/color/index.android.js.map +1 -1
- package/color/index.d.ts +1 -1
- package/color/index.ios.d.ts +2 -2
- package/color/index.ios.js +8 -4
- package/color/index.ios.js.map +1 -1
- package/connectivity/index.android.js +4 -3
- package/connectivity/index.android.js.map +1 -1
- package/core-types/index.d.ts +1 -0
- package/core-types/index.js +4 -0
- package/core-types/index.js.map +1 -1
- package/css/parser.js +1 -1
- package/css/parser.js.map +1 -1
- package/css/reworkcss.d.ts +2 -2
- package/file-system/file-system-access.android.js +26 -13
- package/file-system/file-system-access.android.js.map +1 -1
- package/file-system/index.js +2 -2
- package/file-system/index.js.map +1 -1
- package/fps-meter/fps-native.android.d.ts +0 -1
- package/fps-meter/fps-native.android.js +2 -3
- package/fps-meter/fps-native.android.js.map +1 -1
- package/fps-meter/fps-native.ios.js +2 -1
- package/fps-meter/fps-native.ios.js.map +1 -1
- package/global-types.d.ts +12 -7
- package/globals/index.js +4 -1
- package/globals/index.js.map +1 -1
- package/image-asset/index.ios.js +1 -2
- package/image-asset/index.ios.js.map +1 -1
- package/image-source/index.android.js +5 -1
- package/image-source/index.android.js.map +1 -1
- package/image-source/index.ios.js +2 -4
- package/image-source/index.ios.js.map +1 -1
- package/index.d.ts +5 -1
- package/index.js +6 -1
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/platform/index.android.js +3 -2
- package/platform/index.android.js.map +1 -1
- package/platforms/android/native-api-usage.json +5 -0
- package/platforms/android/widgets-release.aar +0 -0
- package/platforms/ios/src/NativeScriptUtils.h +1 -1
- package/platforms/ios/src/NativeScriptUtils.m +19 -19
- package/platforms/ios/typings/objc!MaterialComponents.d.ts +0 -1
- package/platforms/ios/typings/objc!NativeScriptUtils.d.ts +1 -2
- package/timer/index.android.js +8 -0
- package/timer/index.android.js.map +1 -1
- package/ui/action-bar/action-bar-common.js +4 -8
- package/ui/action-bar/action-bar-common.js.map +1 -1
- package/ui/action-bar/index.android.js +16 -23
- package/ui/action-bar/index.android.js.map +1 -1
- package/ui/action-bar/index.ios.js +9 -15
- package/ui/action-bar/index.ios.js.map +1 -1
- package/ui/animation/animation-common.js +1 -2
- package/ui/animation/animation-common.js.map +1 -1
- package/ui/animation/index.android.js +5 -4
- package/ui/animation/index.android.js.map +1 -1
- package/ui/animation/index.ios.d.ts +2 -2
- package/ui/animation/index.ios.js +31 -31
- package/ui/animation/index.ios.js.map +1 -1
- package/ui/animation/keyframe-animation.js +3 -3
- package/ui/animation/keyframe-animation.js.map +1 -1
- package/ui/builder/index.js +15 -2
- package/ui/builder/index.js.map +1 -1
- package/ui/button/index.android.d.ts +0 -1
- package/ui/button/index.android.js +6 -16
- package/ui/button/index.android.js.map +1 -1
- package/ui/button/index.ios.js +1 -1
- package/ui/button/index.ios.js.map +1 -1
- package/ui/core/bindable/bindable-expressions.js +5 -7
- package/ui/core/bindable/bindable-expressions.js.map +1 -1
- package/ui/core/bindable/index.js +1 -1
- package/ui/core/bindable/index.js.map +1 -1
- package/ui/core/properties/index.d.ts +0 -1
- package/ui/core/properties/index.js.map +1 -1
- package/ui/core/view/index.android.js +9 -13
- package/ui/core/view/index.android.js.map +1 -1
- package/ui/core/view/index.ios.js +2 -2
- package/ui/core/view/index.ios.js.map +1 -1
- package/ui/core/view/view-common.js +9 -10
- package/ui/core/view/view-common.js.map +1 -1
- package/ui/core/view/view-helper/index.ios.js +14 -7
- package/ui/core/view/view-helper/index.ios.js.map +1 -1
- package/ui/core/view-base/index.d.ts +1 -1
- package/ui/core/view-base/index.js +13 -14
- package/ui/core/view-base/index.js.map +1 -1
- package/ui/date-picker/index.ios.js +2 -1
- package/ui/editable-text-base/index.android.js +2 -4
- package/ui/editable-text-base/index.android.js.map +1 -1
- package/ui/editable-text-base/index.ios.js +5 -0
- package/ui/editable-text-base/index.ios.js.map +1 -1
- package/ui/frame/index.android.js +2 -3
- package/ui/frame/index.android.js.map +1 -1
- package/ui/frame/index.ios.d.ts +1 -0
- package/ui/frame/index.ios.js +19 -9
- package/ui/frame/index.ios.js.map +1 -1
- package/ui/gestures/index.ios.js +2 -1
- package/ui/gestures/index.ios.js.map +1 -1
- package/ui/gestures/touch-manager.js +16 -17
- package/ui/gestures/touch-manager.js.map +1 -1
- package/ui/html-view/html-view-common.d.ts +2 -0
- package/ui/html-view/html-view-common.js +7 -0
- package/ui/html-view/html-view-common.js.map +1 -1
- package/ui/html-view/index.android.js +14 -3
- package/ui/html-view/index.android.js.map +1 -1
- package/ui/html-view/index.d.ts +4 -3
- package/ui/html-view/index.ios.js +10 -4
- package/ui/html-view/index.ios.js.map +1 -1
- package/ui/image/index.ios.js +5 -8
- package/ui/image/index.ios.js.map +1 -1
- package/ui/image-cache/index.android.js +2 -2
- package/ui/image-cache/index.android.js.map +1 -1
- package/ui/index.d.ts +1 -1
- package/ui/index.js +1 -1
- package/ui/index.js.map +1 -1
- package/ui/layouts/absolute-layout/absolute-layout-common.js +4 -3
- package/ui/layouts/absolute-layout/absolute-layout-common.js.map +1 -1
- package/ui/layouts/root-layout/index.android.js +14 -8
- package/ui/layouts/root-layout/index.android.js.map +1 -1
- package/ui/layouts/root-layout/index.ios.js +16 -10
- package/ui/layouts/root-layout/index.ios.js.map +1 -1
- package/ui/layouts/root-layout/root-layout-common.js +26 -15
- package/ui/layouts/root-layout/root-layout-common.js.map +1 -1
- package/ui/list-picker/index.android.js +0 -3
- package/ui/list-picker/index.android.js.map +1 -1
- package/ui/list-picker/index.ios.js +6 -3
- package/ui/list-view/index.ios.js +18 -11
- package/ui/list-view/index.ios.js.map +1 -1
- package/ui/page/index.android.d.ts +1 -0
- package/ui/page/index.android.js +21 -9
- package/ui/page/index.android.js.map +1 -1
- package/ui/page/index.ios.d.ts +6 -0
- package/ui/page/index.ios.js +54 -16
- package/ui/page/index.ios.js.map +1 -1
- package/ui/repeater/index.js.map +1 -1
- package/ui/scroll-view/index.android.js +6 -6
- package/ui/scroll-view/index.android.js.map +1 -1
- package/ui/scroll-view/index.ios.js +2 -1
- package/ui/scroll-view/index.ios.js.map +1 -1
- package/ui/search-bar/index.ios.js +6 -3
- package/ui/search-bar/index.ios.js.map +1 -1
- package/ui/segmented-bar/index.android.js +3 -4
- package/ui/segmented-bar/index.android.js.map +1 -1
- package/ui/segmented-bar/index.ios.js +3 -2
- package/ui/segmented-bar/index.ios.js.map +1 -1
- package/ui/slider/index.ios.js +6 -3
- package/ui/slider/index.ios.js.map +1 -1
- package/ui/styling/background.ios.js +2 -3
- package/ui/styling/background.ios.js.map +1 -1
- package/ui/styling/css-animation-parser.js +1 -1
- package/ui/styling/css-animation-parser.js.map +1 -1
- package/ui/styling/{css-selector/index.d.ts → css-selector.d.ts} +4 -3
- package/ui/styling/{css-selector/index.js → css-selector.js} +6 -6
- package/ui/styling/css-selector.js.map +1 -0
- package/ui/styling/css-shadow.js +5 -4
- package/ui/styling/css-shadow.js.map +1 -1
- package/ui/styling/font-common.d.ts +16 -7
- package/ui/styling/font-common.js +71 -5
- package/ui/styling/font-common.js.map +1 -1
- package/ui/styling/font-interfaces.d.ts +9 -4
- package/ui/styling/font.android.d.ts +4 -2
- package/ui/styling/font.android.js +56 -27
- package/ui/styling/font.android.js.map +1 -1
- package/ui/styling/font.d.ts +16 -17
- package/ui/styling/font.ios.d.ts +5 -3
- package/ui/styling/font.ios.js +36 -12
- package/ui/styling/font.ios.js.map +1 -1
- package/ui/styling/style/index.d.ts +3 -3
- package/ui/styling/style-properties.d.ts +4 -4
- package/ui/styling/style-properties.js +35 -20
- package/ui/styling/style-properties.js.map +1 -1
- package/ui/switch/index.ios.js +3 -3
- package/ui/switch/index.ios.js.map +1 -1
- package/ui/tab-view/index.ios.js +16 -8
- package/ui/tab-view/index.ios.js.map +1 -1
- package/ui/text-base/formatted-string.d.ts +5 -5
- package/ui/text-base/formatted-string.js.map +1 -1
- package/ui/text-base/index.android.js +8 -2
- package/ui/text-base/index.android.js.map +1 -1
- package/ui/text-base/index.ios.js +4 -3
- package/ui/text-base/index.ios.js.map +1 -1
- package/ui/text-base/span.d.ts +5 -5
- package/ui/text-base/span.js.map +1 -1
- package/ui/text-base/text-base-common.d.ts +6 -6
- package/ui/text-base/text-base-common.js.map +1 -1
- package/ui/text-field/index.ios.js +18 -15
- package/ui/text-field/index.ios.js.map +1 -1
- package/ui/text-view/index.ios.js +12 -6
- package/ui/text-view/index.ios.js.map +1 -1
- package/ui/time-picker/index.android.js +3 -4
- package/ui/time-picker/index.android.js.map +1 -1
- package/ui/time-picker/index.ios.js +2 -1
- package/ui/utils.ios.js +1 -1
- package/ui/utils.ios.js.map +1 -1
- package/ui/web-view/index.ios.js +12 -6
- package/ui/web-view/index.ios.js.map +1 -1
- package/utils/{utils-common.d.ts → common.d.ts} +6 -2
- package/utils/{utils-common.js → common.js} +13 -3
- package/utils/common.js.map +1 -0
- package/utils/constants.android.d.ts +1 -0
- package/utils/constants.android.js +2 -0
- package/utils/constants.android.js.map +1 -0
- package/utils/constants.d.ts +1 -0
- package/utils/constants.ios.d.ts +1 -0
- package/utils/constants.ios.js +2 -0
- package/utils/constants.ios.js.map +1 -0
- package/utils/debug.js +3 -3
- package/utils/debug.js.map +1 -1
- package/utils/index.android.d.ts +4 -1
- package/utils/index.android.js +28 -8
- package/utils/index.android.js.map +1 -1
- package/utils/index.d.ts +19 -81
- package/utils/index.ios.d.ts +4 -1
- package/utils/index.ios.js +13 -1
- package/utils/index.ios.js.map +1 -1
- package/utils/layout-helper/index.android.d.ts +24 -9
- package/utils/layout-helper/index.android.js +72 -33
- package/utils/layout-helper/index.android.js.map +1 -1
- package/utils/layout-helper/index.d.ts +68 -63
- package/utils/layout-helper/index.ios.d.ts +24 -9
- package/utils/layout-helper/index.ios.js +62 -24
- package/utils/layout-helper/index.ios.js.map +1 -1
- package/utils/native-helper.android.d.ts +2 -0
- package/utils/native-helper.android.js +13 -2
- package/utils/native-helper.android.js.map +1 -1
- package/utils/native-helper.d.ts +25 -0
- package/utils/native-helper.ios.d.ts +3 -1
- package/utils/native-helper.ios.js +29 -12
- package/utils/native-helper.ios.js.map +1 -1
- package/jest.config.d.ts +0 -5
- package/jest.config.js.map +0 -1
- package/ui/styling/css-selector/index.js.map +0 -1
- package/utils/utils-common.js.map +0 -1
- package/utils/utils.android.d.ts +0 -5
- package/utils/utils.android.js +0 -6
- package/utils/utils.android.js.map +0 -1
- package/utils/utils.d.ts +0 -1
- package/utils/utils.ios.d.ts +0 -5
- package/utils/utils.ios.js +0 -6
- package/utils/utils.ios.js.map +0 -1
|
@@ -1,29 +1,33 @@
|
|
|
1
|
-
import { Font as FontBase, parseFontFamily, genericFontFamilies, FontWeight } from './font-common';
|
|
1
|
+
import { Font as FontBase, parseFontFamily, genericFontFamilies, FontWeight, FontVariationSettings } from './font-common';
|
|
2
2
|
import { Trace } from '../../trace';
|
|
3
|
-
import
|
|
3
|
+
import { SDK_VERSION } from '../../utils/constants';
|
|
4
4
|
import * as fs from '../../file-system';
|
|
5
|
+
import { ad } from '../../utils';
|
|
5
6
|
export * from './font-common';
|
|
6
7
|
const FONTS_BASE_PATH = '/fonts/';
|
|
7
8
|
const typefaceCache = new Map();
|
|
8
9
|
let appAssets;
|
|
9
10
|
export class Font extends FontBase {
|
|
10
|
-
constructor(family, size, style, weight) {
|
|
11
|
-
super(family, size, style, weight, 1);
|
|
11
|
+
constructor(family, size, style, weight, fontVariationSettings) {
|
|
12
|
+
super(family, size, style, weight, 1, fontVariationSettings);
|
|
12
13
|
}
|
|
13
14
|
withFontFamily(family) {
|
|
14
|
-
return new Font(family, this.fontSize, this.fontStyle, this.fontWeight);
|
|
15
|
+
return new Font(family, this.fontSize, this.fontStyle, this.fontWeight, this.fontVariationSettings);
|
|
15
16
|
}
|
|
16
17
|
withFontStyle(style) {
|
|
17
|
-
return new Font(this.fontFamily, this.fontSize, style, this.fontWeight);
|
|
18
|
+
return new Font(this.fontFamily, this.fontSize, style, this.fontWeight, this.fontVariationSettings);
|
|
18
19
|
}
|
|
19
20
|
withFontWeight(weight) {
|
|
20
|
-
return new Font(this.fontFamily, this.fontSize, this.fontStyle, weight);
|
|
21
|
+
return new Font(this.fontFamily, this.fontSize, this.fontStyle, weight, this.fontVariationSettings);
|
|
21
22
|
}
|
|
22
23
|
withFontSize(size) {
|
|
23
|
-
return new Font(this.fontFamily, size, this.fontStyle, this.fontWeight);
|
|
24
|
+
return new Font(this.fontFamily, size, this.fontStyle, this.fontWeight, this.fontVariationSettings);
|
|
24
25
|
}
|
|
25
26
|
withFontScale(scale) {
|
|
26
|
-
return new Font(this.fontFamily, this.fontSize, this.fontStyle, this.fontWeight);
|
|
27
|
+
return new Font(this.fontFamily, this.fontSize, this.fontStyle, this.fontWeight, this.fontVariationSettings);
|
|
28
|
+
}
|
|
29
|
+
withFontVariationSettings(variationSettings) {
|
|
30
|
+
return new Font(this.fontFamily, this.fontSize, this.fontStyle, this.fontWeight, variationSettings);
|
|
27
31
|
}
|
|
28
32
|
getAndroidTypeface() {
|
|
29
33
|
if (!this._typeface) {
|
|
@@ -36,12 +40,18 @@ export class Font extends FontBase {
|
|
|
36
40
|
}
|
|
37
41
|
}
|
|
38
42
|
Font.default = new Font(undefined, undefined);
|
|
39
|
-
function
|
|
40
|
-
|
|
43
|
+
function computeFontCacheKey(fontFamily, font) {
|
|
44
|
+
const sep = ':';
|
|
45
|
+
return [fontFamily, String(FontVariationSettings.toString(font.fontVariationSettings)).replace(/'/g, '').replace(/[\s,]/g, '_')].join(sep);
|
|
46
|
+
}
|
|
47
|
+
function loadFontFromFile(fontFamily, font) {
|
|
48
|
+
const apiLevel = android.os.Build.VERSION.SDK_INT;
|
|
49
|
+
const cacheKey = apiLevel >= 26 ? computeFontCacheKey(fontFamily, font) : fontFamily;
|
|
50
|
+
appAssets = appAssets || ad.getApplicationContext().getAssets();
|
|
41
51
|
if (!appAssets) {
|
|
42
52
|
return null;
|
|
43
53
|
}
|
|
44
|
-
let result = typefaceCache.get(
|
|
54
|
+
let result = typefaceCache.get(cacheKey);
|
|
45
55
|
// Check for undefined explicitly as null mean we tried to load the font, but failed.
|
|
46
56
|
if (result === undefined) {
|
|
47
57
|
result = null;
|
|
@@ -53,15 +63,30 @@ function loadFontFromFile(fontFamily) {
|
|
|
53
63
|
else if (fs.File.exists(basePath + '.otf')) {
|
|
54
64
|
fontAssetPath = FONTS_BASE_PATH + fontFamily + '.otf';
|
|
55
65
|
}
|
|
56
|
-
else {
|
|
57
|
-
|
|
58
|
-
Trace.write('Could not find font file for ' + fontFamily, Trace.categories.Error, Trace.messageType.error);
|
|
59
|
-
}
|
|
66
|
+
else if (Trace.isEnabled()) {
|
|
67
|
+
Trace.write('Could not find font file for ' + fontFamily, Trace.categories.Error, Trace.messageType.error);
|
|
60
68
|
}
|
|
61
69
|
if (fontAssetPath) {
|
|
62
70
|
try {
|
|
63
71
|
fontAssetPath = fs.path.join(fs.knownFolders.currentApp().path, fontAssetPath);
|
|
64
|
-
|
|
72
|
+
if (apiLevel >= 26) {
|
|
73
|
+
const builder = new android.graphics.Typeface.Builder(fontAssetPath);
|
|
74
|
+
if (builder) {
|
|
75
|
+
if (font.fontVariationSettings !== undefined) {
|
|
76
|
+
builder.setFontVariationSettings(font.fontVariationSettings?.length ? FontVariationSettings.toString(font.fontVariationSettings) : '');
|
|
77
|
+
}
|
|
78
|
+
result = builder.build();
|
|
79
|
+
}
|
|
80
|
+
else {
|
|
81
|
+
result = android.graphics.Typeface.createFromFile(fontAssetPath);
|
|
82
|
+
if (Trace.isEnabled()) {
|
|
83
|
+
Trace.write('Could not create builder for ' + fontFamily, Trace.categories.Error, Trace.messageType.error);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
else {
|
|
88
|
+
result = android.graphics.Typeface.createFromFile(fontAssetPath);
|
|
89
|
+
}
|
|
65
90
|
}
|
|
66
91
|
catch (e) {
|
|
67
92
|
if (Trace.isEnabled()) {
|
|
@@ -69,7 +94,7 @@ function loadFontFromFile(fontFamily) {
|
|
|
69
94
|
}
|
|
70
95
|
}
|
|
71
96
|
}
|
|
72
|
-
typefaceCache.set(
|
|
97
|
+
typefaceCache.set(cacheKey, result);
|
|
73
98
|
}
|
|
74
99
|
return result;
|
|
75
100
|
}
|
|
@@ -82,10 +107,10 @@ function createTypeface(font) {
|
|
|
82
107
|
fontStyle |= android.graphics.Typeface.ITALIC;
|
|
83
108
|
}
|
|
84
109
|
//http://stackoverflow.com/questions/19691530/valid-values-for-androidfontfamily-and-what-they-map-to
|
|
85
|
-
const
|
|
110
|
+
const fontFamilies = parseFontFamily(font.fontFamily);
|
|
86
111
|
let result = null;
|
|
87
|
-
for (
|
|
88
|
-
switch (
|
|
112
|
+
for (const fontFamily of fontFamilies) {
|
|
113
|
+
switch (fontFamily.toLowerCase()) {
|
|
89
114
|
case genericFontFamilies.serif:
|
|
90
115
|
result = android.graphics.Typeface.create('serif' + getFontWeightSuffix(font.fontWeight), fontStyle);
|
|
91
116
|
break;
|
|
@@ -96,12 +121,13 @@ function createTypeface(font) {
|
|
|
96
121
|
case genericFontFamilies.monospace:
|
|
97
122
|
result = android.graphics.Typeface.create('monospace' + getFontWeightSuffix(font.fontWeight), fontStyle);
|
|
98
123
|
break;
|
|
99
|
-
default:
|
|
100
|
-
result = loadFontFromFile(
|
|
124
|
+
default: {
|
|
125
|
+
result = loadFontFromFile(fontFamily, font);
|
|
101
126
|
if (result && fontStyle) {
|
|
102
127
|
result = android.graphics.Typeface.create(result, fontStyle);
|
|
103
128
|
}
|
|
104
129
|
break;
|
|
130
|
+
}
|
|
105
131
|
}
|
|
106
132
|
if (result) {
|
|
107
133
|
// Found the font!
|
|
@@ -114,12 +140,15 @@ function createTypeface(font) {
|
|
|
114
140
|
return result;
|
|
115
141
|
}
|
|
116
142
|
function getFontWeightSuffix(fontWeight) {
|
|
143
|
+
if (typeof fontWeight === 'number') {
|
|
144
|
+
fontWeight = (fontWeight + '');
|
|
145
|
+
}
|
|
117
146
|
switch (fontWeight) {
|
|
118
147
|
case FontWeight.THIN:
|
|
119
|
-
return
|
|
148
|
+
return SDK_VERSION >= 16 ? '-thin' : '';
|
|
120
149
|
case FontWeight.EXTRA_LIGHT:
|
|
121
150
|
case FontWeight.LIGHT:
|
|
122
|
-
return
|
|
151
|
+
return SDK_VERSION >= 16 ? '-light' : '';
|
|
123
152
|
case FontWeight.NORMAL:
|
|
124
153
|
case '400':
|
|
125
154
|
case undefined:
|
|
@@ -127,13 +156,13 @@ function getFontWeightSuffix(fontWeight) {
|
|
|
127
156
|
return '';
|
|
128
157
|
case FontWeight.MEDIUM:
|
|
129
158
|
case FontWeight.SEMI_BOLD:
|
|
130
|
-
return
|
|
159
|
+
return SDK_VERSION >= 21 ? '-medium' : '';
|
|
131
160
|
case FontWeight.BOLD:
|
|
132
161
|
case '700':
|
|
133
162
|
case FontWeight.EXTRA_BOLD:
|
|
134
163
|
return '';
|
|
135
164
|
case FontWeight.BLACK:
|
|
136
|
-
return
|
|
165
|
+
return SDK_VERSION >= 21 ? '-black' : '';
|
|
137
166
|
default:
|
|
138
167
|
throw new Error(`Invalid font weight: "${fontWeight}"`);
|
|
139
168
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"font.android.js","sourceRoot":"","sources":["../../../../../packages/core/ui/styling/font.android.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,eAAe,EAAE,mBAAmB,
|
|
1
|
+
{"version":3,"file":"font.android.js","sourceRoot":"","sources":["../../../../../packages/core/ui/styling/font.android.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,eAAe,EAAE,mBAAmB,EAAE,UAAU,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AAE1H,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC,cAAc,eAAe,CAAC;AAE9B,MAAM,eAAe,GAAG,SAAS,CAAC;AAClC,MAAM,aAAa,GAAG,IAAI,GAAG,EAAqC,CAAC;AACnE,IAAI,SAA2C,CAAC;AAEhD,MAAM,OAAO,IAAK,SAAQ,QAAQ;IAKjC,YAAY,MAAc,EAAE,IAAY,EAAE,KAAqB,EAAE,MAAuB,EAAE,qBAAwD;QACjJ,KAAK,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,EAAE,qBAAqB,CAAC,CAAC;IAC9D,CAAC;IAEM,cAAc,CAAC,MAAc;QACnC,OAAO,IAAI,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,qBAAqB,CAAC,CAAC;IACrG,CAAC;IAEM,aA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U,CAAC,MAAM,CAAC;QACvB,KAAK,KAAK,CAAC;QACX,KAAK,SAAS,CAAC;QACf,KAAK,IAAI;YACR,OAAO,EAAE,CAAC;QACX,KAAK,UAAU,CAAC,MAAM,CAAC;QACvB,KAAK,UAAU,CAAC,SAAS;YACxB,OAAO,WAAW,IAAI,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3C,KAAK,UAAU,CAAC,IAAI,CAAC;QACrB,KAAK,KAAK,CAAC;QACX,KAAK,UAAU,CAAC,UAAU;YACzB,OAAO,EAAE,CAAC;QACX,KAAK,UAAU,CAAC,KAAK;YACpB,OAAO,WAAW,IAAI,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC;QAC1C;YACC,MAAM,IAAI,KAAK,CAAC,yBAAyB,UAAU,GAAG,CAAC,CAAC;KACzD;AACF,CAAC"}
|
package/ui/styling/font.d.ts
CHANGED
|
@@ -1,38 +1,41 @@
|
|
|
1
|
-
|
|
1
|
+
import { Font as FontBase } from './font-common';
|
|
2
|
+
export type { FontStyleType, FontWeightType, ParsedFont, FontVariationSettingsType } from './font-interfaces';
|
|
3
|
+
|
|
4
|
+
export declare class Font extends FontBase {
|
|
2
5
|
public static default: Font;
|
|
3
6
|
|
|
4
7
|
public fontFamily: string;
|
|
5
|
-
public fontStyle:
|
|
6
|
-
public fontWeight:
|
|
8
|
+
public fontStyle: FontStyleType;
|
|
9
|
+
public fontWeight: FontWeightType;
|
|
7
10
|
public fontSize: number;
|
|
8
11
|
public fontScale: number;
|
|
12
|
+
public fontVariationSettings?: FontVariationSettings[];
|
|
9
13
|
|
|
10
14
|
public isBold: boolean;
|
|
11
15
|
public isItalic: boolean;
|
|
12
16
|
|
|
13
|
-
constructor(family: string, size: number, style?:
|
|
17
|
+
constructor(family: string, size: number, style?: FontStyleType, weight?: FontWeightType, scale?: number, fontVariationSettings?: FontVariationSettings[]);
|
|
14
18
|
|
|
15
19
|
public getAndroidTypeface(): any /* android.graphics.Typeface */;
|
|
16
20
|
public getUIFont(defaultFont: any /* UIFont */): any /* UIFont */;
|
|
17
21
|
|
|
18
22
|
public withFontFamily(family: string): Font;
|
|
19
|
-
public withFontStyle(style:
|
|
20
|
-
public withFontWeight(weight:
|
|
23
|
+
public withFontStyle(style: FontStyleType): Font;
|
|
24
|
+
public withFontWeight(weight: FontWeightType): Font;
|
|
21
25
|
public withFontSize(size: number): Font;
|
|
22
26
|
public withFontScale(scale: number): Font;
|
|
27
|
+
public withFontVariationSettings(variationSettings: FontVariationSettings[] | null): Font;
|
|
23
28
|
|
|
24
29
|
public static equals(value1: Font, value2: Font): boolean;
|
|
25
30
|
}
|
|
26
31
|
|
|
27
|
-
export type FontStyle = 'normal' | 'italic';
|
|
28
32
|
export namespace FontStyle {
|
|
29
33
|
export const NORMAL: 'normal';
|
|
30
34
|
export const ITALIC: 'italic';
|
|
31
35
|
export function isValid(value: any): boolean;
|
|
32
|
-
export function parse(value: string):
|
|
36
|
+
export function parse(value: string): FontStyleType;
|
|
33
37
|
}
|
|
34
38
|
|
|
35
|
-
export type FontWeight = '100' | '200' | '300' | 'normal' | '400' | '500' | '600' | 'bold' | '700' | '800' | '900';
|
|
36
39
|
export namespace FontWeight {
|
|
37
40
|
export const THIN: '100';
|
|
38
41
|
export const EXTRA_LIGHT: '200';
|
|
@@ -44,16 +47,12 @@ export namespace FontWeight {
|
|
|
44
47
|
export const EXTRA_BOLD: '800';
|
|
45
48
|
export const BLACK: '900';
|
|
46
49
|
export function isValid(value: any): boolean;
|
|
47
|
-
export function parse(value: string):
|
|
50
|
+
export function parse(value: string): FontWeightType;
|
|
48
51
|
}
|
|
49
52
|
|
|
50
|
-
export
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
fontWeight?: FontWeight;
|
|
54
|
-
lineHeight?: string;
|
|
55
|
-
fontSize?: string;
|
|
56
|
-
fontFamily?: string;
|
|
53
|
+
export namespace FontVariationSettings {
|
|
54
|
+
export function parse(fontVariationSettings: string): Array<FontVariationSettingsType> | null;
|
|
55
|
+
export function toString(fontVariationSettings: Array<FontVariationSettingsType> | null): string | null;
|
|
57
56
|
}
|
|
58
57
|
|
|
59
58
|
export function parseFont(fontValue: string): ParsedFont;
|
package/ui/styling/font.ios.d.ts
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
|
-
import { Font as FontBase
|
|
2
|
-
|
|
1
|
+
import { Font as FontBase } from './font-common';
|
|
2
|
+
import { FontStyleType, FontWeightType, FontVariationSettingsType } from './font-interfaces';
|
|
3
|
+
export { FontStyle, FontWeight, FontVariationSettings, parseFont } from './font-common';
|
|
3
4
|
export declare class Font extends FontBase {
|
|
4
5
|
static default: Font;
|
|
5
|
-
constructor(family: string, size: number, style?: FontStyleType, weight?: FontWeightType, scale?: number);
|
|
6
|
+
constructor(family: string, size: number, style?: FontStyleType, weight?: FontWeightType, scale?: number, variationSettings?: Array<FontVariationSettingsType>);
|
|
6
7
|
withFontFamily(family: string): Font;
|
|
7
8
|
withFontStyle(style: FontStyleType): Font;
|
|
8
9
|
withFontWeight(weight: FontWeightType): Font;
|
|
9
10
|
withFontSize(size: number): Font;
|
|
10
11
|
withFontScale(scale: number): Font;
|
|
12
|
+
withFontVariationSettings(variationSettings: Array<FontVariationSettingsType> | null): Font;
|
|
11
13
|
getUIFont(defaultFont: UIFont): UIFont;
|
|
12
14
|
getAndroidTypeface(): android.graphics.Typeface;
|
|
13
15
|
}
|
package/ui/styling/font.ios.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Font as FontBase, parseFontFamily, FontWeight } from './font-common';
|
|
1
|
+
import { Font as FontBase, parseFontFamily, FontWeight, FontVariationSettings, fuzzySearch } from './font-common';
|
|
2
2
|
import { Trace } from '../../trace';
|
|
3
3
|
import * as fs from '../../file-system';
|
|
4
|
-
export
|
|
4
|
+
export { FontStyle, FontWeight, FontVariationSettings, parseFont } from './font-common';
|
|
5
5
|
const uiFontCache = new Map();
|
|
6
6
|
function computeFontCacheKey(fontDescriptor) {
|
|
7
|
-
const { fontFamily, fontSize, fontWeight, isBold, isItalic } = fontDescriptor;
|
|
7
|
+
const { fontFamily, fontSize, fontWeight, fontVariationSettings, isBold, isItalic } = fontDescriptor;
|
|
8
8
|
const sep = ':';
|
|
9
|
-
return fontFamily.join(sep)
|
|
9
|
+
return [fontFamily.join(sep), fontSize, fontWeight, String(FontVariationSettings.toString(fontVariationSettings)).replace(/'/g, '').replace(/[\s,]/g, '_'), isBold, isItalic].join(sep);
|
|
10
10
|
}
|
|
11
11
|
function getUIFontCached(fontDescriptor) {
|
|
12
12
|
const cacheKey = computeFontCacheKey(fontDescriptor);
|
|
@@ -16,7 +16,24 @@ function getUIFontCached(fontDescriptor) {
|
|
|
16
16
|
}
|
|
17
17
|
return uiFontCache.get(cacheKey);
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
let uiFont = NativeScriptUtils.createUIFont(fontDescriptor);
|
|
20
|
+
if (fontDescriptor.fontVariationSettings?.length) {
|
|
21
|
+
let font = CGFontCreateWithFontName(uiFont.fontName);
|
|
22
|
+
const variationAxes = CGFontCopyVariationAxes(font);
|
|
23
|
+
const variationAxesNames = [];
|
|
24
|
+
for (const axis of variationAxes) {
|
|
25
|
+
variationAxesNames.push(String(axis.objectForKey('kCGFontVariationAxisName')));
|
|
26
|
+
}
|
|
27
|
+
const variationSettings = {};
|
|
28
|
+
for (const variationSetting of fontDescriptor.fontVariationSettings) {
|
|
29
|
+
const axisName = fuzzySearch(variationSetting.axis, variationAxesNames);
|
|
30
|
+
if (axisName?.length) {
|
|
31
|
+
variationSettings[axisName[0]] = variationSetting.value;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
font = CGFontCreateCopyWithVariations(font, variationSettings);
|
|
35
|
+
uiFont = CTFontCreateWithGraphicsFont(font, fontDescriptor.fontSize, null, null);
|
|
36
|
+
}
|
|
20
37
|
uiFontCache.set(cacheKey, uiFont);
|
|
21
38
|
if (Trace.isEnabled()) {
|
|
22
39
|
Trace.write(`UIFont creation: ${JSON.stringify(fontDescriptor)}, cache size: ${uiFontCache.size}`, Trace.categories.Style, Trace.messageType.info);
|
|
@@ -24,29 +41,33 @@ function getUIFontCached(fontDescriptor) {
|
|
|
24
41
|
return uiFont;
|
|
25
42
|
}
|
|
26
43
|
export class Font extends FontBase {
|
|
27
|
-
constructor(family, size, style, weight, scale) {
|
|
28
|
-
super(family, size, style, weight, scale);
|
|
44
|
+
constructor(family, size, style, weight, scale, variationSettings) {
|
|
45
|
+
super(family, size, style, weight, scale, variationSettings);
|
|
29
46
|
}
|
|
30
47
|
withFontFamily(family) {
|
|
31
|
-
return new Font(family, this.fontSize, this.fontStyle, this.fontWeight, this.fontScale);
|
|
48
|
+
return new Font(family, this.fontSize, this.fontStyle, this.fontWeight, this.fontScale, this.fontVariationSettings);
|
|
32
49
|
}
|
|
33
50
|
withFontStyle(style) {
|
|
34
|
-
return new Font(this.fontFamily, this.fontSize, style, this.fontWeight, this.fontScale);
|
|
51
|
+
return new Font(this.fontFamily, this.fontSize, style, this.fontWeight, this.fontScale, this.fontVariationSettings);
|
|
35
52
|
}
|
|
36
53
|
withFontWeight(weight) {
|
|
37
|
-
return new Font(this.fontFamily, this.fontSize, this.fontStyle, weight, this.fontScale);
|
|
54
|
+
return new Font(this.fontFamily, this.fontSize, this.fontStyle, weight, this.fontScale, this.fontVariationSettings);
|
|
38
55
|
}
|
|
39
56
|
withFontSize(size) {
|
|
40
|
-
return new Font(this.fontFamily, size, this.fontStyle, this.fontWeight, this.fontScale);
|
|
57
|
+
return new Font(this.fontFamily, size, this.fontStyle, this.fontWeight, this.fontScale, this.fontVariationSettings);
|
|
41
58
|
}
|
|
42
59
|
withFontScale(scale) {
|
|
43
|
-
return new Font(this.fontFamily, this.fontSize, this.fontStyle, this.fontWeight, scale);
|
|
60
|
+
return new Font(this.fontFamily, this.fontSize, this.fontStyle, this.fontWeight, scale, this.fontVariationSettings);
|
|
61
|
+
}
|
|
62
|
+
withFontVariationSettings(variationSettings) {
|
|
63
|
+
return new Font(this.fontFamily, this.fontSize, this.fontStyle, this.fontWeight, this.fontScale, variationSettings);
|
|
44
64
|
}
|
|
45
65
|
getUIFont(defaultFont) {
|
|
46
66
|
return getUIFontCached({
|
|
47
67
|
fontFamily: parseFontFamily(this.fontFamily),
|
|
48
68
|
fontSize: this.fontSize || defaultFont.pointSize,
|
|
49
69
|
fontWeight: getNativeFontWeight(this.fontWeight),
|
|
70
|
+
fontVariationSettings: this.fontVariationSettings,
|
|
50
71
|
isBold: this.isBold,
|
|
51
72
|
isItalic: this.isItalic,
|
|
52
73
|
});
|
|
@@ -57,6 +78,9 @@ export class Font extends FontBase {
|
|
|
57
78
|
}
|
|
58
79
|
Font.default = new Font(undefined, undefined);
|
|
59
80
|
function getNativeFontWeight(fontWeight) {
|
|
81
|
+
if (typeof fontWeight === 'number') {
|
|
82
|
+
fontWeight = (fontWeight + '');
|
|
83
|
+
}
|
|
60
84
|
switch (fontWeight) {
|
|
61
85
|
case FontWeight.THIN:
|
|
62
86
|
return UIFontWeightUltraLight;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"font.ios.js","sourceRoot":"","sources":["../../../../../packages/core/ui/styling/font.ios.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"font.ios.js","sourceRoot":"","sources":["../../../../../packages/core/ui/styling/font.ios.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,IAAI,QAAQ,EAAE,eAAe,EAAE,UAAU,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAElH,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,qBAAqB,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC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
|
|
3
|
+
import { Font, FontStyleType, FontWeightType } from '../font';
|
|
4
4
|
import { Background } from '../background';
|
|
5
5
|
import { ViewBase } from '../../core/view-base';
|
|
6
6
|
import { LinearGradient } from '../../styling/linear-gradient';
|
|
@@ -76,8 +76,8 @@ export declare class Style extends Observable implements StyleDefinition {
|
|
|
76
76
|
boxShadow: CSSShadow;
|
|
77
77
|
fontSize: number;
|
|
78
78
|
fontFamily: string;
|
|
79
|
-
fontStyle:
|
|
80
|
-
fontWeight:
|
|
79
|
+
fontStyle: FontStyleType;
|
|
80
|
+
fontWeight: FontWeightType;
|
|
81
81
|
font: string;
|
|
82
82
|
maxLines: CoreTypes.MaxLinesType;
|
|
83
83
|
androidElevation: number;
|
|
@@ -2,7 +2,7 @@ import { CssProperty, CssAnimationProperty, InheritedCssProperty } from '../core
|
|
|
2
2
|
import { Style } from '../styling/style';
|
|
3
3
|
import { TransformFunctionsInfo } from '../animation';
|
|
4
4
|
import { Color } from '../../color';
|
|
5
|
-
import { Font,
|
|
5
|
+
import { Font, FontStyleType, FontWeightType, FontVariationSettingsType } from '../../ui/styling/font';
|
|
6
6
|
import { Background } from '../../ui/styling/background';
|
|
7
7
|
import { CoreTypes } from '../../core-types';
|
|
8
8
|
import { LinearGradient } from './linear-gradient';
|
|
@@ -31,7 +31,6 @@ export declare namespace Length {
|
|
|
31
31
|
(length: CoreTypes.LengthType): string;
|
|
32
32
|
};
|
|
33
33
|
}
|
|
34
|
-
export declare const zeroLength: CoreTypes.LengthType;
|
|
35
34
|
export declare const minWidthProperty: CssProperty<Style, CoreTypes.LengthType>;
|
|
36
35
|
export declare const minHeightProperty: CssProperty<Style, CoreTypes.LengthType>;
|
|
37
36
|
export declare const widthProperty: CssAnimationProperty<Style, CoreTypes.PercentLengthType>;
|
|
@@ -81,8 +80,9 @@ export declare const fontInternalProperty: CssProperty<Style, Font>;
|
|
|
81
80
|
export declare const fontFamilyProperty: InheritedCssProperty<Style, string>;
|
|
82
81
|
export declare const fontScaleProperty: InheritedCssProperty<Style, number>;
|
|
83
82
|
export declare const fontSizeProperty: InheritedCssProperty<Style, number>;
|
|
84
|
-
export declare const fontStyleProperty: InheritedCssProperty<Style,
|
|
85
|
-
export declare const fontWeightProperty: InheritedCssProperty<Style,
|
|
83
|
+
export declare const fontStyleProperty: InheritedCssProperty<Style, FontStyleType>;
|
|
84
|
+
export declare const fontWeightProperty: InheritedCssProperty<Style, FontWeightType>;
|
|
85
|
+
export declare const fontVariationSettingsProperty: InheritedCssProperty<Style, FontVariationSettingsType[]>;
|
|
86
86
|
export declare const visibilityProperty: CssProperty<Style, CoreTypes.VisibilityType>;
|
|
87
87
|
export declare const androidElevationProperty: CssProperty<Style, number>;
|
|
88
88
|
export declare const androidDynamicElevationOffsetProperty: CssProperty<Style, number>;
|