aboutsummaryrefslogtreecommitdiffhomepage
path: root/main.go
diff options
context:
space:
mode:
authornsfisis <nsfisis@gmail.com>2022-04-27 19:59:46 +0900
committernsfisis <nsfisis@gmail.com>2022-04-27 19:59:46 +0900
commitde1c4d2e812b21f65b910742b26ecf07840b2d4d (patch)
treec7c4146dd909fe9f1dc8163bb61e427f17734e01 /main.go
parent0c1be8adcc4773ceb6927b4f38d62539077f8cc8 (diff)
downloadterm-banner-de1c4d2e812b21f65b910742b26ecf07840b2d4d.tar.gz
term-banner-de1c4d2e812b21f65b910742b26ecf07840b2d4d.tar.zst
term-banner-de1c4d2e812b21f65b910742b26ecf07840b2d4d.zip
fix rendering result of some charactersv1.1.0
Diffstat (limited to 'main.go')
-rw-r--r--main.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/main.go b/main.go
index 5101d60..b84d140 100644
--- a/main.go
+++ b/main.go
@@ -30,7 +30,9 @@ const (
fw2FirstByteStart = 0xE0
fw2FirstByteEnd = 0xEF
fwSecondByteStart = 0x40
- fwSecondByteEnd = 0x9F
+ fwSecondByteEnd = 0xFC
+ // There is no character whose 2nd byte is 0x7F.
+ fwSecondUnmapped = 0x7F
)
//go:embed assets/*.png
@@ -308,7 +310,10 @@ func parseGlyphsFW(filePath string) (*[31][189]GlyphFW, *[16][189]GlyphFW, error
}
}
c1 := dy / 2
- c2 := dx + (fwSecondByteEnd-fwSecondByteStart)*(dy%2)
+ c2 := dx + (dy%2)*(fwSecondByteEnd-fwSecondByteStart)/2
+ if c2 >= fwSecondUnmapped-fwSecondByteStart {
+ c2 += 1
+ }
gs1[c1][c2] = glyph
}
}
@@ -327,7 +332,10 @@ func parseGlyphsFW(filePath string) (*[31][189]GlyphFW, *[16][189]GlyphFW, error
}
}
c1 := dy / 2
- c2 := dx + (fwSecondByteEnd-fwSecondByteStart)*(dy%2)
+ c2 := dx + (dy%2)*(fwSecondByteEnd-fwSecondByteStart)/2
+ if c2 >= fwSecondUnmapped-fwSecondByteStart {
+ c2 += 1
+ }
gs2[c1][c2] = glyph
}
}