@maccesar/titools 2.0.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 (120) hide show
  1. package/AGENTS-TEMPLATE.md +173 -0
  2. package/README.md +867 -0
  3. package/agents/ti-researcher.md +108 -0
  4. package/bin/titools.js +53 -0
  5. package/lib/commands/agents.js +126 -0
  6. package/lib/commands/install.js +188 -0
  7. package/lib/commands/uninstall.js +215 -0
  8. package/lib/commands/update.js +159 -0
  9. package/lib/config.js +119 -0
  10. package/lib/downloader.js +153 -0
  11. package/lib/installer.js +253 -0
  12. package/lib/platform.js +108 -0
  13. package/lib/symlink.js +142 -0
  14. package/lib/utils.js +270 -0
  15. package/package.json +67 -0
  16. package/skills/alloy-expert/SKILL.md +247 -0
  17. package/skills/alloy-expert/assets/ControllerAutoCleanup.js +182 -0
  18. package/skills/alloy-expert/references/alloy-structure.md +381 -0
  19. package/skills/alloy-expert/references/anti-patterns.md +133 -0
  20. package/skills/alloy-expert/references/code-conventions.md +469 -0
  21. package/skills/alloy-expert/references/contracts.md +280 -0
  22. package/skills/alloy-expert/references/controller-patterns.md +520 -0
  23. package/skills/alloy-expert/references/error-handling.md +484 -0
  24. package/skills/alloy-expert/references/examples.md +735 -0
  25. package/skills/alloy-expert/references/migration-patterns.md +298 -0
  26. package/skills/alloy-expert/references/patterns.md +448 -0
  27. package/skills/alloy-expert/references/performance-patterns.md +855 -0
  28. package/skills/alloy-expert/references/security-patterns.md +847 -0
  29. package/skills/alloy-expert/references/state-management.md +779 -0
  30. package/skills/alloy-expert/references/testing.md +872 -0
  31. package/skills/alloy-guides/SKILL.md +214 -0
  32. package/skills/alloy-guides/references/CLI_TASKS.md +243 -0
  33. package/skills/alloy-guides/references/CONCEPTS.md +191 -0
  34. package/skills/alloy-guides/references/CONTROLLERS.md +298 -0
  35. package/skills/alloy-guides/references/MODELS.md +1028 -0
  36. package/skills/alloy-guides/references/PURGETSS.md +56 -0
  37. package/skills/alloy-guides/references/VIEWS_DYNAMIC.md +242 -0
  38. package/skills/alloy-guides/references/VIEWS_STYLES.md +388 -0
  39. package/skills/alloy-guides/references/VIEWS_WITHOUT_CONTROLLERS.md +109 -0
  40. package/skills/alloy-guides/references/VIEWS_XML.md +558 -0
  41. package/skills/alloy-guides/references/WIDGETS.md +176 -0
  42. package/skills/alloy-howtos/SKILL.md +203 -0
  43. package/skills/alloy-howtos/references/best_practices.md +138 -0
  44. package/skills/alloy-howtos/references/cli_reference.md +253 -0
  45. package/skills/alloy-howtos/references/config_files.md +87 -0
  46. package/skills/alloy-howtos/references/custom_tags.md +147 -0
  47. package/skills/alloy-howtos/references/debugging_troubleshooting.md +101 -0
  48. package/skills/alloy-howtos/references/samples.md +167 -0
  49. package/skills/purgetss/SKILL.md +442 -0
  50. package/skills/purgetss/assets/purgetss.config.cjs +17 -0
  51. package/skills/purgetss/references/EXAMPLES.md +247 -0
  52. package/skills/purgetss/references/animation-system.md +1294 -0
  53. package/skills/purgetss/references/apply-directive.md +375 -0
  54. package/skills/purgetss/references/arbitrary-values.md +612 -0
  55. package/skills/purgetss/references/class-index.md +1350 -0
  56. package/skills/purgetss/references/cli-commands.md +948 -0
  57. package/skills/purgetss/references/configurable-properties.md +654 -0
  58. package/skills/purgetss/references/custom-rules.md +161 -0
  59. package/skills/purgetss/references/customization-deep-dive.md +722 -0
  60. package/skills/purgetss/references/dynamic-component-creation.md +489 -0
  61. package/skills/purgetss/references/grid-layout.md +455 -0
  62. package/skills/purgetss/references/icon-fonts.md +609 -0
  63. package/skills/purgetss/references/installation-setup.md +366 -0
  64. package/skills/purgetss/references/opacity-modifier.md +291 -0
  65. package/skills/purgetss/references/platform-modifiers.md +479 -0
  66. package/skills/purgetss/references/smart-mappings.md +42 -0
  67. package/skills/purgetss/references/titanium-resets.md +359 -0
  68. package/skills/purgetss/references/ui-ux-design.md +1526 -0
  69. package/skills/ti-guides/SKILL.md +94 -0
  70. package/skills/ti-guides/references/advanced-data-and-images.md +19 -0
  71. package/skills/ti-guides/references/alloy-cli-advanced.md +84 -0
  72. package/skills/ti-guides/references/alloy-data-mastery.md +29 -0
  73. package/skills/ti-guides/references/alloy-widgets-and-themes.md +19 -0
  74. package/skills/ti-guides/references/android-manifest.md +97 -0
  75. package/skills/ti-guides/references/app-distribution.md +258 -0
  76. package/skills/ti-guides/references/application-frameworks.md +377 -0
  77. package/skills/ti-guides/references/cli-reference.md +402 -0
  78. package/skills/ti-guides/references/coding-best-practices.md +102 -0
  79. package/skills/ti-guides/references/commonjs-advanced.md +134 -0
  80. package/skills/ti-guides/references/hello-world.md +100 -0
  81. package/skills/ti-guides/references/hyperloop-native-access.md +62 -0
  82. package/skills/ti-guides/references/javascript-primer.md +411 -0
  83. package/skills/ti-guides/references/reserved-words.md +36 -0
  84. package/skills/ti-guides/references/resources.md +183 -0
  85. package/skills/ti-guides/references/style-and-conventions.md +48 -0
  86. package/skills/ti-guides/references/tiapp-config.md +609 -0
  87. package/skills/ti-howtos/SKILL.md +174 -0
  88. package/skills/ti-howtos/references/android-platform-deep-dives.md +658 -0
  89. package/skills/ti-howtos/references/automation-fastlane-appium.md +95 -0
  90. package/skills/ti-howtos/references/buffer-codec-streams.md +140 -0
  91. package/skills/ti-howtos/references/cross-platform-development.md +348 -0
  92. package/skills/ti-howtos/references/debugging-profiling.md +543 -0
  93. package/skills/ti-howtos/references/extending-titanium.md +723 -0
  94. package/skills/ti-howtos/references/google-maps-v2.md +169 -0
  95. package/skills/ti-howtos/references/ios-map-kit.md +143 -0
  96. package/skills/ti-howtos/references/ios-platform-deep-dives.md +783 -0
  97. package/skills/ti-howtos/references/local-data-sources.md +301 -0
  98. package/skills/ti-howtos/references/location-and-maps.md +252 -0
  99. package/skills/ti-howtos/references/media-apis.md +210 -0
  100. package/skills/ti-howtos/references/notification-services.md +599 -0
  101. package/skills/ti-howtos/references/remote-data-sources.md +349 -0
  102. package/skills/ti-howtos/references/tutorials.md +502 -0
  103. package/skills/ti-howtos/references/using-modules.md +237 -0
  104. package/skills/ti-howtos/references/web-content-integration.md +307 -0
  105. package/skills/ti-howtos/references/webpack-build-pipeline.md +78 -0
  106. package/skills/ti-ui/SKILL.md +179 -0
  107. package/skills/ti-ui/references/accessibility-deep-dive.md +242 -0
  108. package/skills/ti-ui/references/animation-and-matrices.md +599 -0
  109. package/skills/ti-ui/references/application-structures.md +655 -0
  110. package/skills/ti-ui/references/custom-fonts-styling.md +579 -0
  111. package/skills/ti-ui/references/event-handling.md +393 -0
  112. package/skills/ti-ui/references/gestures.md +473 -0
  113. package/skills/ti-ui/references/icons-and-splash-screens.md +409 -0
  114. package/skills/ti-ui/references/layouts-and-positioning.md +462 -0
  115. package/skills/ti-ui/references/listviews-and-performance.md +619 -0
  116. package/skills/ti-ui/references/orientation.md +362 -0
  117. package/skills/ti-ui/references/platform-ui-android.md +635 -0
  118. package/skills/ti-ui/references/platform-ui-ios.md +469 -0
  119. package/skills/ti-ui/references/scrolling-views.md +252 -0
  120. package/skills/ti-ui/references/tableviews.md +568 -0
