Skip to content

Commit 5def478

Browse files
committed
[fix] fix OpenFontRender.cpp
- patch for #45 - update github-actions - update library version - fix example bug - modify document - tweak fix
1 parent 3f66dfb commit 5def478

File tree

8 files changed

+36
-62
lines changed

8 files changed

+36
-62
lines changed

.github/workflows/gh-pages.yml

Lines changed: 15 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- master
7+
workflow_dispatch:
78

89
env:
910
## コンテキスト
@@ -16,7 +17,7 @@ jobs:
1617
actions: write
1718
checks: write
1819
contents: write
19-
runs-on: ubuntu-22.04
20+
runs-on: ubuntu-24.04
2021
steps:
2122
- name: Set current datetime as env variable
2223
env:
@@ -34,25 +35,6 @@ jobs:
3435
git config user.email [email protected]
3536
git config push.default current
3637
37-
- name: Set whether the branch is already existing to GITHUB_ENV
38-
run: |
39-
branch_is_existing=$(
40-
git fetch origin ${{ env.DOCUMENT_BRANCH }} &&
41-
echo true ||
42-
echo false
43-
)
44-
echo "BRANCH_IS_EXISTING=${branch_is_existing}" >> $GITHUB_ENV
45-
46-
- name: Create branch if not exist
47-
if: env.BRANCH_IS_EXISTING == 'false'
48-
run: |
49-
git switch --orphan ${{ env.DOCUMENT_BRANCH }}
50-
touch .gitkeep
51-
git add .gitkeep
52-
git commit -m "initial commit"
53-
git push
54-
git switch master
55-
5638
- name: Load environment variables from .env file
5739
run: |
5840
for line in $(grep -v '^#' ./doxygen/.env.pages); do
@@ -63,7 +45,7 @@ jobs:
6345
# run: printenv
6446

6547
- name: Update submodules
66-
run: git submodule update --init -- "doxygen/doxygen-awesome-css"
48+
run: git submodule update --init -- "jothepro/doxygen-awesome-css"
6749

6850
- name: Make document (run docker compose)
6951
run: docker compose --env-file .env.pages up && docker compose down
@@ -77,26 +59,16 @@ jobs:
7759
sudo chown -R runner:docker ./$DOXYGEN_HTML_OUTPUT_DIR
7860
sudo chown -R runner:docker ./xml
7961
80-
- name: Add Stash
81-
run: |
82-
git add ./$DOXYGEN_HTML_OUTPUT_DIR
83-
git stash push -- ./$DOXYGEN_HTML_OUTPUT_DIR
62+
- name: Back directory
63+
run: cp -r ./$DOXYGEN_HTML_OUTPUT_DIR ~/backup
8464

