Skip to content

Commit

Permalink
fix: add default font weight for local system fonts if not found
Browse files Browse the repository at this point in the history
  • Loading branch information
riccardoperra committed Dec 11, 2023
1 parent 9eb9065 commit 3ef8c22
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions apps/codeimage/src/state/editor/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -288,13 +288,14 @@ export function createEditorsStore() {
const value = selectedFont();
if (
!!value &&
value.types
.map(type => type.weight)
!value.types
.map(({weight}) => weight)
.includes(store.get.options.fontWeight)
) {
// TODO: move to configuration?
// Default is 400 - Regular
store.actions.setFontWeight(400);
const defaultValue =
value.types.find(({weight}) => [400, 500].includes(weight)) ??
value.types[0];
store.actions.setFontWeight(defaultValue?.weight ?? 400);
}
},
},
Expand Down

0 comments on commit 3ef8c22

Please sign in to comment.