Show English mode in the input method icon

macOS: the input method now has two input modes in Info.plist, 中英自動 ("注")
and 英文 ("A"), each with its own menu-bar icon. A Shift tap with nothing typed
switches the mode (TISSelectInputSource), and choosing a mode in the menu bar
switches the engine (setValue:forTag:). --register enables both modes.
Windows: the taskbar IME icon switches between icon.ico and icon-en.ico.
Linux: the IBus mode property also switches its icon.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-13 16:56:08 +08:00
co-authored by Claude Opus 5.5
parent 0155ddd16e
commit 6443f771a0
19 changed files with 184 additions and 9 deletions
+4 -3
View File
@@ -1,8 +1,9 @@
// Renders the menu-bar icon ("注" with a small "A") to a TIFF.
// Usage: swift scripts/make-icon.swift <output.tiff>
// Renders a menu-bar icon (one character, "注" by default; "A" for English mode) to a TIFF.
// Usage: swift scripts/make-icon.swift <output.tiff> [character]
import AppKit
let out = CommandLine.arguments.count > 1 ? CommandLine.arguments[1] : "icon.tiff"
let glyph = CommandLine.arguments.count > 2 ? CommandLine.arguments[2] : "注"
let reps: [NSBitmapImageRep] = [16, 32].map { size in
let rep = NSBitmapImageRep(bitmapDataPlanes: nil, pixelsWide: size, pixelsHigh: size,
bitsPerSample: 8, samplesPerPixel: 4, hasAlpha: true, isPlanar: false,
@@ -11,7 +12,7 @@ let reps: [NSBitmapImageRep] = [16, 32].map { size in
NSGraphicsContext.saveGraphicsState()
NSGraphicsContext.current = NSGraphicsContext(bitmapImageRep: rep)
let font = NSFont.systemFont(ofSize: 13, weight: .semibold)
let text = NSAttributedString(string: "注", attributes: [.font: font, .foregroundColor: NSColor.black])
let text = NSAttributedString(string: glyph, attributes: [.font: font, .foregroundColor: NSColor.black])
let s = text.size()
text.draw(at: NSPoint(x: (16 - s.width) / 2, y: (16 - s.height) / 2))
NSGraphicsContext.restoreGraphicsState()