Skip to content

Commit 9bac645

Browse files
maurerleclaude
authored andcommitted
assets: replace meshviewer.woff2 icon font with SVG masks
Drops the icomoon-managed icon font (.woff2/.woff/.ttf) in favour of individual SVG files extracted from the original TTF. New icons can now be added by dropping an .svg into assets/icons/svg/ and registering it in icon.scss, removing the round-trip through icomoon.io. Icons render via mask-image with background-color: currentColor, so existing font-size and color rules on .ion-* elements keep working unchanged. vertical-align matches the original font's value of 0 (baseline), so icon position relative to surrounding text is preserved. Three SCSS modules (_sidebar, _leaflet, _table) used raw font codepoints inline; those are converted to a new icon.icon-mask($name) mixin. Also drops three unused icon definitions (chevron-right, person, arrow-left-c) and the now-redundant \$font-family-icons variable. DEVELOPMENT.md is updated to describe the new SVG workflow. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 4fe98f4 commit 9bac645

34 files changed

Lines changed: 88 additions & 73 deletions

DEVELOPMENT.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,8 @@ but also names based on elements like `p`, `a`, `div`..
8181

8282
## Addition of new icons
8383

84-
To add new icons to the `meshviewer.woff2` icon-set, one must edit the icon-set manually.
84+
Icons are SVG files in `assets/icons/svg/`. The CSS class `ion-<name>` is generated by `assets/icons/icon.scss` and renders the SVG via `mask-image` with `currentColor`, so icons inherit text color and scale with `font-size`.
8585

86-
- This can be done by uploading the existing `meshviewer.tff` to https://icomoon.io/new-app
87-
- Then, one can add a new icon by searching in the UI or uploading an SVG.
88-
- Finally, export the iconset and replace the existing one
86+
- Add the SVG to `assets/icons/svg/<name>.svg`. Use a square `viewBox` and a single-colour shape (mask uses the alpha channel).
87+
- Register it in `assets/icons/icon.scss` with `@include icon.icon("<name>");`.
88+
- Use it in markup as `class="ion-<name>"`.

assets/fonts/meshviewer.ttf

-4.68 KB
Binary file not shown.

assets/fonts/meshviewer.woff

-4.89 KB
Binary file not shown.

assets/fonts/meshviewer.woff2

-3.08 KB
Binary file not shown.

assets/icons/_icon-mixin.scss

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
1-
@mixin icon($name, $code, $prefix: "ion-") {
2-
.#{$prefix}#{$name} {
3-
&::before {
4-
content: "#{$code}";
5-
}
1+
@mixin icon-mask($name) {
2+
background-color: currentColor;
3+
content: "";
4+
display: inline-block;
5+
height: 1em;
6+
mask-image: url("@icons/#{$name}.svg");
7+
mask-position: center;
8+
mask-repeat: no-repeat;
9+
mask-size: contain;
10+
vertical-align: -2px;
11+
width: 1em;
12+
}
13+
14+
@mixin icon($name, $prefix: "ion-") {
15+
.#{$prefix}#{$name}::before {
16+
mask-image: url("@icons/#{$name}.svg");
617
}
718
}

assets/icons/icon.scss

Lines changed: 28 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,32 @@
1-
@use "sass:string";
21
@use "../../scss/mixins/icon" as icon;
3-
@use "../../scss/modules/variables" as variables;
42

5-
// Needed for standalone scss
6-
// @import 'icon-mixin';
7-
8-
$cache-breaker: string.unique-id();
9-
10-
@font-face {
11-
font-family: "ionicons";
12-
font-style: normal;
13-
font-weight: normal;
14-
src:
15-
url("@fonts/meshviewer.woff2?rel=#{$cache-breaker}") format("woff2"),
16-
url("@fonts/meshviewer.woff?rel=#{$cache-breaker}") format("woff"),
17-
url("@fonts/meshviewer.ttf?rel=#{$cache-breaker}") format("truetype");
18-
}
19-
20-
[class^="ion-"],
21-
[class*=" ion-"] {
22-
&::before {
23-
display: inline-block;
24-
font-family: variables.$font-family-icons;
25-
font-style: normal;
26-
font-variant: normal;
27-
font-weight: normal;
28-
line-height: 1;
29-
text-rendering: auto;
30-
text-transform: none;
31-
vertical-align: 0;
32-
}
3+
[class^="ion-"]::before,
4+
[class*=" ion-"]::before {
5+
background-color: currentColor;
6+
content: "";
7+
display: inline-block;
8+
height: 1em;
9+
mask-position: center;
10+
mask-repeat: no-repeat;
11+
mask-size: contain;
12+
vertical-align: -2px;
13+
width: 1em;
3314
}
3415

35-
@include icon.icon("chevron-left", "\f124");
36-
@include icon.icon("chevron-right", "\f125");
37-
@include icon.icon("pin", "\f3a3");
38-
@include icon.icon("wifi", "\f25c");
39-
@include icon.icon("eye", "\f133");
40-
@include icon.icon("up-b", "\f10d");
41-
@include icon.icon("down-b", "\f104");
42-
@include icon.icon("locate", "\f2e9");
43-
@include icon.icon("close", "\f2d7");
44-
@include icon.icon("location", "\f456");
45-
@include icon.icon("layer", "\f229");
46-
@include icon.icon("filter", "\f38B");
47-
@include icon.icon("connection-bars", "\f274");
48-
@include icon.icon("share-alt", "\f3ac");
49-
@include icon.icon("clipboard", "\f376");
50-
@include icon.icon("people", "\f39e");
51-
@include icon.icon("person", "\f3a0");
52-
@include icon.icon("time", "\f3b3");
53-
@include icon.icon("arrow-resize", "\f264");
54-
@include icon.icon("arrow-left-c", "\f108");
55-
@include icon.icon("arrow-right-c", "\f10b");
56-
@include icon.icon("full-enter", "\e901");
57-
@include icon.icon("full-exit", "\e900");
58-
@include icon.icon("ruler", "\f333");
16+
@include icon.icon("pin");
17+
@include icon.icon("wifi");
18+
@include icon.icon("eye");
19+
@include icon.icon("locate");
20+
@include icon.icon("close");
21+
@include icon.icon("location");
22+
@include icon.icon("filter");
23+
@include icon.icon("connection-bars");
24+
@include icon.icon("share-alt");
25+
@include icon.icon("clipboard");
26+
@include icon.icon("people");
27+
@include icon.icon("time");
28+
@include icon.icon("arrow-resize");
29+
@include icon.icon("arrow-right-c");
30+
@include icon.icon("full-enter");
31+
@include icon.icon("full-exit");
32+
@include icon.icon("ruler");

assets/icons/svg/arrow-resize.svg

Lines changed: 1 addition & 0 deletions
Loading

assets/icons/svg/arrow-right-c.svg

Lines changed: 1 addition & 0 deletions
Loading

assets/icons/svg/chevron-left.svg

Lines changed: 1 addition & 0 deletions
Loading

assets/icons/svg/clipboard.svg

Lines changed: 1 addition & 0 deletions
Loading

0 commit comments

Comments
 (0)