improve: Expand MDI icon set to 7,447 icons (MDI v7.4.47)#101
improve: Expand MDI icon set to 7,447 icons (MDI v7.4.47)#101
Conversation
The panel now supports the full MDI v7.4.47 icon set — 514 more icons than before, including icons that were previously unavailable such as `mdi:thermostat-auto`. ## What changed - TFT fonts rebuilt from the complete MDI v7.4.47 SVG source, expanding coverage from 6,933 to 7,447 icons across all three font sizes (24px, 32px, 48px) - Blueprint icon translation table updated to reflect the new icon set - Icon cheatsheet published at https://edwardtfn.github.io/NSPanel-Easy/icons/cheatsheet.html ## Upgrading Update your Blueprint automation to pick up the new icon table. No other changes needed — existing button configurations continue to work without modification.
📝 WalkthroughWalkthroughA Material Design Icon font build system is introduced via new Python and Bash scripts that generate TTF fonts and related artifacts (C++ headers, JSON mappings, HTML cheatsheets). Generated icon definitions are integrated into C++ headers. HMI files are updated with version bumps and button styling reordering, and display parameter validation is hardened. Changes
Sequence DiagramsequenceDiagram
participant User
participant BuildScript as build_mdi_fonts.py
participant FileSystem as File System
participant FontTools as fonttools/cu2qu
participant OutputDir as Output Directory
User->>BuildScript: Invoke with SVG directory & output paths
BuildScript->>FileSystem: Read meta.json & SVG files
FileSystem-->>BuildScript: Icon metadata & SVG path data
BuildScript->>BuildScript: Detect MDI version from package.json/font-build.json
BuildScript->>FontTools: Convert SVG paths → TTF glyphs (with Y-flip)
FontTools-->>BuildScript: TTF with glyphs & codepoints
BuildScript->>BuildScript: Compute ZI codepoints (ttf_codepoint - 0xE2001)
BuildScript->>OutputDir: Write all_icons.json (icon lookup table)
BuildScript->>OutputDir: Write cheatsheet.html (searchable icon grid)
BuildScript->>OutputDir: Write all_icons.h (C++ constexpr constants)
OutputDir-->>User: Font artifacts & derived files ready
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In @.github/scripts/build_mdi_fonts.py:
- Around line 451-452: The code calls max(len(c) for c in const_names.values())
which will raise ValueError when const_names (the icon map) is empty; add an
explicit guard before computing max: check if const_names is empty (or if not
any values) and raise a clear ValueError (or log and exit) describing "empty
icon map / no icons to build" so the failure is early and informative, then only
compute max_len = max(len(c) for c in const_names.values()) when the guard
passes.
- Around line 237-243: The script currently only prints warnings for glyph
conversion failures (the failed list printed in the block that iterates over
failed), which lets bad batches produce blank artifacts; change this so
unexpected failures cause a non-zero exit: after printing the failure summary
for the failed list, check against an allowlist (if you want known exceptions)
and if any remaining failures exist call sys.exit(1) or raise a RuntimeError to
fail the build; update the logic around the variable failed (and the summary
print block) to perform this check and exit rather than silently continuing.
In `@docs/blueprint.md`:
- Line 14: The link text "[NSPanel-Easy Material Design Icons]" currently points
to the old HASP font cheatsheet URL; update the href target for that link in
docs/blueprint.md so it points to the new NSPanel-Easy cheatsheet URL (replace
the existing
"https://htmlpreview.github.io/?https://github.com/jobr99/Generate-HASP-Fonts/blob/master/cheatsheet.html"
target with the new cheatsheet URL while keeping the link text unchanged).
In `@esphome/nspanel_esphome_page_boot.yaml`:
- Around line 66-77: The current strtoul() usage in parsing params[2]/params[3]
(parsed_mode/parsed_charset -> display_mode/display_charset) allows leading
whitespace and sign characters despite the intended strict validation; before
calling strtoul(), explicitly validate that params[2] and params[3] are
non-empty and consist solely of ASCII digits (no '+'/'-' or whitespace) — e.g.,
iterate the string and ensure isdigit() for every character — and only then call
strtoul() and perform the existing end/limit checks; if the digit-only precheck
fails, treat as invalid and set display_mode/display_charset to 0.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 548f9682-9d59-47d9-83d4-5a1889b0e0d3
⛔ Files ignored due to path filters (1)
docs/icons/MaterialDesignIconsDesktop-7.4.47.ttfis excluded by!**/*.ttf
📒 Files selected for processing (45)
.github/scripts/build_mdi_fonts.py.github/scripts/build_mdi_fonts.shcomponents/nspanel_easy/addon_climate.hcomponents/nspanel_easy/all_icons.hcomponents/nspanel_easy/nextion_constants.hdocs/blueprint.mddocs/icons/all_icons.jsondocs/icons/cheatsheet.htmldocs/icons/mdi_cheatsheet.htmldocs/icons/mdi_icons.jsonesphome/nspanel_esphome_page_boot.yamlhmi/dev/nspanel_CJK_eu_code/boot.txthmi/dev/nspanel_CJK_eu_code/buttonpage01.txthmi/dev/nspanel_CJK_eu_code/buttonpage02.txthmi/dev/nspanel_CJK_eu_code/buttonpage03.txthmi/dev/nspanel_CJK_eu_code/buttonpage04.txthmi/dev/nspanel_CJK_us_code/boot.txthmi/dev/nspanel_CJK_us_code/buttonpage01.txthmi/dev/nspanel_CJK_us_code/buttonpage02.txthmi/dev/nspanel_CJK_us_code/buttonpage03.txthmi/dev/nspanel_CJK_us_code/buttonpage04.txthmi/dev/nspanel_CJK_us_land_code/boot.txthmi/dev/nspanel_CJK_us_land_code/buttonpage01.txthmi/dev/nspanel_CJK_us_land_code/buttonpage02.txthmi/dev/nspanel_CJK_us_land_code/buttonpage03.txthmi/dev/nspanel_CJK_us_land_code/buttonpage04.txthmi/dev/nspanel_easy_landscape/boot.txthmi/dev/nspanel_eu_code/boot.txthmi/dev/nspanel_us_code/boot.txthmi/dev/nspanel_us_land_code/boot.txthmi/nspanel_CJK_eu.HMIhmi/nspanel_CJK_eu.tfthmi/nspanel_CJK_us.HMIhmi/nspanel_CJK_us.tfthmi/nspanel_CJK_us_land.HMIhmi/nspanel_CJK_us_land.tfthmi/nspanel_easy_landscape.hmihmi/nspanel_easy_landscape.tfthmi/nspanel_eu.HMIhmi/nspanel_eu.tfthmi/nspanel_us.HMIhmi/nspanel_us.tfthmi/nspanel_us_land.HMIhmi/nspanel_us_land.tftnspanel_easy_blueprint.yaml
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
The panel now supports the full MDI v7.4.47 icon set — 514 more icons than before, including icons that were previously unavailable such as
mdi:thermostat-auto.What changed
Upgrading
Update all three components: ESPHome firmware, TFT, and Blueprint automation.
Existing button configurations continue to work without modification.
Summary by CodeRabbit
New Features
Bug Fixes
Chores