@maccesar/titools 3.1.0 → 3.3.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.
@@ -0,0 +1,289 @@
1
+ # Custom Fonts
2
+
3
+ Use the `purgetss/fonts/` folder and the `build-fonts` command to register any font in your Titanium app: brand typefaces, custom icon fonts, or community icon libraries that PurgeTSS no longer bundles.
4
+
5
+ For the 4 official icon families that ship with PurgeTSS (Font Awesome 7, Material Icons, Material Symbols, Framework7), see [Icon Fonts](./icon-fonts.md) — they use the `icon-library` command and do **not** require `build-fonts`.
6
+
7
+ ## The `fonts` folder
8
+
9
+ Place `.ttf` or `.otf` files in `./purgetss/fonts/`. For icon fonts, also include the `.css` file that ships with the library. PurgeTSS reads it to extract the Unicode characters for each icon class.
10
+
11
+ This example uses [Bevan and Dancing Script](https://fonts.google.com/share?selection.family=Bevan:ital@0;1%7CDancing%20Script:wght@400;500;600;700) from Google Fonts:
12
+
13
+ `./purgetss/fonts/`
14
+ ```bash
15
+ purgetss
16
+ └─ fonts
17
+ ├─ Bevan-Italic.ttf
18
+ ├─ Bevan-Regular.ttf
19
+ ├─ DancingScript-Bold.ttf
20
+ ├─ DancingScript-Medium.ttf
21
+ ├─ DancingScript-Regular.ttf
22
+ └─ DancingScript-SemiBold.ttf
23
+ ```
24
+
25
+ ### Organizing the fonts folder
26
+
27
+ If you prefer to keep things tidy, group each family in a subfolder. The output is the same.
28
+
29
+ `./purgetss/fonts/`
30
+ ```bash
31
+ purgetss
32
+ └─ fonts
33
+ └─ bevan
34
+ ├─ Bevan-Italic.ttf
35
+ └─ Bevan-Regular.ttf
36
+ └─ dancing-script
37
+ ├─ DancingScript-Bold.ttf
38
+ ├─ DancingScript-Medium.ttf
39
+ ├─ DancingScript-Regular.ttf
40
+ └─ DancingScript-SemiBold.ttf
41
+ ```
42
+
43
+ ## The `build-fonts` command
44
+
45
+ ```bash
46
+ $ purgetss build-fonts [-m] [-f]
47
+
48
+ # alias:
49
+ $ purgetss bf [-m] [-f]
50
+ ```
51
+
52
+ What it does:
53
+
54
+ 1. Creates `./purgetss/styles/fonts.tss` with one `fontFamily` class per file.
55
+ 2. Copies the font files into `./app/assets/fonts/`, renamed to their PostScript names so they work on both iOS and Android.
56
+
57
+ After running `purgetss build-fonts` with the Bevan and Dancing Script example above:
58
+
59
+ `./purgetss/styles/fonts.tss`
60
+ ```css
61
+ // Fonts TSS file generated with PurgeTSS
62
+ // https://purgetss.com/docs/customization/custom-fonts
63
+
64
+ '.bevan-italic': { font: { fontFamily: 'Bevan-Italic' } }
65
+ '.bevan-regular': { font: { fontFamily: 'Bevan-Regular' } }
66
+
67
+ '.dancingscript-bold': { font: { fontFamily: 'DancingScript-Bold' } }
68
+ '.dancingscript-medium': { font: { fontFamily: 'DancingScript-Medium' } }
69
+ '.dancingscript-regular': { font: { fontFamily: 'DancingScript-Regular' } }
70
+ '.dancingscript-semibold': { font: { fontFamily: 'DancingScript-SemiBold' } }
71
+ ```
72
+
73
+ You can now use these classes on any Titanium component with a `font` property: Labels, Buttons, TextFields, TextAreas, ListItems, TableViewRows, and ActivityIndicators.
74
+
75
+ ### Renaming the class
76
+
77
+ To use a shorter or different class name, rename the font file. For example:
78
+
79
+ `./purgetss/fonts/`
80
+ ```bash
81
+ purgetss
82
+ └─ fonts
83
+ └─ dancing-script
84
+ ├─ Script-Bold.ttf
85
+ ├─ Script-Medium.ttf
86
+ ├─ Script-Regular.ttf
87
+ └─ Script-SemiBold.ttf
88
+ ```
89
+
90
+ Running `build-fonts` produces:
91
+
92
+ `./purgetss/styles/fonts.tss`
93
+ ```css
94
+ '.script-bold': { font: { fontFamily: 'DancingScript-Bold' } }
95
+ '.script-medium': { font: { fontFamily: 'DancingScript-Medium' } }
96
+ '.script-regular': { font: { fontFamily: 'DancingScript-Regular' } }
97
+ '.script-semibold': { font: { fontFamily: 'DancingScript-SemiBold' } }
98
+ ```
99
+
100
+ The class name changes, but the actual `fontFamily` value (the PostScript name) stays the same.
101
+
102
+ ## Adding icon fonts
103
+
104
+ Any icon font that ships a `.ttf` (or `.otf`) plus a `.css` file with Unicode characters works the same way.
105
+
106
+ This example uses [map-icons](http://map-icons.com) and [microns](https://www.s-ings.com/projects/microns-icon-font/):
107
+
108
+ `./purgetss/fonts/`
109
+ ```bash
110
+ purgetss
111
+ └─ fonts
112
+ └─ bevan
113
+ └─ dancing-script
114
+ └─ map-icons
115
+ ├─ map-icons.css
116
+ └─ map-icons.ttf
117
+ └─ microns
118
+ ├─ microns.css
119
+ └─ microns.ttf
120
+ ```
121
+
122
+ After `purgetss build-fonts`, the generated `fonts.tss` includes the family classes and one class per icon:
123
+
124
+ `./purgetss/styles/fonts.tss`
125
+ ```css
126
+ // Fonts TSS file generated with PurgeTSS
127
+ // https://purgetss.com/docs/customization/custom-fonts
128
+
129
+ '.map-icons': { font: { fontFamily: 'map-icons' } }
130
+ '.microns': { font: { fontFamily: 'microns' } }
131
+
132
+ /* Unicode Characters */
133
+ /* To use your Icon Fonts in Buttons AND Labels each class sets 'text' and 'title' properties */
134
+
135
+ /* map-icons/map-icons.css */
136
+ '.map-icon-abseiling': { text: '', title: '' }
137
+ '.map-icon-accounting': { text: '', title: '' }
138
+ '.map-icon-airport': { text: '', title: '' }
139
+ '.map-icon-amusement-park': { text: '', title: '' }
140
+ '.map-icon-aquarium': { text: '', title: '' }
141
+ /* ... */
142
+
143
+ /* microns/microns.css */
144
+ '.mu-arrow-left': { text: '', title: '' }
145
+ '.mu-arrow-right': { text: '', title: '' }
146
+ '.mu-arrow-up': { text: '', title: '' }
147
+ '.mu-arrow-down': { text: '', title: '' }
148
+ '.mu-left': { text: '', title: '' }
149
+ /* ... */
150
+ ```
151
+
152
+ ## Options
153
+
154
+ Two optional flags adjust what `build-fonts` generates:
155
+
156
+ - `-m, --module`: generates a CommonJS module in `./app/lib/purgetss.fonts.js` that exposes each icon's Unicode string to JavaScript. Handy when you set `label.text` from a controller.
157
+ - `-f, --font-class-from-filename`: uses the font's filename as the font class name and icon prefix instead of the font family name. Useful when you want shorter prefixes. Replaces the old `-p` flag.
158
+
159
+ ### Using `--module`
160
+
161
+ ```bash
162
+ $ purgetss build-fonts --module
163
+
164
+ # alias:
165
+ $ purgetss bf -m
166
+ ```
167
+
168
+ To avoid prefix conflicts between libraries, each icon keeps its prefix as a nested object. Both `icons` and `families` are exported:
169
+
170
+ `./app/lib/purgetss.fonts.js`
171
+ ```javascript
172
+ const icons = {
173
+ // map-icons/map-icons.css
174
+ 'mapIcon': {
175
+ 'abseiling': '',
176
+ 'accounting': '',
177
+ 'airport': '',
178
+ 'amusementPark': '',
179
+ // ...
180
+ },
181
+ // microns/microns.css
182
+ 'mu': {
183
+ 'arrowLeft': '',
184
+ 'arrowRight': '',
185
+ 'arrowUp': '',
186
+ 'arrowDown': '',
187
+ // ...
188
+ }
189
+ };
190
+ exports.icons = icons;
191
+
192
+ const families = {
193
+ // map-icons/map-icons.css
194
+ 'mapIcon': 'map-icons',
195
+ // microns/microns.css
196
+ 'mu': 'microns'
197
+ };
198
+ exports.families = families;
199
+ ```
200
+
201
+ ### Using `--font-class-from-filename`
202
+
203
+ When you want the class name and the icon prefix to come from the **filename** of the `.ttf` and `.css` instead of the font family, use `-f`.
204
+
205
+ `./purgetss/fonts/`
206
+ ```bash
207
+ purgetss
208
+ └─ fonts
209
+ └─ map-icons
210
+ ├─ map.ttf
211
+ └─ mp.css
212
+ └─ microns
213
+ ├─ mic.ttf
214
+ └─ mc.css
215
+ ```
216
+
217
+ `./purgetss/styles/fonts.tss`
218
+ ```css
219
+ /* "fontFamily" classes use the font's filename */
220
+ '.map': { font: { fontFamily: 'map-icons' } }
221
+ '.mic': { font: { fontFamily: 'microns' } }
222
+
223
+ /* map-icons/mp.css */
224
+ '.mp-abseiling': { text: '', title: '' }
225
+ '.mp-accounting': { text: '', title: '' }
226
+ '.mp-airport': { text: '', title: '' }
227
+ '.mp-amusement-park': { text: '', title: '' }
228
+ '.mp-aquarium': { text: '', title: '' }
229
+ /* ... */
230
+
231
+ /* microns/mc.css */
232
+ '.mc-arrow-left': { text: '', title: '' }
233
+ '.mc-arrow-right': { text: '', title: '' }
234
+ '.mc-arrow-up': { text: '', title: '' }
235
+ '.mc-arrow-down': { text: '', title: '' }
236
+ '.mc-left': { text: '', title: '' }
237
+ /* ... */
238
+ ```
239
+
240
+ `./app/lib/purgetss.fonts.js`
241
+ ```javascript
242
+ const icons = {
243
+ // map-icons/mp.css
244
+ 'mp': {
245
+ 'abseiling': '',
246
+ 'accounting': '',
247
+ 'airport': '',
248
+ 'amusementPark': '',
249
+ // ...
250
+ },
251
+ // microns/mc.css
252
+ 'mc': {
253
+ 'arrowLeft': '',
254
+ 'arrowRight': '',
255
+ 'arrowUp': '',
256
+ 'arrowDown': '',
257
+ // ...
258
+ }
259
+ };
260
+ exports.icons = icons;
261
+
262
+ const families = {
263
+ // map-icons/mp.css
264
+ 'mp': 'map-icons',
265
+ // microns/mc.css
266
+ 'mc': 'microns'
267
+ };
268
+ exports.families = families;
269
+ ```
270
+
271
+ > 🛑 **DANGER**
272
+ > Make sure the new prefix is unique and does not conflict with other class prefixes. A duplicate prefix will silently overwrite earlier rules in the generated `fonts.tss`, leaving you with icons that render the wrong glyph at runtime.
273
+
274
+ ## Custom proprietary icon fonts
275
+
276
+ If your design system ships its own icon font, treat it like any other icon library: drop the `.ttf` + `.css` pair into `./purgetss/fonts/<name>/` and run `build-fonts`. The classes are then available in your TSS.
277
+
278
+ ## Community-Discovered Patterns
279
+
280
+ The following notes reflect community experience with `build-fonts` against real-world Titanium projects.
281
+
282
+ > **💡 PostScript renaming**
283
+ > `build-fonts` copies `.ttf`/`.otf` files into `./app/assets/fonts/` renamed to their **PostScript names**. iOS reads PostScript names while Android tolerates filenames; by renaming both platforms work from the same `fontFamily` value.
284
+
285
+ > **🛑 Font Awesome Duotone**
286
+ > Titanium cannot render Font Awesome duotone icons because each icon uses two glyphs. If you work with Font Awesome Pro, avoid documenting duotone as supported.
287
+
288
+ > **💡 Use `--module` to set `text`/`title` from JavaScript**
289
+ > Hardcoding `` in a controller is brittle. The `-m` flag generates a `purgetss.fonts.js` you can `require()` and reference by friendly name: `label.text = icons.fa.home`. Combine with `families` to set `font.fontFamily` programmatically.
@@ -37,9 +37,10 @@ module.exports = {
37
37
  brand: {
38
38
  logos: {}, // empty = auto-discovers from purgetss/brand/
39
39
  padding: {
40
- ios: '4%', // iOS aesthetic padding. Range 2-8%.
41
- androidLegacy: '10%', // legacy ic_launcher.png padding %
42
- androidAdaptive: '19%' // adaptive icon safe-zone %. Spec floor 19.44%.
40
+ ios: '4%', // iOS aesthetic padding. Range 2-8%.
41
+ androidLegacy: '10%', // legacy ic_launcher.png padding %
42
+ androidAdaptive: '19%', // adaptive icon safe-zone %. Spec floor 19.44%.
43
+ featureGraphic: '12%' // MarketplaceArtworkFeature.png vertical padding (v7.10.0)
43
44
  },
44
45
  android: {
45
46
  splash: false, // also generate splash_icon.png × 5
@@ -59,6 +60,8 @@ module.exports = {
59
60
  quality: 85, // JPEG/WebP/AVIF quality (0-100)
60
61
  format: null, // null = keep original; 'webp' | 'jpeg' | 'png' to convert every image
61
62
  confirmOverwrites: true // prompt before overwriting files (set false to skip)
63
+ // Note: --width (v7.8.0) and --opacity / --padding / --output (v7.10.0) are CLI-only
64
+ // by design — those decisions are per-asset, not project-wide.
62
65
  },
63
66
  theme: {
64
67
  extend: {}
@@ -78,12 +81,15 @@ The config file has four main sections: `purge`, `brand`, `images`, and `theme`.
78
81
 
79
82
  For `brand`, the structure is grouped by purpose (introduced in v7.7.0, refined since):
80
83
 
81
- - `logos`: optional path overrides when you do not want to rely on `purgetss/brand/` auto-discovery
82
- - `padding`: visual sizing for iOS, Android legacy, and Android adaptive icons
84
+ - `logos`: optional path overrides when you do not want to rely on `purgetss/brand/` auto-discovery — including `featureGraphic` for the Google Play 1024×500 banner (v7.10.0)
85
+ - `padding`: visual sizing for iOS, Android legacy, Android adaptive icons, and the Feature Graphic banner (v7.10.0)
83
86
  - `android`: Android-only optional outputs such as `splash_icon.png` and notification icons
84
87
  - `ios`: iOS-only variant toggles (`dark`, `tinted`) and the optional `darkBackground` color
85
88
  - `colors`: shared color settings such as the adaptive background and iOS flatten color
86
89
 
90
+ > **INFO — Pre-7.7.0 flat configs auto-migrate**
91
+ > Since v7.10.2, projects on the flat `brand:` schema (`brand.padding: <number>`, `brand.iosPadding`, `brand.bgColor`, etc.) auto-migrate in memory on every run. The grouped key always wins when both forms coexist, and a one-time deprecation notice lists the migrated keys. Update `config.cjs` to the grouped schema to silence the notice. See [App Icons & Branding → Upgrading from pre-7.7.0 configs](./app-branding.md#upgrading-from-pre-7-7-0-configs).
92
+
87
93
  For the property-by-property reference, see [Configurable Properties](./configurable-properties.md).
88
94
 
89
95
  ### Overriding logo paths
@@ -94,12 +100,13 @@ By default, PurgeTSS auto-discovers logo files from `purgetss/brand/`. If you wa
94
100
  module.exports = {
95
101
  brand: {
96
102
  logos: {
97
- primary: './my-logos/main.svg', // overrides auto-discovered logo.svg
98
- androidLauncher: './my-logos/icon.svg', // overrides auto-discovered logo-icon.svg
99
- androidSplash: './my-logos/splash.svg', // overrides auto-discovered logo-splash.svg
100
- monochrome: './my-logos/mono.svg', // overrides auto-discovered logo-mono.svg
101
- iosDark: './my-logos/dark.svg', // overrides auto-discovered logo-dark.svg
102
- iosTinted: './my-logos/tinted.svg' // overrides auto-discovered logo-tinted.svg
103
+ primary: './my-logos/main.svg', // overrides auto-discovered logo.svg
104
+ androidLauncher: './my-logos/icon.svg', // overrides auto-discovered logo-icon.svg
105
+ androidSplash: './my-logos/splash.svg', // overrides auto-discovered logo-splash.svg
106
+ monochrome: './my-logos/mono.svg', // overrides auto-discovered logo-mono.svg
107
+ iosDark: './my-logos/dark.svg', // overrides auto-discovered logo-dark.svg
108
+ iosTinted: './my-logos/tinted.svg', // overrides auto-discovered logo-tinted.svg
109
+ featureGraphic: './my-logos/feature.svg' // overrides auto-discovered logo-feature.svg (v7.10.0)
103
110
  }
104
111
  }
105
112
  };
@@ -46,7 +46,6 @@ $.UI.create('ComponentType', {
46
46
  function createThemeCard(themeName, themeTitle, imagePath) {
47
47
  return $.UI.create('View', {
48
48
  // View properties
49
- valor: themeName,
50
49
  title: themeTitle, // Add title for TTS support
51
50
 
52
51
  // PurgeTSS utility classes