From 8266a15ac4bb949955455b5088da706af2fea823 Mon Sep 17 00:00:00 2001 From: Vladimir Sadovnikov Date: Mon, 21 Aug 2023 00:50:45 +0300 Subject: [PATCH 01/20] Version up --- CHANGELOG | 3 +++ include/lsp-plug.in/ws/version.h | 2 +- project.mk | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 8dac056..20393ba 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -2,6 +2,9 @@ * RECENT CHANGES ******************************************************************************* +=== 1.0.14 === + + === 1.0.13 === * Updated build scripts. * Updated module versions in dependencies. diff --git a/include/lsp-plug.in/ws/version.h b/include/lsp-plug.in/ws/version.h index ad94e6e..cfeb3e5 100644 --- a/include/lsp-plug.in/ws/version.h +++ b/include/lsp-plug.in/ws/version.h @@ -24,7 +24,7 @@ #define LSP_WS_LIB_MAJOR 1 #define LSP_WS_LIB_MINOR 0 -#define LSP_WS_LIB_MICRO 13 +#define LSP_WS_LIB_MICRO 14 #if defined(LSP_WS_LIB_PUBLISHER) #define LSP_WS_LIB_PUBLIC LSP_EXPORT_MODIFIER diff --git a/project.mk b/project.mk index ca3a60a..3d23cb1 100644 --- a/project.mk +++ b/project.mk @@ -23,5 +23,5 @@ ARTIFACT_ID = LSP_WS_LIB ARTIFACT_NAME = lsp-ws-lib ARTIFACT_DESC = LSP window subsystem core library ARTIFACT_HEADERS = lsp-plug.in -ARTIFACT_VERSION = 1.0.13 +ARTIFACT_VERSION = 1.0.14-devel From bc6197b7d56a604a4ebff236c490d448f42bb527 Mon Sep 17 00:00:00 2001 From: Vladimir Sadovnikov Date: Tue, 29 Aug 2023 01:25:14 +0300 Subject: [PATCH 02/20] Fighting with custom fonts for Windows --- src/main/win/WinDDSurface.cpp | 2 +- src/main/win/WinDisplay.cpp | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/main/win/WinDDSurface.cpp b/src/main/win/WinDDSurface.cpp index 230c9f1..4a0ebb1 100644 --- a/src/main/win/WinDDSurface.cpp +++ b/src/main/win/WinDDSurface.cpp @@ -63,7 +63,7 @@ namespace lsp size_t WinDDShared::Release() { - size_t count = nReferences--; + size_t count = --nReferences; if (count == 0) delete this; return count; diff --git a/src/main/win/WinDisplay.cpp b/src/main/win/WinDisplay.cpp index e29c738..df37877 100644 --- a/src/main/win/WinDisplay.cpp +++ b/src/main/win/WinDisplay.cpp @@ -662,6 +662,7 @@ namespace lsp font_t *f = vCustomFonts.get(name); if (f != NULL) return STATUS_ALREADY_EXISTS; + if ((f = alloc_font(name)) == NULL) return STATUS_NO_MEM; lsp_finally{ drop_font(f); }; @@ -673,19 +674,19 @@ namespace lsp return status_t(-length); // Create file loader - f->file = new WinFontFileLoader(&os); + f->file = safe_acquire(new WinFontFileLoader(&os)); if (f->file == NULL) return STATUS_NO_MEM; - f->file->AddRef(); + hr = pDWriteFactory->RegisterFontFileLoader(f->file); if (FAILED(hr)) return STATUS_UNKNOWN_ERR; // Create collection loader - f->loader = new WinFontCollectionLoader(); + f->loader = safe_acquire(new WinFontCollectionLoader()); if (f->loader == NULL) return STATUS_NO_MEM; - f->loader->AddRef(); + hr = pDWriteFactory->RegisterFontCollectionLoader(f->loader); if (FAILED(hr)) return STATUS_UNKNOWN_ERR; @@ -699,6 +700,7 @@ namespace lsp UINT32 count = f->collection->GetFontFamilyCount(); if (count <= 0) return STATUS_UNKNOWN_ERR; + f->collection->GetFontFamily(0, &f->family); if ((FAILED(hr)) || (f->family == NULL)) return STATUS_UNKNOWN_ERR; @@ -708,6 +710,7 @@ namespace lsp hr = f->family->GetFamilyNames(&names); if ((FAILED(hr)) || (names == NULL)) return STATUS_UNKNOWN_ERR; + lsp_finally{ safe_release(names); }; // Enumerate all possible font family names @@ -728,6 +731,7 @@ namespace lsp // The font has been found, add it to registry and exit if (!vCustomFonts.create(name, f)) return STATUS_UNKNOWN_ERR; + #ifdef LSP_TRACE LSPString out; out.set_utf16(f->wname); @@ -1063,13 +1067,9 @@ namespace lsp { HRESULT hr; - // Obtain the system locale - const WCHAR *wLocale = _wsetlocale(LC_ALL, NULL); - if (wLocale == NULL) - wLocale = L"en-us"; - // Create text format IDWriteTextFormat *tf = NULL; + hr = pDWriteFactory->CreateTextFormat( fname, // Font family name fc, // Font collection (NULL sets it to use the system font collection) @@ -1077,7 +1077,7 @@ namespace lsp (f.italic()) ? DWRITE_FONT_STYLE_ITALIC : DWRITE_FONT_STYLE_NORMAL, DWRITE_FONT_STRETCH_NORMAL, f.size(), - wLocale, + L"", &tf); if ((FAILED(hr)) || (tf == NULL)) { @@ -1092,7 +1092,7 @@ namespace lsp DWRITE_FONT_STYLE_OBLIQUE, DWRITE_FONT_STRETCH_NORMAL, f.size(), - wLocale, + L"", &tf); if ((FAILED(hr)) || (tf == NULL)) return NULL; @@ -1211,7 +1211,9 @@ namespace lsp // Get text layout metrics and font metrics DWRITE_TEXT_METRICS tm; - tl->GetMetrics(&tm); + HRESULT hr = tl->GetMetrics(&tm); + if (FAILED(hr)) + return false; float ratio = f.size() / float(fm.designUnitsPerEm); tp->Width = tm.widthIncludingTrailingWhitespace; @@ -1229,6 +1231,7 @@ namespace lsp const WCHAR *pText = (text != NULL) ? reinterpret_cast(text->get_utf16(first, last)) : NULL; if (pText == NULL) return false; + size_t range = text->range_length(first, last); // Obtain the font family From 7487eed44758d57c3991a1d9db32353703ca7a83 Mon Sep 17 00:00:00 2001 From: Vladimir Sadovnikov Date: Fri, 1 Sep 2023 14:40:08 +0300 Subject: [PATCH 03/20] Updated project file --- .cproject | 86 +++++++++++++++++++++++++++++++++++++++++++++++++------ 1 file changed, 77 insertions(+), 9 deletions(-) diff --git a/.cproject b/.cproject index cf11c93..a760ba8 100644 --- a/.cproject +++ b/.cproject @@ -89,9 +89,6 @@ - - - @@ -145,9 +142,6 @@ - - - @@ -185,6 +179,7 @@ +