Skip to content

hello-world: get_font() called with wrong arity — font manager path is dead code in the template plugin #448

Description

@ChuckBuilds

Summary

hello-world calls FontManager.get_font() with one argument, but the core signature requires two. Every render raises, is swallowed by the surrounding try/except, and the plugin silently falls back to the bundled BDF font. The font-manager path has therefore never executed.

Where

plugins/hello-world/manager.py:148-149 (v1.1.0):

if hasattr(self.plugin_manager, 'font_manager'):
    font_manager = self.plugin_manager.font_manager
    message_font = font_manager.get_font(f"{self.plugin_id}.message")
    time_font = font_manager.get_font(f"{self.plugin_id}.time")
except Exception as e:
    self.logger.warning(f"Error getting fonts from font manager: {e}")

Core (src/font_manager.py:450):

def get_font(self, family: str, size_px: int) -> Union[ImageFont.FreeTypeFont, freetype.Face]:

Reproduction

On a rig with LEDMatrix v3.3.0-4-g0730d952 and hello-world 1.1.0 installed:

cd ~/LEDMatrix
python3 scripts/check_plugin.py -p hello-world -d ~/LEDMatrix/plugin-repos

Output, on every invocation and every size:

Error getting fonts from font manager: FontManager.get_font() missing 1 required positional argument: 'size_px'

=== hello-world ===
  [PASS]   64x32  hello-world
  ...

The renders still [PASS] because the fallback font works — the failure is invisible unless you read the warning line.

Why it matters beyond this plugin

hello-world is the reference/template plugin. The comment block immediately below the broken call explains that "the font manager's face is used when there is one, and the bundled BDF otherwise" — which is documentation of behaviour that cannot happen. Anyone copying this plugin as a starting point copies a call that always throws.

Suggested fix

Pass a pixel size, e.g. derived from the panel height the way other plugins do:

message_font = font_manager.get_font(f"{self.plugin_id}.message", size_px)

and consider narrowing the except Exception so a signature error surfaces instead of being downgraded to a warning that reads like a normal fallback.


Found while installing and validating every catalogued plugin on a 256x64 rig.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions