{"id":15011967,"url":"https://github.com/takkao/openfontrender","last_synced_at":"2026-03-08T02:30:19.460Z","repository":{"id":63669445,"uuid":"393306804","full_name":"takkaO/OpenFontRender","owner":"takkaO","description":"TTF font render support library for microcomputer.","archived":false,"fork":false,"pushed_at":"2024-05-19T08:59:06.000Z","size":3326,"stargazers_count":114,"open_issues_count":18,"forks_count":17,"subscribers_count":6,"default_branch":"master","last_synced_at":"2024-10-14T03:21:04.752Z","etag":null,"topics":["arduino","arduino-ide","esp-idf","esp32","font","freetype2","m5stack","platformio","rp2040","truetype","wioterminal"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/takkaO.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-08-06T08:14:52.000Z","updated_at":"2024-10-11T11:22:49.000Z","dependencies_parsed_at":"2024-05-08T03:29:06.120Z","dependency_job_id":"414d4981-95cc-49ce-896e-58f08aa06fa7","html_url":"https://github.com/takkaO/OpenFontRender","commit_stats":{"total_commits":56,"total_committers":9,"mean_commits":6.222222222222222,"dds":0.7142857142857143,"last_synced_commit":"5100f1f354473c62290e7977bbc74f59363c624f"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takkaO%2FOpenFontRender","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takkaO%2FOpenFontRender/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takkaO%2FOpenFontRender/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/takkaO%2FOpenFontRender/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/takkaO","download_url":"https://codeload.github.com/takkaO/OpenFontRender/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219849223,"owners_count":16556325,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arduino","arduino-ide","esp-idf","esp32","font","freetype2","m5stack","platformio","rp2040","truetype","wioterminal"],"created_at":"2024-09-24T19:41:57.342Z","updated_at":"2026-03-08T02:30:19.392Z","avatar_url":"https://github.com/takkaO.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Open Font Render\r\n\r\nTTF font render support library for microcomputer using Arduino IDE.  \r\nThis library can render TTF font files in the SD card or TTF font files embedded in the program.\r\n\r\nThis program is inspired by [M5FontRender](https://github.com/takkaO/M5FontRender).  \r\n**Any small contribution is welcome.**\r\n\r\n![image](https://github.com/takkaO/OpenFontRender/blob/images/image.jpg?raw=true)\r\n\r\n### Features\r\n\r\n- Available for a variety of hardware using the Arduino IDE\r\n- Draws beautiful, anti-aliased fonts\r\n- Can be loaded from font data embedded in code (no SD card required)\r\n- Can use any drawing library\r\n- Can be changed to any version of FreeType.\r\n\r\n### Installation\r\n\r\nClone this repository into Arduino library folder.\r\n\r\n### API and Usage\r\n\r\nSee **[GitHub Pages](https://takkao.github.io/OpenFontRender/)** for a list of available APIs.\r\nBellow is only a part of the sample code.  \r\nMore detailed examples can be found in [examples](https://github.com/takkaO/OpenFontRender/tree/master/examples).\r\n\r\n#### Load from array (Wio Terminal)\r\n\r\n```cpp\r\n#include \"TFT_eSPI.h\"\r\n#include \"binaryttf.h\"\r\n#include \"OpenFontRender.h\"\r\n\r\nTFT_eSPI tft;\r\nOpenFontRender render;\r\n\r\nvoid setup()\r\n{\r\n\t// put your setup code here, to run once:\r\n\tSerial.begin(115200);\r\n\tSerial.flush();\r\n\tdelay(50);\r\n\r\n\ttft.begin();\r\n\ttft.setRotation(3);\r\n\ttft.fillScreen(TFT_BLACK);\r\n\tdigitalWrite(LCD_BACKLIGHT, HIGH); // turn on the backlight\r\n\r\n\trender.setSerial(Serial);\t  // Need to print render library message\r\n\trender.showFreeTypeVersion(); // print FreeType version\r\n\trender.showCredit();\t\t  // print FTL credit\r\n\r\n\tif (render.loadFont(binaryttf, sizeof(binaryttf)))\r\n\t{\r\n\t\tSerial.println(\"Render initialize error\");\r\n\t\treturn;\r\n\t}\r\n\r\n\trender.setDrawer(tft); // Set drawer object\r\n\t/* You can also be written as follows. */\r\n\t// render.setDrawPixel(tft.drawPixel);\r\n\t// render.setDrawFastHLine(tft.drawFastHLine); // optional\r\n\t// render.setStartWrite(tft.startWrite);       // optional\r\n\t// render.setEndWrite(tft.endWrite);           // optional\r\n\r\n\tunsigned long t_start = millis();\r\n\r\n\trender.setFontColor(TFT_WHITE);\r\n\trender.printf(\"Hello World\\n\");\r\n\trender.seekCursor(0, 10);\r\n\r\n\trender.setFontSize(30);\r\n\trender.setFontColor(TFT_GREEN);\r\n\trender.printf(\"完全なUnicodeサポート\\n\");\r\n\trender.seekCursor(0, 10);\r\n\r\n\trender.setFontSize(40);\r\n\trender.setFontColor(TFT_ORANGE);\r\n\trender.printf(\"こんにちは世界\\n\");\r\n\r\n\tunsigned long t_end = millis();\r\n\tSerial.printf(\"Time: %ld ms\\n\", t_end - t_start);\r\n}\r\n\r\nvoid loop()\r\n{\r\n\t// put your main code here, to run repeatedly:\r\n}\r\n```\r\n\r\n#### Load from SD card (M5Stack)\r\n\r\n```cpp\r\n#include \u003cArduino.h\u003e\r\n#include \u003cM5Unified.h\u003e\r\n#include \u003cSD.h\u003e\r\n\r\n#include \"OpenFontRender.h\"\t\t\t // Include after M5Unified.h\r\n#include \"ofrfs/M5Stack_SD_Preset.h\" // Use preset\r\n\r\nOpenFontRender render;\r\n\r\nvoid setup()\r\n{\r\n\t// put your setup code here, to run once:\r\n\tauto cfg = M5.config();\r\n\tM5.begin(cfg);\r\n\tM5.Display.fillScreen(TFT_BLACK);\r\n\r\n\tSD.begin(GPIO_NUM_4, SPI, 40000000);\r\n\r\n\trender.setSerial(Serial);\t  // Need to print render library message\r\n\trender.showFreeTypeVersion(); // print FreeType version\r\n\trender.showCredit();\t\t  // print FTL credit\r\n\r\n\tif (render.loadFont(\"/JKG-M_3_Tiny.ttf\"))\r\n\t{\r\n\t\tSerial.println(\"Render initialize error\");\r\n\t\treturn;\r\n\t}\r\n\r\n\trender.setDrawer(M5.Display); // Set drawer object\r\n\t/* You can also be written as follows. */\r\n\t// render.setDrawPixel(M5.Display.drawPixel);\r\n\t// render.setDrawFastHLine(M5.Display.drawFastHLine); // optional\r\n\t// render.setStartWrite(M5.Display.startWrite);       // optional\r\n\t// render.setEndWrite(M5.Display.endWrite);           // optional\r\n\r\n\tunsigned long t_start = millis();\r\n\r\n\trender.setFontColor(TFT_WHITE);\r\n\trender.printf(\"Hello World\\n\");\r\n\trender.seekCursor(0, 10);\r\n\r\n\trender.setFontSize(30);\r\n\trender.setFontColor(TFT_GREEN);\r\n\trender.printf(\"完全なUnicodeサポート\\n\");\r\n\trender.seekCursor(0, 10);\r\n\r\n\trender.setFontSize(40);\r\n\trender.setFontColor(TFT_ORANGE);\r\n\trender.printf(\"こんにちは世界\\n\");\r\n\r\n\tunsigned long t_end = millis();\r\n\tSerial.printf(\"Time: %ld ms\\n\", t_end - t_start);\r\n}\r\n\r\nvoid loop()\r\n{\r\n\t// put your main code here, to run repeatedly:\r\n}\r\n\r\n```\r\n\r\n### How to create binary TTF file\r\n\r\nWe use [binary2ttf.py]([/tools/ttf2bin/ttf2bin.py](https://github.com/takkaO/OpenFontRender/blob/master/tools/ttf2bin/ttf2bin.py)) in tools directory to create binary TTF font file.  \r\nThe `binary2ttf.py` is provided in the [M5EPD](https://github.com/m5stack/M5EPD/tree/main/tools/ttf2bin) library.\r\nThe same program is included in `tools` directory in this repo.  \r\nYou only execute below command.\r\n\r\n```sh\r\npython3 binary2ttf.py your_font_file.ttf\r\n```\r\n\r\n### Switch draw function\r\n\r\nIn this library, you can change the drawing-related operations to your favorite functions (e.g. LavyonGFX).  \r\nTo change it, use the following function.\r\n\r\n```cpp\r\nrender.setDrawPixel(my_draw_function);         // necessary\r\n\r\nrender.setDrawFastHLine(my_draw_fast_h_line);  // optional\r\nrender.setStartWrite(my_start_write_function); // optional\r\nrender.setEndWrite(my_end_write_function);     // optional\r\n```\r\n\r\nIf you have an object for drawing and it contains the necessary methods, you can also use `setDrawer` method instead.\r\n\r\n```cpp\r\nrender.setDrawer(my_draw_object);\t// Set drawer object\r\n```\r\n\r\n### Switch other FreeType version\r\n\r\nYou can switch to any FreeType version in this library.  \r\nWe have confirmed that it works with 2.4.12 and 2.12.1.  \r\nDefault version is 2.4.12 because it was the version that worked most stably.\r\n\r\n#### How to switch\r\n\r\n1. Download the version of FreeType that you like.\r\n2. Place the downloaded FreeType folder directly under OpenFontRender.\r\n3. Execute `AutoRun` script.\r\n\r\n#### Note\r\n\r\nIf you are using FreeRTOS, some versions may become unstable.  \r\nYou may have to increase the stack size or enable `useRenderTask` to get it to work.\r\n\r\n### How to load font files from SD/TF cards, SPIFFS, and so on\r\n\r\nControl of file systems such as SD/TF cards and SPIFFS is strongly hardware-dependent.\r\nOpenFontRender supports the following reads as presets.\r\n\r\n- M5Stack\r\n  - SD/TF (`ofrfs/M5Stack_SD_Preset.h`)\r\n  - SPIFFS (`ofrfs/M5Stack_SPIFFS_Preset.h`)\r\n- Wio Terminal\r\n  - SD/TF (`ofrfs/WioTerminal_SD_Preset.h`)\r\n\r\nIf you want to load font file from unsupported file system, \r\nyou will need to overwrite some functions on the user code.\r\n\r\nSee the documentation for details on how to overwrite them.\r\nIf you created a new preset, it would be great if you could provide us with the code.\r\n\r\n### Test\r\n\r\n#### Tested Hardware\r\n\r\nThis library has been tested on the following hardware.  \r\nWe would be happy to receive reports on hardware not listed here.\r\n\r\n- Arduino IDE 2.0\r\n  - Seeed SAMD Boards (Board Manager v1.8.3)\r\n    - Wio Terminal\r\n  - M5Stack (Board Manager v2.0.4)\r\n    - M5Stack Basic (Library v0.1.4)\r\n    - M5Stack Core2 (Library v0.4.0)\r\n- PlatformIO\r\n  - M5Stack Basic (Library v2.0.4)\r\n  - M5Stack Core2 (Library v2.0.4)\r\n- ESP-IDF (4.4)\r\n  - M5Stack Basic\r\n\r\n#### Rendering speed\r\n\r\nThe table below shows the time taken to draw the sample program when it was run.\r\nNote: the time depends on the hardware settings or font file, so this is for reference only.\r\n\r\n|               | Load from SD | Load from array | Load from array \u003cbr\u003e (Use LavyonGFX) |\r\n| ------------- | :----------: | :-------------: | :----------------------------------: |\r\n| Wio Terminal  |    576 ms    |     491 ms      |                405 ms                |\r\n| M5Stack Basic |    227 ms    |     230 ms      |                98 ms                 |\r\n| M5Stack Core2 |    346 ms    |     281 ms      |                148 ms                |\r\n\r\n### LICENSE\r\n\r\nThis library is provided under the FTL license.  \r\nIt is a BSD-style license with a credit clause.  \r\nAll programs and binaries created using this library must be credited (as shown at the bottom of this README).\r\n\r\nHowever, some files that are not related to FreeType can be used under the MIT license (See each files).\r\n\r\nFor more information about FTL licenses, see [FTL.TXT](https://github.com/takkaO/OpenFontRender/blob/master/FTL.TXT) in this repository or [FreeType Licenses](https://www.freetype.org/license.html).\r\n\r\n#### Sample font\r\n\r\nWe have used below font file for the sample program.  \r\nWe would like to thank sozai-font-hako for providing us with an easy-to-use license for these wonderful fonts.\r\n\r\n| Font                                                         | Copyright                                                            |\r\n| ------------------------------------------------------------ | -------------------------------------------------------------------- |\r\n| [JK Gothic M](http://font.cutegirl.jp/jk-font-medium.html#i) | Copyright (c) 2014 M+ FONTS PROJECT \u003cbr\u003e Copyright (c) 2015 JK FONTS |\r\n\r\n---\r\n\r\nPortions of this software are copyright © The FreeTypeProject (www.freetype.org). All rights reserved.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakkao%2Fopenfontrender","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftakkao%2Fopenfontrender","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftakkao%2Fopenfontrender/lists"}