@maccesar/titools 3.2.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.
@@ -1,176 +1,264 @@
1
1
  # Icon Font Libraries
2
2
 
3
+ PurgeTSS ships with four official icon font families, each preconfigured with the TSS classes and `fontFamily` mappings you need to drop icons into Buttons, Labels, and TextFields.
4
+
5
+ For user-defined fonts (Google Fonts, brand typefaces, community icon libraries like map-icons or microns), see [Custom Fonts](./custom-fonts.md) — those use `build-fonts`, not `icon-library`.
6
+
3
7
  > ℹ️ **INFO — Official Icon Fonts for PurgeTSS**
4
- >
5
- > Older versions of PurgeTSS bundled additional icon font libraries — Bootstrap Icons, Boxicons, LineIcons, and Tabler Icons among them. **Those libraries have been deprecated and removed from the official distribution** to keep maintenance under control. They are still usable, but you must rebuild them yourself with `build-fonts` (see below).
6
- >
7
- > The icon fonts officially supported and shipped by PurgeTSS today are:
8
- >
9
8
  > - [Font Awesome 7 Free](https://fontawesome.com) (upgrade with `purgetss il -v=fa`)
10
- > - [Framework 7](https://framework7.io/icons/)
9
+ > - [Framework 7 Icons](https://framework7.io/icons/)
11
10
  > - [Material Icons](https://fonts.google.com/icons?icon.set=Material+Icons)
12
11
  > - [Material Symbols](https://fonts.google.com/icons?icon.set=Material+Symbols)
12
+ >
13
+ > Older versions of PurgeTSS bundled additional libraries (Bootstrap Icons, Boxicons, LineIcons, Tabler Icons). They were removed to keep maintenance under control, but you can [recreate them at the bottom of this page](#recreating-removed-icon-libraries).
13
14
 
14
- For the official install flow for the supported vendors, see [CLI Commands](./cli-commands.md#icon-library-command).
15
+ ## Icon families reference
15
16
 
16
- ## Recreate Removed Libraries
17
+ Each family ships one or more variant classes, each pointing to a specific font file. Combine a variant class with an icon class to render a glyph. For example, `msr ms-home` uses the Material Symbols Rounded font with the `home` icon.
17
18
 
18
- You can recreate any deprecated library using the `build-fonts` command.
19
+ | Family | Variant | Class | `fontFamily` |
20
+ |---|---|---|---|
21
+ | **Material Symbols** | Outlined (default) | `.ms` | `MaterialSymbolsOutlined-Regular` |
22
+ | Material Symbols | Outlined (alias) | `.mso` | `MaterialSymbolsOutlined-Regular` |
23
+ | Material Symbols | Rounded | `.msr` | `MaterialSymbolsRounded-Regular` |
24
+ | Material Symbols | Sharp | `.mss` | `MaterialSymbolsSharp-Regular` |
25
+ | **Font Awesome** | Solid (default) | `.fa` | `FontAwesome7Free-Solid` |
26
+ | Font Awesome | Solid (alias) | `.fas` | `FontAwesome7Free-Solid` |
27
+ | Font Awesome | Regular | `.far` | `FontAwesome7Free-Regular` |
28
+ | Font Awesome | Brands | `.fab` | `FontAwesome7Brands-Regular` |
29
+ | **Material Icons** | Regular | `.mi` | `MaterialIcons-Regular` |
30
+ | **Framework 7** | Regular | `.f7` | `Framework7-Icons` |
19
31
 
20
- ### 1. Download the Libraries
32
+ > 💡 **TIP Icon class names**
33
+ > Across a family, the icon class is shared by every variant. For Material Symbols, there is one `ms-home` class; pair it with `.ms`, `.mso`, `.msr`, or `.mss` to pick the shape (outlined, rounded, or sharp). FontAwesome works the same way: `fa-home` pairs with `.fa`/`.fas` (Solid) or `.far` (Regular), while brand icons like `fa-github` need `.fab`. **The variant class chooses the font file. The icon class chooses the glyph.**
21
34
 
22
- Start by downloading the libraries from their official websites:
35
+ ### Full class lists
23
36
 
24
- - [Bootstrap Icons](https://icons.getbootstrap.com)
25
- - [Boxicons](https://boxicons.com)
26
- - [LineIcons](https://lineicons.com/icons/?type=free)
27
- - [Tabler Icons](https://tabler-icons.io)
37
+ The complete class definitions live in the PurgeTSS `dist/` folder:
28
38
 
29
- ### 2. The `fonts` Folder
39
+ - [fontawesome.tss](https://github.com/macCesar/purgeTSS/blob/main/dist/fontawesome.tss)
40
+ - [materialicons.tss](https://github.com/macCesar/purgeTSS/blob/main/dist/materialicons.tss)
41
+ - [materialsymbols.tss](https://github.com/macCesar/purgeTSS/blob/main/dist/materialsymbols.tss)
42
+ - [framework7icons.tss](https://github.com/macCesar/purgeTSS/blob/main/dist/framework7icons.tss)
30
43
 
31
- Put the desired libraries in the `./purgetss/fonts` folder.
44
+ ## Installing the icon fonts
32
45
 
33
- > ℹ️ **INFO**
34
- > Copy the TrueType or OpenType font files and the `.css` file.
46
+ Run `icon-library` to copy the `.ttf` files into `./app/assets/fonts/`. That is the only step you need. Once the fonts are in place, the icon classes from the table above work out of the box.
35
47
 
36
48
  ```bash
37
- purgetss
38
- └─ fonts
39
- └─ boxicons
40
- ├─ boxicons.css
41
- └─ boxicons.ttf
42
- └─ lineicons
43
- ├─ lineicons.css
44
- └─ lineicons.ttf
49
+ # All four families
50
+ $ purgetss icon-library
51
+
52
+ # Selective install
53
+ $ purgetss il -v=fa,mi,ms,f7
45
54
  ```
46
55
 
47
- ### 3. The `build-fonts` Command
56
+ > ℹ️ **INFO — You do not need the `.tss` files in `./purgetss/styles/`**
57
+ > PurgeTSS already knows every official icon class and resolves them at compile time from its own bundled `dist/` files. You do not need `fontawesome.tss`, `materialsymbols.tss`, `materialicons.tss`, or `framework7icons.tss` inside `./purgetss/styles/` for `class="fas fa-home"` (or any other icon class) to work in your XML and controllers. Install the `.ttf` files with `icon-library` and the classes are ready.
58
+
59
+ ### Optional flags
48
60
 
49
- Run the `build-fonts` command to create a custom `fonts.tss` file.
61
+ Two optional flags adjust what `icon-library` copies into your project:
62
+
63
+ - `-s, --styles`: copies the official `.tss` source files into `./purgetss/styles/` for reference only. Useful if you want to grep the full class list, see how a class is defined, or override a specific class in your own project.
64
+ - `-m, --module`: copies the matching CommonJS module into `./app/lib/`, which exposes each icon's Unicode string to JavaScript. Handy when you set `label.text` from a controller and prefer a friendly name like `icons.fa.home` over a raw ``.
50
65
 
51
66
  ```bash
52
- purgetss build-fonts [--modules]
67
+ # Add either flag when you want them
68
+ $ purgetss il -s
69
+ $ purgetss il -m
70
+ $ purgetss il -m -s
71
+ ```
72
+
73
+ ### Vendor aliases
74
+
75
+ `--vendor` accepts the short or long forms:
76
+
77
+ - `fa`, `fontawesome` = Font Awesome Icons
78
+ - `mi`, `materialicons` = Material Icons
79
+ - `ms`, `materialsymbol` = Material Symbols
80
+ - `f7`, `framework7` = Framework7 Icons
81
+
82
+ ## Using icons in XML
83
+
84
+ The variant class sets the `fontFamily`. The icon class sets the glyph (`text` / `title`). Apply both together:
85
+
86
+ `index.xml`
87
+ ```xml
88
+ <Alloy>
89
+ <Window>
90
+ <View class="grid">
91
+ <View class="vertical mx-auto grid-cols-2 gap-y-2">
92
+ <!-- Material Symbols variants -->
93
+ <Label class="mt-2 text-gray-700" text="Material Symbols" />
94
+ <Button class="ms ms-home my-1 h-10 w-10 text-xl text-blue-500" />
95
+ <Button class="msr ms-home my-1 h-10 w-10 text-xl text-blue-500" />
96
+ <Button class="mss ms-home my-1 h-10 w-10 text-xl text-blue-500" />
97
+ </View>
98
+
99
+ <View class="vertical mx-auto grid-cols-2 gap-y-2">
100
+ <!-- FontAwesome variants -->
101
+ <Label class="mt-2 text-gray-700" text="Font Awesome" />
102
+ <Button class="fas fa-home my-1 h-10 w-10 text-xl text-blue-500" />
103
+ <Button class="far fa-bell my-1 h-10 w-10 text-xl text-blue-500" />
104
+ <Button class="fab fa-github my-1 h-10 w-10 text-xl text-blue-500" />
105
+ </View>
106
+ </View>
107
+ </Window>
108
+ </Alloy>
109
+ ```
53
110
 
54
- # alias:
55
- purgetss bf [-m]
111
+ ## Complete example with all four families
112
+
113
+ A side-by-side example using all four official families.
114
+
115
+ To use this file:
116
+
117
+ - Copy the content of `index.xml` into a new Alloy project.
118
+ - Install the official icon font files using `purgetss icon-library` (without `--vendor`, PurgeTSS copies all official icon fonts).
119
+ - Run `purgetss` once to generate the required files.
120
+ - Compile your app as usual.
121
+ - Use `liveview` if you want faster testing.
122
+
123
+ `index.xml`
124
+ ```xml
125
+ <Alloy>
126
+ <Window>
127
+ <View class="grid">
128
+ <View class="vertical mx-auto grid-cols-2 gap-y-2">
129
+ <!-- FontAwesome -->
130
+ <Label class="mt-2 text-gray-700" text="FontAwesome" />
131
+ <Button class="fa fa-home my-1 h-10 w-10 text-xl text-blue-500" />
132
+ <Button class="fa fa-home my-1 h-10 w-10 rounded bg-blue-500 text-xl text-white" />
133
+ </View>
134
+
135
+ <View class="vertical mx-auto grid-cols-2 gap-y-2">
136
+ <!-- Material Icons -->
137
+ <Label class="mt-2 text-gray-700" text="Material Icons" />
138
+ <Button class="mi mi-home my-1 h-10 w-10 text-xl text-blue-500" />
139
+ <Button class="mi mi-home my-1 h-10 w-10 rounded bg-blue-500 text-xl text-white" />
140
+ </View>
141
+
142
+ <View class="vertical mx-auto grid-cols-2 gap-y-2">
143
+ <!-- Material Symbols -->
144
+ <Label class="mt-2 text-gray-700" text="Material Symbol" />
145
+ <Button class="ms ms-home my-1 h-10 w-10 text-xl text-blue-500" />
146
+ <Button class="ms ms-home my-1 h-10 w-10 rounded bg-blue-500 text-xl text-white" />
147
+ </View>
148
+
149
+ <View class="vertical mx-auto grid-cols-2 gap-y-2">
150
+ <!-- Framework7-Icons -->
151
+ <Label class="mt-2 text-gray-700" text="Framework7-Icons" />
152
+ <Button class="f7 f7-house my-1 h-10 w-10 text-xl text-blue-500" />
153
+ <Button class="f7 f7-house my-1 h-10 w-10 rounded bg-blue-500 text-xl text-white" />
154
+ </View>
155
+ </View>
156
+ </Window>
157
+ </Alloy>
56
158
  ```
57
159
 
58
- ### The `fonts.tss` File
160
+ Generated `app.tss` excerpt:
161
+ ```css
162
+ // PurgeTSS v7.10.2
163
+ // Created by César Estrada
164
+ // https://purgetss.com
59
165
 
60
- The `build-fonts` command generates `./purgetss/styles/fonts.tss` with Unicode characters and style rules.
166
+ /* Ti Elements */
167
+ 'View': { width: Ti.UI.SIZE, height: Ti.UI.SIZE }
168
+ 'Window': { backgroundColor: '#FFFFFF' }
61
169
 
62
- `./purgetss/styles/fonts.tss`
63
- ```tss
64
- '.boxicons': { font: { fontFamily: 'boxicons' } }
65
- '.lineicons': { font: { fontFamily: 'LineIcons' } }
170
+ /* Default Font Awesome */
171
+ '.fa': { font: { fontFamily: 'FontAwesome7Free-Solid' } }
172
+ '.fa-home': { text: '', title: '' }
66
173
 
67
- /* Unicode Characters */
68
- /* To use your Icon Fonts in Buttons AND Labels each class sets 'text' and 'title' properties */
174
+ /* Material Icons */
175
+ '.mi': { font: { fontFamily: 'MaterialIcons-Regular' } }
176
+ '.mi-home': { text: '', title: '' }
69
177
 
70
- /* boxicons.css */
71
- '.bxl-meta': { text: '', title: '' }
72
- '.bx-lemon': { text: '', title: '' }
73
- /* ... */
178
+ /* Material Symbols */
179
+ '.ms': { font: { fontFamily: 'MaterialSymbolsOutlined-Regular' } }
180
+ '.ms-home': { text: '', title: '' }
74
181
 
75
- /* lineicons.css */
76
- '.lni-500px': { text: '', title: '' }
77
- '.lni-add-files': { text: '', title: '' }
78
- /* ... */
182
+ /* Framework7 */
183
+ '.f7': { font: { fontFamily: 'Framework7-Icons' } }
184
+ '.f7-house': { text: 'house', title: 'house' }
79
185
  ```
80
186
 
81
- ### Rename the Style Rule Name
187
+ ## Customizing Font Awesome
82
188
 
83
- PurgeTSS uses the font file name as the style rule name. You can change it by renaming the font file.
189
+ If you have a [Font Awesome Pro account](https://fontawesome.com/pro) or want to try the Beta, PurgeTSS can generate a custom `./purgetss/styles/fontawesome.tss` with the Pro or Beta classes.
84
190
 
85
- `./purgetss/fonts/`
86
- ```bash
87
- purgetss
88
- └─ fonts
89
- └─ boxicons
90
- └─ bx.ttf
91
- ```
191
+ ### Font Awesome Pro
92
192
 
93
- New style rule name: `'.bx'`
193
+ After setting the [@fortawesome scope](https://fontawesome.com/how-to-use/on-the-web/setup/using-package-managers#installing-pro) with your token, install it in your project's root folder with `npm init` and `npm install --save-dev @fortawesome/fontawesome-pro` (current version 7.1.0).
94
194
 
95
- ```tss
96
- '.bx': { font: { fontFamily: 'boxicons' } }
97
- ```
195
+ To generate a new `purgetss/styles/fontawesome.tss`, run `purgetss build`. It also copies the Pro font files into `./app/assets/fonts` if needed.
98
196
 
99
- ### The `assets/fonts` Folder
197
+ Note: Titanium cannot use Font Awesome duotone icons because each icon uses two glyphs.
100
198
 
101
- The `build-fonts` command copies the font files to `./app/assets/fonts` and renames them to their PostScript names so they work on both iOS and Android.
199
+ ### Font Awesome 7 Beta
102
200
 
103
- ```bash
104
- app
105
- └─ assets
106
- └─ fonts
107
- ├─ boxicons.ttf
108
- └─ LineIcons.ttf
109
- ```
201
+ To generate a custom `fontawesome.tss` file from [Font Awesome 7 Beta](https://fontawesome.com/download):
110
202
 
111
- ### The `--modules` Option
112
-
113
- When you use the `--modules` option, it generates a `./app/lib/purgetss.fonts.js` CommonJS module file.
114
-
115
- `./app/lib/purgetss.fonts.js`
116
- ```javascript
117
- const icons = {
118
- /* boxicons */
119
- boxicons: {
120
- bxlMeta: '',
121
- bxLemon: ''
122
- /* ... */
123
- },
124
- /* lineicons */
125
- lni: {
126
- '500px': '',
127
- addFiles: ''
128
- /* ... */
129
- }
130
- };
131
- exports.icons = icons;
132
- ```
203
+ Move the `css` and `webfonts` folders from `fontawesome-pro-7.0.0-beta3-web/`:
133
204
 
134
- ### The `--prefix` Option
205
+ ```bash
206
+ fontawesome-pro-7.0.0-beta3-web
207
+ └─ css
208
+ └─ webfonts
209
+ ```
135
210
 
136
- PurgeTSS determines the group's prefix for each icon family and class name. Use `--prefix` to apply the style's filename as the prefix for class names in `fonts.tss` and property names in `purgetss.fonts.js`.
211
+ Into `./purgetss/fontawesome-beta`:
137
212
 
138
- `./purgetss/fonts/`
139
213
  ```bash
140
214
  purgetss
141
- └─ fonts
142
- └─ lineicons
143
- └─ li.css
215
+ └─ fontawesome-beta
216
+ ├─ css
217
+ └─ webfonts
144
218
  ```
145
219
 
146
- New group prefix: `li`
220
+ Then run `purgetss build` to generate your custom `fontawesome.tss` file and test the new icons.
221
+
222
+ ## Recreating removed icon libraries
223
+
224
+ Older versions of PurgeTSS bundled Bootstrap Icons, Boxicons, LineIcons, and Tabler Icons. The list was trimmed to make maintenance easier, but you can rebuild any of them:
225
+
226
+ 1. Download the library from its official site:
227
+ - [Bootstrap Icons](https://icons.getbootstrap.com)
228
+ - [Boxicons](https://boxicons.com)
229
+ - [LineIcons](https://lineicons.com/icons/?type=free)
230
+ - [Tabler Icons](https://tabler-icons.io)
231
+ 2. Place the `.ttf`/`.otf` and `.css` files into `./purgetss/fonts/<library>/`.
232
+ 3. Run `purgetss build-fonts`.
233
+
234
+ For the underlying mechanics (how `build-fonts` reads the `.css`, options like `-m` and `-f`), see [Custom Fonts](./custom-fonts.md).
235
+
236
+ ### `fonts.tss` example
237
+
238
+ ```css
239
+ '.boxicons': { font: { fontFamily: 'boxicons' } }
240
+ '.lineicons': { font: { fontFamily: 'LineIcons' } }
241
+
242
+ /* Unicode Characters */
243
+ /* To use your Icon Fonts in Buttons AND Labels each class sets 'text' and 'title' properties */
147
244
 
148
- `./purgetss/styles/fonts.tss`
149
- ```tss
150
- /* lineicons/li.css */
151
- '.li-zoom-out': { text: '', title: '' }
152
- '.li-zoom-in': { text: '', title: '' }
245
+ /* boxicons.css */
246
+ '.bxl-meta': { text: '', title: '' }
247
+ '.bx-lemon': { text: '', title: '' }
153
248
  /* ... */
154
- ```
155
249
 
156
- `./app/lib/purgetss.fonts.js`
157
- ```javascript
158
- const icons = {
159
- /* lineicons/li.css */
160
- li: {
161
- /* ... */
162
- }
163
- };
164
- exports.icons = icons;
250
+ /* lineicons.css */
251
+ '.lni-500px': { text: '', title: '' }
252
+ '.lni-add-files': { text: '', title: '' }
253
+ /* ... */
165
254
  ```
166
255
 
167
- > 🛑 **DANGER**
168
- >
169
- > Make sure the new prefix stays unique so it does not collide 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.
170
-
171
256
  ## Community-Discovered Patterns
172
257
 
173
258
  The following note reflects community experience working with icon fonts that depend on multiple glyphs per icon.
174
259
 
175
260
  > 🛑 **DANGER — Font Awesome Duotone**
176
261
  > Titanium cannot render Font Awesome duotone icons correctly because each icon uses two glyphs. If you work with Font Awesome Pro, avoid documenting duotone as supported.
262
+
263
+ > 💡 **Mixing variant + icon in `class=`**
264
+ > A common mistake is omitting the variant class and writing just `class="fa-github"`. The icon class only sets `text`/`title` (the glyph) — without the variant class (`.fa`, `.fas`, `.fab`, etc.) the `fontFamily` is missing and the glyph renders as the system font's fallback character. Always include both: `class="fab fa-github"` or `class="msr ms-home"`.