Fix tofu advance.
This commit is contained in:
parent
a1659198e3
commit
052eeb5a18
5 changed files with 13 additions and 2 deletions
|
@ -143,9 +143,10 @@ proc getGlyphPath*(
|
|||
|
||||
proc getAdvance*(typeface: Typeface, rune: Rune): float32 {.inline, raises: [].} =
|
||||
## The advance for the rune in pixels.
|
||||
let typeface2 = typeface.fallbackTypeface(rune)
|
||||
var typeface2 = typeface.fallbackTypeface(rune)
|
||||
if typeface2 == nil:
|
||||
return
|
||||
# Get tofu advance, see tofu_advance test.
|
||||
typeface2 = typeface
|
||||
|
||||
if typeface2.opentype != nil:
|
||||
result = typeface2.opentype.getAdvance(rune)
|
||||
|
|
BIN
tests/fonts/diffs/tofu_advance.png
Normal file
BIN
tests/fonts/diffs/tofu_advance.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
BIN
tests/fonts/masters/tofu_advance.png
Normal file
BIN
tests/fonts/masters/tofu_advance.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.7 KiB |
BIN
tests/fonts/rendered/tofu_advance.png
Normal file
BIN
tests/fonts/rendered/tofu_advance.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.6 KiB |
|
@ -1091,3 +1091,13 @@ block:
|
|||
image.fillText(font, "Grumpy ウィザード make 有毒な醸造 for the 悪い女王 and Jack.")
|
||||
|
||||
doDiff(image, "fallback2")
|
||||
|
||||
block:
|
||||
var font = readFont("tests/fonts/Inter-Regular.ttf")
|
||||
|
||||
font.size = 26
|
||||
let image = newImage(800, 100)
|
||||
image.fill(rgba(255, 255, 255, 255))
|
||||
image.fillText(font, "This[]Advance!")
|
||||
|
||||
doDiff(image, "tofu_advance")
|
||||
|
|
Loading…
Reference in a new issue