@@ -0,0 +1,579 @@
1
+ # Custom Fonts and Attributed Strings
2
+
3
+ ## Table of Contents
4
+
5
+ - [Custom Fonts and Attributed Strings](#custom-fonts-and-attributed-strings)
6
+ - [Table of Contents](#table-of-contents)
7
+ - [1. Custom Fonts Overview](#1-custom-fonts-overview)
8
+ - [Font Sources](#font-sources)
9
+ - [2. Platform-Specific Font Loading](#2-platform-specific-font-loading)
10
+ - [Key Difference](#key-difference)
11
+ - [Example](#example)
12
+ - [3. Alloy Projects](#3-alloy-projects)
13
+ - [Directory Structure](#directory-structure)
14
+ - [XML Usage](#xml-usage)
15
+ - [TSS Styling](#tss-styling)
16
+ - [Cross-Platform Solution 1: Rename Font File](#cross-platform-solution-1-rename-font-file)
17
+ - [Cross-Platform Solution 2: Platform-Specific Styles](#cross-platform-solution-2-platform-specific-styles)
18
+ - [4. Classic Titanium Projects](#4-classic-titanium-projects)
19
+ - [Directory Structure](#directory-structure-1)
20
+ - [Runtime Platform Switching](#runtime-platform-switching)
21
+ - [Platform-Switching Helper Function](#platform-switching-helper-function)
22
+ - [5. Finding PostScript Name](#5-finding-postscript-name)
23
+ - [Using FontBook (macOS)](#using-fontbook-macos)
24
+ - [Common Font Patterns](#common-font-patterns)
25
+ - [6. iOS Platform Notes](#6-ios-platform-notes)
26
+ - [Automatic Info.plist Registration](#automatic-infoplist-registration)
27
+ - [Using System Fonts](#using-system-fonts)
28
+ - [7. Attributed Strings](#7-attributed-strings)
29
+ - [Basic Syntax](#basic-syntax)
30
+ - [Important Warning](#important-warning)
31
+ - [Property Equivalents](#property-equivalents)
32
+ - [8. Attribute Types](#8-attribute-types)
33
+ - [Font Attribute](#font-attribute)
34
+ - [Foreground Color](#foreground-color)
35
+ - [Background Color](#background-color)
36
+ - [Underline](#underline)
37
+ - [Strikethrough](#strikethrough)
38
+ - [Links (iOS 7+)](#links-ios-7)
39
+ - [9. iOS-Exclusive Attributes](#9-ios-exclusive-attributes)
40
+ - [Ligature](#ligature)
41
+ - [Kerning (Character Spacing)](#kerning-character-spacing)
42
+ - [Stroke Text (iOS 7+)](#stroke-text-ios-7)
43
+ - [Shadow (iOS 7+)](#shadow-ios-7)
44
+ - [Letterpress Effect (iOS 7+)](#letterpress-effect-ios-7)
45
+ - [Writing Direction (iOS 7+)](#writing-direction-ios-7)
46
+ - [Baseline Offset (iOS 7+)](#baseline-offset-ios-7)
47
+ - [Oblique/Skew (iOS 7+)](#obliqueskew-ios-7)
48
+ - [Expansion (iOS 7+)](#expansion-ios-7)
49
+ - [10. Multiple Attributes Example](#10-multiple-attributes-example)
50
+ - [11. Best Practices](#11-best-practices)
51
+ - [Custom Fonts](#custom-fonts)
52
+ - [Attributed Strings](#attributed-strings)
53
+ - [12. Common Issues](#12-common-issues)
54
+ - [Font Not Showing](#font-not-showing)
55
+ - [Wrong Font on One Platform](#wrong-font-on-one-platform)
56
+ - [Attributed String Not Displaying](#attributed-string-not-displaying)
57
+
58
+ ---
59
+
60
+ ## 1. Custom Fonts Overview
61
+
62
+ Titanium supports TrueType (.ttf) and OpenType (.otf) fonts on both iOS and Android. Custom fonts are a quick way to personalize or brand your application.
63
+
64
+ ### Font Sources
65
+
66
+ - [Google Fonts](https://fonts.google.com) - Free open source fonts
67
+ - [FontSquirrel](https://www.fontsquirrel.com) - Free commercial fonts
68
+
69
+ ## 2. Platform-Specific Font Loading
70
+
71
+ ### Key Difference
72
+
73
+ | Platform | fontFamily Value |
74
+ | ----------- | ---------------------------------------------- |
75
+ | **Android** | Font file name without extension |
76
+ | **iOS** | Font's PostScript name (embedded in font file) |
77
+
78
+ ### Example
79
+
80
+ For a file named `BurnstownDam-Regular.otf`:
81
+ - **Android**: `fontFamily: 'burnstown_dam'` (filename without extension)
82
+ - **iOS**: `fontFamily: 'BurnstownDam-Regular'` (PostScript name)
83
+
84
+ ## 3. Alloy Projects
85
+
86
+ ### Directory Structure
87
+
88
+ Place fonts in platform-specific assets:
89
+
90
+ ```
91
+ app/
92
+ assets/
93
+ android/
94
+ fonts/
95
+ CustomFont.ttf
96
+ iphone/
97
+ fonts/
98
+ CustomFont.ttf
99
+ ```
100
+
101
+ ### XML Usage
102
+
103
+ ```xml
104
+ <Alloy>
105
+ <View>
106
+ <Label id="customFont">This uses a custom font</Label>
107
+ </View>
108
+ </Alloy>
109
+ ```
110
+
111
+ ### TSS Styling
112
+
113
+ ```javascript
114
+ "#customFont": {
115
+ font: {
116
+ fontFamily: 'CustomFont-Regular', // iOS PostScript name
117
+ fontSize: 24
118
+ }
119
+ }
120
+ ```
121
+
122
+ ### Cross-Platform Solution 1: Rename Font File
123
+
124
+ Rename font file to match PostScript name, then use same value:
125
+
126
+ ```javascript
127
+ // File renamed from "burnstown_dam.otf" to "BurnstownDam-Regular.otf"
128
+
129
+ "#customFont": {
130
+ font: {
131
+ fontFamily: 'BurnstownDam-Regular', // Works on both platforms
132
+ fontSize: 24
133
+ }
134
+ }
135
+ ```
136
+
137
+ ### Cross-Platform Solution 2: Platform-Specific Styles
138
+
139
+ ```javascript
140
+ // Use platform-specific TSS
141
+ "#customFont[platform=ios]": {
142
+ font: {
143
+ fontFamily: 'BurnstownDam-Regular' // iOS PostScript name
144
+ }
145
+ },
146
+ "#customFont[platform=android]": {
147
+ font: {
148
+ fontFamily: 'burnstown_dam' // Android filename
149
+ }
150
+ }
151
+ ```
152
+
153
+ ## 4. Classic Titanium Projects
154
+
155
+ ### Directory Structure
156
+
157
+ ```
158
+ Resources/
159
+ fonts/
160
+ CustomFont.ttf
161
+ iphone/
162
+ fonts/
163
+ iOSFont.ttf
164
+ android/
165
+ fonts/
166
+ AndroidFont.ttf
167
+ ```
168
+
169
+ ### Runtime Platform Switching
170
+
171
+ ```javascript
172
+ let fontFamilyName;
173
+
174
+ if (Ti.Platform.osname === 'android') {
175
+ // Android: use filename without extension
176
+ fontFamilyName = 'CustomFont-Regular';
177
+ } else {
178
+ // iOS: use PostScript name
179
+ fontFamilyName = 'CustomFont';
180
+ }
181
+
182
+ const label = Ti.UI.createLabel({
183
+ text: 'Custom Font Text',
184
+ font: {
185
+ fontFamily: fontFamilyName,
186
+ fontSize: 24
187
+ }
188
+ });
189
+ ```
190
+
191
+ ### Platform-Switching Helper Function
192
+
193
+ ```javascript
194
+ // Helper function from Tweetanium pattern
195
+ const os = (map) => {
196
+ const def = map.def || null;
197
+ if (map[Ti.Platform.osname]) {
198
+ return (typeof map[Ti.Platform.osname] === 'function')
199
+ ? map[Ti.Platform.osname]()
200
+ : map[Ti.Platform.osname];
201
+ }
202
+ return (typeof def === 'function') ? def() : def;
203
+ };
204
+
205
+ // Usage
206
+ const label = Ti.UI.createLabel({
207
+ text: 'Custom Font Text',
208
+ font: {
209
+ fontFamily: os({
210
+ iphone: 'CustomFont',
211
+ ipad: 'CustomFont',
212
+ android: 'CustomFont-Regular'
213
+ }),
214
+ fontSize: 24
215
+ }
216
+ });
217
+ ```
218
+
219
+ ## 5. Finding PostScript Name
220
+
221
+ ### Using FontBook (macOS)
222
+
223
+ 1. Open FontBook application
224
+ 2. Select desired font
225
+ 3. Press Cmd+I to view font info
226
+ 4. Find **PostScript name** field
227
+
228
+ The PostScript name is embedded in the font file and doesn't change if you rename the file.
229
+
230
+ ### Common Font Patterns
231
+
232
+ | Friendly Name | PostScript Name Pattern |
233
+ | --------------- | --------------------------- |
234
+ | Arial | ArialMT or Arial-BoldMT |
235
+ | Helvetica | Helvetica or Helvetica-Bold |
236
+ | Times New Roman | TimesNewRomanPSMT |
237
+ | Custom-Regular | CustomName-Regular |
238
+
239
+ ## 6. iOS Platform Notes
240
+
241
+ ### Automatic Info.plist Registration
242
+
243
+ All fonts in `Resources/fonts/` are automatically added to iOS Info.plist.
244
+
245
+ **Important**: Place Android-only fonts in `Resources/android/fonts/` to avoid iOS registration errors.
246
+
247
+ ### Using System Fonts
248
+
249
+ Check available system fonts before adding custom fonts:
250
+
251
+ - [iOS Fonts](http://iosfonts.com/)
252
+ - [Android Fonts](https://github.com/android/platform_frameworks_base/tree/master/data/fonts)
253
+
254
+ ## 7. Attributed Strings
255
+
256
+ Attributed strings allow applying different formatting to character ranges within text. Supports Labels, TextAreas, and TextFields.
257
+
258
+ ### Basic Syntax
259
+
260
+ ```javascript
261
+ const text = "Have you tried hyperloop yet?";
262
+ const attr = Ti.UI.createAttributedString({
263
+ text: text,
264
+ attributes: [
265
+ {
266
+ type: Ti.UI.ATTRIBUTE_BACKGROUND_COLOR,
267
+ value: "yellow",
268
+ range: [text.indexOf('hyperloop'), ('hyperloop').length]
269
+ }
270
+ ]
271
+ });
272
+
273
+ const label = Ti.UI.createLabel({
274
+ attributedString: attr
275
+ });
276
+ ```
277
+
278
+ ### Important Warning
279
+
280
+ If using `attributedString` or `attributedHintText`, **do not** set other text-modifying properties (`font`, `color`, etc.). Titanium does not support mixing attributed strings with other text properties.
281
+
282
+ ### Property Equivalents
283
+
284
+ | Component | AttributedString Property | Equivalent |
285
+ | --------- | ------------------------- | ---------- |
286
+ | Label | `attributedString` | `text` |
287
+ | TextArea | `attributedString` | `value` |
288
+ | TextField | `attributedString` | `value` |
289
+ | TextField | `attributedHintText` | `hintText` |
290
+
291
+ ## 8. Attribute Types
292
+
293
+ ### Font Attribute
294
+
295
+ ```javascript
296
+ const attr = Ti.UI.createAttributedString({
297
+ text: text,
298
+ attributes: [
299
+ {
300
+ type: Ti.UI.ATTRIBUTE_FONT,
301
+ value: {
302
+ fontSize: 24,
303
+ fontFamily: 'Didot'
304
+ },
305
+ range: [text.indexOf('hyperloop'), ('hyperloop').length]
306
+ }
307
+ ]
308
+ });
309
+ ```
310
+
311
+ ### Foreground Color
312
+
313
+ ```javascript
314
+ {
315
+ type: Ti.UI.ATTRIBUTE_FOREGROUND_COLOR,
316
+ value: 'cyan',
317
+ range: [start, length]
318
+ }
319
+ ```
320
+
321
+ ### Background Color
322
+
323
+ ```javascript
324
+ {
325
+ type: Ti.UI.ATTRIBUTE_BACKGROUND_COLOR,
326
+ value: "yellow",
327
+ range: [start, length]
328
+ }
329
+ ```
330
+
331
+ ### Underline
332
+
333
+ **Android**: Single line only, `value` ignored.
334
+
335
+ **iOS**: Multiple styles and patterns. You can logically-OR constants together (e.g., `STYLE_DOUBLE | PATTERN_DOT`).
336
+
337
+ ```javascript
338
+ {
339
+ type: Ti.UI.ATTRIBUTE_UNDERLINES_STYLE,
340
+ value: Ti.UI.ATTRIBUTE_UNDERLINE_STYLE_DOUBLE |
341
+ Ti.UI.ATTRIBUTE_UNDERLINE_PATTERN_DOT,
342
+ range: [start, length]
343
+ }
344
+ ```
345
+
346
+ **iOS Underline Styles**:
347
+ - `ATTRIBUTE_UNDERLINE_STYLE_NONE`
348
+ - `ATTRIBUTE_UNDERLINE_STYLE_SINGLE`
349
+ - `ATTRIBUTE_UNDERLINE_STYLE_THICK` (iOS 7+)
350
+ - `ATTRIBUTE_UNDERLINE_STYLE_DOUBLE` (iOS 7+)
351
+
352
+ **iOS Patterns** (iOS 7+):
353
+ - `ATTRIBUTE_UNDERLINE_PATTERN_SOLID`
354
+ - `ATTRIBUTE_UNDERLINE_PATTERN_DOT`
355
+ - `ATTRIBUTE_UNDERLINE_PATTERN_DASH`
356
+ - `ATTRIBUTE_UNDERLINE_PATTERN_DASH_DOT`
357
+ - `ATTRIBUTE_UNDERLINE_PATTERN_DASH_DOT_DOT`
358
+ - `ATTRIBUTE_UNDERLINE_BY_WORD` (Draw lines only under characters, not spaces)
359
+
360
+ **iOS Underline Color** (iOS 7+):
361
+ ```javascript
362
+ {
363
+ type: Ti.UI.ATTRIBUTE_UNDERLINE_COLOR,
364
+ value: 'blue',
365
+ range: [start, length]
366
+ }
367
+ ```
368
+
369
+ ### Strikethrough
370
+
371
+ **Android**: Single line through text only.
372
+
373
+ **iOS**: Supports same styles and patterns as Underline.
374
+
375
+ ### Links (iOS 7+)
376
+
377
+ ```javascript
378
+ {
379
+ type: Ti.UI.ATTRIBUTE_LINK,
380
+ value: "https://github.com/tidev/hyperloop",
381
+ range: [start, length]
382
+ }
383
+ ```
384
+
385
+ Handle link clicks:
386
+
387
+ ```javascript
388
+ label.addEventListener('link', (e) => {
389
+ Ti.API.info(`Link clicked: ${e.url}`);
390
+ });
391
+ ```
392
+
393
+ **Note**: Prior to Titanium Release 4.0, the `link` event was only triggered by a long press on iOS.
394
+
395
+ ## 9. iOS-Exclusive Attributes
396
+
397
+ ### Ligature
398
+
399
+ ```javascript
400
+ {
401
+ type: Ti.UI.ATTRIBUTE_LIGATURE,
402
+ value: 1, // 1 = enabled, 0 = disabled (default)
403
+ range: [start, length]
404
+ }
405
+ ```
406
+
407
+ ### Kerning (Character Spacing)
408
+
409
+ ```javascript
410
+ {
411
+ type: Ti.UI.ATTRIBUTE_KERN,
412
+ value: 5.0, // Distance in points. Positive = wider, 0 = default, negative = tighter
413
+ range: [start, length]
414
+ }
415
+ ```
416
+
417
+ ### Stroke Text (iOS 7+)
418
+
419
+ ```javascript
420
+ // Positive value = outline only, Negative = filled with stroke
421
+ {
422
+ type: Ti.UI.ATTRIBUTE_STROKE_WIDTH,
423
+ value: 3.0,
424
+ range: [start, length]
425
+ }
426
+
427
+ // Stroke color
428
+ {
429
+ type: Ti.UI.ATTRIBUTE_STROKE_COLOR,
430
+ value: 'red',
431
+ range: [start, length]
432
+ }
433
+ ```
434
+
435
+ ### Shadow (iOS 7+)
436
+
437
+ ```javascript
438
+ {
439
+ type: Ti.UI.ATTRIBUTE_SHADOW,
440
+ value: {
441
+ color: 'green',
442
+ offset: { width: 10, height: 5 },
443
+ blurRadius: 3.0 // 0 = no blur
444
+ },
445
+ range: [start, length]
446
+ }
447
+ ```
448
+
449
+ ### Letterpress Effect (iOS 7+)
450
+
451
+ ```javascript
452
+ {
453
+ type: Ti.UI.ATTRIBUTE_TEXT_EFFECT,
454
+ value: Ti.UI.ATTRIBUTE_LETTERPRESS_STYLE,
455
+ range: [start, length]
456
+ }
457
+ ```
458
+
459
+ ### Writing Direction (iOS 7+)
460
+
461
+ Controls text direction for a specific range. Can logically-OR direction with behavior (Embedding or Override).
462
+
463
+ ```javascript
464
+ {
465
+ type: Ti.UI.ATTRIBUTE_WRITING_DIRECTION,
466
+ value: Ti.UI.ATTRIBUTE_WRITING_DIRECTION_RIGHT_TO_LEFT |
467
+ Ti.UI.ATTRIBUTE_WRITING_DIRECTION_OVERRIDE,
468
+ range: [start, length]
469
+ }
470
+ ```
471
+
472
+ **Direction Constants**:
473
+ - `ATTRIBUTE_WRITING_DIRECTION_NATURAL`: Uses Unicode Bidirectional Algorithm.
474
+ - `ATTRIBUTE_WRITING_DIRECTION_LEFT_TO_RIGHT`
475
+ - `ATTRIBUTE_WRITING_DIRECTION_RIGHT_TO_LEFT`
476
+
477
+ **Behavior Modifiers**:
478
+ - `ATTRIBUTE_WRITING_DIRECTION_EMBEDDING`: Use embedded direction.
479
+ - `ATTRIBUTE_WRITING_DIRECTION_OVERRIDE`: Force the direction.
480
+
481
+ ### Baseline Offset (iOS 7+)
482
+
483
+ ```javascript
484
+ {
485
+ type: Ti.UI.ATTRIBUTE_BASELINE_OFFSET,
486
+ value: 10, // Pixels. Positive = above, negative = below baseline
487
+ range: [start, length]
488
+ }
489
+ ```
490
+
491
+ ### Oblique/Skew (iOS 7+)
492
+
493
+ ```javascript
494
+ {
495
+ type: Ti.UI.ATTRIBUTE_OBLIQUENESS,
496
+ value: 0.25, // 0 = no skew
497
+ range: [start, length]
498
+ }
499
+ ```
500
+
501
+ ### Expansion (iOS 7+)
502
+
503
+ ```javascript
504
+ {
505
+ type: Ti.UI.ATTRIBUTE_EXPANSION,
506
+ value: 0.25, // Log of expansion factor, 0 = none
507
+ range: [start, length]
508
+ }
509
+ ```
510
+
511
+ ## 10. Multiple Attributes Example
512
+
513
+ ```javascript
514
+ const text = "Have you tried hyperloop yet?";
515
+ const attr = Ti.UI.createAttributedString({
516
+ text: text,
517
+ attributes: [
518
+ // Background color
519
+ {
520
+ type: Ti.UI.ATTRIBUTE_BACKGROUND_COLOR,
521
+ value: "yellow",
522
+ range: [text.indexOf('hyperloop'), ('hyperloop').length]
523
+ },
524
+ // Bold font
525
+ {
526
+ type: Ti.UI.ATTRIBUTE_FONT,
527
+ value: { fontSize: 24, fontWeight: 'bold' },
528
+ range: [text.indexOf('hyperloop'), ('hyperloop').length]
529
+ },
530
+ // Red text
531
+ {
532
+ type: Ti.UI.ATTRIBUTE_FOREGROUND_COLOR,
533
+ value: 'red',
534
+ range: [text.indexOf('hyperloop'), ('hyperloop').length]
535
+ }
536
+ ]
537
+ });
538
+ ```
539
+
540
+ ## 11. Best Practices
541
+
542
+ ### Custom Fonts
543
+
544
+ 1. **Test on real devices** - Simulator may not reflect actual font rendering
545
+ 2. **Check licensing** - Ensure fonts are licensed for mobile app distribution
546
+ 3. **Consider file size** - Custom fonts increase app size
547
+ 4. **Use system fonts when possible** - Faster loading, smaller app size
548
+ 5. **Provide fallbacks** - Always include a fallback fontFamily
549
+
550
+ ### Attributed Strings
551
+
552
+ 1. **Don't mix with other properties** - Use only attributed string OR text properties
553
+ 2. **Use consistent range calculations** - Off-by-one errors are common
554
+ 3. **Test on both platforms** - Some attributes differ between iOS and Android
555
+ 4. **Performance consideration** - Complex attributed strings can impact scrolling performance
556
+
557
+ ## 12. Common Issues
558
+
559
+ ### Font Not Showing
560
+
561
+ **Problem**: Custom font not appearing
562
+
563
+ **Solutions**:
564
+ 1. Check PostScript name (iOS) vs filename (Android)
565
+ 2. Verify font file is in correct directory
566
+ 4. Clean and rebuild project
567
+ 5. Check font file isn't corrupted
568
+
569
+ ### Wrong Font on One Platform
570
+
571
+ **Problem**: Font works on one platform but not the other
572
+
573
+ **Solution**: You're likely using the wrong naming convention. Use platform-specific styles or rename font file to match PostScript name.
574
+
575
+ ### Attributed String Not Displaying
576
+
577
+ **Problem**: Text appears plain instead of formatted
578
+
579
+ **Solution**: Remove conflicting properties like `font`, `color`, etc. when using `attributedString`.