Skip to content

Commit 31aa735

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 31aa735

File tree

8 files changed

+47
-66
lines changed

8 files changed

+47
-66
lines changed

.github/workflows/gh-pages.yml

Lines changed: 26 additions & 47 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,16 +17,17 @@ 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:
2324
TZ: 'Asia/Tokyo' # Set timezone
2425
run: echo "CURRENT_DATETIME=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV
2526

2627
- name: Checkout code
27-
uses: actions/checkout@v3
28+
uses: actions/checkout@v4
2829
with:
30+
submodules: recursive
2931
fetch-depth: 0
3032

3133
- name: Set git-configs
@@ -34,36 +36,20 @@ jobs:
3436
git config user.email github-actions@github.com
3537
git config push.default current
3638
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-
5639
- name: Load environment variables from .env file
5740
run: |
5841
for line in $(grep -v '^#' ./doxygen/.env.pages); do
5942
echo $line >> $GITHUB_ENV
6043
done
6144
6245
# - name: check env
63-
# run: printenv
46+
# run: ls -a
47+
48+
# - name: check env
49+
# run: cat .gitmodules
6450

65-
- name: Update submodules
66-
run: git submodule update --init -- "doxygen/doxygen-awesome-css"
51+
# - name: Update submodules
52+
# run: git submodule update --init "jothepro/doxygen-awesome-css"
6753

6854
- name: Make document (run docker compose)
6955
run: docker compose --env-file .env.pages up && docker compose down
@@ -77,26 +63,19 @@ jobs:
7763
sudo chown -R runner:docker ./$DOXYGEN_HTML_OUTPUT_DIR
7864
sudo chown -R runner:docker ./xml
7965
80-
- name: Add Stash
81-
run: |
82-
git add ./$DOXYGEN_HTML_OUTPUT_DIR
83-
git stash push -- ./$DOXYGEN_HTML_OUTPUT_DIR
66+
- name: Back directory
67+
run: cp -r ./$DOXYGEN_HTML_OUTPUT_DIR ~/backup
8468

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-
69+
- name: Reset All
70+
run: git checkout .
71+
72+
- name: Switch branch
73+
run: | # ブランチが無い場合は新規作成し、ある場合は切り替える
74+
git switch ${{ env.DOCUMENT_BRANCH }} 2>/dev/null || git switch --orphan ${{ env.DOCUMENT_BRANCH }}
75+
76+
- name: Restore directory
77+
run: cp -rf ~/backup/* ./$DOXYGEN_HTML_OUTPUT_DIR
78+
10079
- name: Commit and push
10180
continue-on-error: true
10281
run: |
@@ -117,7 +96,7 @@ jobs:
11796
url: ${{ steps.deployment.outputs.page_url }}
11897
steps:
11998
- name: Checkout
120-
uses: actions/checkout@v3
99+
uses: actions/checkout@v4
121100
with:
122101
fetch-depth: 0
123102

@@ -131,21 +110,21 @@ jobs:
131110
run: git switch ${{ env.DOCUMENT_BRANCH }}
132111

133112
- name: Setup Pages
134-
uses: actions/configure-pages@v3
113+
uses: actions/configure-pages@v4
135114

136115
# - name: check env
137116
# run: printenv
138117

139118
- name: Upload artifact
140-
uses: actions/upload-pages-artifact@v1
119+
uses: actions/upload-pages-artifact@v3
141120
with:
142121
# Upload entire repository
143122
path: ${{ env.DOXYGEN_HTML_OUTPUT_DIR }}
144123
#path: "./testpages"
145124

146125
- name: Deploy to GitHub Pages
147126
id: deployment
148-
uses: actions/deploy-pages@v2
127+
uses: actions/deploy-pages@v4
149128

150129

151130

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)