@nativescript-community/ui-label 1.1.23 → 1.2.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.
Files changed (33) hide show
  1. package/CHANGELOG.md +35 -0
  2. package/label.android.d.ts +0 -1
  3. package/label.android.js +29 -9
  4. package/label.ios.d.ts +6 -9
  5. package/label.ios.js +91 -223
  6. package/package.json +3 -3
  7. package/platforms/android/include.gradle +1 -1
  8. package/platforms/android/native-api-usage.json +15 -0
  9. package/pnpm-global/5/node_modules/.modules.yaml +0 -22
  10. package/pnpm-global/5/node_modules/.pnpm/@nativescript-community+text@1.4.11/node_modules/@nativescript-community/text/CHANGELOG.md +0 -212
  11. package/pnpm-global/5/node_modules/.pnpm/@nativescript-community+text@1.4.11/node_modules/@nativescript-community/text/LICENSE +0 -201
  12. package/pnpm-global/5/node_modules/.pnpm/@nativescript-community+text@1.4.11/node_modules/@nativescript-community/text/README.md +0 -14
  13. package/pnpm-global/5/node_modules/.pnpm/@nativescript-community+text@1.4.11/node_modules/@nativescript-community/text/index-common.d.ts +0 -40
  14. package/pnpm-global/5/node_modules/.pnpm/@nativescript-community+text@1.4.11/node_modules/@nativescript-community/text/index-common.js +0 -208
  15. package/pnpm-global/5/node_modules/.pnpm/@nativescript-community+text@1.4.11/node_modules/@nativescript-community/text/index.android.d.ts +0 -27
  16. package/pnpm-global/5/node_modules/.pnpm/@nativescript-community+text@1.4.11/node_modules/@nativescript-community/text/index.android.js +0 -298
  17. package/pnpm-global/5/node_modules/.pnpm/@nativescript-community+text@1.4.11/node_modules/@nativescript-community/text/index.d.ts +0 -1
  18. package/pnpm-global/5/node_modules/.pnpm/@nativescript-community+text@1.4.11/node_modules/@nativescript-community/text/index.ios.d.ts +0 -14
  19. package/pnpm-global/5/node_modules/.pnpm/@nativescript-community+text@1.4.11/node_modules/@nativescript-community/text/index.ios.js +0 -189
  20. package/pnpm-global/5/node_modules/.pnpm/@nativescript-community+text@1.4.11/node_modules/@nativescript-community/text/index.js +0 -25
  21. package/pnpm-global/5/node_modules/.pnpm/@nativescript-community+text@1.4.11/node_modules/@nativescript-community/text/package.json +0 -34
  22. package/pnpm-global/5/node_modules/.pnpm/@nativescript-community+text@1.4.11/node_modules/@nativescript-community/text/platforms/android/AndroidManifest.xml +0 -3
  23. package/pnpm-global/5/node_modules/.pnpm/@nativescript-community+text@1.4.11/node_modules/@nativescript-community/text/platforms/android/java/com/nativescript/text/BaselineAdjustedSpan.java +0 -71
  24. package/pnpm-global/5/node_modules/.pnpm/@nativescript-community+text@1.4.11/node_modules/@nativescript-community/text/platforms/android/java/com/nativescript/text/CustomBackgroundSpan.java +0 -70
  25. package/pnpm-global/5/node_modules/.pnpm/@nativescript-community+text@1.4.11/node_modules/@nativescript-community/text/platforms/android/java/com/nativescript/text/CustomTypefaceSpan.java +0 -37
  26. package/pnpm-global/5/node_modules/.pnpm/@nativescript-community+text@1.4.11/node_modules/@nativescript-community/text/platforms/android/java/com/nativescript/text/Font.java +0 -431
  27. package/pnpm-global/5/node_modules/.pnpm/@nativescript-community+text@1.4.11/node_modules/@nativescript-community/text/platforms/android/java/com/nativescript/text/HeightSpan.java +0 -81
  28. package/pnpm-global/5/node_modules/.pnpm/@nativescript-community+text@1.4.11/node_modules/@nativescript-community/text/platforms/android/java/com/nativescript/text/HtmlToSpannedConverter.java +0 -690
  29. package/pnpm-global/5/node_modules/.pnpm/@nativescript-community+text@1.4.11/node_modules/@nativescript-community/text/platforms/android/java/com/nativescript/text/URLSpanNoUnderline.java +0 -24
  30. package/pnpm-global/5/node_modules/.pnpm/@nativescript-community+text@1.4.11/node_modules/@nativescript-community/text/typings/DTCoreText.ios.d.ts +0 -22
  31. package/pnpm-global/5/node_modules/.pnpm/@nativescript-community+text@1.4.11/node_modules/@nativescript-community/text/typings/android.d.ts +0 -32
  32. package/pnpm-global/5/node_modules/.pnpm/lock.yaml +0 -13
  33. package/pnpm-global/5/pnpm-lock.yaml +0 -13
