Fonts.h (1329B)
1 // Copyright (c) Microsoft Corporation. 2 // Licensed under the MIT License. 3 #pragma once 4 #include <AppInstallerVersions.h> 5 #include <dwrite_3.h> 6 #include <wil/com.h> 7 8 namespace AppInstaller::Fonts 9 { 10 struct FontFace 11 { 12 std::wstring Name; 13 std::vector<std::filesystem::path> FilePaths; 14 Utility::OpenTypeFontVersion Version; 15 }; 16 17 struct FontFamily 18 { 19 std::wstring Name; 20 std::vector<FontFace> Faces; 21 }; 22 23 struct FontCatalog 24 { 25 FontCatalog(); 26 27 // Gets all installed font families on the system. If an exact family name is provided and found, returns the installed font family. 28 std::vector<FontFamily> GetInstalledFontFamilies(std::optional<std::wstring> familyName = {}); 29 30 private: 31 FontFamily GetFontFamilyByIndex(const wil::com_ptr<IDWriteFontCollection>& collection, UINT32 index); 32 std::wstring GetLocalizedStringFromFont(const wil::com_ptr<IDWriteLocalizedStrings>& localizedStringCollection); 33 std::wstring GetFontFamilyName(const wil::com_ptr<IDWriteFontFamily>& fontFamily); 34 std::wstring GetFontFaceName(const wil::com_ptr<IDWriteFont>& font); 35 Utility::OpenTypeFontVersion GetFontFaceVersion(const wil::com_ptr<IDWriteFont>& font); 36 37 std::vector<std::wstring> m_preferredLocales; 38 }; 39 }