Skip to content

Commit 2b43a5f

Browse files
byseif21fehmer
andauthored
fix(font): 0xProto not working in screenshot (@byseif21) (monkeytypegame#6817)
### Description starting with number seem to cuzes issue, did some hacking idk --------- Co-authored-by: Christian Fehmer <[email protected]>
1 parent 15feb8a commit 2b43a5f

File tree

5 files changed

+15
-6
lines changed

5 files changed

+15
-6
lines changed

docs/FONTS.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ First, you will have to make a personal copy of the Monkeytype repository, also
1616
Once you have forked the repository you can now add your font. Place the font file in `./frontend/static/webfonts` e.g. `My-Font.woff2`.
1717

1818
> [!NOTE]
19-
> Your font needs to be in the `.woff2` format. Your filename cannot include spaces.
19+
> Your font needs to be in the `.woff2` format. Your filename cannot include spaces or start with a number.
2020
2121
Open `./packages/schemas/src/fonts.ts` and add the new font at the _end_ of the `KnownFontNameSchema` list like this:
2222

@@ -29,7 +29,7 @@ const KnownFontNameSchema = z.enum(
2929
"My_Font",
3030
```
3131
32-
Call it whatever you want but make sure you replace spaces with underscores.
32+
Call it whatever you want but make sure you replace spaces with underscores and the font does not start with a number.
3333
3434
Then, go to `./frontend/src/ts/constants/fonts.ts` and add the following code to the _end_ of the `Fonts` object near to the very end of the file:
3535

frontend/src/ts/commandline/commandline-metadata.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -586,7 +586,11 @@ export const commandlineConfigMetadata: CommandlineConfigMetadataObject = {
586586
},
587587
fontFamily: {
588588
subgroup: {
589-
options: typedKeys(Fonts).sort(),
589+
options: typedKeys(Fonts).sort((a, b) =>
590+
(Fonts[a]?.display ?? a.replace(/_/g, " ")).localeCompare(
591+
Fonts[b]?.display ?? b.replace(/_/g, " ")
592+
)
593+
),
590594
display: (name) =>
591595
Fonts[name as KnownFontName]?.display ?? name.replaceAll(/_/g, " "),
592596
customData: (name) => {

frontend/src/ts/constants/fonts.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,8 @@ export const Fonts: Record<KnownFontName, FontConfig> = {
133133
Iosevka: {
134134
fileName: "Iosevka-Regular.woff2",
135135
},
136-
"0xProto": {
136+
Proto: {
137+
display: "0xProto",
137138
fileName: "0xProto-Regular.woff2",
138139
},
139140
};

frontend/src/ts/pages/settings.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,11 @@ async function fillSettingsPage(): Promise<void> {
580580
if (fontsEl.innerHTML === "") {
581581
let fontsElHTML = "";
582582

583-
for (const name of Misc.typedKeys(Fonts).sort()) {
583+
for (const name of Misc.typedKeys(Fonts).sort((a, b) =>
584+
(Fonts[a].display ?? a.replace(/_/g, " ")).localeCompare(
585+
Fonts[b].display ?? b.replace(/_/g, " ")
586+
)
587+
)) {
584588
const font = Fonts[name];
585589
let fontFamily = name.replace(/_/g, " ");
586590

packages/schemas/src/fonts.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const KnownFontNameSchema = z.enum(
4141
"Kanit",
4242
"Geist_Mono",
4343
"Iosevka",
44-
"0xProto",
44+
"Proto",
4545
],
4646
{
4747
errorMap: customEnumErrorHandler("Must be a known font family"),

0 commit comments

Comments
 (0)