Skip to content

Commit

Permalink
introduce runeAttr method
Browse files Browse the repository at this point in the history
  • Loading branch information
fzipp committed Apr 26, 2024
1 parent fbb6ecd commit e0fdf0d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func parseDescriptor(filename string, r io.Reader) (*Descriptor, error) {
File: tag.stringAttr("file"),
}
case "char":
id := rune(tag.intAttr("id"))
id := tag.runeAttr("id")
font.Chars[id] = Char{
ID: id,
X: tag.intAttr("x"),
Expand All @@ -72,8 +72,8 @@ func parseDescriptor(filename string, r io.Reader) (*Descriptor, error) {
}
case "kerning":
pair := CharPair{
First: rune(tag.intAttr("first")),
Second: rune(tag.intAttr("second")),
First: tag.runeAttr("first"),
Second: tag.runeAttr("second"),
}
font.Kerning[pair] = Kerning{
Amount: tag.intAttr("amount"),
Expand Down Expand Up @@ -199,6 +199,11 @@ func (t *tag) intAttr(name string) int {
return value
}

func (t *tag) runeAttr(name string) rune {
value, _ := strconv.ParseInt(t.stringAttr(name), 10, 32)
return rune(value)
}

func (t *tag) stringAttr(name string) string {
return t.attrs[name]
}
Expand Down

0 comments on commit e0fdf0d

Please sign in to comment.