mirror of
https://github.com/tiennm99/tiennm99bot.git
synced 2026-10-13 16:15:36 +00:00
The monkeyd-crawler repository moved into tiennm99/mttools, so recursive clones of the old submodule URL fail and block every deploy. The crawler, PDF renderer, and export flow now live under internal/modules/monkeyd, trimmed to the bot's use: a fixed phone page, the bundled font only, and the font size as the single export option.
39 lines
1.1 KiB
Go
39 lines
1.1 KiB
Go
package pdf
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"golang.org/x/image/font/sfnt"
|
|
)
|
|
|
|
func TestBundledFontIsParseable(t *testing.T) {
|
|
font := BundledFont()
|
|
if font.Name != BundledFontName {
|
|
t.Errorf("Name = %q, want %q", font.Name, BundledFontName)
|
|
}
|
|
if _, err := sfnt.Parse(font.Data); err != nil {
|
|
t.Fatalf("bundled font does not parse as a TrueType font: %v", err)
|
|
}
|
|
}
|
|
|
|
// The bundled font exists to render Vietnamese. A replacement that lacks these
|
|
// glyphs would silently emit blanks, so check before trusting it.
|
|
func TestBundledFontCoversVietnamese(t *testing.T) {
|
|
parsed, err := sfnt.Parse(BundledFont().Data)
|
|
if err != nil {
|
|
t.Fatalf("parse bundled font: %v", err)
|
|
}
|
|
var buf sfnt.Buffer
|
|
for _, r := range []rune{'ư', 'ơ', 'đ', 'ạ', 'ế', 'ộ', 'ữ', 'ằ', 'ỷ', 'ỹ', 'Ọ', 'Ế', 'Ư', 'Đ'} {
|
|
index, err := parsed.GlyphIndex(&buf, r)
|
|
if err != nil {
|
|
t.Errorf("GlyphIndex(%q): %v", r, err)
|
|
continue
|
|
}
|
|
// Glyph 0 is .notdef — the character is absent from the font.
|
|
if index == 0 {
|
|
t.Errorf("bundled font has no glyph for %q (U+%04X)", r, r)
|
|
}
|
|
}
|
|
}
|