Skip to content

improve: Expand MDI icon set to 7,447 icons (MDI v7.4.47)#101

Merged
edwardtfn merged 12 commits intomainfrom
v9999.99.9
Apr 7, 2026
Merged

improve: Expand MDI icon set to 7,447 icons (MDI v7.4.47)#101
edwardtfn merged 12 commits intomainfrom
v9999.99.9

Conversation

@edwardtfn
Copy link
Copy Markdown
Owner

@edwardtfn edwardtfn commented Apr 6, 2026

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 all three components: ESPHome firmware, TFT, and Blueprint automation.

Existing button configurations continue to work without modification.

Summary by CodeRabbit

  • New Features

    • Introduced Material Design Icons font building system for enhanced icon management and generation
  • Bug Fixes

    • Enhanced input validation for display parameters with stricter numeric validation
  • Chores

    • Updated application versions across interface files
    • Refined button initialization and styling order across UI pages

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.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 6, 2026

📝 Walkthrough

Walkthrough

A 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

Cohort / File(s) Summary
Icon font build infrastructure
.github/scripts/build_mdi_fonts.py, .github/scripts/build_mdi_fonts.sh
New Python script provides CLI to read SVG inputs, detect MDI version, build TTF font, compute ZI codepoint mappings, and generate all_icons.json, cheatsheet.html, and C++ header artifacts. Bash wrapper validates prerequisites and orchestrates the Python script invocation with computed paths.
C++ icon integration
components/nspanel_easy/addon_climate.h, components/nspanel_easy/nextion_constants.h
Headers now include auto-generated all_icons.h and migrate explicit MDI icon constants into that file. Nextion constants now define special icon aliases (MDI_NONE, MDI_BLANK, MDI_VOID, MDI_UNKNOWN, MDI_UNAVAILABLE) locally while importing remaining icon definitions from all_icons.h.
Documentation reference
docs/blueprint.md
Updated icon source reference from "HASwitchPlate Material Design Icons" to "NSPanel-Easy Material Design Icons."
YAML parameter validation
esphome/nspanel_esphome_page_boot.yaml
Replaced atoi()-based parsing with strict strtoul()-based validation for display_mode and display_charset, explicitly checking full string consumption and uint8_t bounds.
HMI version and styling
hmi/dev/nspanel_CJK_*_code/boot.txt, hmi/dev/nspanel_*/boot.txt, hmi/dev/nspanel_CJK_*_code/buttonpage0[1-4].txt
Version attribute incremented across all HMI boot files (text size/max limits adjusted in CJK variants). Button back-font assignments moved from conditional (within theme==1 blocks) to unconditional placement, decoupling font setting from theme-dependent styling.

Sequence Diagram

sequenceDiagram
    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
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

Possibly related PRs

  • Fix: Render issues on button pages #94: Modifies the same HMI button page files (hmi/dev/*/buttonpage*.txt), reordering button styling and visibility assignments in parallel with this PR's font and theme changes.
  • Bug fixes: QR code page and Bluetooth icon #70: Updates nextion_constants.h icon and color constant declarations, directly intersecting with this PR's migration of icon definitions into auto-generated all_icons.h.

Poem

🐰 Hopping through glyphs, we build fonts so fine,
SVG to TTF, each icon must shine,
C++ headers dance, auto-generated with care,
Button styles unified, no theme despair!

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 75.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately summarizes the main change: expanding the MDI icon set from 6,933 to 7,447 icons (MDI v7.4.47), which is reflected throughout the changeset including new build scripts, header generation, and version updates.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch v9999.99.9

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@edwardtfn edwardtfn linked an issue Apr 6, 2026 that may be closed by this pull request
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 2dd0ecb and 14ee756.

⛔ Files ignored due to path filters (1)
  • docs/icons/MaterialDesignIconsDesktop-7.4.47.ttf is excluded by !**/*.ttf
📒 Files selected for processing (45)
  • .github/scripts/build_mdi_fonts.py
  • .github/scripts/build_mdi_fonts.sh
  • components/nspanel_easy/addon_climate.h
  • components/nspanel_easy/all_icons.h
  • components/nspanel_easy/nextion_constants.h
  • docs/blueprint.md
  • docs/icons/all_icons.json
  • docs/icons/cheatsheet.html
  • docs/icons/mdi_cheatsheet.html
  • docs/icons/mdi_icons.json
  • esphome/nspanel_esphome_page_boot.yaml
  • hmi/dev/nspanel_CJK_eu_code/boot.txt
  • hmi/dev/nspanel_CJK_eu_code/buttonpage01.txt
  • hmi/dev/nspanel_CJK_eu_code/buttonpage02.txt
  • hmi/dev/nspanel_CJK_eu_code/buttonpage03.txt
  • hmi/dev/nspanel_CJK_eu_code/buttonpage04.txt
  • hmi/dev/nspanel_CJK_us_code/boot.txt
  • hmi/dev/nspanel_CJK_us_code/buttonpage01.txt
  • hmi/dev/nspanel_CJK_us_code/buttonpage02.txt
  • hmi/dev/nspanel_CJK_us_code/buttonpage03.txt
  • hmi/dev/nspanel_CJK_us_code/buttonpage04.txt
  • hmi/dev/nspanel_CJK_us_land_code/boot.txt
  • hmi/dev/nspanel_CJK_us_land_code/buttonpage01.txt
  • hmi/dev/nspanel_CJK_us_land_code/buttonpage02.txt
  • hmi/dev/nspanel_CJK_us_land_code/buttonpage03.txt
  • hmi/dev/nspanel_CJK_us_land_code/buttonpage04.txt
  • hmi/dev/nspanel_easy_landscape/boot.txt
  • hmi/dev/nspanel_eu_code/boot.txt
  • hmi/dev/nspanel_us_code/boot.txt
  • hmi/dev/nspanel_us_land_code/boot.txt
  • hmi/nspanel_CJK_eu.HMI
  • hmi/nspanel_CJK_eu.tft
  • hmi/nspanel_CJK_us.HMI
  • hmi/nspanel_CJK_us.tft
  • hmi/nspanel_CJK_us_land.HMI
  • hmi/nspanel_CJK_us_land.tft
  • hmi/nspanel_easy_landscape.hmi
  • hmi/nspanel_easy_landscape.tft
  • hmi/nspanel_eu.HMI
  • hmi/nspanel_eu.tft
  • hmi/nspanel_us.HMI
  • hmi/nspanel_us.tft
  • hmi/nspanel_us_land.HMI
  • hmi/nspanel_us_land.tft
  • nspanel_easy_blueprint.yaml

@edwardtfn edwardtfn changed the title feat: expand MDI icon set to 7,447 icons (MDI v7.4.47) feat: Expand MDI icon set to 7,447 icons (MDI v7.4.47) Apr 6, 2026
@edwardtfn edwardtfn changed the title feat: Expand MDI icon set to 7,447 icons (MDI v7.4.47) improve: Expand MDI icon set to 7,447 icons (MDI v7.4.47) Apr 6, 2026
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
@edwardtfn edwardtfn enabled auto-merge April 7, 2026 00:25
@edwardtfn edwardtfn merged commit a15e037 into main Apr 7, 2026
42 checks passed
@edwardtfn edwardtfn deleted the v9999.99.9 branch April 7, 2026 00:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug Climate page does not show icon of entities

1 participant