From b5f42fb807c9897ef67e428173cf1b6888841a4b Mon Sep 17 00:00:00 2001 From: Seo Youngjin Date: Thu, 16 Jul 2020 13:08:59 +0900 Subject: [PATCH 1/3] TTC file added to fontmanger - fontmanager 1. Truetype collection(*.ttc) added 2. font number double counting fixed - compile error fixed --- src/dlangui/core/settings.d | 4 ++-- src/dlangui/graphics/ftfonts.d | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/dlangui/core/settings.d b/src/dlangui/core/settings.d index 6f287fd9..ef9d5b6d 100644 --- a/src/dlangui/core/settings.d +++ b/src/dlangui/core/settings.d @@ -498,7 +498,7 @@ final class Setting { case UINTEGER: return to!string(_store.uinteger); case FLOAT: - return to!string(_store.floating); + return to!string(cast(double)_store.floating); case TRUE: return "true"; case FALSE: @@ -519,7 +519,7 @@ final class Setting { case UINTEGER: return to!string(_store.uinteger); case FLOAT: - return to!string(_store.floating); + return to!string(cast(double)_store.floating); case TRUE: return "true"; case FALSE: diff --git a/src/dlangui/graphics/ftfonts.d b/src/dlangui/graphics/ftfonts.d index b1aed796..662a7be8 100644 --- a/src/dlangui/graphics/ftfonts.d +++ b/src/dlangui/graphics/ftfonts.d @@ -771,7 +771,9 @@ bool registerFontConfigFonts(FreeTypeFontManager fontMan) { } string fn = fromStringz(s).dup; string fn16 = toLower(fn); - if (!fn16.endsWith(".ttf") && !fn16.endsWith(".odf") && !fn16.endsWith(".otf") && !fn16.endsWith(".pfb") && !fn16.endsWith(".pfa") ) { + if (!fn16.endsWith(".ttf") && !fn16.endsWith(".odf") && !fn16.endsWith(".otf") && + !fn16.endsWith(".ttc") && !fn16.endsWith(".pfb") && !fn16.endsWith(".pfa") ) + { continue; } int weight = FC_WEIGHT_MEDIUM; @@ -912,9 +914,6 @@ bool registerFontConfigFonts(FreeTypeFontManager fontMan) { } */ - facesFound++; - - } FcFontSetDestroy(fontset); From cd0415e79a9cfb64b9509bc2756a8fa5312ebf48 Mon Sep 17 00:00:00 2001 From: Seo Youngjin Date: Thu, 16 Jul 2020 13:09:24 +0900 Subject: [PATCH 2/3] OEM charset face name on Windows --- src/dlangui/platforms/windows/win32fonts.d | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/dlangui/platforms/windows/win32fonts.d b/src/dlangui/platforms/windows/win32fonts.d index 26a7d182..1e78d6f6 100644 --- a/src/dlangui/platforms/windows/win32fonts.d +++ b/src/dlangui/platforms/windows/win32fonts.d @@ -30,6 +30,7 @@ import dlangui.graphics.fonts; import dlangui.platforms.windows.win32drawbuf; import std.string; import std.utf; +import std.windows.charset; /// define debug=FontResources for logging of font file resources creation/freeing //debug = FontResources; @@ -446,9 +447,13 @@ class Win32Font : Font { if (!isNull()) clear(); LOGFONTA lf; - lf.lfCharSet = ANSI_CHARSET; //DEFAULT_CHARSET; - lf.lfFaceName[0..def.face.length] = def.face; - lf.lfFaceName[def.face.length] = 0; + // OEM charset face name + lf.lfCharSet = DEFAULT_CHARSET; //ANSI_CHARSET; + // lf.lfFaceName[0..def.face.length] = def.face; + // lf.lfFaceName[def.face.length] = 0; + string oemFace = fromStringz(toMBSz(def.face)).dup; + lf.lfFaceName[0..oemFace.length] = oemFace; + lf.lfFaceName[oemFace.length] = 0; lf.lfHeight = -size; //pixelsToPoints(size); lf.lfItalic = italic; lf.lfWeight = weight; @@ -545,7 +550,7 @@ class Win32FontManager : FontManager { debug Log.i("Win32FontManager.initialize()"); Win32ColorDrawBuf drawbuf = new Win32ColorDrawBuf(1,1); LOGFONTA lf; - lf.lfCharSet = ANSI_CHARSET; //DEFAULT_CHARSET; + lf.lfCharSet = DEFAULT_CHARSET; //ANSI_CHARSET; lf.lfFaceName[0] = 0; HDC dc = drawbuf.dc; int res = @@ -705,7 +710,9 @@ extern(Windows) { { void * p = cast(void*)lParam; Win32FontManager fontman = cast(Win32FontManager)p; - string face = fromStringz(lf.lfFaceName.ptr).dup; + // OEM charset face name + // string face = fromStringz(lf.lfFaceName.ptr).dup; + string face = fromMBSz(cast(immutable)lf.lfFaceName.ptr).dup; FontFamily family = pitchAndFamilyToFontFamily(lf.lfPitchAndFamily); if (face.length < 2 || face[0] == '@') return 1; From 925401b26a88fa1c0e68fa235c91eca3567f0a03 Mon Sep 17 00:00:00 2001 From: Seo Youngjin Date: Tue, 21 Jul 2020 21:41:07 +0900 Subject: [PATCH 3/3] Division by 0 error in Font::measureText() with MathJax_Vector and MathJax_Vector-Bold fonts. --- src/dlangui/graphics/fonts.d | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/dlangui/graphics/fonts.d b/src/dlangui/graphics/fonts.d index bbb224e9..78074e4f 100644 --- a/src/dlangui/graphics/fonts.d +++ b/src/dlangui/graphics/fonts.d @@ -239,6 +239,8 @@ class Font : RefCountedObject { bool fixed = isFixed; bool useKerning = allowKerning && !fixed; int fixedCharWidth = charWidth('M'); + if (fixedCharWidth == 0) + fixedCharWidth = spaceWidth; int x = 0; int charsMeasured = 0; int * pwidths = widths.ptr;