@@ -435,16 +435,16 @@ FT_Error OpenFontRender::loadFont(const unsigned char *data, size_t size, uint8_
435435 * @param[in] (target_face_index) Load font index. Default is 0.
436436 * @return FreeType error code. 0 is success.
437437 * @ingroup rendering_api
438- * @note SD card access is strongly hardware dependent, so for hardware other than M5Stack and Wio Terminal,
439- * @note you will need to add file manipulation functions to FileSupport.cpp/.h .
438+ * @note SD card access is strongly hardware dependent, so you will need to include preset in `ofrfs` or
439+ * @note implement custom file I/O code (see Manuals) .
440440 * @note Any better solutions are welcome.
441441 */
442442FT_Error OpenFontRender::loadFont (const char *fpath, uint8_t target_face_index) {
443- size_t len = strlen (fpath);
443+ size_t len = strlen (fpath) + 1 ; // +1 is for NULL character because strlen do not include NULL character
444444
445- _face_id.filepath = new char [len + 1 ] ; // Release on unloadFont method
445+ _face_id.filepath = new char [len]() ; // Release on unloadFont method
446446 strncpy (_face_id.filepath , fpath, len);
447- _face_id.filepath [len] = ' \0 ' ;
447+ _face_id.filepath [len - 1 ] = ' \0 ' ; // Not required but explicitly stated.
448448
449449 _face_id.face_index = target_face_index;
450450 return loadFont (OFR::FROM_FILE);
@@ -650,7 +650,7 @@ uint16_t OpenFontRender::drawHString(
650650 break ;
651651 }
652652
653- abbox.yMin = std::min (abbox.yMin , baseline_y - ascender);
653+ abbox.yMin = std::min (abbox.yMin , static_cast <FT_Pos>( baseline_y - ascender) );
654654 std::vector<std::pair<int32_t , int32_t >> linePositions; // To store starting positions for each line
655655
656656 // calculate x postion for each line.
@@ -768,7 +768,7 @@ uint16_t OpenFontRender::drawHString(
768768 }
769769
770770 }
771- abbox.yMax = std::max (abbox.yMax , baseline_y + descender);
771+ abbox.yMax = std::max (abbox.yMax , static_cast <FT_Pos>( baseline_y + descender) );
772772 }
773773 return chars_written;
774774}
0 commit comments