CI / test (push) Canceled after 0s
Compositor-drawn Win+. style picker. The focused app keeps keyboard focus so
its text-input-v3 field stays enabled; the emoji goes in with commit_string,
or onto the clipboard with a visible notice when the app has no text field.
Shortcut lives in the shortcut table (rebindable in Settings > Shortcuts).
- compositor/wayland/text_input.mbt: zwp_text_input_manager_v3 (global 12)
- compositor/emoji: Emoji 18.0 + CLDR 49 data (Unicode License), search,
picker model, CBDT/CBLC + GSUB reader for Noto Color Emoji
- Chandra's own pinned bitmap Noto Color Emoji (scripts/fetch-emoji-font.sh,
just emoji-font); Fedora's COLRv1 copy can't be drawn. Missing font shows
an error panel.
- raster WIT: emoji-font, emoji-has, emoji-image; served by wasmhost
- state.edn :emoji {:recent [...] :skin-tone n}
- tests incl. a fake text-input client; docs/emoji-picker.md
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DPL5hkABDGJixotaqFv2X2
71 lines
2.3 KiB
MoonBit
71 lines
2.3 KiB
MoonBit
///| Chandra's own copy (scripts/fetch-emoji-font.sh; `just test` fetches it).
|
||
let test_font : String = @emoji.font_path
|
||
|
||
///|
|
||
fn open_font() -> @emoji.EmojiFont {
|
||
let data = @sys.read_file_bytes(test_font)
|
||
if data.length() == 0 {
|
||
abort("font_test needs Noto Color Emoji at " + test_font + ": run scripts/fetch-emoji-font.sh")
|
||
}
|
||
@emoji.EmojiFont::parse(data) catch {
|
||
e => abort("Noto Color Emoji didn't parse: " + Show::to_string(e))
|
||
}
|
||
}
|
||
|
||
///|
|
||
test "Noto Color Emoji: the same emoji as HarfBuzz finds" {
|
||
let f = open_font()
|
||
assert_eq(f.ppem, 109)
|
||
// Counted with HarfBuzz (uharfbuzz) on Noto Color Emoji 2.051: of the 1923 listed emoji the
|
||
// font draws 1914 (some Emoji 17/18 additions are missing), and 1650 skin tone variants.
|
||
let mut base = 0
|
||
let mut tones = 0
|
||
for e in @emoji.all() {
|
||
if f.has(e.text) {
|
||
base = base + 1
|
||
}
|
||
for t in e.tones {
|
||
if f.has(t) {
|
||
tones = tones + 1
|
||
}
|
||
}
|
||
}
|
||
assert_eq(base, 1914)
|
||
assert_eq(tones, 1650)
|
||
// Ligatures: a family, a keycap, a flag and a skin tone are one picture each.
|
||
for s in ["👨👩👧👦", "#️⃣", "🇩🇪", "👍🏽", "🏴☠️", "🏴"] {
|
||
assert_eq(f.shape(s).length(), 1)
|
||
assert_true(f.has(s))
|
||
}
|
||
// Text the font can't draw as one picture.
|
||
assert_false(f.has("ab"))
|
||
let cracking = @emoji.all().filter(e => e.name == "cracking face")[0]
|
||
assert_false(f.has(cracking.text)) // Emoji 18.0, newer than this font
|
||
}
|
||
|
||
///|
|
||
test "pictures are scaled to a square, centred, with transparent corners" {
|
||
let f = open_font()
|
||
let p = f.picture("😀", 32).unwrap()
|
||
assert_eq(p.width, 32)
|
||
assert_eq(p.height, 32)
|
||
// The corner is transparent, the middle of the face is opaque yellow.
|
||
assert_eq(p.data[3].to_int(), 0)
|
||
let o = (16 * 32 + 16) * 4
|
||
assert_eq(p.data[o + 3].to_int(), 255)
|
||
assert_true(p.data[o].to_int() > 200 && p.data[o + 1].to_int() > 150 && p.data[o + 2].to_int() < 100)
|
||
assert_true(f.picture("ab", 32) is None)
|
||
}
|
||
|
||
///|
|
||
test "a file that is not a colour emoji font is an error that says why" {
|
||
let msg = try {
|
||
ignore(@emoji.EmojiFont::parse(b"\x00\x01\x00\x00\x00\x00"))
|
||
"parsed"
|
||
} catch {
|
||
e => Show::to_string(e)
|
||
}
|
||
assert_true(msg.contains("no cmap table"))
|
||
assert_true(@emoji.missing_font_message("").contains("just install"))
|
||
}
|