@maccesar/titools 5.2.5 → 5.4.0

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 (138) hide show
  1. package/CONTRIBUTING.md +1 -1
  2. package/README.md +58 -97
  3. package/agents/ti-pro.md +4 -2
  4. package/commands/ti-audit.md +7 -5
  5. package/docs/examples.md +24 -13
  6. package/docs/knowledge-index.md +2 -1
  7. package/lib/config.js +1 -0
  8. package/package.json +1 -1
  9. package/skills/alloy-guides/SKILL.md +18 -179
  10. package/skills/alloy-guides/references/CLI_TASKS.md +17 -216
  11. package/skills/alloy-guides/references/CONCEPTS.md +27 -162
  12. package/skills/alloy-guides/references/CONTROLLERS.md +38 -236
  13. package/skills/alloy-guides/references/MODELS.md +47 -723
  14. package/skills/alloy-guides/references/MODELS_ADVANCED.md +21 -482
  15. package/skills/alloy-guides/references/VIEWS_DYNAMIC.md +12 -222
  16. package/skills/alloy-guides/references/VIEWS_STYLES.md +39 -358
  17. package/skills/alloy-guides/references/VIEWS_XML.md +36 -552
  18. package/skills/alloy-guides/references/WIDGETS.md +49 -127
  19. package/skills/alloy-howtos/SKILL.md +14 -169
  20. package/skills/alloy-howtos/references/best_practices.md +9 -113
  21. package/skills/alloy-howtos/references/cli_reference.md +18 -223
  22. package/skills/alloy-howtos/references/config_files.md +50 -133
  23. package/skills/alloy-howtos/references/debugging_troubleshooting.md +19 -63
  24. package/skills/alloy-howtos/references/samples.md +21 -138
  25. package/skills/ti-api/SKILL.md +10 -2
  26. package/skills/ti-api/references/api-android.md +36 -2
  27. package/skills/ti-api/references/api-app-platform.md +39 -3
  28. package/skills/ti-api/references/api-core.md +50 -18
  29. package/skills/ti-api/references/api-data-network.md +49 -35
  30. package/skills/ti-api/references/api-media.md +45 -27
  31. package/skills/ti-api/references/api-services.md +39 -9
  32. package/skills/ti-api/references/api-ui-android.md +33 -13
  33. package/skills/ti-api/references/api-ui-extras.md +41 -15
  34. package/skills/ti-api/references/api-ui-ios-animator.md +42 -26
  35. package/skills/ti-api/references/api-ui-ios.md +74 -2
  36. package/skills/ti-api/references/api-ui-lists.md +32 -16
  37. package/skills/ti-api/references/api-ui-text-input.md +34 -17
  38. package/skills/ti-api/references/api-ui-views.md +27 -1
  39. package/skills/ti-api/references/api-ui-windows-navigation.md +32 -18
  40. package/skills/ti-api/references/api-xml-global.md +66 -16
  41. package/skills/ti-create-release/SKILL.md +98 -0
  42. package/skills/ti-create-release/references/module-discovery.md +69 -0
  43. package/skills/ti-expert/references/adaptive-layouts.md +1 -1
  44. package/skills/ti-guides/SKILL.md +37 -76
  45. package/skills/ti-guides/references/advanced-data-and-images.md +122 -126
  46. package/skills/ti-guides/references/android-manifest.md +24 -83
  47. package/skills/ti-guides/references/app-distribution.md +31 -377
  48. package/skills/ti-guides/references/application-frameworks.md +127 -335
  49. package/skills/ti-guides/references/cli-reference.md +184 -633
  50. package/skills/ti-guides/references/commonjs-advanced.md +81 -231
  51. package/skills/ti-guides/references/compatibility-matrix.md +36 -75
  52. package/skills/ti-guides/references/hello-world.md +95 -70
  53. package/skills/ti-guides/references/hyperloop-native-access.md +52 -448
  54. package/skills/ti-guides/references/resources.md +174 -142
  55. package/skills/ti-guides/references/sdk-release-notes.md +28 -71
  56. package/skills/ti-guides/references/tiapp-config.md +222 -598
  57. package/skills/ti-howtos/SKILL.md +23 -123
  58. package/skills/ti-howtos/references/cross-platform-development.md +119 -324
  59. package/skills/ti-howtos/references/debugging-profiling.md +77 -445
  60. package/skills/ti-howtos/references/extending-titanium.md +199 -673
  61. package/skills/ti-howtos/references/local-data-sources.md +87 -300
  62. package/skills/ti-howtos/references/location-and-maps.md +86 -213
  63. package/skills/ti-howtos/references/media-apis.md +103 -223
  64. package/skills/ti-howtos/references/notification-services.md +86 -506
  65. package/skills/ti-howtos/references/remote-data-sources.md +97 -316
  66. package/skills/ti-howtos/references/using-modules.md +77 -133
  67. package/skills/ti-synthengine/SKILL.md +62 -111
  68. package/skills/ti-synthengine/assets/example/README.md +50 -59
  69. package/skills/ti-synthengine/assets/example/app.js +67 -65
  70. package/skills/ti-synthengine/assets/example/lib/sequenceOwner.js +39 -40
  71. package/skills/ti-synthengine/assets/example/lib/soundPreset.js +34 -0
  72. package/skills/ti-synthengine/assets/index.d.ts +122 -2
  73. package/skills/ti-synthengine/references/advanced-examples.md +4 -4
  74. package/skills/ti-synthengine/references/api.md +40 -18
  75. package/skills/ti-synthengine/references/audio-engine.md +15 -57
  76. package/skills/ti-synthengine/references/examples.md +63 -6
  77. package/skills/ti-synthengine/references/guide.md +61 -57
  78. package/skills/ti-synthengine/references/instruments-and-effects.md +15 -15
  79. package/skills/ti-synthengine/references/native-variation.md +53 -14
  80. package/skills/ti-synthengine/references/recipes-interaction.md +25 -20
  81. package/skills/ti-synthengine/references/recipes.md +19 -16
  82. package/skills/ti-synthengine/references/recommendations.md +12 -12
  83. package/skills/ti-synthengine/references/sound-api.md +197 -0
  84. package/skills/ti-synthengine/references/sound-design.md +7 -7
  85. package/skills/ti-synthengine/references/source-notes.md +62 -172
  86. package/skills/ti-synthengine/references/troubleshooting.md +17 -19
  87. package/skills/ti-synthengine/references/upgrade-2.0.0.md +40 -0
  88. package/skills/ti-ui/SKILL.md +28 -143
  89. package/skills/ti-ui/references/icons-and-splash-screens.md +74 -403
  90. package/skills/ti-ui/references/layouts-and-positioning.md +175 -402
  91. package/skills/ti-ui/references/listviews-and-performance.md +100 -703
  92. package/skills/ti-ui/references/platform-conventions.md +180 -0
  93. package/skills/ti-ui/references/user-interface.md +43 -0
  94. package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +0 -102
  95. package/skills/alloy-howtos/references/custom_tags.md +0 -148
  96. package/skills/ti-guides/references/coding-best-practices.md +0 -149
  97. package/skills/ti-guides/references/javascript-primer.md +0 -414
  98. package/skills/ti-guides/references/reserved-words.md +0 -36
  99. package/skills/ti-guides/references/style-and-conventions.md +0 -103
  100. package/skills/ti-howtos/references/android-platform-deep-dives.md +0 -624
  101. package/skills/ti-howtos/references/automation-fastlane-appium.md +0 -96
  102. package/skills/ti-howtos/references/buffer-codec-streams.md +0 -162
  103. package/skills/ti-howtos/references/google-maps-v2.md +0 -172
  104. package/skills/ti-howtos/references/ios-map-kit.md +0 -149
  105. package/skills/ti-howtos/references/ios-platform-deep-dives.md +0 -611
  106. package/skills/ti-howtos/references/tutorials.md +0 -565
  107. package/skills/ti-howtos/references/web-content-integration.md +0 -287
  108. package/skills/ti-howtos/references/webpack-build-pipeline.md +0 -124
  109. package/skills/ti-synthengine/references/android-sim80-correction-evidence.zip +0 -0
  110. package/skills/ti-synthengine/references/android-sim80-correction.json +0 -162
  111. package/skills/ti-synthengine/references/audio-pipeline-validation.md +0 -19
  112. package/skills/ti-synthengine/references/bypass-physical-recheck-evidence.zip +0 -0
  113. package/skills/ti-synthengine/references/frontier-android-evidence.zip +0 -0
  114. package/skills/ti-synthengine/references/frontier-ipad-evidence.zip +0 -0
  115. package/skills/ti-synthengine/references/frontier-physical-validation.json +0 -1918
  116. package/skills/ti-synthengine/references/native-tone-repetition-validation.md +0 -59
  117. package/skills/ti-synthengine/references/native-variation-proposal.md +0 -182
  118. package/skills/ti-synthengine/references/native-variation-validation.md +0 -63
  119. package/skills/ti-synthengine/references/performance-review-evidence.zip +0 -0
  120. package/skills/ti-synthengine/references/performance-review.json +0 -1146
  121. package/skills/ti-synthengine/references/physical-validation.json +0 -1457
  122. package/skills/ti-synthengine/references/source-snapshot.json +0 -542
  123. package/skills/ti-synthengine/references/stats-performance.json +0 -2992
  124. package/skills/ti-synthengine/references/stats-performance.md +0 -82
  125. package/skills/ti-synthengine/references/studio-validation.json +0 -6202
  126. package/skills/ti-synthengine/references/unified-bypass-performance.json +0 -22425
  127. package/skills/ti-synthengine/references/unified-validation.json +0 -314
  128. package/skills/ti-ui/references/accessibility-deep-dive.md +0 -288
  129. package/skills/ti-ui/references/animation-and-matrices.md +0 -569
  130. package/skills/ti-ui/references/application-structures.md +0 -626
  131. package/skills/ti-ui/references/custom-fonts-styling.md +0 -549
  132. package/skills/ti-ui/references/event-handling.md +0 -401
  133. package/skills/ti-ui/references/gestures.md +0 -448
  134. package/skills/ti-ui/references/orientation.md +0 -374
  135. package/skills/ti-ui/references/platform-ui-android.md +0 -727
  136. package/skills/ti-ui/references/platform-ui-ios.md +0 -576
  137. package/skills/ti-ui/references/scrolling-views.md +0 -288
  138. package/skills/ti-ui/references/tableviews.md +0 -542
