Skip to content

Commit

Permalink
A check for ability to support Arabic fonts
Browse files Browse the repository at this point in the history
  • Loading branch information
drug007 committed Sep 22, 2022
1 parent 7019d1b commit 2d10e7a
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
Binary file added examples/sdl/resources/fonts/Amiri-Regular.ttf
Binary file not shown.
Binary file not shown.
38 changes: 38 additions & 0 deletions examples/sdl/source/app.d
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,44 @@ class MyGui : SdlBackend
tb = new TextBox(window, "中国");
tb.theme = asian_theme;
tb.editable = true;

version(none)
{

// Added two arabic themes after https://forum.dlang.org/thread/sbymyafmdrsfgemlgsld@forum.dlang.org
// currently don't work as expected

auto arabic_theme1 = new Theme(ctx);
{
// sorta hack because loading font in nvg results in
// conflicting font id
auto nvg2 = nvgCreateContext(NVGContextFlag.Debug);
scope(exit) nvg2.kill;
nvg2.createFont("arabic1", "./resources/fonts/Amiri-Regular.ttf");
ctx.nvg.addFontsFrom(nvg2);
arabic_theme1.mFontNormal = ctx.nvg.findFont("arabic1");
}

auto arabic_theme2 = new Theme(ctx);
{
// sorta hack because loading font in nvg results in
// conflicting font id
auto nvg2 = nvgCreateContext(NVGContextFlag.Debug);
scope(exit) nvg2.kill;
nvg2.createFont("arabic2", "./resources/fonts/ElMessiri-VariableFont_wght.ttf");
ctx.nvg.addFontsFrom(nvg2);
arabic_theme2.mFontNormal = ctx.nvg.findFont("arabic2");
}

tb = new TextBox(window, "حالكم");
tb.theme = arabic_theme1;
tb.editable = true;

tb = new TextBox(window, "حالكم");
tb.theme = arabic_theme2;
tb.editable = true;

} // version(none)
}

{
Expand Down

0 comments on commit 2d10e7a

Please sign in to comment.