Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method to create Font from (const) string #1737

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

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
  }

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