@@ -1,549 +0,0 @@
1
- # Custom fonts and attributed strings
2
-
3
- <!-- TOC-START -->
4
- ## Contents
5
-
6
- - [1. Custom fonts overview](#1-custom-fonts-overview)
7
- - [2. Platform-specific font loading](#2-platform-specific-font-loading)
8
- - [3. Alloy projects](#3-alloy-projects)
9
- - [4. Classic Titanium projects](#4-classic-titanium-projects)
10
- - [5. Finding the PostScript name](#5-finding-the-postscript-name)
11
- - [6. iOS platform notes](#6-ios-platform-notes)
12
- - [7. Attributed strings](#7-attributed-strings)
13
- - [8. Attribute types](#8-attribute-types)
14
- - [9. iOS-exclusive attributes](#9-ios-exclusive-attributes)
15
- - [10. Multiple attributes example](#10-multiple-attributes-example)
16
- - [11. Best practices](#11-best-practices)
17
- - [12. Common issues](#12-common-issues)
18
-
19
- <!-- TOC-END -->
20
-
21
- ## 1. Custom fonts overview
22
-
23
- 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.
24
-
25
- ### Font sources
26
-
27
- - [Google Fonts](https://fonts.google.com) - Free, open source fonts
28
- - [FontSquirrel](https://www.fontsquirrel.com) - Free fonts, often licensed for commercial use
29
-
30
- ## 2. Platform-specific font loading
31
-
32
- ### Key difference
33
-
34
- | Platform | fontFamily value |
35
- | -------- | ------------------------------------------- |
36
- | Android | Font file name without extension |
37
- | iOS | Font PostScript name (embedded in the file) |
38
-
39
- ### Example
40
-
41
- For a file named `BurnstownDam-Regular.otf`:
42
- - Android: `fontFamily: 'burnstown_dam'` (filename without extension)
43
- - iOS: `fontFamily: 'BurnstownDam-Regular'` (PostScript name)
44
-
45
- ## 3. Alloy projects
46
-
47
- ### Directory structure
48
-
49
- Place fonts in platform-specific assets:
50
-
51
- ```
52
- app/
53
- assets/
54
- android/
55
- fonts/
56
- CustomFont.ttf
57
- iphone/
58
- fonts/
59
- CustomFont.ttf
60
- ```
61
-
62
- ### XML usage
63
-
64
- ```xml
65
- <Alloy>
66
- <View>
67
- <Label id="customFont">This uses a custom font</Label>
68
- </View>
69
- </Alloy>
70
- ```
71
-
72
- ### TSS styling
73
-
74
- ```javascript
75
- "#customFont": {
76
- font: {
77
- fontFamily: 'CustomFont-Regular', // iOS PostScript name
78
- fontSize: 24
79
- }
80
- }
81
- ```
82
-
83
- ### Cross-platform solution 1: rename the font file
84
-
85
- Rename the font file to match the PostScript name and use one value.
86
-
87
- ```javascript
88
- // File renamed from "burnstown_dam.otf" to "BurnstownDam-Regular.otf"
89
-
90
- "#customFont": {
91
- font: {
92
- fontFamily: 'BurnstownDam-Regular', // Works on both platforms
93
- fontSize: 24
94
- }
95
- }
96
- ```
97
-
98
- ### Cross-platform solution 2: platform-specific styles
99
-
100
- ```javascript
101
- // Use platform-specific TSS
102
- "#customFont[platform=ios]": {
103
- font: {
104
- fontFamily: 'BurnstownDam-Regular' // iOS PostScript name
105
- }
106
- },
107
- "#customFont[platform=android]": {
108
- font: {
109
- fontFamily: 'burnstown_dam' // Android filename
110
- }
111
- }
112
- ```
113
-
114
- ## 4. Classic Titanium projects
115
-
116
- ### Directory structure
117
-
118
- ```
119
- Resources/
120
- fonts/
121
- CustomFont.ttf
122
- iphone/
123
- fonts/
124
- iOSFont.ttf
125
- android/
126
- fonts/
127
- AndroidFont.ttf
128
- ```
129
-
130
- ### Runtime platform switching
131
-
132
- ```javascript
133
- let fontFamilyName;
134
-
135
- if (Ti.Platform.osname === 'android') {
136
- // Android: use filename without extension
137
- fontFamilyName = 'CustomFont-Regular';
138
- } else {
139
- // iOS: use PostScript name
140
- fontFamilyName = 'CustomFont';
141
- }
142
-
143
- const label = Ti.UI.createLabel({
144
- text: 'Custom Font Text',
145
- font: {
146
- fontFamily: fontFamilyName,
147
- fontSize: 24
148
- }
149
- });
150
- ```
151
-
152
- ### Platform-switching helper function
153
-
154
- ```javascript
155
- // Helper function from Tweetanium pattern
156
- const os = (map) => {
157
- const def = map.def || null;
158
- if (map[Ti.Platform.osname]) {
159
- return (typeof map[Ti.Platform.osname] === 'function')
160
- ? map[Ti.Platform.osname]()
161
- : map[Ti.Platform.osname];
162
- }
163
- return (typeof def === 'function') ? def() : def;
164
- };
165
-
166
- // Usage
167
- const label = Ti.UI.createLabel({
168
- text: 'Custom Font Text',
169
- font: {
170
- fontFamily: os({
171
- iphone: 'CustomFont',
172
- ipad: 'CustomFont',
173
- android: 'CustomFont-Regular'
174
- }),
175
- fontSize: 24
176
- }
177
- });
178
- ```
179
-
180
- ## 5. Finding the PostScript name
181
-
182
- ### Using Font Book (macOS)
183
-
184
- 1. Open Font Book.
185
- 2. Select the font.
186
- 3. Press Cmd+I to view font info.
187
- 4. Look for the PostScript name field.
188
-
189
- The PostScript name is embedded in the font file and does not change if you rename the file.
190
-
191
- ### Common font patterns
192
-
193
- | Friendly name | PostScript name pattern |
194
- | --------------- | --------------------------- |
195
- | Arial | ArialMT or Arial-BoldMT |
196
- | Helvetica | Helvetica or Helvetica-Bold |
197
- | Times New Roman | TimesNewRomanPSMT |
198
- | Custom-Regular | CustomName-Regular |
199
-
200
- ## 6. iOS platform notes
201
-
202
- ### Automatic Info.plist registration
203
-
204
- All fonts in `Resources/fonts/` are automatically added to the iOS Info.plist.
205
-
206
- Important: Put Android-only fonts in `Resources/android/fonts/` to avoid iOS registration errors.
207
-
208
- ### Using system fonts
209
-
210
- Check available system fonts before adding custom fonts.
211
-
212
- - [iOS Fonts](http://iosfonts.com/)
213
- - [Android Fonts](https://github.com/android/platform_frameworks_base/tree/master/data/fonts)
214
-
215
- ## 7. Attributed strings
216
-
217
- Attributed strings let you style ranges within a string. They work with Labels, TextAreas, and TextFields.
218
-
219
- ### Basic syntax
220
-
221
- ```javascript
222
- const text = "Have you tried hyperloop yet?";
223
- const attr = Ti.UI.createAttributedString({
224
- text: text,
225
- attributes: [
226
- {
227
- type: Ti.UI.ATTRIBUTE_BACKGROUND_COLOR,
228
- value: "yellow",
229
- range: [text.indexOf('hyperloop'), ('hyperloop').length]
230
- }
231
- ]
232
- });
233
-
234
- const label = Ti.UI.createLabel({
235
- attributedString: attr
236
- });
237
- ```
238
-
239
- ### Important warning
240
-
241
- 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.
242
-
243
- ### Property equivalents
244
-
245
- | Component | AttributedString property | Equivalent |
246
- | --------- | ------------------------- | ---------- |
247
- | Label | `attributedString` | `text` |
248
- | TextArea | `attributedString` | `value` |
249
- | TextField | `attributedString` | `value` |
250
- | TextField | `attributedHintText` | `hintText` |
251
-
252
- ## 8. Attribute types
253
-
254
- ### Font attribute
255
-
256
- ```javascript
257
- const attr = Ti.UI.createAttributedString({
258
- text: text,
259
- attributes: [
260
- {
261
- type: Ti.UI.ATTRIBUTE_FONT,
262
- value: {
263
- fontSize: 24,
264
- fontFamily: 'Didot'
265
- },
266
- range: [text.indexOf('hyperloop'), ('hyperloop').length]
267
- }
268
- ]
269
- });
270
- ```
271
-
272
- ### Foreground color
273
-
274
- ```javascript
275
- {
276
- type: Ti.UI.ATTRIBUTE_FOREGROUND_COLOR,
277
- value: 'cyan',
278
- range: [start, length]
279
- }
280
- ```
281
-
282
- ### Background color
283
-
284
- ```javascript
285
- {
286
- type: Ti.UI.ATTRIBUTE_BACKGROUND_COLOR,
287
- value: "yellow",
288
- range: [start, length]
289
- }
290
- ```
291
-
292
- ### Underline
293
-
294
- Android: single line only, `value` ignored.
295
-
296
- iOS: multiple styles and patterns. You can OR constants together (for example, `STYLE_DOUBLE | PATTERN_DOT`).
297
-
298
- ```javascript
299
- {
300
- type: Ti.UI.ATTRIBUTE_UNDERLINES_STYLE,
301
- value: Ti.UI.ATTRIBUTE_UNDERLINE_STYLE_DOUBLE |
302
- Ti.UI.ATTRIBUTE_UNDERLINE_PATTERN_DOT,
303
- range: [start, length]
304
- }
305
- ```
306
-
307
- iOS underline styles:
308
- - `ATTRIBUTE_UNDERLINE_STYLE_NONE`
309
- - `ATTRIBUTE_UNDERLINE_STYLE_SINGLE`
310
- - `ATTRIBUTE_UNDERLINE_STYLE_THICK` (iOS 7+)
311
- - `ATTRIBUTE_UNDERLINE_STYLE_DOUBLE` (iOS 7+)
312
-
313
- iOS patterns (iOS 7+):
314
- - `ATTRIBUTE_UNDERLINE_PATTERN_SOLID`
315
- - `ATTRIBUTE_UNDERLINE_PATTERN_DOT`
316
- - `ATTRIBUTE_UNDERLINE_PATTERN_DASH`
317
- - `ATTRIBUTE_UNDERLINE_PATTERN_DASH_DOT`
318
- - `ATTRIBUTE_UNDERLINE_PATTERN_DASH_DOT_DOT`
319
- - `ATTRIBUTE_UNDERLINE_BY_WORD` (Draw lines only under characters, not spaces)
320
-
321
- iOS underline color (iOS 7+):
322
- ```javascript
323
- {
324
- type: Ti.UI.ATTRIBUTE_UNDERLINE_COLOR,
325
- value: 'blue',
326
- range: [start, length]
327
- }
328
- ```
329
-
330
- ### Strikethrough
331
-
332
- Android: single line through text only.
333
-
334
- iOS: supports the same styles and patterns as underline.
335
-
336
- iOS strikethrough color (iOS 7+):
337
- ```javascript
338
- {
339
- type: Ti.UI.ATTRIBUTE_STRIKETHROUGH_COLOR,
340
- value: 'red',
341
- range: [start, length]
342
- }
343
- ```
344
-
345
- ### Links (iOS 7+)
346
-
347
- ```javascript
348
- {
349
- type: Ti.UI.ATTRIBUTE_LINK,
350
- value: "https://github.com/tidev/hyperloop",
351
- range: [start, length]
352
- }
353
- ```
354
-
355
- Handle link clicks:
356
-
357
- ```javascript
358
- label.addEventListener('link', (e) => {
359
- Ti.API.info(`Link clicked: ${e.url}`);
360
- });
361
- ```
362
-
363
- Note: Prior to Titanium Release 4.0, the `link` event was only triggered by a long press on iOS.
364
-
365
- ## 9. iOS-exclusive attributes
366
-
367
- ### Ligature
368
-
369
- ```javascript
370
- {
371
- type: Ti.UI.ATTRIBUTE_LIGATURE,
372
- value: 1, // 1 = enabled, 0 = disabled (default)
373
- range: [start, length]
374
- }
375
- ```
376
-
377
- ### Kerning (character spacing)
378
-
379
- ```javascript
380
- {
381
- type: Ti.UI.ATTRIBUTE_KERN,
382
- value: 5.0, // Distance in points. Positive = wider, 0 = default, negative = tighter
383
- range: [start, length]
384
- }
385
- ```
386
-
387
- ### Stroke text (iOS 7+)
388
-
389
- ```javascript
390
- // Positive value = outline only, negative = filled with stroke
391
- {
392
- type: Ti.UI.ATTRIBUTE_STROKE_WIDTH,
393
- value: 3.0,
394
- range: [start, length]
395
- }
396
-
397
- // Stroke color
398
- {
399
- type: Ti.UI.ATTRIBUTE_STROKE_COLOR,
400
- value: 'red',
401
- range: [start, length]
402
- }
403
- ```
404
-
405
- ### Shadow (iOS 7+)
406
-
407
- ```javascript
408
- {
409
- type: Ti.UI.ATTRIBUTE_SHADOW,
410
- value: {
411
- color: 'green',
412
- offset: { width: 10, height: 5 },
413
- blurRadius: 3.0 // 0 = no blur
414
- },
415
- range: [start, length]
416
- }
417
- ```
418
-
419
- ### Letterpress effect (iOS 7+)
420
-
421
- ```javascript
422
- {
423
- type: Ti.UI.ATTRIBUTE_TEXT_EFFECT,
424
- value: Ti.UI.ATTRIBUTE_LETTERPRESS_STYLE,
425
- range: [start, length]
426
- }
427
- ```
428
-
429
- ### Writing direction (iOS 7+)
430
-
431
- Controls text direction for a specific range. You can OR a direction with a behavior (Embedding or Override).
432
-
433
- ```javascript
434
- {
435
- type: Ti.UI.ATTRIBUTE_WRITING_DIRECTION,
436
- value: Ti.UI.ATTRIBUTE_WRITING_DIRECTION_RIGHT_TO_LEFT |
437
- Ti.UI.ATTRIBUTE_WRITING_DIRECTION_OVERRIDE,
438
- range: [start, length]
439
- }
440
- ```
441
-
442
- Direction constants:
443
- - `ATTRIBUTE_WRITING_DIRECTION_NATURAL`: Uses the Unicode Bidirectional Algorithm.
444
- - `ATTRIBUTE_WRITING_DIRECTION_LEFT_TO_RIGHT`
445
- - `ATTRIBUTE_WRITING_DIRECTION_RIGHT_TO_LEFT`
446
-
447
- Behavior modifiers:
448
- - `ATTRIBUTE_WRITING_DIRECTION_EMBEDDING`: Use embedded direction.
449
- - `ATTRIBUTE_WRITING_DIRECTION_OVERRIDE`: Force the direction.
450
-
451
- ### Baseline offset (iOS 7+)
452
-
453
- ```javascript
454
- {
455
- type: Ti.UI.ATTRIBUTE_BASELINE_OFFSET,
456
- value: 10, // Pixels. Positive = above, negative = below baseline
457
- range: [start, length]
458
- }
459
- ```
460
-
461
- ### Oblique or skew (iOS 7+)
462
-
463
- ```javascript
464
- {
465
- type: Ti.UI.ATTRIBUTE_OBLIQUENESS,
466
- value: 0.25, // 0 = no skew
467
- range: [start, length]
468
- }
469
- ```
470
-
471
- ### Expansion (iOS 7+)
472
-
473
- ```javascript
474
- {
475
- type: Ti.UI.ATTRIBUTE_EXPANSION,
476
- value: 0.25, // Log of expansion factor, 0 = none
477
- range: [start, length]
478
- }
479
- ```
480
-
481
- ## 10. Multiple attributes example
482
-
483
- ```javascript
484
- const text = "Have you tried hyperloop yet?";
485
- const attr = Ti.UI.createAttributedString({
486
- text: text,
487
- attributes: [
488
- // Background color
489
- {
490
- type: Ti.UI.ATTRIBUTE_BACKGROUND_COLOR,
491
- value: "yellow",
492
- range: [text.indexOf('hyperloop'), ('hyperloop').length]
493
- },
494
- // Bold font
495
- {
496
- type: Ti.UI.ATTRIBUTE_FONT,
497
- value: { fontSize: 24, fontWeight: 'bold' },
498
- range: [text.indexOf('hyperloop'), ('hyperloop').length]
499
- },
500
- // Red text
501
- {
502
- type: Ti.UI.ATTRIBUTE_FOREGROUND_COLOR,
503
- value: 'red',
504
- range: [text.indexOf('hyperloop'), ('hyperloop').length]
505
- }
506
- ]
507
- });
508
- ```
509
-
510
- ## 11. Best practices
511
-
512
- ### Custom fonts
513
-
514
- 1. Test on real devices. Simulators can render fonts differently.
515
- 2. Check licensing. Make sure the font is licensed for mobile apps.
516
- 3. Consider file size. Custom fonts increase the app size.
517
- 4. Use system fonts when possible. They load faster.
518
- 5. Provide fallbacks. Always include a fallback `fontFamily`.
519
-
520
- ### Attributed strings
521
-
522
- 1. Do not mix with other properties. Use attributed strings or plain text styling.
523
- 2. Use consistent range calculations. Off-by-one errors are easy to introduce.
524
- 3. Test on both platforms. Attributes differ between iOS and Android.
525
- 4. Keep performance in mind. Complex attributed strings can slow scrolling.
526
-
527
- ## 12. Common issues
528
-
529
- ### Font not showing
530
-
531
- Problem: A custom font does not appear.
532
-
533
- Solutions:
534
- 1. Check the PostScript name (iOS) and filename (Android).
535
- 2. Verify the font file is in the correct directory.
536
- 3. Clean and rebuild the project.
537
- 4. Check that the font file is not corrupted.
538
-
539
- ### Wrong font on one platform
540
-
541
- Problem: The font works on one platform but not the other.
542
-
543
- Solution: You are likely using the wrong naming convention. Use platform-specific styles or rename the font file to match the PostScript name.
544
-
545
- ### Attributed string not displaying
546
-
547
- Problem: Text shows as plain instead of formatted.
548
-
549
- Solution: Remove conflicting properties like `font` and `color` when using `attributedString`.