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

Feature request: loading fonts from SPIFFS/LittleFS #30

Open
marcelstoer opened this issue May 8, 2023 · 4 comments
Open

Feature request: loading fonts from SPIFFS/LittleFS #30

marcelstoer opened this issue May 8, 2023 · 4 comments
Labels
progress: waiting for confirmation and close Waiting for confirmation and close

Comments

@marcelstoer
Copy link

Maybe I didn't quite get it yet but from what I understand OpenFontRender can only load fonts from SD card or binary (i.e. embedded in code).

Working with ESP32 it would be most helpful to be able to load fonts from the internal LittleFS file system.

@infrafast
Copy link

Hello I have same understanding and need. Loading from LittleFS Thanks!

@infrafast
Copy link

Here is the code I've used:

  // Open the font file
  File fontFile = LittleFS.open("/myfont.ttf", "r");
  if (!fontFile) {
    DEBUG_PRINT("Failed to open icon file");
  }

  // Read font file contents into a buffer
  size_t fileSize = fontFile.size();
  uint8_t* fontBuffer = (uint8_t*)malloc(fileSize);
  fontFile.read(fontBuffer, fileSize);
  fontFile.close();
  if (iconOfr.loadFont(fontBuffer, fileSize)) { 
    DEBUG_PRINT("\nIcon Initialise error"); 
  }

hope this helps

@takkaO
Copy link
Owner

takkaO commented May 8, 2024

@marcelstoer , @infrafast

OpenFontRender v1.2 now includes enhanced support for file systems.
Font loading from SPIFFS is also supported and can be enabled simply by using a preset.
Unfortunately, no LittleFS presets are provided yet, but it should be possible to support the LittleFS file system by implementing custom code.
Please see document and sample code for more info.
Welcome your feedback.

Sorry for the crazy slow response.

@takkaO takkaO added the progress: waiting for confirmation and close Waiting for confirmation and close label May 8, 2024
@infrafast
Copy link

Hi thanks a lot, I suggest you enapsulate the code I provided for littleFS in a method of your class then

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
progress: waiting for confirmation and close Waiting for confirmation and close
Projects
None yet
Development

No branches or pull requests

3 participants