Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework windows font collector #107

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
eea7006
[src\meson.build] Add DirectWrite has dependency
moi15moi Feb 1, 2024
042f0c5
[src\font_file_lister_gdi] Rework GDI FontCollector to use DirectWrite
moi15moi Feb 1, 2024
11cc16d
[src\meson.build] Remove Uniscribe has dependency
moi15moi Feb 1, 2024
e3107ac
[src\dialog_fonts_collector] Catch exceptions that FontCollector may …
moi15moi Feb 1, 2024
6a3643f
[src\font_file_lister] Document the exception that GdiFontFileLister …
moi15moi Feb 1, 2024
ea6a339
[src\font_file_lister_gdi] Correct possible memory leak when an error…
moi15moi Feb 2, 2024
de1d3e3
Fix error caused by AddFontResource on Windows 10 or higher
moi15moi Feb 9, 2024
7d099da
[meson.build] Replace add_project_arguments with conf.set for HAVE_DW…
moi15moi Mar 2, 2024
9697588
[src\dialog_fonts_collector] Update message error and optimisation
moi15moi Mar 2, 2024
5212d1c
[src\font_file_lister_gdi] Correct documentation typo
moi15moi Mar 2, 2024
9af7c22
[src\font_file_lister_gdi] Cosmetic nit - Initialize hfont in one line
moi15moi Mar 2, 2024
863d427
[src\font_file_lister_gdi] Cosmetic nit - Remove if statements brace
moi15moi Mar 2, 2024
38a5a99
[src\font_file_lister_gdi] Replace WCHAR param of normalizeFilePathCa…
moi15moi Mar 3, 2024
62813a6
[src\font_file_lister_gdi] Replace WCHAR by std::wstring
moi15moi Mar 3, 2024
83f8c7f
[src\font_file_lister_gdi] Use IDWriteFontFace::GetSimulations to det…
moi15moi Mar 5, 2024
2988f79
[src\font_file_lister_gdi] If Win7/8 has Win 10 SDK on compile time, …
moi15moi Mar 8, 2024
fd08ee2
[src\font_file_lister_gdi] Support facename that contains only whites…
moi15moi Mar 16, 2024
44b81fd
[src\font_file_lister_gdi] Add a FIXME comment regarding the utilizat…
moi15moi Mar 17, 2024
17a3f48
[src\font_file_lister_gdi] Add FIXME comment about charset
moi15moi Mar 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ if host_machine.system() == 'windows'
# Windows 8 not required if XAudio2 fails to be found. revert for compat.
add_project_arguments('-D_WIN32_WINNT=0x0601', language: 'cpp')
endif

if not have_dsound_h and get_option('xaudio2').enabled()
error('xaudio2 enabled but xaudio2.h not found')
endif
Expand All @@ -327,6 +327,10 @@ if host_machine.system() == 'windows'
endif
endif

if host_machine.system() == 'windows' and cc.has_header('dwrite_3.h')
conf.set('HAVE_DWRITE_3', 1)
endif

if host_machine.system() == 'darwin'
frameworks_dep = dependency('appleframeworks', modules : ['CoreText', 'CoreFoundation', 'AppKit', 'Carbon', 'IOKit', 'QuartzCore'])
deps += frameworks_dep
Expand Down
9 changes: 8 additions & 1 deletion src/dialog_fonts_collector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,14 @@ void FontsCollectorThread(AssFile *subs, agi::fs::path const& destination, FcMod
collector->AddPendingEvent(ValueEvent<color_str_pair>(EVT_ADD_TEXT, -1, {colour, text.Clone()}));
};

auto paths = FontCollector(AppendText).GetFontPaths(subs);
std::vector<agi::fs::path> paths;
try {
paths = FontCollector(AppendText).GetFontPaths(subs);
}
catch (agi::EnvironmentError const& err) {
AppendText(fmt_tl("* An error occurred when enumerating the used fonts: %s.\n", err.GetMessage()), 2);
}

if (paths.empty()) {
collector->AddPendingEvent(wxThreadEvent(EVT_COLLECTION_DONE));
return;
Expand Down
14 changes: 7 additions & 7 deletions src/font_file_lister.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,17 @@ struct CollectionResult {
};

#ifdef _WIN32
#include <dwrite.h>
class GdiFontFileLister {
std::unordered_multimap<uint32_t, agi::fs::path> index;
agi::scoped_holder<HDC> dc;
std::string buffer;

bool ProcessLogFont(LOGFONTW const& expected, LOGFONTW const& actual, std::vector<int> const& characters);
agi::scoped_holder<HDC> dc_sh;
agi::scoped_holder<IDWriteFactory*> dwrite_factory_sh;
agi::scoped_holder<IDWriteFontCollection*> font_collection_sh;
agi::scoped_holder<IDWriteGdiInterop*> gdi_interop_sh;

public:
/// Constructor
/// @param cb Callback for status logging
GdiFontFileLister(FontCollectorStatusCallback &cb);
/// @throws agi::EnvironmentError if an error occurs during construction.
GdiFontFileLister(FontCollectorStatusCallback &);

/// @brief Get the path to the font with the given styles
/// @param facename Name of font face
Expand Down
Loading