Skip to content

Commit

Permalink
fix: add default font weight for local system fonts if not found (#604)
Browse files Browse the repository at this point in the history
* fix: add default font weight for local system fonts if not found
* Create khaki-mirrors-listen.md
  • Loading branch information
riccardoperra authored Dec 11, 2023
1 parent 9eb9065 commit e4f58de
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/khaki-mirrors-listen.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@codeimage/app": patch
---

fix: add default font weight for local system fonts if not found
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 e4f58de

Please sign in to comment.