diff --git a/src/dlangui/platforms/sdl/sdlapp.d b/src/dlangui/platforms/sdl/sdlapp.d index 92b2a03b..848bc5b1 100644 --- a/src/dlangui/platforms/sdl/sdlapp.d +++ b/src/dlangui/platforms/sdl/sdlapp.d @@ -646,6 +646,8 @@ class SDLWindow : Window { return KeyCode.RSHIFT; case SDLK_RALT: return KeyCode.RALT; + case '/': + return KeyCode.KEY_DIVIDE; default: return 0x10000 | keyCode; } @@ -1137,8 +1139,72 @@ version (Windows) { //_cmdShow = iCmdShow; //_hInstance = hInstance; + try { + /// testing freetype font manager + version(USE_FREETYPE) { + import dlangui.graphics.ftfonts; + // trying to create font manager + FreeTypeFontManager ftfontMan = new FreeTypeFontManager(); - FontManager.instance = new Win32FontManager(); + import win32.shlobj; + string fontsPath = "c:\\Windows\\Fonts\\"; + static if (true) { // SHGetFolderPathW not found in shell32.lib + WCHAR[MAX_PATH] szPath; + static if (false) { + const CSIDL_FLAG_NO_ALIAS = 0x1000; + const CSIDL_FLAG_DONT_UNEXPAND = 0x2000; + if(SUCCEEDED(SHGetFolderPathW(NULL, + CSIDL_FONTS|CSIDL_FLAG_NO_ALIAS|CSIDL_FLAG_DONT_UNEXPAND, + NULL, + 0, + szPath.ptr))) + { + fontsPath = toUTF8(fromWStringz(szPath)); + } + } else { + if (GetWindowsDirectory(szPath.ptr, MAX_PATH - 1)) { + fontsPath = toUTF8(fromWStringz(szPath)); + Log.i("Windows directory: ", fontsPath); + fontsPath ~= "\\Fonts\\"; + Log.i("Fonts directory: ", fontsPath); + } + } + } + ftfontMan.registerFont(fontsPath ~ "arial.ttf", FontFamily.SansSerif, "Arial", false, FontWeight.Normal); + ftfontMan.registerFont(fontsPath ~ "arialbd.ttf", FontFamily.SansSerif, "Arial", false, FontWeight.Bold); + ftfontMan.registerFont(fontsPath ~ "arialbi.ttf", FontFamily.SansSerif, "Arial", true, FontWeight.Bold); + ftfontMan.registerFont(fontsPath ~ "ariali.ttf", FontFamily.SansSerif, "Arial", true, FontWeight.Normal); + ftfontMan.registerFont(fontsPath ~ "cour.ttf", FontFamily.MonoSpace, "Courier New", false, FontWeight.Normal); + ftfontMan.registerFont(fontsPath ~ "courbd.ttf", FontFamily.MonoSpace, "Courier New", false, FontWeight.Bold); + ftfontMan.registerFont(fontsPath ~ "courbi.ttf", FontFamily.MonoSpace, "Courier New", true, FontWeight.Bold); + ftfontMan.registerFont(fontsPath ~ "couri.ttf", FontFamily.MonoSpace, "Courier New", true, FontWeight.Normal); + ftfontMan.registerFont(fontsPath ~ "times.ttf", FontFamily.Serif, "Times New Roman", false, FontWeight.Normal); + ftfontMan.registerFont(fontsPath ~ "timesbd.ttf", FontFamily.Serif, "Times New Roman", false, FontWeight.Bold); + ftfontMan.registerFont(fontsPath ~ "timesbi.ttf", FontFamily.Serif, "Times New Roman", true, FontWeight.Bold); + ftfontMan.registerFont(fontsPath ~ "timesi.ttf", FontFamily.Serif, "Times New Roman", true, FontWeight.Normal); + ftfontMan.registerFont(fontsPath ~ "consola.ttf", FontFamily.MonoSpace, "Consolas", false, FontWeight.Normal); + ftfontMan.registerFont(fontsPath ~ "consolab.ttf", FontFamily.MonoSpace, "Consolas", false, FontWeight.Bold); + ftfontMan.registerFont(fontsPath ~ "consolai.ttf", FontFamily.MonoSpace, "Consolas", true, FontWeight.Normal); + ftfontMan.registerFont(fontsPath ~ "consolaz.ttf", FontFamily.MonoSpace, "Consolas", true, FontWeight.Bold); + ftfontMan.registerFont(fontsPath ~ "verdana.ttf", FontFamily.SansSerif, "Verdana", false, FontWeight.Normal); + ftfontMan.registerFont(fontsPath ~ "verdanab.ttf", FontFamily.SansSerif, "Verdana", false, FontWeight.Bold); + ftfontMan.registerFont(fontsPath ~ "verdanai.ttf", FontFamily.SansSerif, "Verdana", true, FontWeight.Normal); + ftfontMan.registerFont(fontsPath ~ "verdanaz.ttf", FontFamily.SansSerif, "Verdana", true, FontWeight.Bold); + if (ftfontMan.registeredFontCount()) { + FontManager.instance = ftfontMan; + } else { + Log.w("No fonts registered in FreeType font manager. Disabling FreeType."); + destroy(ftfontMan); + } + } + } catch (Exception e) { + Log.e("Cannot create FreeTypeFontManager - falling back to win32"); + } + + // use Win32 font manager + if (FontManager.instance is null) { + FontManager.instance = new Win32FontManager(); + } return sdlmain(args); }