diff --git a/src/pixie/fonts.nim b/src/pixie/fonts.nim index 648f964..0b42065 100644 --- a/src/pixie/fonts.nim +++ b/src/pixie/fonts.nim @@ -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) diff --git a/tests/fonts/diffs/tofu_advance.png b/tests/fonts/diffs/tofu_advance.png new file mode 100644 index 0000000..2b30fd2 Binary files /dev/null and b/tests/fonts/diffs/tofu_advance.png differ diff --git a/tests/fonts/masters/tofu_advance.png b/tests/fonts/masters/tofu_advance.png new file mode 100644 index 0000000..adee2e3 Binary files /dev/null and b/tests/fonts/masters/tofu_advance.png differ diff --git a/tests/fonts/rendered/tofu_advance.png b/tests/fonts/rendered/tofu_advance.png new file mode 100644 index 0000000..a1deb57 Binary files /dev/null and b/tests/fonts/rendered/tofu_advance.png differ diff --git a/tests/test_fonts.nim b/tests/test_fonts.nim index c54150d..6b78f7c 100644 --- a/tests/test_fonts.nim +++ b/tests/test_fonts.nim @@ -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")