[Bug/Medium] Canon printer media types display Thai characters instead of English labels #181
Notifications
Due Date
No due date set.
Blocks
Depends on
Reference: gronod/iccery-v2-mac#181
Reference in New Issue
Block a user
Summary
The media type list for Canon Pro9500 Mark II shows Thai characters instead of English:
กระดาษธรรมดาinstead of "Plain Paper"กระดาษภาพถ่ายมันเงา+ IIinstead of "Photo Paper Plus Glossy II"กระดาษกึ่งเงา ภาพถ่ายพิเศษinstead of "Photo Paper Plus Semi-gloss"กระดาษ Fine Art อื่นinstead of "Other Fine Art Paper"แผ่นกระดาษแข็งinstead of "Board Paper"ดิสก์ที่พิมพ์ได้instead of "Printable disc"ดิสก์ที่พิมพ์ได้ (กันซึม)instead of "Printable disc (bleed-proof)"The correct list (as seen in TargetPrint) should be the full
CNIJMediaTypechoice set in English — 18 types are enumerated in the acceptance criteria below; the true count is verified against the real PPD (do not hardcode).Root Cause Analysis
PPD Locale Translation Order
The Canon PPD contains locale-specific translations for
CNIJMediaType:*CNIJMediaType 0/Plain Paper: ""(base, no locale prefix)*th.CNIJMediaType 0/กระดาษธรรมดา: ""(Thai — LAST)The Bug in
CupsParsers.ppdChoiceLabels()(Packages/ICCeryCore/Sources/ICCeryCore/Print/CupsParsers.swift:177-211)
Problem: The function processes lines sequentially and uses a dictionary
map[id] = human. Since Thai translation comes LAST (line 5350), it overwrites the English label.Locale stripping logic exists but doesn't prioritize:
For
th.CNIJMediaType, prefix isth(2 chars, all letters) →looksLikeLocale = true. The stripping works, but the function doesn't skip locale-qualified lines — it just processes them and the last write wins.PPD Evidence (Canon Pro9500 Mark II)
Comparison with ICCery-CPU
ICCery-CPU's
CUPSManager.optionDetails()(Sources/Printing/CUPSManager.swift:312-341) also parses PPD choice lines but:decodePPDString()to handle PPD hex escapes (<2F>→/, etc.)Proposed Fix Options
Option 1: Deterministic locale precedence (Recommended)
Replace last-write-wins in
ppdChoiceLabelswith deterministic precedence — unqualified*Key>en_US>en> first-qualified-seen:map[id] == nilguard) is fragile — it silently depends on base lines preceding locale lines in file orderOption 2: Add Locale Priority Parameter
Accept preferred locale (e.g.,
en,en_US) and prioritize those translations — subsumed by Option 1's fixed precedence unless configurability is needed.Option 3: PPD Encoding + Hex Escape Decoding
loadPPDreads UTF-8 first, ISO-Latin-1 only on decode failure (CupsService.swift:168-171 is currently UTF-8-only viatry?) — a blanket ISO-Latin-1 read would garble this PPD's UTF-8 Thai labels<XX>hex-escape decoding (<2F>→/,<20>→ space) in the label parser — needed for proper PPD parsing anywayAcceptance Criteria
CNIJMediaTypechoice fromlpoptions -lhas a non-Thai label — the 18 known labels below must all appear correctly; hardware verification confirms the true count against the real PPD:Dependencies
References
Sources/Printing/CUPSManager.swift(optionDetails, decodePPDString)Packages/ICCeryCore/Sources/ICCeryCore/Print/CupsParsers.swift(ppdChoiceLabels)Packages/ICCeryCore/Sources/ICCeryCore/Print/CupsService.swift(loadPPD uses UTF-8)Tests/ICCeryCoreTests/CupsParserTests.swift(testPpdLabels)Planning errata (verified on develop@736fd08):
CNIJMediaTypechoice fromlpoptions -lhas a non-Thai label" + spot-check the 18 named; the hardware gate verifies the true count against the real PPD.loadPPDreads UTF-8 first, ISO-Latin-1 only on decode failure (CupsService.swift:168–171 currently UTF-8-only viatry?); add<XX>hex-escape decoding (<2F>→/,<20>→space) in the label parser.*Key>en_US>en> first-qualified-seen — a locale-qualified line never overwrites an unqualified one, and a qualified-only key still gets its first-seen qualified label.Errata above incorporated into the issue body — the ticket itself is now the corrected contract.