Skip to content

Commit

Permalink
Handle unicode in colour parsing
Browse files Browse the repository at this point in the history
Fixes #4270
  • Loading branch information
andydotxyz committed Sep 27, 2023
1 parent 912f47c commit d35e57e
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
2 changes: 1 addition & 1 deletion theme/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ type hexColor string

func (h hexColor) color() (color.Color, error) {
data := h
switch len(h) {
switch len([]rune(h)) {
case 8, 6:
case 9, 7: // remove # prefix
data = h[1:]
Expand Down
4 changes: 4 additions & 0 deletions theme/json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ func TestFromJSON(t *testing.T) {
assert.Equal(t, float32(5), th.Size(SizeNameInlineIcon))
assert.Equal(t, "NotoMono-Regular.ttf", th.Font(fyne.TextStyle{Monospace: true}).Name())
assert.Equal(t, "cancel_Paths.svg", th.Icon(IconNameCancel).Name())

th, _ = FromJSON("{\"Colors\":{\"foreground\":\"\xb1\"}}")
c := th.Color(ColorNameForeground, VariantLight)
assert.NotNil(t, c)
}

func TestFromTOML_Resource(t *testing.T) {
Expand Down

0 comments on commit d35e57e

Please sign in to comment.