Skip to content

Commit

Permalink
Added Noto Sans Arabic
Browse files Browse the repository at this point in the history
Added a font for Arabic, making the glyphs available for rendering.

Of course, this doesn't solve Arabic text rendering yet. There is still the RTL direction to work out and possibly some missing glyph combining rules.

IssueID #195
  • Loading branch information
skyjake committed Mar 28, 2021
1 parent 7512470 commit 4756b0a
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 2 deletions.
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ set (EMBED_RESOURCES
res/fonts/Literata-LightItalic-opsz=10.ttf
res/fonts/NanumGothic-Regular.ttf
res/fonts/NotoEmoji-Regular.ttf
res/fonts/NotoSansArabicUI-Regular.ttf
res/fonts/NotoSansJP-Regular.ttf
res/fonts/NotoSansSC-Regular.ttf
res/fonts/Nunito-Bold.ttf
Expand Down Expand Up @@ -188,6 +189,7 @@ set (SOURCES
res/about/about.gmi
res/about/help.gmi
res/about/lagrange.gmi
res/about/license.gmi
res/about/version.gmi
${CMAKE_CURRENT_BINARY_DIR}/resources.lgr
${CMAKE_CURRENT_BINARY_DIR}/embedded.c
Expand Down
3 changes: 2 additions & 1 deletion res/about/license.gmi
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ This application uses fonts licensed under the Open Font License.
=> https://typeof.net/Iosevka/ Iosevka
=> https://github.com/googlefonts/literata/blob/master/OFL.txt Literata
=> https://github.com/google/fonts/blob/master/ofl/nanumgothic/OFL.txt Nanum Gothic
=> https://www.google.com/get/noto/help/cjk/ Noto Sans CJK JP
=> https://www.google.com/get/noto/#sans-arab Noto Sans Arabic
=> https://www.google.com/get/noto/help/cjk/ Noto Sans CJK (JP, SC)
=> https://github.com/googlefonts/nunito/blob/master/OFL.txt Nunito
=> https://github.com/adobe-fonts/source-sans-pro/blob/release/LICENSE.md Source Sans Pro

Expand Down
Binary file added res/fonts/NotoSansArabic-Regular.ttf
Binary file not shown.
Binary file added res/fonts/NotoSansArabicUI-Regular.ttf
Binary file not shown.
8 changes: 8 additions & 0 deletions src/ui/text.c
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ static void initFonts_Text_(iText *d) {
DEFINE_FONT_SET(fontNotoSansJPRegular_Embedded),
DEFINE_FONT_SET(fontNotoSansSCRegular_Embedded),
DEFINE_FONT_SET(fontNanumGothicRegular_Embedded), /* TODO: should use Noto Sans here, too */
DEFINE_FONT_SET(fontNotoSansArabicUIRegular_Embedded),
};
iForIndices(i, fontData) {
iFont *font = &d->fonts[i];
Expand Down Expand Up @@ -584,6 +585,13 @@ iLocalDef iFont *characterFont_Font_(iFont *d, iChar ch, uint32_t *glyphIndex) {
return japanese;
}
}
/* Maybe Arabic. */
if (ch >= 0x600) {
iFont *arabic = font_Text_(arabic_FontId + d->sizeId);
if (arabic != d && (*glyphIndex = glyphIndex_Font_(arabic, ch)) != 0) {
return arabic;
}
}
#if defined (iPlatformApple)
/* White up arrow is used for the Shift key on macOS. Symbola's glyph is not a great
match to the other text, so use the UI font instead. */
Expand Down
3 changes: 2 additions & 1 deletion src/ui/text.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,8 @@ enum iFontId {
japanese_FontId = emoji_FontId + max_FontSize,
chineseSimplified_FontId = japanese_FontId + max_FontSize,
korean_FontId = chineseSimplified_FontId + max_FontSize,
max_FontId = korean_FontId + max_FontSize,
arabic_FontId = korean_FontId + max_FontSize,
max_FontId = arabic_FontId + max_FontSize,

/* Meta: */
mask_FontId = 0xffff,
Expand Down

0 comments on commit 4756b0a

Please sign in to comment.