fontawesome_subsetter 0.1.7 → 0.1.9
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.
- checksums.yaml +4 -4
- data/README.md +31 -0
- data/lib/fontawesome_subsetter/subsetter.rb +16 -12
- data/lib/fontawesome_subsetter/version.rb +1 -1
- data/lib/fontawesome_subsetter.rb +8 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 33c3b2edc76b53a04844718df0b26cee93aed21d85db538f25f52fafe6453287
|
|
4
|
+
data.tar.gz: 963351cb3b73e82827ab710e27ceed76d3a4c034ef966025f6df386a13d6bb37
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 0f503ad4e00f742e74a499341fde0cd4c837589ad95a57845f24a8a8723589ea44f7147d37df4179dbf3dc164badc382f84fb7fae3dddd0eeb40faa492ae4cdf
|
|
7
|
+
data.tar.gz: d4a51a28bd5bdd8a5c1499683def9dc88091a8bbd88b1668aa643e76fcdf318dcdde3216c3f67ebcb3a765d34d7d8aa371fe59008989cd288a0b9c937fdb2924
|
data/README.md
CHANGED
|
@@ -103,9 +103,40 @@ FontawesomeSubsetter.configure do | config |
|
|
|
103
103
|
|
|
104
104
|
# Custom SCSS template (optional — receives @styles hash, must return SCSS string)
|
|
105
105
|
# config.scss_template = ->(styles) { "..." }
|
|
106
|
+
|
|
107
|
+
# Additional SCSS variables to inject into the `@use "variables" with (...)` block.
|
|
108
|
+
# Keys may be symbols/strings (with or without leading `$`). Values are raw SCSS.
|
|
109
|
+
# config.variables = {
|
|
110
|
+
# "fa-font-display" => "swap",
|
|
111
|
+
# "fa-css-prefix" => '"fa"'
|
|
112
|
+
# }
|
|
113
|
+
|
|
114
|
+
# Optional presentational FontAwesome SCSS partials to include. Defaults to `:all`.
|
|
115
|
+
# Available: "sizing", "widths", "list", "bordered", "animated", "rotated-flipped", "stacked"
|
|
116
|
+
# (Core partials — functions, mixins, core, icons — are always included.)
|
|
117
|
+
# config.features = ["animated"]
|
|
106
118
|
end
|
|
107
119
|
```
|
|
108
120
|
|
|
121
|
+
## Deploying with Kamal (Docker)
|
|
122
|
+
|
|
123
|
+
`pyftsubset` must be available during `assets:precompile` in your Docker build stage. Add the following to the **build** stage of your Dockerfile:
|
|
124
|
+
|
|
125
|
+
```dockerfile
|
|
126
|
+
# In the build stage, install pyftsubset for font subsetting
|
|
127
|
+
RUN apt-get update -qq && \
|
|
128
|
+
apt-get install --no-install-recommends -y python3 python3-pip python3-venv pipx && \
|
|
129
|
+
pipx ensurepath && \
|
|
130
|
+
pipx install fonttools && \
|
|
131
|
+
pipx inject fonttools brotli && \
|
|
132
|
+
ln -s /root/.local/bin/pyftsubset /usr/local/bin/pyftsubset && \
|
|
133
|
+
rm -rf /var/lib/apt/lists /var/cache/apt/archives
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Font subsetting runs automatically during `assets:precompile`, so no additional Dockerfile steps are needed — just make sure the line above appears before your `RUN ... assets:precompile` step.
|
|
137
|
+
|
|
138
|
+
The final (runtime) stage does **not** need `pyftsubset`; subsetted fonts are already baked into the image.
|
|
139
|
+
|
|
109
140
|
## License
|
|
110
141
|
|
|
111
142
|
[MIT](LICENSE.txt) — Copyright (c) 2026
|
|
@@ -234,28 +234,32 @@ module FontawesomeSubsetter
|
|
|
234
234
|
private
|
|
235
235
|
|
|
236
236
|
def default_scss_template(styles)
|
|
237
|
-
|
|
237
|
+
extra_vars = FontawesomeSubsetter.configuration.variables || {}
|
|
238
|
+
extra_lines = extra_vars.map { | name, value | " #{ name.to_s.start_with?('$') ? name : "$#{ name }" }: #{ value }," }.join("\n")
|
|
238
239
|
|
|
240
|
+
icons = @styles.except("brands").values.reduce(Set.new) { | all_icons, style | all_icons.merge(style[:sass_icon_cache]) }.join(", ")
|
|
241
|
+
brand_icons = @styles["brands"][:sass_icon_cache].to_a.join(", ")
|
|
242
|
+
style_uses = styles.map { | s | "@use \"./vendor/fontawesome/scss/#{ s[:name] }.scss\";" }.join("\n")
|
|
243
|
+
|
|
244
|
+
features = FontawesomeSubsetter.configuration.features
|
|
245
|
+
enabled_features = features == :all ? Configuration::AVAILABLE_FEATURES : Array(features).map(&:to_s)
|
|
246
|
+
feature_uses = enabled_features.map { | f | "@use \"./vendor/fontawesome/scss/#{ f }\";" }.join("\n")
|
|
247
|
+
|
|
248
|
+
<<~SCSS
|
|
239
249
|
// The custom importer strips populated $icons/$brand-icons maps from variables.scss in memory.
|
|
240
250
|
@use "./vendor/fontawesome/scss/variables" with (
|
|
241
251
|
$font-path: "webfonts",
|
|
242
|
-
|
|
243
|
-
$
|
|
252
|
+
#{ extra_lines }
|
|
253
|
+
$icons: (#{ icons }),
|
|
254
|
+
$brand-icons: (#{ brand_icons }));
|
|
244
255
|
|
|
245
256
|
@use "./vendor/fontawesome/scss/functions";
|
|
246
257
|
@use "./vendor/fontawesome/scss/mixins";
|
|
247
258
|
@use "./vendor/fontawesome/scss/core";
|
|
248
|
-
|
|
249
|
-
// @use "./vendor/fontawesome/scss/widths";
|
|
250
|
-
// @use "./vendor/fontawesome/scss/list";
|
|
251
|
-
// @use "./vendor/fontawesome/scss/bordered";
|
|
252
|
-
@use "./vendor/fontawesome/scss/animated";
|
|
253
|
-
// @use "./vendor/fontawesome/scss/rotated-flipped";
|
|
254
|
-
// @use "./vendor/fontawesome/scss/stacked";
|
|
259
|
+
#{ feature_uses }
|
|
255
260
|
@use "./vendor/fontawesome/scss/icons";
|
|
256
261
|
|
|
257
|
-
#{
|
|
258
|
-
|
|
262
|
+
#{ style_uses }
|
|
259
263
|
SCSS
|
|
260
264
|
end
|
|
261
265
|
|
|
@@ -22,12 +22,19 @@ module FontawesomeSubsetter
|
|
|
22
22
|
class Configuration
|
|
23
23
|
|
|
24
24
|
attr_accessor :meta_path, :fonts_dir, :build_dir, :scan_globs, :watch_paths,
|
|
25
|
-
:watch_file_type_regex, :icon_regex, :scss_template, :styles
|
|
25
|
+
:watch_file_type_regex, :icon_regex, :scss_template, :styles,
|
|
26
|
+
:variables, :features
|
|
27
|
+
|
|
28
|
+
# Optional presentational FontAwesome SCSS partials.
|
|
29
|
+
# Core partials (functions, mixins, core, icons) are always included.
|
|
30
|
+
AVAILABLE_FEATURES = ["sizing", "widths", "list", "bordered", "animated", "rotated-flipped", "stacked"].freeze
|
|
26
31
|
|
|
27
32
|
def initialize
|
|
28
33
|
@scan_globs = ["app/views/**/*.slim", "app/helpers/**/*.rb"]
|
|
29
34
|
@watch_file_type_regex = /\.(slim|rb)$/
|
|
30
35
|
@icon_regex = /icon\(\s*:(?<prefix>fas|far|fab|fad|fal|fat)\s*,\s*:(?<icon>[\w_\-]+)\b/
|
|
36
|
+
@variables = {}
|
|
37
|
+
@features = :all
|
|
31
38
|
end
|
|
32
39
|
|
|
33
40
|
end
|