@@ -1,208 +0,0 @@
1
- import { Color, FormattedString, InheritedCssProperty, Observable, ObservableArray, Span, Style, colorProperty, makeParser, makeValidator, } from '@nativescript/core';
2
- import { TextBase } from '@nativescript/core/ui/text-base';
3
- import { createNativeAttributedString } from './index';
4
- const CHILD_SPAN = 'Span';
5
- const CHILD_FORMATTED_TEXT = 'formattedText';
6
- const CHILD_FORMATTED_STRING = 'FormattedString';
7
- const CHILD_LIGHT_FORMATTED_STRING = 'LightFormattedString';
8
- export function enableIOSDTCoreText() { }
9
- export function computeBaseLineOffset(align, fontAscent, fontDescent, fontBottom, fontTop, fontSize, maxFontSize) {
10
- let result = 0;
11
- switch (align) {
12
- case 'top':
13
- result = -maxFontSize - fontBottom - fontTop;
14
- break;
15
- case 'bottom':
16
- result = fontBottom;
17
- break;
18
- case 'text-top':
19
- result = -maxFontSize - fontDescent - fontAscent;
20
- break;
21
- case 'text-bottom':
22
- result = fontBottom - fontDescent;
23
- break;
24
- case 'middle':
25
- case 'center':
26
- result = (fontAscent - fontDescent) / 2 - fontAscent - maxFontSize / 2;
27
- break;
28
- case 'super':
29
- result = -(maxFontSize - fontSize);
30
- break;
31
- case 'sub':
32
- result = 0;
33
- break;
34
- }
35
- return result;
36
- }
37
- export const cssProperty = (target, key) => {
38
- // property getter
39
- const getter = function () {
40
- return this.style[key];
41
- };
42
- // property setter
43
- const setter = function (newVal) {
44
- this.style[key] = newVal;
45
- };
46
- Object.defineProperty(target, key, {
47
- get: getter,
48
- set: setter,
49
- enumerable: true,
50
- configurable: true,
51
- });
52
- };
53
- export const verticalTextAlignmentConverter = makeParser(makeValidator('initial', 'top', 'middle', 'bottom', 'center'));
54
- export const verticalTextAlignmentProperty = new InheritedCssProperty({
55
- name: 'verticalTextAlignment',
56
- cssName: 'vertical-text-align',
57
- valueConverter: verticalTextAlignmentConverter,
58
- });
59
- verticalTextAlignmentProperty.register(Style);
60
- export const textAlignmentConverter = makeParser(makeValidator('initial', 'left', 'right', 'center'));
61
- export class LightFormattedString extends Observable {
62
- constructor() {
63
- super();
64
- this._spans = new ObservableArray();
65
- this._spans.addEventListener(ObservableArray.changeEvent, this.onSpansCollectionChanged, this);
66
- }
67
- get style() {
68
- return this;
69
- }
70
- get spans() {
71
- if (!this._spans) {
72
- this._spans = new ObservableArray();
73
- }
74
- return this._spans;
75
- }
76
- set spans(value) {
77
- if (value instanceof ObservableArray) {
78
- this._spans.removeEventListener(ObservableArray.changeEvent, this.onSpansCollectionChanged, this);
79
- this._spans = value;
80
- this._spans.addEventListener(ObservableArray.changeEvent, this.onSpansCollectionChanged, this);
81
- }
82
- else if (Array.isArray(value)) {
83
- this._spans.push(...value);
84
- }
85
- else {
86
- this._spans.push(value);
87
- }
88
- }
89
- toString() {
90
- let result = '';
91
- for (let i = 0, length = this._spans.length; i < length; i++) {
92
- result += this._spans.getItem(i).text;
93
- }
94
- return result;
95
- }
96
- _addArrayFromBuilder(name, value) {
97
- if (name === 'spans') {
98
- this.spans.push(...value);
99
- }
100
- }
101
- _addChildFromBuilder(name, value) {
102
- if (value instanceof Span) {
103
- this.spans.push(value);
104
- }
105
- }
106
- onSpansCollectionChanged(eventData) {
107
- if (eventData.addedCount > 0) {
108
- for (let i = 0; i < eventData.addedCount; i++) {
109
- const span = eventData.object.getItem(eventData.index + i);
110
- span.parent = this;
111
- // Then attach handlers - we skip the first nofitication because
112
- // we raise change for the whole instance.
113
- this.addPropertyChangeHandler(span);
114
- }
115
- }
116
- if (eventData.removed && eventData.removed.length > 0) {
117
- for (let p = 0; p < eventData.removed.length; p++) {
118
- const span = eventData.removed[p];
119
- span.parent = null;
120
- // First remove handlers so that we don't listen for changes
121
- // on inherited properties.
122
- this.removePropertyChangeHandler(span);
123
- }
124
- }
125
- this.notifyPropertyChange('.', this);
126
- }
127
- addPropertyChangeHandler(span) {
128
- span.on(Observable.propertyChangeEvent, this.onPropertyChange, this);
129
- }
130
- removePropertyChangeHandler(span) {
131
- span.off(Observable.propertyChangeEvent, this.onPropertyChange, this);
132
- }
133
- onPropertyChange(data) {
134
- this.notifyPropertyChange(data.propertyName, this);
135
- }
136
- toNativeString() { }
137
- }
138
- export function getMaxFontSize(value) {
139
- let max = value.fontSize || 0;
140
- value.spans &&
141
- value.spans.forEach((s) => {
142
- if (s.fontSize) {
143
- max = Math.max(max, s.fontSize);
144
- }
145
- });
146
- return max;
147
- }
148
- export let overrideSpanAndFormattedStringEnabled = false;
149
- export function overrideSpanAndFormattedString() {
150
- if (!overrideSpanAndFormattedStringEnabled) {
151
- overrideSpanAndFormattedStringEnabled = true;
152
- }
153
- TextBase.prototype._addChildFromBuilder = function (name, value) {
154
- if (name === CHILD_SPAN) {
155
- if (!this.formattedText) {
156
- const formattedText = new LightFormattedString();
157
- formattedText.spans.push(value);
158
- this.formattedText = formattedText;
159
- formattedText.parent = this;
160
- }
161
- else {
162
- this.formattedText.spans.push(value);
163
- }
164
- }
165
- else if (name === CHILD_FORMATTED_TEXT || name === CHILD_FORMATTED_STRING || name === CHILD_LIGHT_FORMATTED_STRING) {
166
- this.formattedText = value;
167
- value.parent = this;
168
- }
169
- };
170
- TextBase.prototype._addView = function (view) {
171
- if (view instanceof LightFormattedString) {
172
- return;
173
- }
174
- this._super._addView(view);
175
- };
176
- TextBase.prototype._removeView = function (view) {
177
- if (view instanceof LightFormattedString) {
178
- return;
179
- }
180
- this._super._removeView(view);
181
- };
182
- TextBase.prototype.eachChild = function (callback) {
183
- const text = this.formattedText;
184
- if (text instanceof FormattedString) {
185
- callback(text);
186
- }
187
- };
188
- TextBase.prototype.createFormattedTextNative = function (value) {
189
- return createNativeAttributedString(value, this);
190
- };
191
- TextBase.prototype[colorProperty.setNative] = function (value) {
192
- if (value instanceof Color) {
193
- if (global.isIOS) {
194
- const color = value instanceof Color ? value.ios : value;
195
- this._setColor(color);
196
- }
197
- else if (global.isAndroid) {
198
- if (value instanceof Color) {
199
- this.nativeTextViewProtected.setTextColor(value.android);
200
- }
201
- else {
202
- this.nativeTextViewProtected.setTextColor(value);
203
- }
204
- }
205
- }
206
- };
207
- }
208
- //# sourceMappingURL=index-common.js.map
@@ -1,27 +0,0 @@
1
- import { Color, CoreTypes, FormattedString, ViewBase } from '@nativescript/core';
2
- export * from './index-common';
3
- export declare const typefaceCache: {
4
- [k: string]: android.graphics.Typeface;
5
- };
6
- export declare function init(): void;
7
- declare module '@nativescript/core/ui/text-base/formatted-string' {
8
- interface FormattedString {
9
- toNativeString(maxFontSize?: number): string;
10
- }
11
- }
12
- declare module '@nativescript/core/ui/text-base/span' {
13
- interface Span {
14
- toNativeString(maxFontSize?: number): string;
15
- }
16
- }
17
- export declare const createNativeAttributedString: (data: {
18
- text: string;
19
- color?: Color | string | number;
20
- familyName?: string;
21
- fontSize?: number;
22
- fontWeight?: string;
23
- letterSpacing?: number;
24
- lineHeight?: number;
25
- textAlignment?: number | CoreTypes.TextAlignmentType;
26
- } | FormattedString, parent: ViewBase) => any;
27
- export declare const createSpannable: (span: any, parentView: any, parent?: any, maxFontSize?: number) => any;
@@ -1,298 +0,0 @@
1
- import { Application, Color, FormattedString, Span, backgroundColorProperty, knownFolders, path, profile } from '@nativescript/core';
2
- import { Font } from '@nativescript/core/ui/styling/font';
3
- import { getTransformedText, textDecorationProperty } from '@nativescript/core/ui/text-base';
4
- import { LightFormattedString } from './index-common';
5
- import { layout } from '@nativescript/core/utils/utils';
6
- export * from './index-common';
7
- // eslint-disable-next-line no-redeclare
8
- let ClickableSpan;
9
- function initializeClickableSpan() {
10
- if (ClickableSpan) {
11
- return;
12
- }
13
- var ClickableSpanImpl = /** @class */ (function (_super) {
14
- __extends(ClickableSpanImpl, _super);
15
- function ClickableSpanImpl(owner) {
16
- var _this = _super.call(this) || this;
17
- _this.owner = new WeakRef(owner);
18
- return global.__native(_this);
19
- }
20
- ClickableSpanImpl.prototype.onClick = function (view) {
21
- var owner = this.owner.get();
22
- if (owner) {
23
- owner._emit(Span.linkTapEvent);
24
- }
25
- view.clearFocus();
26
- view.invalidate();
27
- };
28
- ClickableSpanImpl.prototype.updateDrawState = function (tp) {
29
- // don't style as link
30
- };
31
- return ClickableSpanImpl;
32
- }(android.text.style.ClickableSpan));
33
- ClickableSpan = ClickableSpanImpl;
34
- }
35
- export const typefaceCache = {};
36
- let context;
37
- const fontPath = path.join(knownFolders.currentApp().path, 'fonts');
38
- let initialized = false;
39
- export function init() {
40
- if (initialized) {
41
- return;
42
- }
43
- initialized = true;
44
- context = Application.android.context;
45
- Font.prototype.getAndroidTypeface = profile('getAndroidTypeface', function () {
46
- var _a;
47
- if (!this._typeface) {
48
- // css loader to json transform font-family: res/toto to font-family: res,toto
49
- const fontFamily = ((_a = this.fontFamily) === null || _a === void 0 ? void 0 : _a.replace(/res,/g, 'res/')) || '';
50
- const fontCacheKey = fontFamily + (this.fontWeight || '') + (this.fontStyle || '');
51
- const typeface = typefaceCache[fontCacheKey];
52
- if (!typeface) {
53
- if (!context) {
54
- context = Application.android.context;
55
- }
56
- this._typeface = typefaceCache[fontCacheKey] = com.nativescript.text.Font.createTypeface(context, fontPath, fontFamily, this.fontWeight, this.isBold, this.isItalic);
57
- }
58
- else {
59
- this._typeface = typeface;
60
- }
61
- }
62
- return this._typeface;
63
- });
64
- FormattedString.prototype.toNativeString = LightFormattedString.prototype.toNativeString = function () {
65
- var _a, _b;
66
- let result = '';
67
- const length = this.spans.length;
68
- let span;
69
- let maxFontSize = ((_a = this.style) === null || _a === void 0 ? void 0 : _a.fontSize) || ((_b = this.parent) === null || _b === void 0 ? void 0 : _b.style.fontSize) || 0;
70
- for (let i = 0; i < length; i++) {
71
- const s = this.spans.getItem(i);
72
- if (s.style.fontSize) {
73
- maxFontSize = Math.max(maxFontSize, s.style.fontSize);
74
- }
75
- }
76
- for (let i = 0; i < length; i++) {
77
- span = this.spans.getItem(i);
78
- result += span.toNativeString(maxFontSize) + (i < length - 1 ? String.fromCharCode(0x1f) : '');
79
- }
80
- return result;
81
- };
82
- const delimiter = String.fromCharCode(0x1e);
83
- Span.prototype.toNativeString = function (maxFontSize) {
84
- const textTransform = this.parent.parent.textTransform;
85
- const spanStyle = this.style;
86
- let backgroundColor;
87
- if (backgroundColorProperty.isSet(spanStyle)) {
88
- backgroundColor = spanStyle.backgroundColor;
89
- }
90
- let textDecoration;
91
- if (textDecorationProperty.isSet(spanStyle)) {
92
- textDecoration = spanStyle.textDecoration;
93
- }
94
- else if (this.parent.textDecoration) {
95
- // span.parent is FormattedString
96
- textDecoration = this.parent.style.textDecoration;
97
- }
98
- else if (textDecorationProperty.isSet(this.parent.parent.style)) {
99
- // span.parent.parent is TextBase
100
- textDecoration = this.parent.parent.style.textDecorations;
101
- }
102
- let verticalTextAlignment = this.verticalAlignment || this.parent.verticalAlignment;
103
- if (!verticalTextAlignment || verticalTextAlignment === 'stretch') {
104
- verticalTextAlignment = this.parent.parent.verticalTextAlignment;
105
- }
106
- let text = this.text;
107
- if (text && textTransform != null && textTransform !== 'none') {
108
- text = getTransformedText(text, textTransform);
109
- }
110
- const density = layout.getDisplayDensity();
111
- const result = `${this.fontFamily || 0}${delimiter}\
112
- ${this.fontSize !== undefined ? this.fontSize * density : -1}${delimiter}\
113
- ${this.fontWeight || ''}${delimiter}\
114
- ${this.fontStyle === 'italic' ? 1 : 0}${delimiter}\
115
- ${textDecoration || 0}${delimiter}\
116
- ${maxFontSize * density}${delimiter}\
117
- ${verticalTextAlignment && verticalTextAlignment !== 'stretch' ? verticalTextAlignment : ''}${delimiter}\
118
- ${this.lineHeight !== undefined ? this.lineHeight * density : -1}${delimiter}\
119
- ${this.letterSpacing !== undefined ? this.lineHeight * density : 9}${delimiter}\
120
- ${this.color ? this.color.android : -1}${delimiter}\
121
- ${backgroundColor ? backgroundColor.android : -1}${delimiter}\
122
- ${this.text}`;
123
- return result;
124
- };
125
- }
126
- function isBold(fontWeight) {
127
- return fontWeight === 'bold' || fontWeight === '700' || fontWeight === '800' || fontWeight === '900';
128
- }
129
- // type BaselineAdjustedSpan = new (fontSize, align: string, maxFontSize) => android.text.style.MetricAffectingSpan;
130
- // // eslint-disable-next-line no-redeclare
131
- // let BaselineAdjustedSpan: BaselineAdjustedSpan;
132
- // function initializeBaselineAdjustedSpan(): void {
133
- // if (BaselineAdjustedSpan) {
134
- // return;
135
- // }
136
- // @NativeClass
137
- // class BaselineAdjustedSpanImpl extends android.text.style.CharacterStyle {
138
- // align: string = 'baseline';
139
- // maxFontSize: number;
140
- // constructor(private fontSize, align: string, maxFontSize) {
141
- // super();
142
- // this.align = align;
143
- // this.maxFontSize = maxFontSize;
144
- // }
145
- // updateDrawState(paint: android.text.TextPaint) {
146
- // this.updateState(paint);
147
- // }
148
- // updateState(paint: android.text.TextPaint) {
149
- // const fontSize = this.fontSize;
150
- // paint.setTextSize(fontSize);
151
- // const metrics = paint.getFontMetrics();
152
- // let result = computeBaseLineOffset(this.align, metrics.ascent, metrics.descent, metrics.bottom, metrics.top, fontSize, this.maxFontSize);
153
- // result += metrics.bottom;
154
- // paint.baselineShift = result;
155
- // }
156
- // }
157
- // BaselineAdjustedSpan = BaselineAdjustedSpanImpl as any;
158
- // }
159
- export const createNativeAttributedString = profile('getAndroidTypeface', function createNativeAttributedString(data, parent) {
160
- if (!context) {
161
- init();
162
- }
163
- if (typeof data['toNativeString'] === 'function') {
164
- const nativeString = data.toNativeString();
165
- return com.nativescript.text.Font.stringBuilderFromFormattedString(context, fontPath, nativeString);
166
- }
167
- // if (data.textAlignment && typeof data.textAlignment === 'string') {
168
- // data.textAlignment = textAlignmentConverter(data.textAlignment);
169
- // }
170
- // if (data.color && !(data.color instanceof Color)) {
171
- // data.color = new Color(data.color as any);
172
- // }
173
- const result = com.nativescript.text.Font.stringBuilderFromHtmlString(context, fontPath, data.text);
174
- return result;
175
- });
176
- let lineSeparator;
177
- let Style;
178
- let Spanned;
179
- export const createSpannable = profile('createSpannable', function (span, parentView, parent, maxFontSize) {
180
- let text = span.text;
181
- if (!text || span.visibility !== 'visible') {
182
- return null;
183
- }
184
- const fontSize = span.fontSize;
185
- const fontWeight = span.fontWeight || 'normal';
186
- const fontStyle = span.fontStyle || (parent && parent.fontStyle) || 'normal';
187
- const fontFamily = span.fontFamily;
188
- const color = span.color;
189
- const textDecorations = span.textDecoration || (parent && parent.textDecoration);
190
- const backgroundcolor = span.backgroundColor || (parent && parent.backgroundColor);
191
- const verticalTextAlignment = span.verticalTextAlignment;
192
- const letterSpacing = span.letterSpacing || (parent && parent.letterSpacing);
193
- const lineHeight = span.lineHeight || (parent && parent.lineHeight);
194
- const realMaxFontSize = Math.max(maxFontSize, parentView.fontSize || 0);
195
- if (typeof text === 'boolean' || typeof text === 'number') {
196
- text = text.toString();
197
- }
198
- const textTransform = span.textTransform || (parent && parent.textTransform);
199
- if (textTransform) {
200
- text = getTransformedText(text, textTransform);
201
- }
202
- if (typeof text === 'string') {
203
- if (text.indexOf('\n') !== -1) {
204
- if (!lineSeparator) {
205
- lineSeparator = java.lang.System.getProperty('line.separator');
206
- }
207
- text = text.replace(/\\n/g, lineSeparator);
208
- }
209
- }
210
- const length = typeof text.length === 'function' ? text.length() : text.length;
211
- let ssb = span._ssb;
212
- if (!ssb) {
213
- span._ssb = ssb = new android.text.SpannableStringBuilder(text);
214
- }
215
- else {
216
- ssb.clear();
217
- ssb.clearSpans();
218
- ssb.append(text);
219
- }
220
- if (!Style) {
221
- Style = android.text.style;
222
- }
223
- if (!Spanned) {
224
- Spanned = android.text.Spanned;
225
- }
226
- const bold = isBold(fontWeight);
227
- const italic = fontStyle === 'italic';
228
- // if (getSDK() < 28) {
229
- if (bold && italic) {
230
- ssb.setSpan(new Style.StyleSpan(android.graphics.Typeface.BOLD_ITALIC), 0, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
231
- }
232
- else if (bold) {
233
- ssb.setSpan(new Style.StyleSpan(android.graphics.Typeface.BOLD), 0, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
234
- }
235
- else if (italic) {
236
- ssb.setSpan(new Style.StyleSpan(android.graphics.Typeface.ITALIC), 0, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
237
- }
238
- // }
239
- if (fontFamily || (fontWeight !== 'normal' && !bold)) {
240
- const fontCacheKey = fontFamily + fontWeight + fontStyle;
241
- let typeface = typefaceCache[fontCacheKey];
242
- if (!typeface) {
243
- if (span.paint) {
244
- // let paint: Paint = paintFontCache[fontCacheKey];
245
- // if (!paint) {
246
- // paint = span.paint;
247
- // paint.setFontFamily(fontFamily);
248
- // paint.setFontWeight(fontWeight);
249
- // paint.setFontStyle(fontStyle);
250
- // paintFontCache[fontCacheKey] = paint;
251
- // }
252
- // typeface = typefaceCache[fontCacheKey] = paint.getFont().getAndroidTypeface();
253
- }
254
- else {
255
- const font = new Font(fontFamily, 10, fontStyle, fontWeight);
256
- typeface = typefaceCache[fontCacheKey] = font.getAndroidTypeface();
257
- }
258
- }
259
- const typefaceSpan = new com.nativescript.text.CustomTypefaceSpan(fontFamily, typeface);
260
- ssb.setSpan(typefaceSpan, 0, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
261
- }
262
- if (verticalTextAlignment && verticalTextAlignment !== 'initial') {
263
- ssb.setSpan(new com.nativescript.text.BaselineAdjustedSpan(fontSize, verticalTextAlignment, realMaxFontSize), 0, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
264
- }
265
- if (fontSize) {
266
- ssb.setSpan(new Style.AbsoluteSizeSpan(fontSize), 0, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
267
- }
268
- if (letterSpacing) {
269
- ssb.setSpan(new Style.ScaleXSpan((letterSpacing + 1) / 10), 0, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
270
- }
271
- if (lineHeight !== undefined) {
272
- ssb.setSpan(new com.nativescript.text.HeightSpan(lineHeight), 0, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
273
- }
274
- if (color) {
275
- const ncolor = color instanceof Color ? color : new Color(color);
276
- ssb.setSpan(new Style.ForegroundColorSpan(ncolor.android), 0, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
277
- }
278
- if (backgroundcolor) {
279
- const color = backgroundcolor instanceof Color ? backgroundcolor : new Color(backgroundcolor);
280
- ssb.setSpan(new Style.BackgroundColorSpan(color.android), 0, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
281
- }
282
- if (textDecorations) {
283
- const underline = textDecorations.indexOf('underline') !== -1;
284
- if (underline) {
285
- ssb.setSpan(new Style.UnderlineSpan(), 0, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
286
- }
287
- const strikethrough = textDecorations.indexOf('line-through') !== -1;
288
- if (strikethrough) {
289
- ssb.setSpan(new Style.StrikethroughSpan(), 0, length, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
290
- }
291
- }
292
- if (span.tappable) {
293
- initializeClickableSpan();
294
- ssb.setSpan(new ClickableSpan(span), 0, length, android.text.Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
295
- }
296
- return ssb;
297
- });
298
- //# sourceMappingURL=index.android.js.map
@@ -1,14 +0,0 @@
1
- import { Color, CoreTypes, FormattedString, ViewBase } from '@nativescript/core';
2
- export * from './index-common';
3
- export declare function enableIOSDTCoreText(): void;
4
- export declare function init(): void;
5
- export declare function createNativeAttributedString(data: {
6
- text: string;
7
- color?: Color | string | number;
8
- familyName?: string;
9
- fontSize?: number;
10
- letterSpacing?: number;
11
- lineHeight?: number;
12
- textAlignment?: NSTextAlignment | CoreTypes.TextAlignmentType;
13
- } | FormattedString, parent: ViewBase): any;
14
- export declare function createSpannable(span: any, parentView: any, parent?: any, maxFontSize?: any): NSMutableAttributedString;