85-
- name: Reset changes
86-
run: git reset --hard
87-
88-
- name: Switch to document branch
89-
run: git switch ${{ env.DOCUMENT_BRANCH }}
90-
91-
- name: Remove unnecessary files
92-
run: git clean -df
93-
94-
# - name: ls
95-
# run: ls -all
96-
97-
- name: Apply stash
98-
run: git checkout stash -- ./$DOXYGEN_HTML_OUTPUT_DIR
99-
65+
- name: Switch branch
66+
run: | # ブランチが無い場合は新規作成し、ある場合は切り替える
67+
git switch ${{ env.DOCUMENT_BRANCH }} 2>/dev/null || git switch --orphan ${{ env.DOCUMENT_BRANCH }}
68+
69+
- name: Restore directory
70+
run: cp -rf ~/backup/* ./$DOXYGEN_HTML_OUTPUT_DIR
71+
10072
- name: Commit and push
10173
continue-on-error: true
10274
run: |
@@ -131,21 +103,21 @@ jobs:
131103
run: git switch ${{ env.DOCUMENT_BRANCH }}
132104

133105
- name: Setup Pages
134-
uses: actions/configure-pages@v3
106+
uses: actions/configure-pages@v4
135107

136108
# - name: check env
137109
# run: printenv
138110

139111
- name: Upload artifact
140-
uses: actions/upload-pages-artifact@v1
112+
uses: actions/upload-artifact@v4
141113
with:
142114
# Upload entire repository
143115
path: ${{ env.DOXYGEN_HTML_OUTPUT_DIR }}
144116
#path: "./testpages"
145117

146118
- name: Deploy to GitHub Pages
147119
id: deployment
148-
uses: actions/deploy-pages@v2
120+
uses: actions/deploy-pages@v4
149121

150122

151123

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,8 @@ We would be happy to receive reports on hardware not listed here.
231231
- M5Stack (Board Manager v2.0.4)
232232
- M5Stack Basic (Library v0.1.4)
233233
- M5Stack Core2 (Library v0.4.0)
234+
- STM32
235+
- STM32H750 (by wystewart #34)
234236
- PlatformIO
235237
- M5Stack Basic (Library v2.0.4)
236238
- M5Stack Core2 (Library v2.0.4)

doxygen/.env.pages

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
DOXYGEN_HTML_OUTPUT_DIR=testpages
1+
DOXYGEN_HTML_OUTPUT_DIR=docs

examples/WioTerminal/alignment_string/alignment_string.ino

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,11 @@ void loop()
110110

111111
void refreshGridLine()
112112
{
113-
M5.Lcd.fillScreen(TFT_BLACK);
114-
M5.Lcd.drawFastVLine(10, 0, 240, TFT_DARKGREY);
115-
M5.Lcd.drawFastVLine(160, 0, 240, TFT_DARKGREY);
116-
M5.Lcd.drawFastVLine(310, 0, 240, TFT_DARKGREY);
117-
M5.Lcd.drawFastHLine(0, 30, 320, TFT_DARKGREY);
118-
M5.Lcd.drawFastHLine(0, 120, 320, TFT_DARKGREY);
119-
M5.Lcd.drawFastHLine(0, 210, 320, TFT_DARKGREY);
113+
tft.fillScreen(TFT_BLACK);
114+
tft.drawFastVLine(10, 0, 240, TFT_DARKGREY);
115+
tft.drawFastVLine(160, 0, 240, TFT_DARKGREY);
116+
tft.drawFastVLine(310, 0, 240, TFT_DARKGREY);
117+
tft.drawFastHLine(0, 30, 320, TFT_DARKGREY);
118+
tft.drawFastHLine(0, 120, 320, TFT_DARKGREY);
119+
tft.drawFastHLine(0, 210, 320, TFT_DARKGREY);
120120
}

manuals/HOW_TO_OVERWRITE_FS_FUNC.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
# How to load font files from file system {#tests_testa}
2+
# How to load font files from file system {#how_to_load_font_files_from_file_system}
33

44
Control of file systems such as SD/TF cards and SPIFFS is strongly hardware-dependent.
55
OpenFontRender supports the following reads as presets.

manuals/pages.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# Manuals
22

3-
@subpage tests_testa
3+
@subpage how_to_load_font_files_from_file_system

src/OpenFontRender.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -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
*/
442442
FT_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
}

src/OpenFontRender.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,8 +182,8 @@ namespace OFR {
182182

183183
class OpenFontRender {
184184
public:
185-
static const unsigned char MAIN_VERSION = 1; ///< Open Font Render library main version.
186-
static const unsigned char MINOR_VERSION = 2; ///< Open Font Render library minor version.
185+
static const unsigned char MAIN_VERSION = 2; ///< Open Font Render library main version.
186+
static const unsigned char MINOR_VERSION = 0; ///< Open Font Render library minor version.
187187

188188
static const unsigned char CACHE_SIZE_NO_LIMIT = 0; ///< FreeType cache size alias.
189189
static const unsigned char CACHE_SIZE_MINIMUM = 1; ///< FreeType cache size alias.

0 commit comments

Comments
 (0)