Skip to content

Commit 24a03ad

Browse files
committed
feat: generate LaTeX docs listing all icon's per icon set
1 parent da4fd01 commit 24a03ad

13 files changed

Lines changed: 221 additions & 69 deletions

Cargo.lock

Lines changed: 83 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,11 @@ version = "0.1.0"
44
edition = "2021"
55

66
[dependencies]
7+
chrono = "0.4.38"
78
clap = { version = "4.5.21", features = ["derive"] }
89
convert_case = "0.6.0"
910
log = "0.4.22"
11+
ordermap = {version = "0.5.3", features = ["serde"]}
1012
regex = "^1.11.1"
1113
reqwest = "0.12.9"
1214
serde = { version = "1.0.215", features = ["derive"] }

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,10 @@ generate:
33
deno run iconsets2svgfont
44
deno run svgfonts2ttf
55
cargo run generate-packages
6+
7+
clear:
8+
find ./temp/icon-sets ! -name '.gitkeep' -type f -exec rm -f {} +
9+
find ./temp/fonts ! -name '.gitkeep' -type f -exec rm -f {} +
10+
11+
submodules-update:
12+
git submodule foreach git pull

packages/texicons.sty

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
\NeedsTeXFormat{LaTeX2e}
22
\ProvidesPackage{texicons}[2024/11/13 Base TeXicons package to be used with icon sets]
33

4+
\usepackage{xcolor}
5+
46
\newcommand{\icon}[2][.]{
57
\textcolor{#1}
68
{{\csname icon@#2\endcsname}}

src/iconsets2svgfont.ts

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,16 +25,6 @@ for await (const dirEntry of Deno.readDir("./temp/icon-sets")) {
2525
const fontStream = new SVGIcons2SVGFontStream({
2626
fontName: iconSetData.prefix,
2727
});
28-
const codepointsStream = createWriteStream(
29-
`./temp/fonts/${iconSetData.prefix}.codepoints`,
30-
).on("finish", function () {
31-
console.log(
32-
`Code points ${iconSetData.prefix}.codepoints successfully created!`,
33-
);
34-
})
35-
.on("error", function (err) {
36-
console.log(`Error when creating ${iconSetData.prefix}.codepoints`, err);
37-
});
3828

3929
// Setting the font destination
4030
fontStream
@@ -46,11 +36,10 @@ for await (const dirEntry of Deno.readDir("./temp/icon-sets")) {
4636
console.log(`Error when creating ${iconSetData.prefix}.svg`, err);
4737
});
4838

49-
let codePoint = 0xE000;
5039
for (const iconName in iconSetData.icons) {
5140
// optimize SVG with svgo before writing to fontStream
5241
const result = optimize(
53-
iconSetData.icons[iconName],
42+
iconSetData.icons[iconName].svg,
5443
{
5544
plugins: [
5645
"preset-default",
@@ -66,16 +55,12 @@ for await (const dirEntry of Deno.readDir("./temp/icon-sets")) {
6655
// @ts-ignore
6756
glyph.metadata = {
6857
name: iconName,
69-
unicode: [String.fromCodePoint(codePoint)],
58+
unicode: [String.fromCodePoint(
59+
parseInt(iconSetData.icons[iconName].codepoint, 16),
60+
)],
7061
};
71-
7262
fontStream.write(glyph);
73-
codepointsStream.write(`${iconName} ${codePoint.toString(16)}\n`);
74-
75-
codePoint++;
7663
}
7764

78-
// End streams
7965
fontStream.end();
80-
codepointsStream.end();
8166
}

0 commit comments

Comments
 (0)