Skip to content

Conversation

@mcder017
Copy link

@mcder017 mcder017 commented Dec 8, 2024

...rather than requiring fonts to be loaded through a File handle. New ReadFont method is useful for allowing default built-in font simply using a header file with a defined string constant (e.g. BDF_10X20)

rather than requiring to read from File.  Useful
for allowing default built-in font.
@mcder017
Copy link
Author

Users can then create a header file, such as bdf_10x20_local.h, that has content:

#ifndef BDF_10X20_LOCAL_H
#define BDF_10X20_LOCAL_H
const char* BDF_10X20_STRING = R"BDF_NON_KEYWORD(
---copy-paste the entire bdf font file here, from the STARTFONT line all the way through to the ENDFONT line---
)BDF_NON_KEYWORD";
#endif //BDF_10X20_LOCAL_H

and in the program itself, #include the header file and then load the font programmatically (no file access):

  rgb_matrix::Font smallFont;
  if (!myFont.ReadFont(BDF_10X20_STRING)) {
    fprintf(stderr, "Couldn't read internal font '%s'\n", BDF_10X20_STRING);  // should never happen if bdf font valid when pasted
  }

@mcder017
Copy link
Author

mcder017 commented Mar 26, 2025

@hzeller, merged in the recently approved 1-line change (to respect bbx offset) that WardBrian had resolved.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant