@maccesar/titools 2.2.3 → 2.2.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/README.md +28 -27
- package/lib/commands/update.js +80 -101
- package/package.json +1 -1
- package/skills/alloy-guides/SKILL.md +31 -31
- package/skills/alloy-guides/references/CONCEPTS.md +3 -3
- package/skills/alloy-guides/references/CONTROLLERS.md +1 -1
- package/skills/alloy-guides/references/MODELS.md +6 -6
- package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +1 -1
- package/skills/alloy-guides/references/VIEWS_XML.md +1 -1
- package/skills/alloy-guides/references/WIDGETS.md +1 -1
- package/skills/alloy-howtos/SKILL.md +27 -27
- package/skills/alloy-howtos/references/best_practices.md +9 -9
- package/skills/alloy-howtos/references/cli_reference.md +14 -14
- package/skills/alloy-howtos/references/config_files.md +16 -16
- package/skills/alloy-howtos/references/custom_tags.md +16 -16
- package/skills/alloy-howtos/references/debugging_troubleshooting.md +11 -15
- package/skills/alloy-howtos/references/samples.md +19 -19
- package/skills/purgetss/SKILL.md +11 -1
- package/skills/purgetss/references/animation-system.md +1 -1
- package/skills/purgetss/references/cli-commands.md +3 -3
- package/skills/purgetss/references/customization-deep-dive.md +1 -1
- package/skills/purgetss/references/dynamic-component-creation.md +1 -1
- package/skills/purgetss/references/icon-fonts.md +4 -0
- package/skills/purgetss/references/installation-setup.md +8 -1
- package/skills/purgetss/references/migration-guide.md +4 -0
- package/skills/purgetss/references/tikit-components.md +193 -204
- package/skills/purgetss/references/ui-ux-design.md +1 -1
- package/skills/ti-expert/SKILL.md +78 -118
- package/skills/ti-expert/references/alloy-builtins.md +18 -18
- package/skills/ti-expert/references/alloy-structure.md +21 -21
- package/skills/ti-expert/references/anti-patterns.md +15 -15
- package/skills/ti-expert/references/cli-expert.md +15 -15
- package/skills/ti-expert/references/code-conventions.md +38 -38
- package/skills/ti-expert/references/contracts.md +8 -8
- package/skills/ti-expert/references/controller-patterns.md +14 -14
- package/skills/ti-expert/references/error-handling.md +11 -11
- package/skills/ti-expert/references/examples.md +12 -12
- package/skills/ti-expert/references/migration-patterns.md +24 -24
- package/skills/ti-expert/references/patterns.md +10 -10
- package/skills/ti-expert/references/performance-listview.md +16 -16
- package/skills/ti-expert/references/performance-optimization.md +41 -41
- package/skills/ti-expert/references/security-device.md +22 -22
- package/skills/ti-expert/references/security-fundamentals.md +19 -19
- package/skills/ti-expert/references/state-management.md +33 -33
- package/skills/ti-expert/references/testing-e2e-ci.md +25 -25
- package/skills/ti-expert/references/testing-unit.md +24 -24
- package/skills/ti-expert/references/theming.md +15 -15
- package/skills/ti-guides/SKILL.md +58 -60
- package/skills/ti-guides/references/advanced-data-and-images.md +33 -33
- package/skills/ti-guides/references/android-manifest.md +15 -15
- package/skills/ti-guides/references/app-distribution.md +70 -166
- package/skills/ti-guides/references/application-frameworks.md +96 -114
- package/skills/ti-guides/references/cli-reference.md +294 -294
- package/skills/ti-guides/references/coding-best-practices.md +42 -33
- package/skills/ti-guides/references/commonjs-advanced.md +57 -51
- package/skills/ti-guides/references/hello-world.md +36 -36
- package/skills/ti-guides/references/hyperloop-native-access.md +66 -66
- package/skills/ti-guides/references/javascript-primer.md +83 -101
- package/skills/ti-guides/references/reserved-words.md +9 -9
- package/skills/ti-guides/references/resources.md +75 -83
- package/skills/ti-guides/references/style-and-conventions.md +35 -28
- package/skills/ti-guides/references/tiapp-config.md +110 -74
- package/skills/ti-howtos/SKILL.md +88 -92
- package/skills/ti-howtos/references/android-platform-deep-dives.md +104 -104
- package/skills/ti-howtos/references/automation-fastlane-appium.md +39 -39
- package/skills/ti-howtos/references/buffer-codec-streams.md +60 -60
- package/skills/ti-howtos/references/cross-platform-development.md +115 -136
- package/skills/ti-howtos/references/debugging-profiling.md +167 -181
- package/skills/ti-howtos/references/extending-titanium.md +121 -121
- package/skills/ti-howtos/references/google-maps-v2.md +84 -82
- package/skills/ti-howtos/references/ios-map-kit.md +65 -60
- package/skills/ti-howtos/references/ios-platform-deep-dives.md +123 -123
- package/skills/ti-howtos/references/local-data-sources.md +79 -78
- package/skills/ti-howtos/references/location-and-maps.md +116 -120
- package/skills/ti-howtos/references/media-apis.md +87 -86
- package/skills/ti-howtos/references/notification-services.md +250 -260
- package/skills/ti-howtos/references/remote-data-sources.md +98 -93
- package/skills/ti-howtos/references/tutorials.md +226 -216
- package/skills/ti-howtos/references/using-modules.md +73 -102
- package/skills/ti-howtos/references/web-content-integration.md +101 -103
- package/skills/ti-howtos/references/webpack-build-pipeline.md +52 -44
- package/skills/ti-ui/SKILL.md +85 -85
- package/skills/ti-ui/references/accessibility-deep-dive.md +57 -57
- package/skills/ti-ui/references/animation-and-matrices.md +79 -79
- package/skills/ti-ui/references/application-structures.md +96 -99
- package/skills/ti-ui/references/custom-fonts-styling.md +99 -99
- package/skills/ti-ui/references/event-handling.md +58 -58
- package/skills/ti-ui/references/gestures.md +62 -64
- package/skills/ti-ui/references/icons-and-splash-screens.md +88 -88
- package/skills/ti-ui/references/layouts-and-positioning.md +87 -97
- package/skills/ti-ui/references/listviews-and-performance.md +107 -107
- package/skills/ti-ui/references/orientation.md +87 -88
- package/skills/ti-ui/references/platform-ui-android.md +87 -81
- package/skills/ti-ui/references/platform-ui-ios.md +63 -61
- package/skills/ti-ui/references/scrolling-views.md +29 -29
- package/skills/ti-ui/references/tableviews.md +56 -56
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
# Custom
|
|
1
|
+
# Custom fonts and attributed strings
|
|
2
2
|
|
|
3
|
-
## 1. Custom
|
|
3
|
+
## 1. Custom fonts overview
|
|
4
4
|
|
|
5
|
-
Titanium supports TrueType (
|
|
5
|
+
Titanium supports TrueType (`.ttf`) and OpenType (`.otf`) fonts on iOS and Android. Custom fonts are a practical way to match a brand or add a distinct tone to your UI.
|
|
6
6
|
|
|
7
|
-
### Font
|
|
7
|
+
### Font sources
|
|
8
8
|
|
|
9
|
-
- [Google Fonts](https://fonts.google.com) - Free open source fonts
|
|
10
|
-
- [FontSquirrel](https://www.fontsquirrel.com) - Free commercial
|
|
9
|
+
- [Google Fonts](https://fonts.google.com) - Free, open source fonts
|
|
10
|
+
- [FontSquirrel](https://www.fontsquirrel.com) - Free fonts, often licensed for commercial use
|
|
11
11
|
|
|
12
|
-
## 2. Platform-
|
|
12
|
+
## 2. Platform-specific font loading
|
|
13
13
|
|
|
14
|
-
### Key
|
|
14
|
+
### Key difference
|
|
15
15
|
|
|
16
|
-
| Platform
|
|
17
|
-
|
|
|
18
|
-
|
|
|
19
|
-
|
|
|
16
|
+
| Platform | fontFamily value |
|
|
17
|
+
| -------- | ------------------------------------------- |
|
|
18
|
+
| Android | Font file name without extension |
|
|
19
|
+
| iOS | Font PostScript name (embedded in the file) |
|
|
20
20
|
|
|
21
21
|
### Example
|
|
22
22
|
|
|
23
23
|
For a file named `BurnstownDam-Regular.otf`:
|
|
24
|
-
-
|
|
25
|
-
-
|
|
24
|
+
- Android: `fontFamily: 'burnstown_dam'` (filename without extension)
|
|
25
|
+
- iOS: `fontFamily: 'BurnstownDam-Regular'` (PostScript name)
|
|
26
26
|
|
|
27
|
-
## 3. Alloy
|
|
27
|
+
## 3. Alloy projects
|
|
28
28
|
|
|
29
|
-
### Directory
|
|
29
|
+
### Directory structure
|
|
30
30
|
|
|
31
31
|
Place fonts in platform-specific assets:
|
|
32
32
|
|
|
@@ -41,7 +41,7 @@ app/
|
|
|
41
41
|
CustomFont.ttf
|
|
42
42
|
```
|
|
43
43
|
|
|
44
|
-
### XML
|
|
44
|
+
### XML usage
|
|
45
45
|
|
|
46
46
|
```xml
|
|
47
47
|
<Alloy>
|
|
@@ -51,7 +51,7 @@ app/
|
|
|
51
51
|
</Alloy>
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
### TSS
|
|
54
|
+
### TSS styling
|
|
55
55
|
|
|
56
56
|
```javascript
|
|
57
57
|
"#customFont": {
|
|
@@ -62,9 +62,9 @@ app/
|
|
|
62
62
|
}
|
|
63
63
|
```
|
|
64
64
|
|
|
65
|
-
### Cross-
|
|
65
|
+
### Cross-platform solution 1: rename the font file
|
|
66
66
|
|
|
67
|
-
Rename font file to match PostScript name
|
|
67
|
+
Rename the font file to match the PostScript name and use one value.
|
|
68
68
|
|
|
69
69
|
```javascript
|
|
70
70
|
// File renamed from "burnstown_dam.otf" to "BurnstownDam-Regular.otf"
|
|
@@ -77,7 +77,7 @@ Rename font file to match PostScript name, then use same value:
|
|
|
77
77
|
}
|
|
78
78
|
```
|
|
79
79
|
|
|
80
|
-
### Cross-
|
|
80
|
+
### Cross-platform solution 2: platform-specific styles
|
|
81
81
|
|
|
82
82
|
```javascript
|
|
83
83
|
// Use platform-specific TSS
|
|
@@ -93,9 +93,9 @@ Rename font file to match PostScript name, then use same value:
|
|
|
93
93
|
}
|
|
94
94
|
```
|
|
95
95
|
|
|
96
|
-
## 4. Classic Titanium
|
|
96
|
+
## 4. Classic Titanium projects
|
|
97
97
|
|
|
98
|
-
### Directory
|
|
98
|
+
### Directory structure
|
|
99
99
|
|
|
100
100
|
```
|
|
101
101
|
Resources/
|
|
@@ -109,7 +109,7 @@ Resources/
|
|
|
109
109
|
AndroidFont.ttf
|
|
110
110
|
```
|
|
111
111
|
|
|
112
|
-
### Runtime
|
|
112
|
+
### Runtime platform switching
|
|
113
113
|
|
|
114
114
|
```javascript
|
|
115
115
|
let fontFamilyName;
|
|
@@ -131,7 +131,7 @@ const label = Ti.UI.createLabel({
|
|
|
131
131
|
});
|
|
132
132
|
```
|
|
133
133
|
|
|
134
|
-
### Platform-
|
|
134
|
+
### Platform-switching helper function
|
|
135
135
|
|
|
136
136
|
```javascript
|
|
137
137
|
// Helper function from Tweetanium pattern
|
|
@@ -159,46 +159,46 @@ const label = Ti.UI.createLabel({
|
|
|
159
159
|
});
|
|
160
160
|
```
|
|
161
161
|
|
|
162
|
-
## 5. Finding PostScript
|
|
162
|
+
## 5. Finding the PostScript name
|
|
163
163
|
|
|
164
|
-
### Using
|
|
164
|
+
### Using Font Book (macOS)
|
|
165
165
|
|
|
166
|
-
1. Open
|
|
167
|
-
2. Select
|
|
168
|
-
3. Press Cmd+I to view font info
|
|
169
|
-
4.
|
|
166
|
+
1. Open Font Book.
|
|
167
|
+
2. Select the font.
|
|
168
|
+
3. Press Cmd+I to view font info.
|
|
169
|
+
4. Look for the PostScript name field.
|
|
170
170
|
|
|
171
|
-
The PostScript name is embedded in the font file and
|
|
171
|
+
The PostScript name is embedded in the font file and does not change if you rename the file.
|
|
172
172
|
|
|
173
|
-
### Common
|
|
173
|
+
### Common font patterns
|
|
174
174
|
|
|
175
|
-
| Friendly
|
|
175
|
+
| Friendly name | PostScript name pattern |
|
|
176
176
|
| --------------- | --------------------------- |
|
|
177
177
|
| Arial | ArialMT or Arial-BoldMT |
|
|
178
178
|
| Helvetica | Helvetica or Helvetica-Bold |
|
|
179
179
|
| Times New Roman | TimesNewRomanPSMT |
|
|
180
180
|
| Custom-Regular | CustomName-Regular |
|
|
181
181
|
|
|
182
|
-
## 6. iOS
|
|
182
|
+
## 6. iOS platform notes
|
|
183
183
|
|
|
184
|
-
### Automatic Info.plist
|
|
184
|
+
### Automatic Info.plist registration
|
|
185
185
|
|
|
186
|
-
All fonts in `Resources/fonts/` are automatically added to iOS Info.plist.
|
|
186
|
+
All fonts in `Resources/fonts/` are automatically added to the iOS Info.plist.
|
|
187
187
|
|
|
188
|
-
|
|
188
|
+
Important: Put Android-only fonts in `Resources/android/fonts/` to avoid iOS registration errors.
|
|
189
189
|
|
|
190
|
-
### Using
|
|
190
|
+
### Using system fonts
|
|
191
191
|
|
|
192
|
-
Check available system fonts before adding custom fonts
|
|
192
|
+
Check available system fonts before adding custom fonts.
|
|
193
193
|
|
|
194
194
|
- [iOS Fonts](http://iosfonts.com/)
|
|
195
195
|
- [Android Fonts](https://github.com/android/platform_frameworks_base/tree/master/data/fonts)
|
|
196
196
|
|
|
197
|
-
## 7. Attributed
|
|
197
|
+
## 7. Attributed strings
|
|
198
198
|
|
|
199
|
-
Attributed strings
|
|
199
|
+
Attributed strings let you style ranges within a string. They work with Labels, TextAreas, and TextFields.
|
|
200
200
|
|
|
201
|
-
### Basic
|
|
201
|
+
### Basic syntax
|
|
202
202
|
|
|
203
203
|
```javascript
|
|
204
204
|
const text = "Have you tried hyperloop yet?";
|
|
@@ -218,22 +218,22 @@ const label = Ti.UI.createLabel({
|
|
|
218
218
|
});
|
|
219
219
|
```
|
|
220
220
|
|
|
221
|
-
### Important
|
|
221
|
+
### Important warning
|
|
222
222
|
|
|
223
|
-
If
|
|
223
|
+
If you use `attributedString` or `attributedHintText`, do not set other text properties like `font` or `color`. Titanium does not support mixing attributed strings with other text properties.
|
|
224
224
|
|
|
225
|
-
### Property
|
|
225
|
+
### Property equivalents
|
|
226
226
|
|
|
227
|
-
| Component | AttributedString
|
|
227
|
+
| Component | AttributedString property | Equivalent |
|
|
228
228
|
| --------- | ------------------------- | ---------- |
|
|
229
229
|
| Label | `attributedString` | `text` |
|
|
230
230
|
| TextArea | `attributedString` | `value` |
|
|
231
231
|
| TextField | `attributedString` | `value` |
|
|
232
232
|
| TextField | `attributedHintText` | `hintText` |
|
|
233
233
|
|
|
234
|
-
## 8. Attribute
|
|
234
|
+
## 8. Attribute types
|
|
235
235
|
|
|
236
|
-
### Font
|
|
236
|
+
### Font attribute
|
|
237
237
|
|
|
238
238
|
```javascript
|
|
239
239
|
const attr = Ti.UI.createAttributedString({
|
|
@@ -251,7 +251,7 @@ const attr = Ti.UI.createAttributedString({
|
|
|
251
251
|
});
|
|
252
252
|
```
|
|
253
253
|
|
|
254
|
-
### Foreground
|
|
254
|
+
### Foreground color
|
|
255
255
|
|
|
256
256
|
```javascript
|
|
257
257
|
{
|
|
@@ -261,7 +261,7 @@ const attr = Ti.UI.createAttributedString({
|
|
|
261
261
|
}
|
|
262
262
|
```
|
|
263
263
|
|
|
264
|
-
### Background
|
|
264
|
+
### Background color
|
|
265
265
|
|
|
266
266
|
```javascript
|
|
267
267
|
{
|
|
@@ -273,9 +273,9 @@ const attr = Ti.UI.createAttributedString({
|
|
|
273
273
|
|
|
274
274
|
### Underline
|
|
275
275
|
|
|
276
|
-
|
|
276
|
+
Android: single line only, `value` ignored.
|
|
277
277
|
|
|
278
|
-
|
|
278
|
+
iOS: multiple styles and patterns. You can OR constants together (for example, `STYLE_DOUBLE | PATTERN_DOT`).
|
|
279
279
|
|
|
280
280
|
```javascript
|
|
281
281
|
{
|
|
@@ -286,13 +286,13 @@ const attr = Ti.UI.createAttributedString({
|
|
|
286
286
|
}
|
|
287
287
|
```
|
|
288
288
|
|
|
289
|
-
|
|
289
|
+
iOS underline styles:
|
|
290
290
|
- `ATTRIBUTE_UNDERLINE_STYLE_NONE`
|
|
291
291
|
- `ATTRIBUTE_UNDERLINE_STYLE_SINGLE`
|
|
292
292
|
- `ATTRIBUTE_UNDERLINE_STYLE_THICK` (iOS 7+)
|
|
293
293
|
- `ATTRIBUTE_UNDERLINE_STYLE_DOUBLE` (iOS 7+)
|
|
294
294
|
|
|
295
|
-
|
|
295
|
+
iOS patterns (iOS 7+):
|
|
296
296
|
- `ATTRIBUTE_UNDERLINE_PATTERN_SOLID`
|
|
297
297
|
- `ATTRIBUTE_UNDERLINE_PATTERN_DOT`
|
|
298
298
|
- `ATTRIBUTE_UNDERLINE_PATTERN_DASH`
|
|
@@ -300,7 +300,7 @@ const attr = Ti.UI.createAttributedString({
|
|
|
300
300
|
- `ATTRIBUTE_UNDERLINE_PATTERN_DASH_DOT_DOT`
|
|
301
301
|
- `ATTRIBUTE_UNDERLINE_BY_WORD` (Draw lines only under characters, not spaces)
|
|
302
302
|
|
|
303
|
-
|
|
303
|
+
iOS underline color (iOS 7+):
|
|
304
304
|
```javascript
|
|
305
305
|
{
|
|
306
306
|
type: Ti.UI.ATTRIBUTE_UNDERLINE_COLOR,
|
|
@@ -311,11 +311,11 @@ const attr = Ti.UI.createAttributedString({
|
|
|
311
311
|
|
|
312
312
|
### Strikethrough
|
|
313
313
|
|
|
314
|
-
|
|
314
|
+
Android: single line through text only.
|
|
315
315
|
|
|
316
|
-
|
|
316
|
+
iOS: supports the same styles and patterns as underline.
|
|
317
317
|
|
|
318
|
-
|
|
318
|
+
iOS strikethrough color (iOS 7+):
|
|
319
319
|
```javascript
|
|
320
320
|
{
|
|
321
321
|
type: Ti.UI.ATTRIBUTE_STRIKETHROUGH_COLOR,
|
|
@@ -342,9 +342,9 @@ label.addEventListener('link', (e) => {
|
|
|
342
342
|
});
|
|
343
343
|
```
|
|
344
344
|
|
|
345
|
-
|
|
345
|
+
Note: Prior to Titanium Release 4.0, the `link` event was only triggered by a long press on iOS.
|
|
346
346
|
|
|
347
|
-
## 9. iOS-
|
|
347
|
+
## 9. iOS-exclusive attributes
|
|
348
348
|
|
|
349
349
|
### Ligature
|
|
350
350
|
|
|
@@ -356,7 +356,7 @@ label.addEventListener('link', (e) => {
|
|
|
356
356
|
}
|
|
357
357
|
```
|
|
358
358
|
|
|
359
|
-
### Kerning (
|
|
359
|
+
### Kerning (character spacing)
|
|
360
360
|
|
|
361
361
|
```javascript
|
|
362
362
|
{
|
|
@@ -366,10 +366,10 @@ label.addEventListener('link', (e) => {
|
|
|
366
366
|
}
|
|
367
367
|
```
|
|
368
368
|
|
|
369
|
-
### Stroke
|
|
369
|
+
### Stroke text (iOS 7+)
|
|
370
370
|
|
|
371
371
|
```javascript
|
|
372
|
-
// Positive value = outline only,
|
|
372
|
+
// Positive value = outline only, negative = filled with stroke
|
|
373
373
|
{
|
|
374
374
|
type: Ti.UI.ATTRIBUTE_STROKE_WIDTH,
|
|
375
375
|
value: 3.0,
|
|
@@ -398,7 +398,7 @@ label.addEventListener('link', (e) => {
|
|
|
398
398
|
}
|
|
399
399
|
```
|
|
400
400
|
|
|
401
|
-
### Letterpress
|
|
401
|
+
### Letterpress effect (iOS 7+)
|
|
402
402
|
|
|
403
403
|
```javascript
|
|
404
404
|
{
|
|
@@ -408,9 +408,9 @@ label.addEventListener('link', (e) => {
|
|
|
408
408
|
}
|
|
409
409
|
```
|
|
410
410
|
|
|
411
|
-
### Writing
|
|
411
|
+
### Writing direction (iOS 7+)
|
|
412
412
|
|
|
413
|
-
Controls text direction for a specific range.
|
|
413
|
+
Controls text direction for a specific range. You can OR a direction with a behavior (Embedding or Override).
|
|
414
414
|
|
|
415
415
|
```javascript
|
|
416
416
|
{
|
|
@@ -421,16 +421,16 @@ Controls text direction for a specific range. Can logically-OR direction with be
|
|
|
421
421
|
}
|
|
422
422
|
```
|
|
423
423
|
|
|
424
|
-
|
|
425
|
-
- `ATTRIBUTE_WRITING_DIRECTION_NATURAL`: Uses Unicode Bidirectional Algorithm.
|
|
424
|
+
Direction constants:
|
|
425
|
+
- `ATTRIBUTE_WRITING_DIRECTION_NATURAL`: Uses the Unicode Bidirectional Algorithm.
|
|
426
426
|
- `ATTRIBUTE_WRITING_DIRECTION_LEFT_TO_RIGHT`
|
|
427
427
|
- `ATTRIBUTE_WRITING_DIRECTION_RIGHT_TO_LEFT`
|
|
428
428
|
|
|
429
|
-
|
|
429
|
+
Behavior modifiers:
|
|
430
430
|
- `ATTRIBUTE_WRITING_DIRECTION_EMBEDDING`: Use embedded direction.
|
|
431
431
|
- `ATTRIBUTE_WRITING_DIRECTION_OVERRIDE`: Force the direction.
|
|
432
432
|
|
|
433
|
-
### Baseline
|
|
433
|
+
### Baseline offset (iOS 7+)
|
|
434
434
|
|
|
435
435
|
```javascript
|
|
436
436
|
{
|
|
@@ -440,7 +440,7 @@ Controls text direction for a specific range. Can logically-OR direction with be
|
|
|
440
440
|
}
|
|
441
441
|
```
|
|
442
442
|
|
|
443
|
-
### Oblique
|
|
443
|
+
### Oblique or skew (iOS 7+)
|
|
444
444
|
|
|
445
445
|
```javascript
|
|
446
446
|
{
|
|
@@ -460,7 +460,7 @@ Controls text direction for a specific range. Can logically-OR direction with be
|
|
|
460
460
|
}
|
|
461
461
|
```
|
|
462
462
|
|
|
463
|
-
## 10. Multiple
|
|
463
|
+
## 10. Multiple attributes example
|
|
464
464
|
|
|
465
465
|
```javascript
|
|
466
466
|
const text = "Have you tried hyperloop yet?";
|
|
@@ -489,43 +489,43 @@ const attr = Ti.UI.createAttributedString({
|
|
|
489
489
|
});
|
|
490
490
|
```
|
|
491
491
|
|
|
492
|
-
## 11. Best
|
|
492
|
+
## 11. Best practices
|
|
493
493
|
|
|
494
|
-
### Custom
|
|
494
|
+
### Custom fonts
|
|
495
495
|
|
|
496
|
-
1.
|
|
497
|
-
2.
|
|
498
|
-
3.
|
|
499
|
-
4.
|
|
500
|
-
5.
|
|
496
|
+
1. Test on real devices. Simulators can render fonts differently.
|
|
497
|
+
2. Check licensing. Make sure the font is licensed for mobile apps.
|
|
498
|
+
3. Consider file size. Custom fonts increase the app size.
|
|
499
|
+
4. Use system fonts when possible. They load faster.
|
|
500
|
+
5. Provide fallbacks. Always include a fallback `fontFamily`.
|
|
501
501
|
|
|
502
|
-
### Attributed
|
|
502
|
+
### Attributed strings
|
|
503
503
|
|
|
504
|
-
1.
|
|
505
|
-
2.
|
|
506
|
-
3.
|
|
507
|
-
4.
|
|
504
|
+
1. Do not mix with other properties. Use attributed strings or plain text styling.
|
|
505
|
+
2. Use consistent range calculations. Off-by-one errors are easy to introduce.
|
|
506
|
+
3. Test on both platforms. Attributes differ between iOS and Android.
|
|
507
|
+
4. Keep performance in mind. Complex attributed strings can slow scrolling.
|
|
508
508
|
|
|
509
|
-
## 12. Common
|
|
509
|
+
## 12. Common issues
|
|
510
510
|
|
|
511
|
-
### Font
|
|
511
|
+
### Font not showing
|
|
512
512
|
|
|
513
|
-
|
|
513
|
+
Problem: A custom font does not appear.
|
|
514
514
|
|
|
515
|
-
|
|
516
|
-
1. Check PostScript name (iOS)
|
|
517
|
-
2. Verify font file is in correct directory
|
|
518
|
-
|
|
519
|
-
|
|
515
|
+
Solutions:
|
|
516
|
+
1. Check the PostScript name (iOS) and filename (Android).
|
|
517
|
+
2. Verify the font file is in the correct directory.
|
|
518
|
+
3. Clean and rebuild the project.
|
|
519
|
+
4. Check that the font file is not corrupted.
|
|
520
520
|
|
|
521
|
-
### Wrong
|
|
521
|
+
### Wrong font on one platform
|
|
522
522
|
|
|
523
|
-
|
|
523
|
+
Problem: The font works on one platform but not the other.
|
|
524
524
|
|
|
525
|
-
|
|
525
|
+
Solution: You are likely using the wrong naming convention. Use platform-specific styles or rename the font file to match the PostScript name.
|
|
526
526
|
|
|
527
|
-
### Attributed
|
|
527
|
+
### Attributed string not displaying
|
|
528
528
|
|
|
529
|
-
|
|
529
|
+
Problem: Text shows as plain instead of formatted.
|
|
530
530
|
|
|
531
|
-
|
|
531
|
+
Solution: Remove conflicting properties like `font` and `color` when using `attributedString`.
|