From dcb7b7adb043793ce161bd6666a02dbccdbee6a2 Mon Sep 17 00:00:00 2001 From: --global Date: Mon, 7 Oct 2024 14:02:34 -0700 Subject: [PATCH 01/15] add initial experimental feature --- schemas/JSON/settings/settings.schema.0.2.json | 5 +++++ src/AppInstallerCommonCore/ExperimentalFeature.cpp | 5 +++++ .../Public/winget/ExperimentalFeature.h | 1 + src/AppInstallerCommonCore/Public/winget/UserSettings.h | 2 ++ src/AppInstallerCommonCore/UserSettings.cpp | 1 + 5 files changed, 14 insertions(+) diff --git a/schemas/JSON/settings/settings.schema.0.2.json b/schemas/JSON/settings/settings.schema.0.2.json index 7cc2001c1d..2113127f0e 100644 --- a/schemas/JSON/settings/settings.schema.0.2.json +++ b/schemas/JSON/settings/settings.schema.0.2.json @@ -287,6 +287,11 @@ "description": "Enable support for the configure export command", "type": "boolean", "default": false + }, + "fonts": { + "description": "Enable support for managing fonts", + "type": "boolean", + "default": false } } } diff --git a/src/AppInstallerCommonCore/ExperimentalFeature.cpp b/src/AppInstallerCommonCore/ExperimentalFeature.cpp index 733ff9ccd5..25c6c607f2 100644 --- a/src/AppInstallerCommonCore/ExperimentalFeature.cpp +++ b/src/AppInstallerCommonCore/ExperimentalFeature.cpp @@ -48,6 +48,8 @@ namespace AppInstaller::Settings return userSettings.Get(); case ExperimentalFeature::Feature::ConfigureExport: return userSettings.Get(); + case ExperimentalFeature::Feature::Fonts: + return userSettings.Get(); default: THROW_HR(E_UNEXPECTED); } @@ -85,6 +87,9 @@ namespace AppInstaller::Settings return ExperimentalFeature{ "Configure Self Elevation", "configureSelfElevate", "https://aka.ms/winget-settings", Feature::ConfigureSelfElevation }; case Feature::ConfigureExport: return ExperimentalFeature{ "Configure Export", "configureExport", "https://aka.ms/winget-settings", Feature::ConfigureExport }; + case Feature::Fonts: + return ExperimentalFeature{ "Fonts", "fonts", "https://aka.ms/winget-settings", Feature::Fonts }; + default: THROW_HR(E_UNEXPECTED); } diff --git a/src/AppInstallerCommonCore/Public/winget/ExperimentalFeature.h b/src/AppInstallerCommonCore/Public/winget/ExperimentalFeature.h index 733f1aa453..fc0af918a5 100644 --- a/src/AppInstallerCommonCore/Public/winget/ExperimentalFeature.h +++ b/src/AppInstallerCommonCore/Public/winget/ExperimentalFeature.h @@ -27,6 +27,7 @@ namespace AppInstaller::Settings Configuration03 = 0x4, ConfigureSelfElevation = 0x8, ConfigureExport = 0x10, + Fonts = 0x20, Max, // This MUST always be after all experimental features // Features listed after Max will not be shown with the features command diff --git a/src/AppInstallerCommonCore/Public/winget/UserSettings.h b/src/AppInstallerCommonCore/Public/winget/UserSettings.h index 5d8615485a..b580775c28 100644 --- a/src/AppInstallerCommonCore/Public/winget/UserSettings.h +++ b/src/AppInstallerCommonCore/Public/winget/UserSettings.h @@ -78,6 +78,7 @@ namespace AppInstaller::Settings EFConfiguration03, EFConfigureSelfElevation, EFConfigureExport, + EFFonts, // Telemetry TelemetryDisable, // Install behavior @@ -161,6 +162,7 @@ namespace AppInstaller::Settings SETTINGMAPPING_SPECIALIZATION(Setting::EFConfiguration03, bool, bool, false, ".experimentalFeatures.configuration03"sv); SETTINGMAPPING_SPECIALIZATION(Setting::EFConfigureSelfElevation, bool, bool, false, ".experimentalFeatures.configureSelfElevate"sv); SETTINGMAPPING_SPECIALIZATION(Setting::EFConfigureExport, bool, bool, false, ".experimentalFeatures.configureExport"sv); + SETTINGMAPPING_SPECIALIZATION(Setting::EFFonts, bool, bool, false, ".experimentalFeatures.fonts"sv); // Telemetry SETTINGMAPPING_SPECIALIZATION(Setting::TelemetryDisable, bool, bool, false, ".telemetry.disable"sv); // Install behavior diff --git a/src/AppInstallerCommonCore/UserSettings.cpp b/src/AppInstallerCommonCore/UserSettings.cpp index 476971d2f0..9e13610537 100644 --- a/src/AppInstallerCommonCore/UserSettings.cpp +++ b/src/AppInstallerCommonCore/UserSettings.cpp @@ -269,6 +269,7 @@ namespace AppInstaller::Settings WINGET_VALIDATE_PASS_THROUGH(EFConfiguration03) WINGET_VALIDATE_PASS_THROUGH(EFConfigureSelfElevation) WINGET_VALIDATE_PASS_THROUGH(EFConfigureExport) + WINGET_VALIDATE_PASS_THROUGH(EFFonts) WINGET_VALIDATE_PASS_THROUGH(AnonymizePathForDisplay) WINGET_VALIDATE_PASS_THROUGH(TelemetryDisable) WINGET_VALIDATE_PASS_THROUGH(InteractivityDisable) From 963d36e4b02e0d0a94c1ec8857b6061935bf273a Mon Sep 17 00:00:00 2001 From: --global Date: Mon, 7 Oct 2024 15:25:38 -0700 Subject: [PATCH 02/15] add initial fonts command --- .../AppInstallerCLICore.vcxproj | 2 + .../AppInstallerCLICore.vcxproj.filters | 6 + .../Commands/FontsCommand.cpp | 110 ++++++++++++++++++ .../Commands/FontsCommand.h | 40 +++++++ .../Commands/RootCommand.cpp | 2 + src/AppInstallerCLICore/Resources.h | 4 + .../Shared/Strings/en-us/Resources.resw | 6 + .../Shared/Strings/en-us/winget.resw | 8 +- 8 files changed, 177 insertions(+), 1 deletion(-) create mode 100644 src/AppInstallerCLICore/Commands/FontsCommand.cpp create mode 100644 src/AppInstallerCLICore/Commands/FontsCommand.h diff --git a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj index 58c83d1efb..76a89cad08 100644 --- a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj +++ b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj @@ -364,6 +364,7 @@ + @@ -441,6 +442,7 @@ + diff --git a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters index 6c072ed000..6c75ef565b 100644 --- a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters +++ b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters @@ -260,6 +260,9 @@ Header Files + + Commands + @@ -490,6 +493,9 @@ Source Files + + Commands + diff --git a/src/AppInstallerCLICore/Commands/FontsCommand.cpp b/src/AppInstallerCLICore/Commands/FontsCommand.cpp new file mode 100644 index 0000000000..74bfa9e1de --- /dev/null +++ b/src/AppInstallerCLICore/Commands/FontsCommand.cpp @@ -0,0 +1,110 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#include "pch.h" +#include "FontsCommand.h" +#include "Workflows/CompletionFlow.h" +#include "Workflows/WorkflowBase.h" +#include "Resources.h" + +namespace AppInstaller::CLI +{ + using namespace AppInstaller::CLI::Execution; + using namespace AppInstaller::CLI::Workflow; + using namespace AppInstaller::Utility::literals; + using namespace std::string_view_literals; + + Utility::LocIndView s_FontsCommand_HelpLink = "https://aka.ms/winget-command-fonts"_liv; + + std::vector> FontsCommand::GetCommands() const + { + return InitializeFromMoveOnly>>({ + std::make_unique(FullName()), + }); + } + + Resource::LocString FontsCommand::ShortDescription() const + { + return { Resource::String::FontsCommandShortDescription }; + } + + Resource::LocString FontsCommand::LongDescription() const + { + return { Resource::String::FontsCommandLongDescription }; + } + + Utility::LocIndView FontsCommand::HelpLink() const + { + return s_FontsCommand_HelpLink; + } + + void FontsCommand::ExecuteInternal(Execution::Context& context) const + { + OutputHelp(context.Reporter); + } + + std::vector FontsListCommand::GetArguments() const + { + return { + Argument::ForType(Args::Type::Query), + Argument::ForType(Args::Type::Id), + Argument::ForType(Args::Type::Name), + Argument::ForType(Args::Type::Moniker), + Argument::ForType(Args::Type::Source), + Argument::ForType(Args::Type::Tag), + Argument::ForType(Args::Type::Command), + Argument::ForType(Args::Type::Exact), + Argument::ForType(Args::Type::CustomHeader), + Argument::ForType(Args::Type::AuthenticationMode), + Argument::ForType(Args::Type::AuthenticationAccount), + Argument::ForType(Args::Type::AcceptSourceAgreements), + }; + } + + Resource::LocString FontsListCommand::ShortDescription() const + { + return { Resource::String::FontsListCommandShortDescription }; + } + + Resource::LocString FontsListCommand::LongDescription() const + { + return { Resource::String::FontsListCommandLongDescription }; + } + + void FontsListCommand::Complete(Execution::Context& context, Args::Type valueType) const + { + context << + Workflow::OpenSource() << + Workflow::OpenCompositeSource(Repository::PredefinedSource::Installed); + + switch (valueType) + { + case Execution::Args::Type::Query: + context << + Workflow::RequireCompletionWordNonEmpty << + Workflow::SearchSourceForManyCompletion << + Workflow::CompleteWithMatchedField; + break; + case Execution::Args::Type::Id: + case Execution::Args::Type::Name: + case Execution::Args::Type::Moniker: + case Execution::Args::Type::Source: + case Execution::Args::Type::Tag: + case Execution::Args::Type::Command: + context << + Workflow::CompleteWithSingleSemanticsForValueUsingExistingSource(valueType); + break; + } + } + + Utility::LocIndView FontsListCommand::HelpLink() const + { + return s_FontsCommand_HelpLink; + } + + void FontsListCommand::ExecuteInternal(Execution::Context& context) const + { + context << + Workflow::OpenSource() << + Workflow::OpenCompositeSource(Repository::PredefinedSource::Installed); + } +} diff --git a/src/AppInstallerCLICore/Commands/FontsCommand.h b/src/AppInstallerCLICore/Commands/FontsCommand.h new file mode 100644 index 0000000000..460e476a4c --- /dev/null +++ b/src/AppInstallerCLICore/Commands/FontsCommand.h @@ -0,0 +1,40 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#pragma once +#include "Command.h" +#include + +namespace AppInstaller::CLI +{ + struct FontsCommand final : public Command + { + FontsCommand(std::string_view parent) : Command("fonts", {} /* aliases */, parent) {} + + std::vector> GetCommands() const override; + + Resource::LocString ShortDescription() const override; + Resource::LocString LongDescription() const override; + + Utility::LocIndView HelpLink() const override; + + protected: + void ExecuteInternal(Execution::Context& context) const override; + }; + + struct FontsListCommand final : public Command + { + FontsListCommand(std::string_view parent) : Command("list", parent) {} + + std::vector GetArguments() const override; + + Resource::LocString ShortDescription() const override; + Resource::LocString LongDescription() const override; + + void Complete(Execution::Context& context, Execution::Args::Type valueType) const override; + + Utility::LocIndView HelpLink() const override; + + protected: + void ExecuteInternal(Execution::Context& context) const override; + }; +} diff --git a/src/AppInstallerCLICore/Commands/RootCommand.cpp b/src/AppInstallerCLICore/Commands/RootCommand.cpp index f5a61d79fa..2d8821a776 100644 --- a/src/AppInstallerCLICore/Commands/RootCommand.cpp +++ b/src/AppInstallerCLICore/Commands/RootCommand.cpp @@ -15,6 +15,7 @@ #include "ValidateCommand.h" #include "SettingsCommand.h" #include "FeaturesCommand.h" +#include "FontsCommand.h" #include "ExperimentalCommand.h" #include "CompleteCommand.h" #include "ExportCommand.h" @@ -194,6 +195,7 @@ namespace AppInstaller::CLI std::make_unique(FullName()), std::make_unique(FullName()), std::make_unique(FullName()), + std::make_unique(FullName()), #if _DEBUG std::make_unique(FullName()), #endif diff --git a/src/AppInstallerCLICore/Resources.h b/src/AppInstallerCLICore/Resources.h index 04b932f07f..898479013d 100644 --- a/src/AppInstallerCLICore/Resources.h +++ b/src/AppInstallerCLICore/Resources.h @@ -248,6 +248,10 @@ namespace AppInstaller::CLI::Resource WINGET_DEFINE_RESOURCE_STRINGID(FileNotFound); WINGET_DEFINE_RESOURCE_STRINGID(FilesRemainInInstallDirectory); WINGET_DEFINE_RESOURCE_STRINGID(FlagContainAdjoinedError); + WINGET_DEFINE_RESOURCE_STRINGID(FontsCommandLongDescription); + WINGET_DEFINE_RESOURCE_STRINGID(FontsCommandShortDescription); + WINGET_DEFINE_RESOURCE_STRINGID(FontsListCommandLongDescription); + WINGET_DEFINE_RESOURCE_STRINGID(FontsListCommandShortDescription); WINGET_DEFINE_RESOURCE_STRINGID(ForceArgumentDescription); WINGET_DEFINE_RESOURCE_STRINGID(GatedVersionArgumentDescription); WINGET_DEFINE_RESOURCE_STRINGID(GetManifestResultVersionNotFound); diff --git a/src/AppInstallerCLIPackage/Shared/Strings/en-us/Resources.resw b/src/AppInstallerCLIPackage/Shared/Strings/en-us/Resources.resw index 6fa1b87984..e028ab2bfe 100644 --- a/src/AppInstallerCLIPackage/Shared/Strings/en-us/Resources.resw +++ b/src/AppInstallerCLIPackage/Shared/Strings/en-us/Resources.resw @@ -121,4 +121,10 @@ Not Localized {Locked} This file is required to establish the basic expected subresource in the resource map. It is not used to facilitate localization with other projects. + + List installed fonts + + + List all installed fonts, or full details of a specific font. + \ No newline at end of file diff --git a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw index 9a6bff5c87..fb4d1fdc2b 100644 --- a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw +++ b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw @@ -3130,4 +3130,10 @@ Please specify one of them using the --source option to proceed. Failed to retrieve Microsoft Store package license. The Microsoft Entra Id account does not have required privilege. - + + Manage fonts + + + Manage fonts with sub-commands. Fonts can be installed, upgraded, or uninstalled similar to packages. + + \ No newline at end of file From 3758808a377b2816248d9f6652c31439ab32940c Mon Sep 17 00:00:00 2001 From: --global Date: Thu, 10 Oct 2024 14:25:10 -0700 Subject: [PATCH 03/15] save work --- .../JSON/settings/settings.schema.0.2.json | 4 +- .../AppInstallerCLICore.vcxproj | 6 +- .../AppInstallerCLICore.vcxproj.filters | 10 +++- .../{FontsCommand.cpp => FontCommand.cpp} | 45 ++++++++------- .../{FontsCommand.h => FontCommand.h} | 8 +-- .../Commands/RootCommand.cpp | 4 +- src/AppInstallerCLICore/Resources.h | 8 +-- .../Workflows/FontFlow.cpp | 55 +++++++++++++++++++ src/AppInstallerCLICore/Workflows/FontFlow.h | 13 +++++ .../Shared/Strings/en-us/Resources.resw | 8 +-- .../Shared/Strings/en-us/winget.resw | 8 +-- .../AppInstallerCommonCore.vcxproj | 2 + .../AppInstallerCommonCore.vcxproj.filters | 6 ++ .../ExperimentalFeature.cpp | 8 +-- src/AppInstallerCommonCore/Fonts.cpp | 54 ++++++++++++++++++ .../Public/winget/ExperimentalFeature.h | 2 +- .../Public/winget/Fonts.h | 14 +++++ .../Public/winget/UserSettings.h | 4 +- src/AppInstallerCommonCore/UserSettings.cpp | 2 +- 19 files changed, 206 insertions(+), 55 deletions(-) rename src/AppInstallerCLICore/Commands/{FontsCommand.cpp => FontCommand.cpp} (60%) rename src/AppInstallerCLICore/Commands/{FontsCommand.h => FontCommand.h} (78%) create mode 100644 src/AppInstallerCLICore/Workflows/FontFlow.cpp create mode 100644 src/AppInstallerCLICore/Workflows/FontFlow.h create mode 100644 src/AppInstallerCommonCore/Fonts.cpp create mode 100644 src/AppInstallerCommonCore/Public/winget/Fonts.h diff --git a/schemas/JSON/settings/settings.schema.0.2.json b/schemas/JSON/settings/settings.schema.0.2.json index 2113127f0e..93d682006a 100644 --- a/schemas/JSON/settings/settings.schema.0.2.json +++ b/schemas/JSON/settings/settings.schema.0.2.json @@ -288,8 +288,8 @@ "type": "boolean", "default": false }, - "fonts": { - "description": "Enable support for managing fonts", + "Font": { + "description": "Enable support for managing Font", "type": "boolean", "default": false } diff --git a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj index 76a89cad08..45c9c0fa04 100644 --- a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj +++ b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj @@ -364,7 +364,7 @@ - + @@ -411,6 +411,7 @@ + @@ -442,7 +443,7 @@ - + @@ -492,6 +493,7 @@ + diff --git a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters index 6c75ef565b..a8f48edd34 100644 --- a/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters +++ b/src/AppInstallerCLICore/AppInstallerCLICore.vcxproj.filters @@ -260,9 +260,12 @@ Header Files - + Commands + + Workflows + @@ -493,9 +496,12 @@ Source Files - + Commands + + Workflows + diff --git a/src/AppInstallerCLICore/Commands/FontsCommand.cpp b/src/AppInstallerCLICore/Commands/FontCommand.cpp similarity index 60% rename from src/AppInstallerCLICore/Commands/FontsCommand.cpp rename to src/AppInstallerCLICore/Commands/FontCommand.cpp index 74bfa9e1de..456d796e07 100644 --- a/src/AppInstallerCLICore/Commands/FontsCommand.cpp +++ b/src/AppInstallerCLICore/Commands/FontCommand.cpp @@ -1,9 +1,10 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. #include "pch.h" -#include "FontsCommand.h" +#include "FontCommand.h" #include "Workflows/CompletionFlow.h" #include "Workflows/WorkflowBase.h" +#include "Workflows/FontFlow.h" #include "Resources.h" namespace AppInstaller::CLI @@ -13,36 +14,36 @@ namespace AppInstaller::CLI using namespace AppInstaller::Utility::literals; using namespace std::string_view_literals; - Utility::LocIndView s_FontsCommand_HelpLink = "https://aka.ms/winget-command-fonts"_liv; + Utility::LocIndView s_FontCommand_HelpLink = "https://aka.ms/winget-command-Font"_liv; - std::vector> FontsCommand::GetCommands() const + std::vector> FontCommand::GetCommands() const { return InitializeFromMoveOnly>>({ - std::make_unique(FullName()), + std::make_unique(FullName()), }); } - Resource::LocString FontsCommand::ShortDescription() const + Resource::LocString FontCommand::ShortDescription() const { - return { Resource::String::FontsCommandShortDescription }; + return { Resource::String::FontCommandShortDescription }; } - Resource::LocString FontsCommand::LongDescription() const + Resource::LocString FontCommand::LongDescription() const { - return { Resource::String::FontsCommandLongDescription }; + return { Resource::String::FontCommandLongDescription }; } - Utility::LocIndView FontsCommand::HelpLink() const + Utility::LocIndView FontCommand::HelpLink() const { - return s_FontsCommand_HelpLink; + return s_FontCommand_HelpLink; } - void FontsCommand::ExecuteInternal(Execution::Context& context) const + void FontCommand::ExecuteInternal(Execution::Context& context) const { OutputHelp(context.Reporter); } - std::vector FontsListCommand::GetArguments() const + std::vector FontListCommand::GetArguments() const { return { Argument::ForType(Args::Type::Query), @@ -60,17 +61,17 @@ namespace AppInstaller::CLI }; } - Resource::LocString FontsListCommand::ShortDescription() const + Resource::LocString FontListCommand::ShortDescription() const { - return { Resource::String::FontsListCommandShortDescription }; + return { Resource::String::FontListCommandShortDescription }; } - Resource::LocString FontsListCommand::LongDescription() const + Resource::LocString FontListCommand::LongDescription() const { - return { Resource::String::FontsListCommandLongDescription }; + return { Resource::String::FontListCommandLongDescription }; } - void FontsListCommand::Complete(Execution::Context& context, Args::Type valueType) const + void FontListCommand::Complete(Execution::Context& context, Args::Type valueType) const { context << Workflow::OpenSource() << @@ -96,15 +97,13 @@ namespace AppInstaller::CLI } } - Utility::LocIndView FontsListCommand::HelpLink() const + Utility::LocIndView FontListCommand::HelpLink() const { - return s_FontsCommand_HelpLink; + return s_FontCommand_HelpLink; } - void FontsListCommand::ExecuteInternal(Execution::Context& context) const + void FontListCommand::ExecuteInternal(Execution::Context& context) const { - context << - Workflow::OpenSource() << - Workflow::OpenCompositeSource(Repository::PredefinedSource::Installed); + context << Workflow::ReportInstalledFontFamiliesResult; } } diff --git a/src/AppInstallerCLICore/Commands/FontsCommand.h b/src/AppInstallerCLICore/Commands/FontCommand.h similarity index 78% rename from src/AppInstallerCLICore/Commands/FontsCommand.h rename to src/AppInstallerCLICore/Commands/FontCommand.h index 460e476a4c..12e953b5ab 100644 --- a/src/AppInstallerCLICore/Commands/FontsCommand.h +++ b/src/AppInstallerCLICore/Commands/FontCommand.h @@ -6,9 +6,9 @@ namespace AppInstaller::CLI { - struct FontsCommand final : public Command + struct FontCommand final : public Command { - FontsCommand(std::string_view parent) : Command("fonts", {} /* aliases */, parent) {} + FontCommand(std::string_view parent) : Command("Font", {} /* aliases */, parent) {} std::vector> GetCommands() const override; @@ -21,9 +21,9 @@ namespace AppInstaller::CLI void ExecuteInternal(Execution::Context& context) const override; }; - struct FontsListCommand final : public Command + struct FontListCommand final : public Command { - FontsListCommand(std::string_view parent) : Command("list", parent) {} + FontListCommand(std::string_view parent) : Command("list", parent) {} std::vector GetArguments() const override; diff --git a/src/AppInstallerCLICore/Commands/RootCommand.cpp b/src/AppInstallerCLICore/Commands/RootCommand.cpp index 2d8821a776..5580efa14a 100644 --- a/src/AppInstallerCLICore/Commands/RootCommand.cpp +++ b/src/AppInstallerCLICore/Commands/RootCommand.cpp @@ -15,7 +15,7 @@ #include "ValidateCommand.h" #include "SettingsCommand.h" #include "FeaturesCommand.h" -#include "FontsCommand.h" +#include "FontCommand.h" #include "ExperimentalCommand.h" #include "CompleteCommand.h" #include "ExportCommand.h" @@ -195,7 +195,7 @@ namespace AppInstaller::CLI std::make_unique(FullName()), std::make_unique(FullName()), std::make_unique(FullName()), - std::make_unique(FullName()), + std::make_unique(FullName()), #if _DEBUG std::make_unique(FullName()), #endif diff --git a/src/AppInstallerCLICore/Resources.h b/src/AppInstallerCLICore/Resources.h index 898479013d..cb56d35958 100644 --- a/src/AppInstallerCLICore/Resources.h +++ b/src/AppInstallerCLICore/Resources.h @@ -248,10 +248,10 @@ namespace AppInstaller::CLI::Resource WINGET_DEFINE_RESOURCE_STRINGID(FileNotFound); WINGET_DEFINE_RESOURCE_STRINGID(FilesRemainInInstallDirectory); WINGET_DEFINE_RESOURCE_STRINGID(FlagContainAdjoinedError); - WINGET_DEFINE_RESOURCE_STRINGID(FontsCommandLongDescription); - WINGET_DEFINE_RESOURCE_STRINGID(FontsCommandShortDescription); - WINGET_DEFINE_RESOURCE_STRINGID(FontsListCommandLongDescription); - WINGET_DEFINE_RESOURCE_STRINGID(FontsListCommandShortDescription); + WINGET_DEFINE_RESOURCE_STRINGID(FontCommandLongDescription); + WINGET_DEFINE_RESOURCE_STRINGID(FontCommandShortDescription); + WINGET_DEFINE_RESOURCE_STRINGID(FontListCommandLongDescription); + WINGET_DEFINE_RESOURCE_STRINGID(FontListCommandShortDescription); WINGET_DEFINE_RESOURCE_STRINGID(ForceArgumentDescription); WINGET_DEFINE_RESOURCE_STRINGID(GatedVersionArgumentDescription); WINGET_DEFINE_RESOURCE_STRINGID(GetManifestResultVersionNotFound); diff --git a/src/AppInstallerCLICore/Workflows/FontFlow.cpp b/src/AppInstallerCLICore/Workflows/FontFlow.cpp new file mode 100644 index 0000000000..0b8dadc005 --- /dev/null +++ b/src/AppInstallerCLICore/Workflows/FontFlow.cpp @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#include "pch.h" +#include "FontFlow.h" +#include +#include + +namespace AppInstaller::CLI::Workflow +{ + struct InstalledFontFamiliesTableLine + { + InstalledFontFamiliesTableLine(Utility::LocIndString familyName, int faceCount) + : FamilyName(familyName), FaceCount(faceCount) {} + + Utility::LocIndString FamilyName; + int FaceCount; + }; + + void OutputInstalledFontFamiliesTable(Execution::Context& context, const std::vector& lines) + { + Execution::TableOutput<2> table(context.Reporter, + { + Resource::String::SearchName, + Resource::String::SearchId, + }); + + for (const auto& line : lines) + { + table.OutputLine({ + line.FamilyName, + std::to_string(line.FaceCount) + }); + } + table.Complete(); + } + + void ReportInstalledFontFamiliesResult(Execution::Context& context) + { + const auto& fontFamilyNames = AppInstaller::Fonts::GetInstalledFontFamilies(); + + std::vector lines; + + for (const auto& familyName : fontFamilyNames) + { + InstalledFontFamiliesTableLine line( + Utility::LocIndString(Utility::ConvertToUTF8(familyName)), + 1 + ); + + lines.push_back(std::move(line)); + } + + OutputInstalledFontFamiliesTable(context, lines); + } +} diff --git a/src/AppInstallerCLICore/Workflows/FontFlow.h b/src/AppInstallerCLICore/Workflows/FontFlow.h new file mode 100644 index 0000000000..947699a519 --- /dev/null +++ b/src/AppInstallerCLICore/Workflows/FontFlow.h @@ -0,0 +1,13 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#pragma once +#include "ExecutionContext.h" + +namespace AppInstaller::CLI::Workflow +{ + // Reports the installed font families as a table. + // Required Args: None + // Inputs: None + // Outputs: None + void ReportInstalledFontFamiliesResult(Execution::Context& context); +} diff --git a/src/AppInstallerCLIPackage/Shared/Strings/en-us/Resources.resw b/src/AppInstallerCLIPackage/Shared/Strings/en-us/Resources.resw index e028ab2bfe..50c2e8bbc5 100644 --- a/src/AppInstallerCLIPackage/Shared/Strings/en-us/Resources.resw +++ b/src/AppInstallerCLIPackage/Shared/Strings/en-us/Resources.resw @@ -121,10 +121,10 @@ Not Localized {Locked} This file is required to establish the basic expected subresource in the resource map. It is not used to facilitate localization with other projects. - - List installed fonts + + List installed Font - - List all installed fonts, or full details of a specific font. + + List all installed Font, or full details of a specific font. \ No newline at end of file diff --git a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw index fb4d1fdc2b..91877e1105 100644 --- a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw +++ b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw @@ -3130,10 +3130,10 @@ Please specify one of them using the --source option to proceed. Failed to retrieve Microsoft Store package license. The Microsoft Entra Id account does not have required privilege. - - Manage fonts + + Manage Font - - Manage fonts with sub-commands. Fonts can be installed, upgraded, or uninstalled similar to packages. + + Manage Font with sub-commands. Font can be installed, upgraded, or uninstalled similar to packages. \ No newline at end of file diff --git a/src/AppInstallerCommonCore/AppInstallerCommonCore.vcxproj b/src/AppInstallerCommonCore/AppInstallerCommonCore.vcxproj index 6fac55a5fc..5fa724cc17 100644 --- a/src/AppInstallerCommonCore/AppInstallerCommonCore.vcxproj +++ b/src/AppInstallerCommonCore/AppInstallerCommonCore.vcxproj @@ -422,6 +422,7 @@ + true @@ -473,6 +474,7 @@ + true diff --git a/src/AppInstallerCommonCore/AppInstallerCommonCore.vcxproj.filters b/src/AppInstallerCommonCore/AppInstallerCommonCore.vcxproj.filters index 3498d88dfb..1cb64a4d0e 100644 --- a/src/AppInstallerCommonCore/AppInstallerCommonCore.vcxproj.filters +++ b/src/AppInstallerCommonCore/AppInstallerCommonCore.vcxproj.filters @@ -204,6 +204,9 @@ Public\winget + + Public\winget + @@ -368,6 +371,9 @@ Source Files + + Source Files + diff --git a/src/AppInstallerCommonCore/ExperimentalFeature.cpp b/src/AppInstallerCommonCore/ExperimentalFeature.cpp index 25c6c607f2..049139083a 100644 --- a/src/AppInstallerCommonCore/ExperimentalFeature.cpp +++ b/src/AppInstallerCommonCore/ExperimentalFeature.cpp @@ -48,8 +48,8 @@ namespace AppInstaller::Settings return userSettings.Get(); case ExperimentalFeature::Feature::ConfigureExport: return userSettings.Get(); - case ExperimentalFeature::Feature::Fonts: - return userSettings.Get(); + case ExperimentalFeature::Feature::Font: + return userSettings.Get(); default: THROW_HR(E_UNEXPECTED); } @@ -87,8 +87,8 @@ namespace AppInstaller::Settings return ExperimentalFeature{ "Configure Self Elevation", "configureSelfElevate", "https://aka.ms/winget-settings", Feature::ConfigureSelfElevation }; case Feature::ConfigureExport: return ExperimentalFeature{ "Configure Export", "configureExport", "https://aka.ms/winget-settings", Feature::ConfigureExport }; - case Feature::Fonts: - return ExperimentalFeature{ "Fonts", "fonts", "https://aka.ms/winget-settings", Feature::Fonts }; + case Feature::Font: + return ExperimentalFeature{ "Font", "Font", "https://aka.ms/winget-settings", Feature::Font }; default: THROW_HR(E_UNEXPECTED); diff --git a/src/AppInstallerCommonCore/Fonts.cpp b/src/AppInstallerCommonCore/Fonts.cpp new file mode 100644 index 0000000000..be91e84481 --- /dev/null +++ b/src/AppInstallerCommonCore/Fonts.cpp @@ -0,0 +1,54 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#include "pch.h" +#include "Public/winget/Fonts.h" +#include + +namespace AppInstaller::Fonts +{ + std::vector GetInstalledFontFamilies() + { + wchar_t localeNameBuffer[LOCALE_NAME_MAX_LENGTH]; + const auto localeName = GetUserDefaultLocaleName(localeNameBuffer, LOCALE_NAME_MAX_LENGTH) ? localeNameBuffer : L"en-US"; + + wil::com_ptr factory; + THROW_IF_FAILED(DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(factory), factory.put_unknown())); + + wil::com_ptr collection; + THROW_IF_FAILED(factory->GetSystemFontCollection(collection.addressof(), FALSE)); + + const auto familyCount = collection->GetFontFamilyCount(); + std::vector familyNames; + + for (UINT32 index = 0; index < familyCount; index++) + { + wil::com_ptr family; + THROW_IF_FAILED(collection->GetFontFamily(index, family.addressof())); + + wil::com_ptr singleFont; + THROW_IF_FAILED(family->GetFont(0, &singleFont)); + + // Prepare to retrieve font information + wil::com_ptr fullName; + BOOL fullNameExists; + THROW_IF_FAILED(singleFont->GetInformationalStrings(DWRITE_INFORMATIONAL_STRING_FULL_NAME, &fullName, &fullNameExists)); + UINT32 fullNameIndex; + if (FAILED(fullName->FindLocaleName(localeName, &fullNameIndex, &fullNameExists)) || !fullNameExists) + { + fullNameIndex = 0; + } + + UINT32 fullNameLength = 0; + THROW_IF_FAILED(fullName->GetStringLength(fullNameIndex, &fullNameLength)); + fullNameLength += 1; // Account for the trailing null terminator during allocation. + + wchar_t result[512]; + THROW_HR_IF(E_OUTOFMEMORY, fullNameLength > ARRAYSIZE(result)); + THROW_IF_FAILED(fullName->GetString(fullNameIndex, &result[0], fullNameLength)); + std::wstring familyName(result); + familyNames.emplace_back(familyName); + } + + return familyNames; + } +} diff --git a/src/AppInstallerCommonCore/Public/winget/ExperimentalFeature.h b/src/AppInstallerCommonCore/Public/winget/ExperimentalFeature.h index fc0af918a5..80469aa24c 100644 --- a/src/AppInstallerCommonCore/Public/winget/ExperimentalFeature.h +++ b/src/AppInstallerCommonCore/Public/winget/ExperimentalFeature.h @@ -27,7 +27,7 @@ namespace AppInstaller::Settings Configuration03 = 0x4, ConfigureSelfElevation = 0x8, ConfigureExport = 0x10, - Fonts = 0x20, + Font = 0x20, Max, // This MUST always be after all experimental features // Features listed after Max will not be shown with the features command diff --git a/src/AppInstallerCommonCore/Public/winget/Fonts.h b/src/AppInstallerCommonCore/Public/winget/Fonts.h new file mode 100644 index 0000000000..f373982bb4 --- /dev/null +++ b/src/AppInstallerCommonCore/Public/winget/Fonts.h @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#pragma once +#include +#include + +namespace AppInstaller::Fonts +{ + /// + /// Gets all installed font families on the system. + /// + /// A list of installed font family names. + std::vector GetInstalledFontFamilies(); +} diff --git a/src/AppInstallerCommonCore/Public/winget/UserSettings.h b/src/AppInstallerCommonCore/Public/winget/UserSettings.h index b580775c28..a8517a3122 100644 --- a/src/AppInstallerCommonCore/Public/winget/UserSettings.h +++ b/src/AppInstallerCommonCore/Public/winget/UserSettings.h @@ -78,7 +78,7 @@ namespace AppInstaller::Settings EFConfiguration03, EFConfigureSelfElevation, EFConfigureExport, - EFFonts, + EFFont, // Telemetry TelemetryDisable, // Install behavior @@ -162,7 +162,7 @@ namespace AppInstaller::Settings SETTINGMAPPING_SPECIALIZATION(Setting::EFConfiguration03, bool, bool, false, ".experimentalFeatures.configuration03"sv); SETTINGMAPPING_SPECIALIZATION(Setting::EFConfigureSelfElevation, bool, bool, false, ".experimentalFeatures.configureSelfElevate"sv); SETTINGMAPPING_SPECIALIZATION(Setting::EFConfigureExport, bool, bool, false, ".experimentalFeatures.configureExport"sv); - SETTINGMAPPING_SPECIALIZATION(Setting::EFFonts, bool, bool, false, ".experimentalFeatures.fonts"sv); + SETTINGMAPPING_SPECIALIZATION(Setting::EFFont, bool, bool, false, ".experimentalFeatures.Font"sv); // Telemetry SETTINGMAPPING_SPECIALIZATION(Setting::TelemetryDisable, bool, bool, false, ".telemetry.disable"sv); // Install behavior diff --git a/src/AppInstallerCommonCore/UserSettings.cpp b/src/AppInstallerCommonCore/UserSettings.cpp index 9e13610537..202a1cb199 100644 --- a/src/AppInstallerCommonCore/UserSettings.cpp +++ b/src/AppInstallerCommonCore/UserSettings.cpp @@ -269,7 +269,7 @@ namespace AppInstaller::Settings WINGET_VALIDATE_PASS_THROUGH(EFConfiguration03) WINGET_VALIDATE_PASS_THROUGH(EFConfigureSelfElevation) WINGET_VALIDATE_PASS_THROUGH(EFConfigureExport) - WINGET_VALIDATE_PASS_THROUGH(EFFonts) + WINGET_VALIDATE_PASS_THROUGH(EFFont) WINGET_VALIDATE_PASS_THROUGH(AnonymizePathForDisplay) WINGET_VALIDATE_PASS_THROUGH(TelemetryDisable) WINGET_VALIDATE_PASS_THROUGH(InteractivityDisable) From c83e58f7e4ef3c164accb81f19acb7547fd4385c Mon Sep 17 00:00:00 2001 From: --global Date: Mon, 14 Oct 2024 17:04:01 -0700 Subject: [PATCH 04/15] save work --- src/AppInstallerCLICore/Argument.cpp | 6 + .../Commands/FontCommand.cpp | 4 +- src/AppInstallerCLICore/ExecutionArgs.h | 3 + src/AppInstallerCLICore/Resources.h | 5 + .../Workflows/FontFlow.cpp | 79 ++++++-- src/AppInstallerCLIE2ETests/BaseCommand.cs | 5 +- .../Shared/Strings/en-us/winget.resw | 15 ++ src/AppInstallerCommonCore/Fonts.cpp | 171 +++++++++++++++--- .../Public/winget/Fonts.h | 21 ++- 9 files changed, 267 insertions(+), 42 deletions(-) diff --git a/src/AppInstallerCLICore/Argument.cpp b/src/AppInstallerCLICore/Argument.cpp index a5334a2ceb..b750981924 100644 --- a/src/AppInstallerCLICore/Argument.cpp +++ b/src/AppInstallerCLICore/Argument.cpp @@ -198,6 +198,10 @@ namespace AppInstaller::CLI case Execution::Args::Type::IgnoreResumeLimit: return { type, "ignore-resume-limit"_liv, ArgTypeCategory::None }; + // Font command + case Execution::Args::Type::FamilyName: + return { type, "family-name"_liv, ArgTypeCategory::None }; + // Configuration commands case Execution::Args::Type::ConfigurationFile: return { type, "file"_liv, 'f', ArgTypeCategory::ConfigurationSetChoice, ArgTypeExclusiveSet::ConfigurationSetChoice }; @@ -430,6 +434,8 @@ namespace AppInstaller::CLI return Argument{ type, Resource::String::ProxyArgumentDescription, ArgumentType::Standard, TogglePolicy::Policy::ProxyCommandLineOptions, BoolAdminSetting::ProxyCommandLineOptions }; case Args::Type::NoProxy: return Argument{ type, Resource::String::NoProxyArgumentDescription, ArgumentType::Flag, TogglePolicy::Policy::ProxyCommandLineOptions, BoolAdminSetting::ProxyCommandLineOptions }; + case Args::Type::FamilyName: + return Argument{ type, Resource::String::FontFamilyNameArgumentDescription, ArgumentType::Standard, false }; default: THROW_HR(E_UNEXPECTED); } diff --git a/src/AppInstallerCLICore/Commands/FontCommand.cpp b/src/AppInstallerCLICore/Commands/FontCommand.cpp index 456d796e07..dad6dd7951 100644 --- a/src/AppInstallerCLICore/Commands/FontCommand.cpp +++ b/src/AppInstallerCLICore/Commands/FontCommand.cpp @@ -46,9 +46,7 @@ namespace AppInstaller::CLI std::vector FontListCommand::GetArguments() const { return { - Argument::ForType(Args::Type::Query), - Argument::ForType(Args::Type::Id), - Argument::ForType(Args::Type::Name), + Argument::ForType(Args::Type::FamilyName), Argument::ForType(Args::Type::Moniker), Argument::ForType(Args::Type::Source), Argument::ForType(Args::Type::Tag), diff --git a/src/AppInstallerCLICore/ExecutionArgs.h b/src/AppInstallerCLICore/ExecutionArgs.h index 41739b36f4..e96114aea7 100644 --- a/src/AppInstallerCLICore/ExecutionArgs.h +++ b/src/AppInstallerCLICore/ExecutionArgs.h @@ -121,6 +121,9 @@ namespace AppInstaller::CLI::Execution ResumeId, IgnoreResumeLimit, + // Font Command + FamilyName, + // Configuration ConfigurationFile, ConfigurationAcceptWarning, diff --git a/src/AppInstallerCLICore/Resources.h b/src/AppInstallerCLICore/Resources.h index cb56d35958..de46be77f6 100644 --- a/src/AppInstallerCLICore/Resources.h +++ b/src/AppInstallerCLICore/Resources.h @@ -250,6 +250,11 @@ namespace AppInstaller::CLI::Resource WINGET_DEFINE_RESOURCE_STRINGID(FlagContainAdjoinedError); WINGET_DEFINE_RESOURCE_STRINGID(FontCommandLongDescription); WINGET_DEFINE_RESOURCE_STRINGID(FontCommandShortDescription); + WINGET_DEFINE_RESOURCE_STRINGID(FontFaceCount); + WINGET_DEFINE_RESOURCE_STRINGID(FontFaceName); + WINGET_DEFINE_RESOURCE_STRINGID(FontFamilyName); + WINGET_DEFINE_RESOURCE_STRINGID(FontFamilyNameArgumentDescription); + WINGET_DEFINE_RESOURCE_STRINGID(FontFilePaths); WINGET_DEFINE_RESOURCE_STRINGID(FontListCommandLongDescription); WINGET_DEFINE_RESOURCE_STRINGID(FontListCommandShortDescription); WINGET_DEFINE_RESOURCE_STRINGID(ForceArgumentDescription); diff --git a/src/AppInstallerCLICore/Workflows/FontFlow.cpp b/src/AppInstallerCLICore/Workflows/FontFlow.cpp index 0b8dadc005..0e299088de 100644 --- a/src/AppInstallerCLICore/Workflows/FontFlow.cpp +++ b/src/AppInstallerCLICore/Workflows/FontFlow.cpp @@ -7,6 +7,8 @@ namespace AppInstaller::CLI::Workflow { + using namespace AppInstaller::CLI::Execution; + struct InstalledFontFamiliesTableLine { InstalledFontFamiliesTableLine(Utility::LocIndString familyName, int faceCount) @@ -16,12 +18,22 @@ namespace AppInstaller::CLI::Workflow int FaceCount; }; + struct InstalledFontFacesTableLine + { + InstalledFontFacesTableLine(Utility::LocIndString faceName, Utility::LocIndString familyName, std::filesystem::path filePath) + : FaceName(faceName), FamilyName(familyName), FilePath(filePath){} + + Utility::LocIndString FaceName; + Utility::LocIndString FamilyName; + std::filesystem::path FilePath; + }; + void OutputInstalledFontFamiliesTable(Execution::Context& context, const std::vector& lines) { Execution::TableOutput<2> table(context.Reporter, { - Resource::String::SearchName, - Resource::String::SearchId, + Resource::String::FontFamilyName, + Resource::String::FontFaceCount, }); for (const auto& line : lines) @@ -34,22 +46,65 @@ namespace AppInstaller::CLI::Workflow table.Complete(); } - void ReportInstalledFontFamiliesResult(Execution::Context& context) + void OutputInstalledFontFacesTable(Execution::Context& context, const std::vector& lines) { - const auto& fontFamilyNames = AppInstaller::Fonts::GetInstalledFontFamilies(); + Execution::TableOutput<3> table(context.Reporter, + { + Resource::String::FontFaceName, + Resource::String::FontFamilyName, + Resource::String::FontFilePaths, + }); - std::vector lines; + for (const auto& line : lines) + { + table.OutputLine({ + line.FaceName, + line.FamilyName, + line.FilePath.u8string(), + }); + } + table.Complete(); + } - for (const auto& familyName : fontFamilyNames) + void ReportInstalledFontFamiliesResult(Execution::Context& context) + { + if (context.Args.Contains(Args::Type::FamilyName)) { - InstalledFontFamiliesTableLine line( - Utility::LocIndString(Utility::ConvertToUTF8(familyName)), - 1 - ); + const auto& familyNameArg = context.Args.GetArg(Args::Type::FamilyName); + const auto& fontFamily = AppInstaller::Fonts::GetInstalledFontFamily(AppInstaller::Utility::ConvertToUTF16(familyNameArg)); + + std::vector lines; + const auto& familyName = Utility::LocIndString(familyNameArg); + + for (const auto& fontFace : fontFamily.FontFaces) + { + InstalledFontFacesTableLine line( + Utility::LocIndString(Utility::ConvertToUTF8(fontFace.FaceName)), + familyName, + fontFace.FilePaths[0] // Todo: update so that all paths are joined together by new line. + ); + + lines.push_back(std::move(line)); + } - lines.push_back(std::move(line)); + OutputInstalledFontFacesTable(context, lines); } + else + { + const auto& fontFamilies = AppInstaller::Fonts::GetInstalledFontFamilies(); + std::vector lines; - OutputInstalledFontFamiliesTable(context, lines); + for (const auto& fontFamily : fontFamilies) + { + InstalledFontFamiliesTableLine line( + Utility::LocIndString(Utility::ConvertToUTF8(fontFamily.FamilyName)), + (int)fontFamily.FontFaces.size() + ); + + lines.push_back(std::move(line)); + } + + OutputInstalledFontFamiliesTable(context, lines); + } } } diff --git a/src/AppInstallerCLIE2ETests/BaseCommand.cs b/src/AppInstallerCLIE2ETests/BaseCommand.cs index 1b28227fd5..faa07c2dd0 100644 --- a/src/AppInstallerCLIE2ETests/BaseCommand.cs +++ b/src/AppInstallerCLIE2ETests/BaseCommand.cs @@ -1,4 +1,4 @@ -// ----------------------------------------------------------------------------- +// ----------------------------------------------------------------------------- // // Copyright (c) Microsoft Corporation. Licensed under the MIT License. // @@ -6,10 +6,7 @@ namespace AppInstallerCLIE2ETests { - using System; - using System.IO; using AppInstallerCLIE2ETests.Helpers; - using Newtonsoft.Json.Linq; using NUnit.Framework; /// diff --git a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw index 85538fa556..3ac0624bc9 100644 --- a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw +++ b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw @@ -3139,4 +3139,19 @@ Please specify one of them using the --source option to proceed. Manage Font with sub-commands. Font can be installed, upgraded, or uninstalled similar to packages. + + Family Name + + + Face Count + + + Filter results by family name + + + Face Name + + + File Paths + \ No newline at end of file diff --git a/src/AppInstallerCommonCore/Fonts.cpp b/src/AppInstallerCommonCore/Fonts.cpp index be91e84481..bc40c74f1f 100644 --- a/src/AppInstallerCommonCore/Fonts.cpp +++ b/src/AppInstallerCommonCore/Fonts.cpp @@ -6,11 +6,95 @@ namespace AppInstaller::Fonts { - std::vector GetInstalledFontFamilies() + namespace { - wchar_t localeNameBuffer[LOCALE_NAME_MAX_LENGTH]; - const auto localeName = GetUserDefaultLocaleName(localeNameBuffer, LOCALE_NAME_MAX_LENGTH) ? localeNameBuffer : L"en-US"; + std::vector GetFontFilePaths(const wil::com_ptr& fontFace) + { + UINT32 fileCount = 0; + THROW_IF_FAILED(fontFace->GetFiles(&fileCount, nullptr)); + + wil::com_ptr fontFiles[8]; + THROW_HR_IF(E_OUTOFMEMORY, fileCount > ARRAYSIZE(fontFiles)); + THROW_IF_FAILED(fontFace->GetFiles(&fileCount, fontFiles[0].addressof())); + + std::vector filePaths; + for (UINT32 i = 0; i < fileCount; ++i) { + wil::com_ptr loader; + THROW_IF_FAILED(fontFiles[i]->GetLoader(loader.addressof())); + + const void* fontFileReferenceKey; + UINT32 fontFileReferenceKeySize; + THROW_IF_FAILED(fontFiles[i]->GetReferenceKey(&fontFileReferenceKey, &fontFileReferenceKeySize)); + + if (const auto localLoader = loader.try_query()) { + UINT32 pathLength; + THROW_IF_FAILED(localLoader->GetFilePathLengthFromKey(fontFileReferenceKey, fontFileReferenceKeySize, &pathLength)); + pathLength += 1; // Account for the trailing null terminator during allocation. + + wchar_t path[512]; + THROW_HR_IF(E_OUTOFMEMORY, pathLength > ARRAYSIZE(path)); + THROW_IF_FAILED(localLoader->GetFilePathFromKey(fontFileReferenceKey, fontFileReferenceKeySize, &path[0], pathLength)); + filePaths.emplace_back(std::wstring(path)); + } + } + + return filePaths; + } + + std::wstring GetFontFaceName(const wil::com_ptr& font) + { + wil::com_ptr faceNames; + THROW_IF_FAILED(font->GetFaceNames(faceNames.addressof())); + + wchar_t localeNameBuffer[LOCALE_NAME_MAX_LENGTH]; + const auto localeName = GetUserDefaultLocaleName(localeNameBuffer, LOCALE_NAME_MAX_LENGTH) ? localeNameBuffer : L"en-US"; + + UINT32 faceNameIndex; + BOOL faceNameExists; + if (FAILED(faceNames->FindLocaleName(localeName, &faceNameIndex, &faceNameExists)) || !faceNameExists) + { + faceNameIndex = 0; + } + + UINT32 faceNameLength = 0; + THROW_IF_FAILED(faceNames->GetStringLength(faceNameIndex, &faceNameLength)); + faceNameLength += 1; // Account for the trailing null terminator during allocation. + + wchar_t faceName[512]; + THROW_HR_IF(E_OUTOFMEMORY, faceNameLength > ARRAYSIZE(faceName)); + THROW_IF_FAILED(faceNames->GetString(faceNameIndex, &faceName[0], faceNameLength)); + return std::wstring(faceName); + } + + std::wstring GetFontFamilyName(const wil::com_ptr& fontFamily) + { + // Retrieve family names. + wil::com_ptr familyNames; + THROW_IF_FAILED(fontFamily->GetFamilyNames(familyNames.addressof())); + + wchar_t localeNameBuffer[LOCALE_NAME_MAX_LENGTH]; + const auto localeName = GetUserDefaultLocaleName(localeNameBuffer, LOCALE_NAME_MAX_LENGTH) ? localeNameBuffer : L"en-US"; + + UINT32 familyNameIndex; + BOOL familyNameExists; + if (FAILED(familyNames->FindLocaleName(localeName, &familyNameIndex, &familyNameExists)) || !familyNameExists) + { + familyNameIndex = 0; + } + UINT32 familyNameLength = 0; + THROW_IF_FAILED(familyNames->GetStringLength(familyNameIndex, &familyNameLength)); + familyNameLength += 1; // Account for the trailing null terminator during allocation. + + wchar_t familyName[512]; + THROW_HR_IF(E_OUTOFMEMORY, familyNameLength > ARRAYSIZE(familyName)); + THROW_IF_FAILED(familyNames->GetString(0, &familyName[0], familyNameLength)); + return std::wstring(familyName); + } + } + + std::vector GetInstalledFontFamilies() + { wil::com_ptr factory; THROW_IF_FAILED(DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(factory), factory.put_unknown())); @@ -18,37 +102,80 @@ namespace AppInstaller::Fonts THROW_IF_FAILED(factory->GetSystemFontCollection(collection.addressof(), FALSE)); const auto familyCount = collection->GetFontFamilyCount(); - std::vector familyNames; + std::vector fontFamilies; for (UINT32 index = 0; index < familyCount; index++) { wil::com_ptr family; THROW_IF_FAILED(collection->GetFontFamily(index, family.addressof())); - wil::com_ptr singleFont; - THROW_IF_FAILED(family->GetFont(0, &singleFont)); + std::wstring familyName = GetFontFamilyName(family); - // Prepare to retrieve font information - wil::com_ptr fullName; - BOOL fullNameExists; - THROW_IF_FAILED(singleFont->GetInformationalStrings(DWRITE_INFORMATIONAL_STRING_FULL_NAME, &fullName, &fullNameExists)); - UINT32 fullNameIndex; - if (FAILED(fullName->FindLocaleName(localeName, &fullNameIndex, &fullNameExists)) || !fullNameExists) + std::vector fontFaces; + const auto& fontCount = family->GetFontCount(); + for (UINT32 fontIndex = 0; fontIndex < fontCount; fontIndex++) { - fullNameIndex = 0; + wil::com_ptr font; + THROW_IF_FAILED(family->GetFont(fontIndex, font.addressof())); + std::wstring faceName = GetFontFaceName(font); + + wil::com_ptr fontFace; + THROW_IF_FAILED(font->CreateFontFace(fontFace.addressof())); + + std::vector filePaths = GetFontFilePaths(fontFace); + + FontFace fontFaceEntry; + fontFaceEntry.FaceName = std::wstring(faceName); + fontFaceEntry.FilePaths = std::move(filePaths); + fontFaces.emplace_back(fontFaceEntry); } - UINT32 fullNameLength = 0; - THROW_IF_FAILED(fullName->GetStringLength(fullNameIndex, &fullNameLength)); - fullNameLength += 1; // Account for the trailing null terminator during allocation. + FontFamily fontFamily; + fontFamily.FamilyName = familyName; + fontFamily.FontFaces = fontFaces; + fontFamilies.emplace_back(std::move(fontFamily)); + } + + return fontFamilies; + } + + FontFamily GetInstalledFontFamily(const std::wstring& familyName) + { + wil::com_ptr factory; + THROW_IF_FAILED(DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(factory), factory.put_unknown())); + + wil::com_ptr collection; + THROW_IF_FAILED(factory->GetSystemFontCollection(collection.addressof(), FALSE)); + + UINT32 familyIndex; + BOOL familyExists; + THROW_IF_FAILED(collection->FindFamilyName(familyName.c_str(), &familyIndex, &familyExists)); + + wil::com_ptr family; + THROW_IF_FAILED(collection->GetFontFamily(familyIndex, family.addressof())); + const auto fontCount = family->GetFontCount(); + + std::vector fontFaces; + for (UINT32 fontIndex = 0; fontIndex < fontCount; fontIndex++) + { + wil::com_ptr font; + THROW_IF_FAILED(family->GetFont(fontIndex, font.addressof())); + std::wstring faceName = GetFontFaceName(font); + + wil::com_ptr fontFace; + THROW_IF_FAILED(font->CreateFontFace(fontFace.addressof())); + + std::vector filePaths = GetFontFilePaths(fontFace); - wchar_t result[512]; - THROW_HR_IF(E_OUTOFMEMORY, fullNameLength > ARRAYSIZE(result)); - THROW_IF_FAILED(fullName->GetString(fullNameIndex, &result[0], fullNameLength)); - std::wstring familyName(result); - familyNames.emplace_back(familyName); + FontFace fontFaceEntry; + fontFaceEntry.FaceName = std::wstring(faceName); + fontFaceEntry.FilePaths = std::move(filePaths); + fontFaces.emplace_back(fontFaceEntry); } - return familyNames; + FontFamily fontFamily; + fontFamily.FamilyName = familyName; + fontFamily.FontFaces = std::move(fontFaces); + return fontFamily; } } diff --git a/src/AppInstallerCommonCore/Public/winget/Fonts.h b/src/AppInstallerCommonCore/Public/winget/Fonts.h index f373982bb4..17a1b50209 100644 --- a/src/AppInstallerCommonCore/Public/winget/Fonts.h +++ b/src/AppInstallerCommonCore/Public/winget/Fonts.h @@ -6,9 +6,28 @@ namespace AppInstaller::Fonts { + struct FontFace + { + std::wstring FaceName; + std::vector FilePaths; + }; + + struct FontFamily + { + std::wstring FamilyName; + std::vector FontFaces; + }; + /// /// Gets all installed font families on the system. /// /// A list of installed font family names. - std::vector GetInstalledFontFamilies(); + std::vector GetInstalledFontFamilies(); + + /// + /// Gets the installed font family from the provided family name. + /// + /// + /// + FontFamily GetInstalledFontFamily(const std::wstring& familyName); } From ca9f29602cf1c46cbd54adaf9a1c4e196637b319 Mon Sep 17 00:00:00 2001 From: --global Date: Tue, 15 Oct 2024 13:20:55 -0700 Subject: [PATCH 05/15] save work and add initial tests --- .../Commands/FontCommand.cpp | 31 +---- .../Commands/FontCommand.h | 2 +- src/AppInstallerCLICore/Resources.h | 5 +- .../Workflows/FontFlow.cpp | 120 ++++++++++-------- src/AppInstallerCLICore/Workflows/FontFlow.h | 4 +- .../Shared/Strings/en-us/winget.resw | 13 +- .../AppInstallerCLITests.vcxproj | 1 + .../AppInstallerCLITests.vcxproj.filters | 3 + src/AppInstallerCLITests/Fonts.cpp | 33 +++++ src/AppInstallerCommonCore/Fonts.cpp | 41 +++--- .../Public/winget/Fonts.h | 14 +- .../Public/winget/UserSettings.h | 2 +- 12 files changed, 152 insertions(+), 117 deletions(-) create mode 100644 src/AppInstallerCLITests/Fonts.cpp diff --git a/src/AppInstallerCLICore/Commands/FontCommand.cpp b/src/AppInstallerCLICore/Commands/FontCommand.cpp index dad6dd7951..76e904dca5 100644 --- a/src/AppInstallerCLICore/Commands/FontCommand.cpp +++ b/src/AppInstallerCLICore/Commands/FontCommand.cpp @@ -14,7 +14,7 @@ namespace AppInstaller::CLI using namespace AppInstaller::Utility::literals; using namespace std::string_view_literals; - Utility::LocIndView s_FontCommand_HelpLink = "https://aka.ms/winget-command-Font"_liv; + Utility::LocIndView s_FontCommand_HelpLink = "https://aka.ms/winget-command-help"_liv; std::vector> FontCommand::GetCommands() const { @@ -50,9 +50,7 @@ namespace AppInstaller::CLI Argument::ForType(Args::Type::Moniker), Argument::ForType(Args::Type::Source), Argument::ForType(Args::Type::Tag), - Argument::ForType(Args::Type::Command), Argument::ForType(Args::Type::Exact), - Argument::ForType(Args::Type::CustomHeader), Argument::ForType(Args::Type::AuthenticationMode), Argument::ForType(Args::Type::AuthenticationAccount), Argument::ForType(Args::Type::AcceptSourceAgreements), @@ -71,28 +69,9 @@ namespace AppInstaller::CLI void FontListCommand::Complete(Execution::Context& context, Args::Type valueType) const { - context << - Workflow::OpenSource() << - Workflow::OpenCompositeSource(Repository::PredefinedSource::Installed); - - switch (valueType) - { - case Execution::Args::Type::Query: - context << - Workflow::RequireCompletionWordNonEmpty << - Workflow::SearchSourceForManyCompletion << - Workflow::CompleteWithMatchedField; - break; - case Execution::Args::Type::Id: - case Execution::Args::Type::Name: - case Execution::Args::Type::Moniker: - case Execution::Args::Type::Source: - case Execution::Args::Type::Tag: - case Execution::Args::Type::Command: - context << - Workflow::CompleteWithSingleSemanticsForValueUsingExistingSource(valueType); - break; - } + UNREFERENCED_PARAMETER(valueType); + context.Reporter.Error() << Resource::String::PendingWorkError << std::endl; + THROW_HR(E_NOTIMPL); } Utility::LocIndView FontListCommand::HelpLink() const @@ -102,6 +81,6 @@ namespace AppInstaller::CLI void FontListCommand::ExecuteInternal(Execution::Context& context) const { - context << Workflow::ReportInstalledFontFamiliesResult; + context << Workflow::ReportInstalledFontsResult; } } diff --git a/src/AppInstallerCLICore/Commands/FontCommand.h b/src/AppInstallerCLICore/Commands/FontCommand.h index 12e953b5ab..d875c5dc6f 100644 --- a/src/AppInstallerCLICore/Commands/FontCommand.h +++ b/src/AppInstallerCLICore/Commands/FontCommand.h @@ -8,7 +8,7 @@ namespace AppInstaller::CLI { struct FontCommand final : public Command { - FontCommand(std::string_view parent) : Command("Font", {} /* aliases */, parent) {} + FontCommand(std::string_view parent) : Command("font", {} /* aliases */, parent, Settings::ExperimentalFeature::Feature::Font) {} std::vector> GetCommands() const override; diff --git a/src/AppInstallerCLICore/Resources.h b/src/AppInstallerCLICore/Resources.h index de46be77f6..8dc3b5bdaa 100644 --- a/src/AppInstallerCLICore/Resources.h +++ b/src/AppInstallerCLICore/Resources.h @@ -251,8 +251,8 @@ namespace AppInstaller::CLI::Resource WINGET_DEFINE_RESOURCE_STRINGID(FontCommandLongDescription); WINGET_DEFINE_RESOURCE_STRINGID(FontCommandShortDescription); WINGET_DEFINE_RESOURCE_STRINGID(FontFaceCount); - WINGET_DEFINE_RESOURCE_STRINGID(FontFaceName); - WINGET_DEFINE_RESOURCE_STRINGID(FontFamilyName); + WINGET_DEFINE_RESOURCE_STRINGID(FontFace); + WINGET_DEFINE_RESOURCE_STRINGID(FontFamily); WINGET_DEFINE_RESOURCE_STRINGID(FontFamilyNameArgumentDescription); WINGET_DEFINE_RESOURCE_STRINGID(FontFilePaths); WINGET_DEFINE_RESOURCE_STRINGID(FontListCommandLongDescription); @@ -411,6 +411,7 @@ namespace AppInstaller::CLI::Resource WINGET_DEFINE_RESOURCE_STRINGID(NoAdminRepairForUserScopePackage); WINGET_DEFINE_RESOURCE_STRINGID(NoApplicableInstallers); WINGET_DEFINE_RESOURCE_STRINGID(NoExperimentalFeaturesMessage); + WINGET_DEFINE_RESOURCE_STRINGID(NoInstalledFontFound); WINGET_DEFINE_RESOURCE_STRINGID(NoInstalledPackageFound); WINGET_DEFINE_RESOURCE_STRINGID(NoPackageFound); WINGET_DEFINE_RESOURCE_STRINGID(NoPackageSelectionArgumentProvided); diff --git a/src/AppInstallerCLICore/Workflows/FontFlow.cpp b/src/AppInstallerCLICore/Workflows/FontFlow.cpp index 0e299088de..a7f4f05375 100644 --- a/src/AppInstallerCLICore/Workflows/FontFlow.cpp +++ b/src/AppInstallerCLICore/Workflows/FontFlow.cpp @@ -2,89 +2,97 @@ // Licensed under the MIT License. #include "pch.h" #include "FontFlow.h" -#include +#include "TableOutput.h" #include namespace AppInstaller::CLI::Workflow { using namespace AppInstaller::CLI::Execution; - struct InstalledFontFamiliesTableLine + namespace { - InstalledFontFamiliesTableLine(Utility::LocIndString familyName, int faceCount) - : FamilyName(familyName), FaceCount(faceCount) {} + struct InstalledFontFamiliesTableLine + { + InstalledFontFamiliesTableLine(Utility::LocIndString familyName, int faceCount) + : FamilyName(familyName), FaceCount(faceCount) {} - Utility::LocIndString FamilyName; - int FaceCount; - }; + Utility::LocIndString FamilyName; + int FaceCount; + }; - struct InstalledFontFacesTableLine - { - InstalledFontFacesTableLine(Utility::LocIndString faceName, Utility::LocIndString familyName, std::filesystem::path filePath) - : FaceName(faceName), FamilyName(familyName), FilePath(filePath){} + struct InstalledFontFacesTableLine + { + InstalledFontFacesTableLine(Utility::LocIndString faceName, Utility::LocIndString familyName, std::filesystem::path filePath) + : FaceName(faceName), FamilyName(familyName), FilePath(filePath) {} - Utility::LocIndString FaceName; - Utility::LocIndString FamilyName; - std::filesystem::path FilePath; - }; + Utility::LocIndString FaceName; + Utility::LocIndString FamilyName; + std::filesystem::path FilePath; + }; - void OutputInstalledFontFamiliesTable(Execution::Context& context, const std::vector& lines) - { - Execution::TableOutput<2> table(context.Reporter, + void OutputInstalledFontFamiliesTable(Execution::Context& context, const std::vector& lines) + { + Execution::TableOutput<2> table(context.Reporter, { Resource::String::FontFamily, Resource::String::FontFaceCount }); + + for (const auto& line : lines) { - Resource::String::FontFamilyName, - Resource::String::FontFaceCount, - }); + table.OutputLine({ line.FamilyName, std::to_string(line.FaceCount) }); + } - for (const auto& line : lines) - { - table.OutputLine({ - line.FamilyName, - std::to_string(line.FaceCount) - }); + table.Complete(); } - table.Complete(); - } - void OutputInstalledFontFacesTable(Execution::Context& context, const std::vector& lines) - { - Execution::TableOutput<3> table(context.Reporter, + void OutputInstalledFontFacesTable(Execution::Context& context, const std::vector& lines) + { + Execution::TableOutput<3> table(context.Reporter, { Resource::String::FontFace, Resource::String::FontFamily, Resource::String::FontFilePaths }); + + for (const auto& line : lines) { - Resource::String::FontFaceName, - Resource::String::FontFamilyName, - Resource::String::FontFilePaths, - }); + table.OutputLine({ line.FaceName, line.FamilyName, line.FilePath.u8string() }); + } - for (const auto& line : lines) - { - table.OutputLine({ - line.FaceName, - line.FamilyName, - line.FilePath.u8string(), - }); + table.Complete(); } - table.Complete(); } - void ReportInstalledFontFamiliesResult(Execution::Context& context) + void ReportInstalledFontsResult(Execution::Context& context) { if (context.Args.Contains(Args::Type::FamilyName)) { + // TODO: Utilize font index for better searching capabitility. const auto& familyNameArg = context.Args.GetArg(Args::Type::FamilyName); const auto& fontFamily = AppInstaller::Fonts::GetInstalledFontFamily(AppInstaller::Utility::ConvertToUTF16(familyNameArg)); - std::vector lines; + if (!fontFamily.has_value()) + { + context.Reporter.Info() << Resource::String::NoInstalledFontFound << std::endl; + return; + } + const auto& familyName = Utility::LocIndString(familyNameArg); + std::vector lines; - for (const auto& fontFace : fontFamily.FontFaces) + for (const auto& fontFace : fontFamily->Faces) { - InstalledFontFacesTableLine line( - Utility::LocIndString(Utility::ConvertToUTF8(fontFace.FaceName)), - familyName, - fontFace.FilePaths[0] // Todo: update so that all paths are joined together by new line. - ); - - lines.push_back(std::move(line)); + bool isFirstLine = true; + for (const auto& filePath : fontFace.FilePaths) + { + if (isFirstLine) + { + InstalledFontFacesTableLine line( + Utility::LocIndString(Utility::ToLower(Utility::ConvertToUTF8(fontFace.Name))), + familyName, + filePath.u8string() + ); + isFirstLine = false; + lines.push_back(std::move(line)); + } + else + { + InstalledFontFacesTableLine line({}, {}, filePath.u8string()); + lines.push_back(std::move(line)); + } + } } OutputInstalledFontFacesTable(context, lines); @@ -97,8 +105,8 @@ namespace AppInstaller::CLI::Workflow for (const auto& fontFamily : fontFamilies) { InstalledFontFamiliesTableLine line( - Utility::LocIndString(Utility::ConvertToUTF8(fontFamily.FamilyName)), - (int)fontFamily.FontFaces.size() + Utility::LocIndString(Utility::ConvertToUTF8(fontFamily.Name)), + static_cast(fontFamily.Faces.size()) ); lines.push_back(std::move(line)); diff --git a/src/AppInstallerCLICore/Workflows/FontFlow.h b/src/AppInstallerCLICore/Workflows/FontFlow.h index 947699a519..b84267ebb3 100644 --- a/src/AppInstallerCLICore/Workflows/FontFlow.h +++ b/src/AppInstallerCLICore/Workflows/FontFlow.h @@ -5,9 +5,9 @@ namespace AppInstaller::CLI::Workflow { - // Reports the installed font families as a table. + // Reports the installed fonts as a table. // Required Args: None // Inputs: None // Outputs: None - void ReportInstalledFontFamiliesResult(Execution::Context& context); + void ReportInstalledFontsResult(Execution::Context& context); } diff --git a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw index 3ac0624bc9..5355ee4ec1 100644 --- a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw +++ b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw @@ -3139,8 +3139,8 @@ Please specify one of them using the --source option to proceed. Manage Font with sub-commands. Font can be installed, upgraded, or uninstalled similar to packages. - - Family Name + + Family Face Count @@ -3148,10 +3148,13 @@ Please specify one of them using the --source option to proceed. Filter results by family name - - Face Name + + Face - File Paths + Paths + + + No installed font found matching input criteria. \ No newline at end of file diff --git a/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj b/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj index 9b0e2e2853..e13ff2d4bd 100644 --- a/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj +++ b/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj @@ -284,6 +284,7 @@ + diff --git a/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj.filters b/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj.filters index 2bbcd74516..f770c00c50 100644 --- a/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj.filters +++ b/src/AppInstallerCLITests/AppInstallerCLITests.vcxproj.filters @@ -365,6 +365,9 @@ Source Files\CLI + + Source Files\Common + diff --git a/src/AppInstallerCLITests/Fonts.cpp b/src/AppInstallerCLITests/Fonts.cpp new file mode 100644 index 0000000000..29fbbd4ca9 --- /dev/null +++ b/src/AppInstallerCLITests/Fonts.cpp @@ -0,0 +1,33 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. +#include "pch.h" +#include "TestCommon.h" +#include + +using namespace AppInstaller::Fonts; +using namespace TestCommon; + +constexpr std::wstring_view s_testFontName = L"Times New Roman"; + +TEST_CASE("GetInstalledFonts", "[fonts]") +{ + std::vector installedFontFamilies; + REQUIRE_NOTHROW(installedFontFamilies = GetInstalledFontFamilies()); + REQUIRE(installedFontFamilies.size() > 0); +} + +TEST_CASE("GetSingleFontFamily", "[fonts]") +{ + std::optional fontFamily; + REQUIRE_NOTHROW(fontFamily = GetInstalledFontFamily(std::wstring(s_testFontName))); + REQUIRE(fontFamily.has_value()); + REQUIRE(AppInstaller::Utility::CaseInsensitiveEquals(fontFamily->Name, s_testFontName)); + REQUIRE(fontFamily->Faces.size() > 0); +} + +TEST_CASE("GetInvalidFontFamily", "[fonts]") +{ + std::optional fontFamily; + REQUIRE_NOTHROW(fontFamily = GetInstalledFontFamily(L"Invalid Font")); + REQUIRE_FALSE(fontFamily.has_value()); +} diff --git a/src/AppInstallerCommonCore/Fonts.cpp b/src/AppInstallerCommonCore/Fonts.cpp index bc40c74f1f..5ec847931d 100644 --- a/src/AppInstallerCommonCore/Fonts.cpp +++ b/src/AppInstallerCommonCore/Fonts.cpp @@ -1,14 +1,15 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. #include "pch.h" -#include "Public/winget/Fonts.h" #include +#include +#include namespace AppInstaller::Fonts { namespace { - std::vector GetFontFilePaths(const wil::com_ptr& fontFace) + std::vector GetFontFilePaths(const wil::com_ptr& fontFace) { UINT32 fileCount = 0; THROW_IF_FAILED(fontFace->GetFiles(&fileCount, nullptr)); @@ -17,7 +18,7 @@ namespace AppInstaller::Fonts THROW_HR_IF(E_OUTOFMEMORY, fileCount > ARRAYSIZE(fontFiles)); THROW_IF_FAILED(fontFace->GetFiles(&fileCount, fontFiles[0].addressof())); - std::vector filePaths; + std::vector filePaths; for (UINT32 i = 0; i < fileCount; ++i) { wil::com_ptr loader; THROW_IF_FAILED(fontFiles[i]->GetLoader(loader.addressof())); @@ -31,14 +32,15 @@ namespace AppInstaller::Fonts THROW_IF_FAILED(localLoader->GetFilePathLengthFromKey(fontFileReferenceKey, fontFileReferenceKeySize, &pathLength)); pathLength += 1; // Account for the trailing null terminator during allocation. - wchar_t path[512]; + wchar_t path[MAX_PATH]; THROW_HR_IF(E_OUTOFMEMORY, pathLength > ARRAYSIZE(path)); THROW_IF_FAILED(localLoader->GetFilePathFromKey(fontFileReferenceKey, fontFileReferenceKeySize, &path[0], pathLength)); - filePaths.emplace_back(std::wstring(path)); + std::filesystem::path fontFilePath = { AppInstaller::Utility::Normalize(std::wstring(path)) }; + filePaths.push_back(std::move(fontFilePath)); } } - return filePaths; + return std::move(filePaths); } std::wstring GetFontFaceName(const wil::com_ptr& font) @@ -122,24 +124,24 @@ namespace AppInstaller::Fonts wil::com_ptr fontFace; THROW_IF_FAILED(font->CreateFontFace(fontFace.addressof())); - std::vector filePaths = GetFontFilePaths(fontFace); + const auto& filePaths = GetFontFilePaths(fontFace); FontFace fontFaceEntry; - fontFaceEntry.FaceName = std::wstring(faceName); - fontFaceEntry.FilePaths = std::move(filePaths); + fontFaceEntry.Name = std::wstring(faceName); + fontFaceEntry.FilePaths = filePaths; fontFaces.emplace_back(fontFaceEntry); } FontFamily fontFamily; - fontFamily.FamilyName = familyName; - fontFamily.FontFaces = fontFaces; + fontFamily.Name = familyName; + fontFamily.Faces = fontFaces; fontFamilies.emplace_back(std::move(fontFamily)); } return fontFamilies; } - FontFamily GetInstalledFontFamily(const std::wstring& familyName) + std::optional GetInstalledFontFamily(const std::wstring& familyName) { wil::com_ptr factory; THROW_IF_FAILED(DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(factory), factory.put_unknown())); @@ -151,6 +153,11 @@ namespace AppInstaller::Fonts BOOL familyExists; THROW_IF_FAILED(collection->FindFamilyName(familyName.c_str(), &familyIndex, &familyExists)); + if (!familyExists) + { + return {}; + } + wil::com_ptr family; THROW_IF_FAILED(collection->GetFontFamily(familyIndex, family.addressof())); const auto fontCount = family->GetFontCount(); @@ -165,17 +172,17 @@ namespace AppInstaller::Fonts wil::com_ptr fontFace; THROW_IF_FAILED(font->CreateFontFace(fontFace.addressof())); - std::vector filePaths = GetFontFilePaths(fontFace); + const auto& filePaths = GetFontFilePaths(fontFace); FontFace fontFaceEntry; - fontFaceEntry.FaceName = std::wstring(faceName); - fontFaceEntry.FilePaths = std::move(filePaths); + fontFaceEntry.Name = std::wstring(faceName); + fontFaceEntry.FilePaths = filePaths; fontFaces.emplace_back(fontFaceEntry); } FontFamily fontFamily; - fontFamily.FamilyName = familyName; - fontFamily.FontFaces = std::move(fontFaces); + fontFamily.Name = familyName; + fontFamily.Faces = std::move(fontFaces); return fontFamily; } } diff --git a/src/AppInstallerCommonCore/Public/winget/Fonts.h b/src/AppInstallerCommonCore/Public/winget/Fonts.h index 17a1b50209..555265c05f 100644 --- a/src/AppInstallerCommonCore/Public/winget/Fonts.h +++ b/src/AppInstallerCommonCore/Public/winget/Fonts.h @@ -8,14 +8,14 @@ namespace AppInstaller::Fonts { struct FontFace { - std::wstring FaceName; - std::vector FilePaths; + std::wstring Name; + std::vector FilePaths; }; struct FontFamily { - std::wstring FamilyName; - std::vector FontFaces; + std::wstring Name; + std::vector Faces; }; /// @@ -27,7 +27,7 @@ namespace AppInstaller::Fonts /// /// Gets the installed font family from the provided family name. /// - /// - /// - FontFamily GetInstalledFontFamily(const std::wstring& familyName); + /// The font family name. + /// The Font Family. + std::optional GetInstalledFontFamily(const std::wstring& familyName); } diff --git a/src/AppInstallerCommonCore/Public/winget/UserSettings.h b/src/AppInstallerCommonCore/Public/winget/UserSettings.h index a8517a3122..02a96c829e 100644 --- a/src/AppInstallerCommonCore/Public/winget/UserSettings.h +++ b/src/AppInstallerCommonCore/Public/winget/UserSettings.h @@ -162,7 +162,7 @@ namespace AppInstaller::Settings SETTINGMAPPING_SPECIALIZATION(Setting::EFConfiguration03, bool, bool, false, ".experimentalFeatures.configuration03"sv); SETTINGMAPPING_SPECIALIZATION(Setting::EFConfigureSelfElevation, bool, bool, false, ".experimentalFeatures.configureSelfElevate"sv); SETTINGMAPPING_SPECIALIZATION(Setting::EFConfigureExport, bool, bool, false, ".experimentalFeatures.configureExport"sv); - SETTINGMAPPING_SPECIALIZATION(Setting::EFFont, bool, bool, false, ".experimentalFeatures.Font"sv); + SETTINGMAPPING_SPECIALIZATION(Setting::EFFont, bool, bool, false, ".experimentalFeatures.font"sv); // Telemetry SETTINGMAPPING_SPECIALIZATION(Setting::TelemetryDisable, bool, bool, false, ".telemetry.disable"sv); // Install behavior From a50d0721577c4f33294174280f25c7319d9e1c71 Mon Sep 17 00:00:00 2001 From: --global Date: Wed, 16 Oct 2024 09:52:58 -0700 Subject: [PATCH 06/15] minor fixes --- src/AppInstallerCLICore/Workflows/FontFlow.cpp | 2 +- src/AppInstallerCommonCore/Fonts.cpp | 6 +++--- src/AppInstallerCommonCore/Public/winget/Fonts.h | 2 ++ 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/AppInstallerCLICore/Workflows/FontFlow.cpp b/src/AppInstallerCLICore/Workflows/FontFlow.cpp index a7f4f05375..3d5db687fc 100644 --- a/src/AppInstallerCLICore/Workflows/FontFlow.cpp +++ b/src/AppInstallerCLICore/Workflows/FontFlow.cpp @@ -69,7 +69,7 @@ namespace AppInstaller::CLI::Workflow return; } - const auto& familyName = Utility::LocIndString(familyNameArg); + const auto& familyName = Utility::LocIndString(Utility::ConvertToUTF8(fontFamily->Name)); std::vector lines; for (const auto& fontFace : fontFamily->Faces) diff --git a/src/AppInstallerCommonCore/Fonts.cpp b/src/AppInstallerCommonCore/Fonts.cpp index 5ec847931d..0cf5679482 100644 --- a/src/AppInstallerCommonCore/Fonts.cpp +++ b/src/AppInstallerCommonCore/Fonts.cpp @@ -62,7 +62,7 @@ namespace AppInstaller::Fonts THROW_IF_FAILED(faceNames->GetStringLength(faceNameIndex, &faceNameLength)); faceNameLength += 1; // Account for the trailing null terminator during allocation. - wchar_t faceName[512]; + wchar_t faceName[32]; // Max size for font name including null terminator is 32. THROW_HR_IF(E_OUTOFMEMORY, faceNameLength > ARRAYSIZE(faceName)); THROW_IF_FAILED(faceNames->GetString(faceNameIndex, &faceName[0], faceNameLength)); return std::wstring(faceName); @@ -88,7 +88,7 @@ namespace AppInstaller::Fonts THROW_IF_FAILED(familyNames->GetStringLength(familyNameIndex, &familyNameLength)); familyNameLength += 1; // Account for the trailing null terminator during allocation. - wchar_t familyName[512]; + wchar_t familyName[32]; // Max size for font name including null terminator is 32. THROW_HR_IF(E_OUTOFMEMORY, familyNameLength > ARRAYSIZE(familyName)); THROW_IF_FAILED(familyNames->GetString(0, &familyName[0], familyNameLength)); return std::wstring(familyName); @@ -181,7 +181,7 @@ namespace AppInstaller::Fonts } FontFamily fontFamily; - fontFamily.Name = familyName; + fontFamily.Name = GetFontFamilyName(family); fontFamily.Faces = std::move(fontFaces); return fontFamily; } diff --git a/src/AppInstallerCommonCore/Public/winget/Fonts.h b/src/AppInstallerCommonCore/Public/winget/Fonts.h index 555265c05f..d4f03d8d00 100644 --- a/src/AppInstallerCommonCore/Public/winget/Fonts.h +++ b/src/AppInstallerCommonCore/Public/winget/Fonts.h @@ -10,6 +10,8 @@ namespace AppInstaller::Fonts { std::wstring Name; std::vector FilePaths; + + // TODO: Add support for font face versions. }; struct FontFamily From 104f465c047ab82b2e4f0d1f823a8480da6a8a5e Mon Sep 17 00:00:00 2001 From: --global Date: Wed, 16 Oct 2024 09:57:59 -0700 Subject: [PATCH 07/15] update comments --- src/AppInstallerCommonCore/Public/winget/Fonts.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/AppInstallerCommonCore/Public/winget/Fonts.h b/src/AppInstallerCommonCore/Public/winget/Fonts.h index d4f03d8d00..1d86ef1efa 100644 --- a/src/AppInstallerCommonCore/Public/winget/Fonts.h +++ b/src/AppInstallerCommonCore/Public/winget/Fonts.h @@ -23,13 +23,13 @@ namespace AppInstaller::Fonts /// /// Gets all installed font families on the system. /// - /// A list of installed font family names. + /// A list of installed font families. std::vector GetInstalledFontFamilies(); /// /// Gets the installed font family from the provided family name. /// /// The font family name. - /// The Font Family. + /// The specified font family if found. std::optional GetInstalledFontFamily(const std::wstring& familyName); } From 637faa5aaf27788cc2627b99dd6d490b92184978 Mon Sep 17 00:00:00 2001 From: --global Date: Thu, 17 Oct 2024 20:14:56 -0700 Subject: [PATCH 08/15] address initial comments --- .github/actions/spelling/expect.txt | 1 + .../JSON/settings/settings.schema.0.2.json | 4 +- src/AppInstallerCLICore/Argument.cpp | 8 +- .../Commands/FontCommand.cpp | 6 +- .../Commands/FontCommand.h | 2 +- src/AppInstallerCLICore/ExecutionArgs.h | 2 +- .../Workflows/FontFlow.cpp | 8 +- src/AppInstallerCLICore/Workflows/FontFlow.h | 2 +- .../Shared/Strings/en-us/Resources.resw | 6 - .../Shared/Strings/en-us/winget.resw | 16 +-- .../ExperimentalFeature.cpp | 2 +- src/AppInstallerCommonCore/Fonts.cpp | 117 ++++++++---------- .../Public/winget/UserSettings.h | 4 +- src/AppInstallerCommonCore/UserSettings.cpp | 2 +- 14 files changed, 82 insertions(+), 98 deletions(-) diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt index f063332bb8..8c2cff836e 100644 --- a/.github/actions/spelling/expect.txt +++ b/.github/actions/spelling/expect.txt @@ -143,6 +143,7 @@ DUPLICATEALIAS dustojnikhummer dvinns dwgs +dwrite ecfr ecfrbrowse EFGH diff --git a/schemas/JSON/settings/settings.schema.0.2.json b/schemas/JSON/settings/settings.schema.0.2.json index 93d682006a..2113127f0e 100644 --- a/schemas/JSON/settings/settings.schema.0.2.json +++ b/schemas/JSON/settings/settings.schema.0.2.json @@ -288,8 +288,8 @@ "type": "boolean", "default": false }, - "Font": { - "description": "Enable support for managing Font", + "fonts": { + "description": "Enable support for managing fonts", "type": "boolean", "default": false } diff --git a/src/AppInstallerCLICore/Argument.cpp b/src/AppInstallerCLICore/Argument.cpp index b750981924..0b1864df3c 100644 --- a/src/AppInstallerCLICore/Argument.cpp +++ b/src/AppInstallerCLICore/Argument.cpp @@ -199,8 +199,8 @@ namespace AppInstaller::CLI return { type, "ignore-resume-limit"_liv, ArgTypeCategory::None }; // Font command - case Execution::Args::Type::FamilyName: - return { type, "family-name"_liv, ArgTypeCategory::None }; + case Execution::Args::Type::Family: + return { type, "family"_liv, ArgTypeCategory::None }; // Configuration commands case Execution::Args::Type::ConfigurationFile: @@ -434,8 +434,8 @@ namespace AppInstaller::CLI return Argument{ type, Resource::String::ProxyArgumentDescription, ArgumentType::Standard, TogglePolicy::Policy::ProxyCommandLineOptions, BoolAdminSetting::ProxyCommandLineOptions }; case Args::Type::NoProxy: return Argument{ type, Resource::String::NoProxyArgumentDescription, ArgumentType::Flag, TogglePolicy::Policy::ProxyCommandLineOptions, BoolAdminSetting::ProxyCommandLineOptions }; - case Args::Type::FamilyName: - return Argument{ type, Resource::String::FontFamilyNameArgumentDescription, ArgumentType::Standard, false }; + case Args::Type::Family: + return Argument{ type, Resource::String::FontFamilyNameArgumentDescription, ArgumentType::Positional, false }; default: THROW_HR(E_UNEXPECTED); } diff --git a/src/AppInstallerCLICore/Commands/FontCommand.cpp b/src/AppInstallerCLICore/Commands/FontCommand.cpp index 76e904dca5..c6faae5b44 100644 --- a/src/AppInstallerCLICore/Commands/FontCommand.cpp +++ b/src/AppInstallerCLICore/Commands/FontCommand.cpp @@ -14,7 +14,7 @@ namespace AppInstaller::CLI using namespace AppInstaller::Utility::literals; using namespace std::string_view_literals; - Utility::LocIndView s_FontCommand_HelpLink = "https://aka.ms/winget-command-help"_liv; + Utility::LocIndView s_FontCommand_HelpLink = "https://aka.ms/winget-command-font"_liv; std::vector> FontCommand::GetCommands() const { @@ -46,7 +46,7 @@ namespace AppInstaller::CLI std::vector FontListCommand::GetArguments() const { return { - Argument::ForType(Args::Type::FamilyName), + Argument::ForType(Args::Type::Family), Argument::ForType(Args::Type::Moniker), Argument::ForType(Args::Type::Source), Argument::ForType(Args::Type::Tag), @@ -81,6 +81,6 @@ namespace AppInstaller::CLI void FontListCommand::ExecuteInternal(Execution::Context& context) const { - context << Workflow::ReportInstalledFontsResult; + context << Workflow::ReportInstalledFonts; } } diff --git a/src/AppInstallerCLICore/Commands/FontCommand.h b/src/AppInstallerCLICore/Commands/FontCommand.h index d875c5dc6f..c29f703f6c 100644 --- a/src/AppInstallerCLICore/Commands/FontCommand.h +++ b/src/AppInstallerCLICore/Commands/FontCommand.h @@ -8,7 +8,7 @@ namespace AppInstaller::CLI { struct FontCommand final : public Command { - FontCommand(std::string_view parent) : Command("font", {} /* aliases */, parent, Settings::ExperimentalFeature::Feature::Font) {} + FontCommand(std::string_view parent) : Command("font", { "fonts" }, parent, Settings::ExperimentalFeature::Feature::Font) {} std::vector> GetCommands() const override; diff --git a/src/AppInstallerCLICore/ExecutionArgs.h b/src/AppInstallerCLICore/ExecutionArgs.h index e96114aea7..7bb2c28628 100644 --- a/src/AppInstallerCLICore/ExecutionArgs.h +++ b/src/AppInstallerCLICore/ExecutionArgs.h @@ -122,7 +122,7 @@ namespace AppInstaller::CLI::Execution IgnoreResumeLimit, // Font Command - FamilyName, + Family, // Configuration ConfigurationFile, diff --git a/src/AppInstallerCLICore/Workflows/FontFlow.cpp b/src/AppInstallerCLICore/Workflows/FontFlow.cpp index 3d5db687fc..5180b2ad8e 100644 --- a/src/AppInstallerCLICore/Workflows/FontFlow.cpp +++ b/src/AppInstallerCLICore/Workflows/FontFlow.cpp @@ -55,12 +55,12 @@ namespace AppInstaller::CLI::Workflow } } - void ReportInstalledFontsResult(Execution::Context& context) + void ReportInstalledFonts(Execution::Context& context) { - if (context.Args.Contains(Args::Type::FamilyName)) + if (context.Args.Contains(Args::Type::Family)) { - // TODO: Utilize font index for better searching capabitility. - const auto& familyNameArg = context.Args.GetArg(Args::Type::FamilyName); + // TODO: Utilize font index for better searching capability. + const auto& familyNameArg = context.Args.GetArg(Args::Type::Family); const auto& fontFamily = AppInstaller::Fonts::GetInstalledFontFamily(AppInstaller::Utility::ConvertToUTF16(familyNameArg)); if (!fontFamily.has_value()) diff --git a/src/AppInstallerCLICore/Workflows/FontFlow.h b/src/AppInstallerCLICore/Workflows/FontFlow.h index b84267ebb3..c3346e1a60 100644 --- a/src/AppInstallerCLICore/Workflows/FontFlow.h +++ b/src/AppInstallerCLICore/Workflows/FontFlow.h @@ -9,5 +9,5 @@ namespace AppInstaller::CLI::Workflow // Required Args: None // Inputs: None // Outputs: None - void ReportInstalledFontsResult(Execution::Context& context); + void ReportInstalledFonts(Execution::Context& context); } diff --git a/src/AppInstallerCLIPackage/Shared/Strings/en-us/Resources.resw b/src/AppInstallerCLIPackage/Shared/Strings/en-us/Resources.resw index 50c2e8bbc5..6fa1b87984 100644 --- a/src/AppInstallerCLIPackage/Shared/Strings/en-us/Resources.resw +++ b/src/AppInstallerCLIPackage/Shared/Strings/en-us/Resources.resw @@ -121,10 +121,4 @@ Not Localized {Locked} This file is required to establish the basic expected subresource in the resource map. It is not used to facilitate localization with other projects. - - List installed Font - - - List all installed Font, or full details of a specific font. - \ No newline at end of file diff --git a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw index 028fc0f1f1..208b6ce9ca 100644 --- a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw +++ b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw @@ -3133,17 +3133,11 @@ Please specify one of them using the --source option to proceed. Parameter cannot be passed across integrity boundary. - - Downloaded zero byte installer; ensure that your network connection is working properly. - - - Downloaded zero byte installer; ensure that your network connection is working properly. - - Manage Font + Manage fonts - Manage Font with sub-commands. Font can be installed, upgraded, or uninstalled similar to packages. + Manage fonts with sub-commands. Fonts can be installed, upgraded, or uninstalled similar to packages. Family @@ -3163,4 +3157,10 @@ Please specify one of them using the --source option to proceed. No installed font found matching input criteria. + + List installed fonts + + + List all installed fonts, or full details of a specific font. + \ No newline at end of file diff --git a/src/AppInstallerCommonCore/ExperimentalFeature.cpp b/src/AppInstallerCommonCore/ExperimentalFeature.cpp index 049139083a..c3709c6802 100644 --- a/src/AppInstallerCommonCore/ExperimentalFeature.cpp +++ b/src/AppInstallerCommonCore/ExperimentalFeature.cpp @@ -49,7 +49,7 @@ namespace AppInstaller::Settings case ExperimentalFeature::Feature::ConfigureExport: return userSettings.Get(); case ExperimentalFeature::Feature::Font: - return userSettings.Get(); + return userSettings.Get(); default: THROW_HR(E_UNEXPECTED); } diff --git a/src/AppInstallerCommonCore/Fonts.cpp b/src/AppInstallerCommonCore/Fonts.cpp index 0cf5679482..814152111f 100644 --- a/src/AppInstallerCommonCore/Fonts.cpp +++ b/src/AppInstallerCommonCore/Fonts.cpp @@ -14,8 +14,10 @@ namespace AppInstaller::Fonts UINT32 fileCount = 0; THROW_IF_FAILED(fontFace->GetFiles(&fileCount, nullptr)); - wil::com_ptr fontFiles[8]; - THROW_HR_IF(E_OUTOFMEMORY, fileCount > ARRAYSIZE(fontFiles)); + static_assert(sizeof(wil::com_ptr) == sizeof(IDWriteFontFile*)); + std::vector> fontFiles; + fontFiles.resize(fileCount); + THROW_IF_FAILED(fontFace->GetFiles(&fileCount, fontFiles[0].addressof())); std::vector filePaths; @@ -32,66 +34,59 @@ namespace AppInstaller::Fonts THROW_IF_FAILED(localLoader->GetFilePathLengthFromKey(fontFileReferenceKey, fontFileReferenceKeySize, &pathLength)); pathLength += 1; // Account for the trailing null terminator during allocation. - wchar_t path[MAX_PATH]; - THROW_HR_IF(E_OUTOFMEMORY, pathLength > ARRAYSIZE(path)); + std::wstring path; + path.reserve(pathLength); + THROW_IF_FAILED(localLoader->GetFilePathFromKey(fontFileReferenceKey, fontFileReferenceKeySize, &path[0], pathLength)); - std::filesystem::path fontFilePath = { AppInstaller::Utility::Normalize(std::wstring(path)) }; + std::filesystem::path fontFilePath = { std::move(path) }; filePaths.push_back(std::move(fontFilePath)); } } - return std::move(filePaths); + return filePaths; } - std::wstring GetFontFaceName(const wil::com_ptr& font) + std::wstring GetLocalizedStringFromFont(const wil::com_ptr& localizedStringCollection) { - wil::com_ptr faceNames; - THROW_IF_FAILED(font->GetFaceNames(faceNames.addressof())); - wchar_t localeNameBuffer[LOCALE_NAME_MAX_LENGTH]; const auto localeName = GetUserDefaultLocaleName(localeNameBuffer, LOCALE_NAME_MAX_LENGTH) ? localeNameBuffer : L"en-US"; - UINT32 faceNameIndex; - BOOL faceNameExists; - if (FAILED(faceNames->FindLocaleName(localeName, &faceNameIndex, &faceNameExists)) || !faceNameExists) + UINT32 index; + BOOL exists; + if (FAILED(localizedStringCollection->FindLocaleName(localeName, &index, &exists)) || !exists) { - faceNameIndex = 0; + index = 0; } - UINT32 faceNameLength = 0; - THROW_IF_FAILED(faceNames->GetStringLength(faceNameIndex, &faceNameLength)); - faceNameLength += 1; // Account for the trailing null terminator during allocation. + UINT32 length = 0; + THROW_IF_FAILED(localizedStringCollection->GetStringLength(index, &length)); + length += 1; // Account for the trailing null terminator during allocation. - wchar_t faceName[32]; // Max size for font name including null terminator is 32. - THROW_HR_IF(E_OUTOFMEMORY, faceNameLength > ARRAYSIZE(faceName)); - THROW_IF_FAILED(faceNames->GetString(faceNameIndex, &faceName[0], faceNameLength)); - return std::wstring(faceName); + wchar_t* localizedString = new wchar_t[length]; + HRESULT hr = localizedStringCollection->GetString(index, localizedString, length); + THROW_IF_FAILED(hr); + return std::wstring(localizedString); + } + + std::wstring GetFontFaceName(const wil::com_ptr& font) + { + wil::com_ptr faceNames; + THROW_IF_FAILED(font->GetFaceNames(faceNames.addressof())); + return GetLocalizedStringFromFont(faceNames); } std::wstring GetFontFamilyName(const wil::com_ptr& fontFamily) { - // Retrieve family names. wil::com_ptr familyNames; THROW_IF_FAILED(fontFamily->GetFamilyNames(familyNames.addressof())); + return GetLocalizedStringFromFont(familyNames); + } - wchar_t localeNameBuffer[LOCALE_NAME_MAX_LENGTH]; - const auto localeName = GetUserDefaultLocaleName(localeNameBuffer, LOCALE_NAME_MAX_LENGTH) ? localeNameBuffer : L"en-US"; - - UINT32 familyNameIndex; - BOOL familyNameExists; - if (FAILED(familyNames->FindLocaleName(localeName, &familyNameIndex, &familyNameExists)) || !familyNameExists) - { - familyNameIndex = 0; - } - - UINT32 familyNameLength = 0; - THROW_IF_FAILED(familyNames->GetStringLength(familyNameIndex, &familyNameLength)); - familyNameLength += 1; // Account for the trailing null terminator during allocation. - - wchar_t familyName[32]; // Max size for font name including null terminator is 32. - THROW_HR_IF(E_OUTOFMEMORY, familyNameLength > ARRAYSIZE(familyName)); - THROW_IF_FAILED(familyNames->GetString(0, &familyName[0], familyNameLength)); - return std::wstring(familyName); + wil::com_ptr CreateFontFamily(const wil::com_ptr& collection, UINT32 index) + { + wil::com_ptr family; + THROW_IF_FAILED(collection->GetFontFamily(index, family.addressof())); + return family; } } @@ -103,38 +98,35 @@ namespace AppInstaller::Fonts wil::com_ptr collection; THROW_IF_FAILED(factory->GetSystemFontCollection(collection.addressof(), FALSE)); - const auto familyCount = collection->GetFontFamilyCount(); + UINT32 familyCount = collection->GetFontFamilyCount(); std::vector fontFamilies; for (UINT32 index = 0; index < familyCount; index++) { - wil::com_ptr family; - THROW_IF_FAILED(collection->GetFontFamily(index, family.addressof())); - + wil::com_ptr family = CreateFontFamily(collection, index); std::wstring familyName = GetFontFamilyName(family); std::vector fontFaces; - const auto& fontCount = family->GetFontCount(); + UINT32 fontCount = family->GetFontCount(); for (UINT32 fontIndex = 0; fontIndex < fontCount; fontIndex++) { wil::com_ptr font; THROW_IF_FAILED(family->GetFont(fontIndex, font.addressof())); + std::wstring faceName = GetFontFaceName(font); wil::com_ptr fontFace; THROW_IF_FAILED(font->CreateFontFace(fontFace.addressof())); - const auto& filePaths = GetFontFilePaths(fontFace); - FontFace fontFaceEntry; - fontFaceEntry.Name = std::wstring(faceName); - fontFaceEntry.FilePaths = filePaths; - fontFaces.emplace_back(fontFaceEntry); + fontFaceEntry.Name = faceName; + fontFaceEntry.FilePaths = GetFontFilePaths(fontFace); + fontFaces.emplace_back(std::move(fontFaceEntry)); } FontFamily fontFamily; - fontFamily.Name = familyName; - fontFamily.Faces = fontFaces; + fontFamily.Name = std::move(familyName); + fontFamily.Faces = std::move(fontFaces); fontFamilies.emplace_back(std::move(fontFamily)); } @@ -149,18 +141,17 @@ namespace AppInstaller::Fonts wil::com_ptr collection; THROW_IF_FAILED(factory->GetSystemFontCollection(collection.addressof(), FALSE)); - UINT32 familyIndex; - BOOL familyExists; - THROW_IF_FAILED(collection->FindFamilyName(familyName.c_str(), &familyIndex, &familyExists)); + UINT32 index; + BOOL exists; + THROW_IF_FAILED(collection->FindFamilyName(familyName.c_str(), &index, &exists)); - if (!familyExists) + if (!exists) { return {}; } - wil::com_ptr family; - THROW_IF_FAILED(collection->GetFontFamily(familyIndex, family.addressof())); - const auto fontCount = family->GetFontCount(); + wil::com_ptr family = CreateFontFamily(collection, index); + UINT32 fontCount = family->GetFontCount(); std::vector fontFaces; for (UINT32 fontIndex = 0; fontIndex < fontCount; fontIndex++) @@ -172,12 +163,10 @@ namespace AppInstaller::Fonts wil::com_ptr fontFace; THROW_IF_FAILED(font->CreateFontFace(fontFace.addressof())); - const auto& filePaths = GetFontFilePaths(fontFace); - FontFace fontFaceEntry; - fontFaceEntry.Name = std::wstring(faceName); - fontFaceEntry.FilePaths = filePaths; - fontFaces.emplace_back(fontFaceEntry); + fontFaceEntry.Name = faceName; + fontFaceEntry.FilePaths = GetFontFilePaths(fontFace); + fontFaces.emplace_back(std::move(fontFaceEntry)); } FontFamily fontFamily; diff --git a/src/AppInstallerCommonCore/Public/winget/UserSettings.h b/src/AppInstallerCommonCore/Public/winget/UserSettings.h index 02a96c829e..b580775c28 100644 --- a/src/AppInstallerCommonCore/Public/winget/UserSettings.h +++ b/src/AppInstallerCommonCore/Public/winget/UserSettings.h @@ -78,7 +78,7 @@ namespace AppInstaller::Settings EFConfiguration03, EFConfigureSelfElevation, EFConfigureExport, - EFFont, + EFFonts, // Telemetry TelemetryDisable, // Install behavior @@ -162,7 +162,7 @@ namespace AppInstaller::Settings SETTINGMAPPING_SPECIALIZATION(Setting::EFConfiguration03, bool, bool, false, ".experimentalFeatures.configuration03"sv); SETTINGMAPPING_SPECIALIZATION(Setting::EFConfigureSelfElevation, bool, bool, false, ".experimentalFeatures.configureSelfElevate"sv); SETTINGMAPPING_SPECIALIZATION(Setting::EFConfigureExport, bool, bool, false, ".experimentalFeatures.configureExport"sv); - SETTINGMAPPING_SPECIALIZATION(Setting::EFFont, bool, bool, false, ".experimentalFeatures.font"sv); + SETTINGMAPPING_SPECIALIZATION(Setting::EFFonts, bool, bool, false, ".experimentalFeatures.fonts"sv); // Telemetry SETTINGMAPPING_SPECIALIZATION(Setting::TelemetryDisable, bool, bool, false, ".telemetry.disable"sv); // Install behavior diff --git a/src/AppInstallerCommonCore/UserSettings.cpp b/src/AppInstallerCommonCore/UserSettings.cpp index 202a1cb199..9e13610537 100644 --- a/src/AppInstallerCommonCore/UserSettings.cpp +++ b/src/AppInstallerCommonCore/UserSettings.cpp @@ -269,7 +269,7 @@ namespace AppInstaller::Settings WINGET_VALIDATE_PASS_THROUGH(EFConfiguration03) WINGET_VALIDATE_PASS_THROUGH(EFConfigureSelfElevation) WINGET_VALIDATE_PASS_THROUGH(EFConfigureExport) - WINGET_VALIDATE_PASS_THROUGH(EFFont) + WINGET_VALIDATE_PASS_THROUGH(EFFonts) WINGET_VALIDATE_PASS_THROUGH(AnonymizePathForDisplay) WINGET_VALIDATE_PASS_THROUGH(TelemetryDisable) WINGET_VALIDATE_PASS_THROUGH(InteractivityDisable) From 9dfbc5d864bdf9efac243d999d4684a2988e612f Mon Sep 17 00:00:00 2001 From: --global Date: Fri, 18 Oct 2024 15:19:31 -0700 Subject: [PATCH 09/15] save work --- .../Commands/RootCommand.cpp | 7 +++++ src/AppInstallerCLICore/Resources.h | 2 ++ .../Workflows/FontFlow.cpp | 10 +++++- .../Shared/Strings/en-us/winget.resw | 6 ++++ src/AppInstallerCommonCore/Fonts.cpp | 18 +++++------ .../Public/AppInstallerRuntime.h | 7 +++++ src/AppInstallerCommonCore/Runtime.cpp | 31 +++++++++++++------ 7 files changed, 61 insertions(+), 20 deletions(-) diff --git a/src/AppInstallerCLICore/Commands/RootCommand.cpp b/src/AppInstallerCLICore/Commands/RootCommand.cpp index 5580efa14a..eee5a33a16 100644 --- a/src/AppInstallerCLICore/Commands/RootCommand.cpp +++ b/src/AppInstallerCLICore/Commands/RootCommand.cpp @@ -154,6 +154,13 @@ namespace AppInstaller::CLI keyDirectories.OutputLine({ Resource::LocString{ Resource::String::PortableRoot }, Runtime::GetPathTo(Runtime::PathName::PortablePackageMachineRoot, true).u8string() }); keyDirectories.OutputLine({ Resource::LocString{ Resource::String::PortableRoot86 }, Runtime::GetPathTo(Runtime::PathName::PortablePackageMachineRootX86, true).u8string() }); keyDirectories.OutputLine({ Resource::LocString{ Resource::String::InstallerDownloads }, Runtime::GetPathTo(Runtime::PathName::UserProfileDownloads, true).u8string() }); + + if (Settings::ExperimentalFeature::IsEnabled(Settings::ExperimentalFeature::Feature::Font)) + { + keyDirectories.OutputLine({ Resource::LocString{ Resource::String::FontsInstallLocationUser }, Runtime::GetPathTo(Runtime::PathName::FontsUserInstallLocation, true).u8string() }); + keyDirectories.OutputLine({ Resource::LocString{ Resource::String::FontsInstallLocationMachine }, Runtime::GetPathTo(Runtime::PathName::FontsMachineInstallLocation, true).u8string() }); + } + keyDirectories.Complete(); context.Reporter.Info() << std::endl; } diff --git a/src/AppInstallerCLICore/Resources.h b/src/AppInstallerCLICore/Resources.h index 53b922d65a..fec47f6f7b 100644 --- a/src/AppInstallerCLICore/Resources.h +++ b/src/AppInstallerCLICore/Resources.h @@ -257,6 +257,8 @@ namespace AppInstaller::CLI::Resource WINGET_DEFINE_RESOURCE_STRINGID(FontFilePaths); WINGET_DEFINE_RESOURCE_STRINGID(FontListCommandLongDescription); WINGET_DEFINE_RESOURCE_STRINGID(FontListCommandShortDescription); + WINGET_DEFINE_RESOURCE_STRINGID(FontsInstallLocationUser); + WINGET_DEFINE_RESOURCE_STRINGID(FontsInstallLocationMachine); WINGET_DEFINE_RESOURCE_STRINGID(ForceArgumentDescription); WINGET_DEFINE_RESOURCE_STRINGID(GatedVersionArgumentDescription); WINGET_DEFINE_RESOURCE_STRINGID(GetManifestResultVersionNotFound); diff --git a/src/AppInstallerCLICore/Workflows/FontFlow.cpp b/src/AppInstallerCLICore/Workflows/FontFlow.cpp index 5180b2ad8e..00b7e08a38 100644 --- a/src/AppInstallerCLICore/Workflows/FontFlow.cpp +++ b/src/AppInstallerCLICore/Workflows/FontFlow.cpp @@ -4,6 +4,7 @@ #include "FontFlow.h" #include "TableOutput.h" #include +#include namespace AppInstaller::CLI::Workflow { @@ -46,8 +47,15 @@ namespace AppInstaller::CLI::Workflow { Execution::TableOutput<3> table(context.Reporter, { Resource::String::FontFace, Resource::String::FontFamily, Resource::String::FontFilePaths }); - for (const auto& line : lines) + bool anonymizePath = Settings::User().Get(); + + for (auto line : lines) { + if (anonymizePath) + { + AppInstaller::Runtime::ReplaceProfilePathsWithEnvironmentVariable(line.FilePath); + } + table.OutputLine({ line.FaceName, line.FamilyName, line.FilePath.u8string() }); } diff --git a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw index 208b6ce9ca..a7f69d192e 100644 --- a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw +++ b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw @@ -3163,4 +3163,10 @@ Please specify one of them using the --source option to proceed. List all installed fonts, or full details of a specific font. + + Fonts Install Location (User) + + + Fonts Install Location (Machine) + \ No newline at end of file diff --git a/src/AppInstallerCommonCore/Fonts.cpp b/src/AppInstallerCommonCore/Fonts.cpp index 814152111f..0a9c1b2ea1 100644 --- a/src/AppInstallerCommonCore/Fonts.cpp +++ b/src/AppInstallerCommonCore/Fonts.cpp @@ -4,6 +4,7 @@ #include #include #include +#include namespace AppInstaller::Fonts { @@ -34,12 +35,9 @@ namespace AppInstaller::Fonts THROW_IF_FAILED(localLoader->GetFilePathLengthFromKey(fontFileReferenceKey, fontFileReferenceKeySize, &pathLength)); pathLength += 1; // Account for the trailing null terminator during allocation. - std::wstring path; - path.reserve(pathLength); - + wchar_t* path = new wchar_t[pathLength]; THROW_IF_FAILED(localLoader->GetFilePathFromKey(fontFileReferenceKey, fontFileReferenceKeySize, &path[0], pathLength)); - std::filesystem::path fontFilePath = { std::move(path) }; - filePaths.push_back(std::move(fontFilePath)); + filePaths.push_back(std::move(std::wstring(path))); } } @@ -48,12 +46,13 @@ namespace AppInstaller::Fonts std::wstring GetLocalizedStringFromFont(const wil::com_ptr& localizedStringCollection) { - wchar_t localeNameBuffer[LOCALE_NAME_MAX_LENGTH]; - const auto localeName = GetUserDefaultLocaleName(localeNameBuffer, LOCALE_NAME_MAX_LENGTH) ? localeNameBuffer : L"en-US"; + std::vector locales = AppInstaller::Locale::GetUserPreferredLanguages(); + std::wstring preferredLocale = Utility::ConvertToUTF16(!locales.empty() ? locales[0] : "en-US"); UINT32 index; BOOL exists; - if (FAILED(localizedStringCollection->FindLocaleName(localeName, &index, &exists)) || !exists) + // TODO: Aggregrate available locales and find best alternative locale if preferred locale does not exist. + if (FAILED(localizedStringCollection->FindLocaleName(preferredLocale.c_str(), &index, &exists)) || !exists) { index = 0; } @@ -63,8 +62,7 @@ namespace AppInstaller::Fonts length += 1; // Account for the trailing null terminator during allocation. wchar_t* localizedString = new wchar_t[length]; - HRESULT hr = localizedStringCollection->GetString(index, localizedString, length); - THROW_IF_FAILED(hr); + THROW_IF_FAILED(localizedStringCollection->GetString(index, localizedString, length)); return std::wstring(localizedString); } diff --git a/src/AppInstallerCommonCore/Public/AppInstallerRuntime.h b/src/AppInstallerCommonCore/Public/AppInstallerRuntime.h index 2b8a729a2d..cecadb24d8 100644 --- a/src/AppInstallerCommonCore/Public/AppInstallerRuntime.h +++ b/src/AppInstallerCommonCore/Public/AppInstallerRuntime.h @@ -56,6 +56,10 @@ namespace AppInstaller::Runtime CLIExecutable, // The location of the image assets, if it exists. ImageAssets, + // The location where fonts are installed with user scope. + FontsUserInstallLocation, + // The location where fonts are installed with machine scope. + FontsMachineInstallLocation, // Always one more than the last path; for being able to iterate paths in tests. Max }; @@ -70,6 +74,9 @@ namespace AppInstaller::Runtime return Filesystem::GetPathTo(path, forDisplay); } + // Replaces the substring in the path with the user profile environment variable. + void ReplaceProfilePathsWithEnvironmentVariable(std::filesystem::path& path); + // Gets a new temp file path. std::filesystem::path GetNewTempFilePath(); diff --git a/src/AppInstallerCommonCore/Runtime.cpp b/src/AppInstallerCommonCore/Runtime.cpp index 92bb493a83..3a8973d8e9 100644 --- a/src/AppInstallerCommonCore/Runtime.cpp +++ b/src/AppInstallerCommonCore/Runtime.cpp @@ -29,6 +29,7 @@ namespace AppInstaller::Runtime constexpr std::string_view s_PortablePackageRoot = "WinGet"sv; constexpr std::string_view s_PortablePackagesDirectory = "Packages"sv; constexpr std::string_view s_LinksDirectory = "Links"sv; + constexpr std::string_view s_FontsInstallDirectory = "Microsoft\\Windows\\Fonts"sv; // Use production CLSIDs as a surrogate for repository location. #if USE_PROD_CLSIDS constexpr std::string_view s_ImageAssetsDirectoryRelative = "Assets\\WinGet"sv; @@ -162,15 +163,6 @@ namespace AppInstaller::Runtime return result; } - - // Try to replace LOCALAPPDATA first as it is the likely location, fall back to trying USERPROFILE. - void ReplaceProfilePathsWithEnvironmentVariable(std::filesystem::path& path) - { - if (!ReplaceCommonPathPrefix(path, GetKnownFolderPath(FOLDERID_LocalAppData), s_LocalAppDataEnvironmentVariable)) - { - ReplaceCommonPathPrefix(path, GetKnownFolderPath(FOLDERID_Profile), s_UserProfileEnvironmentVariable); - } - } } void SetRuntimePathStateName(std::string name) @@ -240,6 +232,14 @@ namespace AppInstaller::Runtime result.Path = GetKnownFolderPath(FOLDERID_Downloads); mayBeInProfilePath = true; break; + case PathName::FontsUserInstallLocation: + result.Path = GetKnownFolderPath(FOLDERID_LocalAppData); + result.Path /= s_FontsInstallDirectory; + mayBeInProfilePath = true; + break; + case PathName::FontsMachineInstallLocation: + result.Path = GetKnownFolderPath(FOLDERID_Fonts); + break; default: THROW_HR(E_UNEXPECTED); } @@ -314,6 +314,8 @@ namespace AppInstaller::Runtime case PathName::PortableLinksUserLocation: case PathName::PortablePackageUserRoot: case PathName::UserProfileDownloads: + case PathName::FontsUserInstallLocation: + case PathName::FontsMachineInstallLocation: result = GetPathDetailsCommon(path, forDisplay); break; case PathName::SelfPackageRoot: @@ -418,6 +420,8 @@ namespace AppInstaller::Runtime case PathName::PortableLinksUserLocation: case PathName::PortablePackageUserRoot: case PathName::UserProfileDownloads: + case PathName::FontsUserInstallLocation: + case PathName::FontsMachineInstallLocation: result = GetPathDetailsCommon(path, forDisplay); break; case PathName::SelfPackageRoot: @@ -476,6 +480,15 @@ namespace AppInstaller::Runtime return result; } + // Try to replace LOCALAPPDATA first as it is the likely location, fall back to trying USERPROFILE. + void ReplaceProfilePathsWithEnvironmentVariable(std::filesystem::path& path) + { + if (!ReplaceCommonPathPrefix(path, GetKnownFolderPath(FOLDERID_LocalAppData), s_LocalAppDataEnvironmentVariable)) + { + ReplaceCommonPathPrefix(path, GetKnownFolderPath(FOLDERID_Profile), s_UserProfileEnvironmentVariable); + } + } + std::filesystem::path GetNewTempFilePath() { GUID guid; From 2c73853b0dc1e761c09cb7e46686e9d28ab75f19 Mon Sep 17 00:00:00 2001 From: --global Date: Mon, 21 Oct 2024 14:46:32 -0700 Subject: [PATCH 10/15] save work --- .../Policies/de-DE/DesktopAppInstaller.adml | 45 ++++++++++++++----- .../Policies/es-ES/DesktopAppInstaller.adml | 45 ++++++++++++++----- .../Policies/fr-FR/DesktopAppInstaller.adml | 45 ++++++++++++++----- .../Policies/it-IT/DesktopAppInstaller.adml | 45 ++++++++++++++----- .../Policies/ja-JP/DesktopAppInstaller.adml | 45 ++++++++++++++----- .../Policies/ko-KR/DesktopAppInstaller.adml | 45 ++++++++++++++----- .../Policies/pt-BR/DesktopAppInstaller.adml | 45 ++++++++++++++----- .../Policies/ru-RU/DesktopAppInstaller.adml | 45 ++++++++++++++----- .../Policies/zh-CN/DesktopAppInstaller.adml | 45 ++++++++++++++----- .../Policies/zh-TW/DesktopAppInstaller.adml | 45 ++++++++++++++----- Localization/Resources/de-DE/winget.resw | 9 ++++ Localization/Resources/es-ES/winget.resw | 9 ++++ Localization/Resources/fr-FR/winget.resw | 9 ++++ Localization/Resources/it-IT/winget.resw | 9 ++++ Localization/Resources/ja-JP/winget.resw | 9 ++++ Localization/Resources/ko-KR/winget.resw | 9 ++++ Localization/Resources/pt-BR/winget.resw | 9 ++++ Localization/Resources/ru-RU/winget.resw | 9 ++++ Localization/Resources/zh-CN/winget.resw | 9 ++++ Localization/Resources/zh-TW/winget.resw | 9 ++++ src/AppInstallerCLICore/Resources.h | 1 + .../Workflows/FontFlow.cpp | 12 ++--- .../Shared/Strings/en-us/winget.resw | 3 ++ src/AppInstallerCommonCore/Fonts.cpp | 30 +++++++++++++ .../Public/winget/Fonts.h | 4 +- 25 files changed, 463 insertions(+), 127 deletions(-) diff --git a/Localization/Policies/de-DE/DesktopAppInstaller.adml b/Localization/Policies/de-DE/DesktopAppInstaller.adml index 41869407b0..a4489b6f64 100644 --- a/Localization/Policies/de-DE/DesktopAppInstaller.adml +++ b/Localization/Policies/de-DE/DesktopAppInstaller.adml @@ -7,51 +7,51 @@ Desktop-App-Installer - App-Installer aktivieren + Windows-Paket-Manager aktivieren Mit dieser Richt Linie wird gesteuert, ob der Windows-Paket-Manager von Benutzern verwendet werden kann. Wenn Sie diese Einstellung aktivieren oder nicht konfigurieren, können Benutzer die Windows-Paket-Manager verwenden. Wenn Sie diese Einstellung deaktivieren, können Benutzer den Windows-Paket-Manager nicht verwenden. - Einstellungen für den App-Installer aktivieren + Einstellungen des Windows-Paket-Manager aktivieren Mit dieser Richt Linie wird gesteuert, ob Benutzer Ihre Einstellungen ändern können. Wenn Sie diese Einstellung aktivieren oder nicht konfigurieren, können Benutzer Einstellungen für die Windows-Paket-Manager ändern. Wenn Sie diese Einstellung deaktivieren, können Benutzer Einstellungen für die Windows-Paket-Manager nicht ändern. - Experimentelle Features für den App-Installer aktivieren + Enable Windows Package Manager Experimental Features Mit dieser Richt Linie wird gesteuert, ob Benutzer Experiment elle Funktionen in der Windows-Paket-Manager aktivieren können. Wenn Sie diese Einstellung aktivieren oder nicht konfigurieren, können Benutzer Experiment elle Features für die Windows-Paket-Manager aktivieren. Wenn Sie diese Einstellung deaktivieren, können Benutzer Experiment elle Features für die Windows-Paket-Manager nicht aktivieren. - Lokale Manifestdateien für App-Installer aktivieren + Enable Windows Package Manager Local Manifest Files Mit dieser Richt Linie wird gesteuert, ob Benutzer Pakete mit lokalen Manifestdateien installieren können. Wenn Sie diese Einstellung aktivieren oder nicht konfigurieren, können Benutzer Pakete mit lokalen Manifeste mithilfe des Windows-Paket-Manager installieren. Wenn Sie diese Einstellung deaktivieren, können Benutzer keine Pakete mit lokalen Manifeste unter Verwendung des Windows-Paket-Manager installieren. - App-Installer Microsoft Store Umgehung der Quellzertifikatüberprüfung aktivieren + Enable Windows Package Manager Microsoft Store Source Certificate Validation Bypass Diese Richtlinie steuert, ob der Windows-Paket-Manager beim Initiieren einer Verbindung mit der Microsoft Speicherquelle überprüft, ob der Microsoft Speicherzertifikathash mit einem bekannten Microsoft Speicherzertifikat übereinstimmt. Wenn Sie diese Richtlinie aktivieren, umgehen die Windows-Paket-Manager die Überprüfung des Microsoft Speicherzertifikats. Wenn Sie diese Richtlinie deaktivieren, überprüft der Windows-Paket-Manager, ob das verwendete Microsoft Speicherzertifikat gültig ist und zum Microsoft Speicher gehört, bevor mit der Microsoft Store-Quelle kommuniziert wird. Wenn Sie diese Richtlinie nicht konfigurieren, werden die Windows-Paket-Manager Administratoreinstellungen eingehalten. - Hash-Überschreibung für den App-Installer aktivieren + Enable Windows Package Manager Hash Override Diese Richtlinie steuert, ob der Windows-Paket-Manager so konfiguriert werden kann, dass die Fähigkeit „SHA256-Sicherheitsvalidierung überschreiben“ in den Einstellungen aktiviert werden kann. Wenn Sie diese Richtlinie aktivieren oder nicht konfigurieren, können Benutzer die Fähigkeit „SHA256-Sicherheitsvalidierung überschreiben“ in den Windows-Paket-Manager-Einstellungen aktivieren. Wenn Sie diese Richtlinie deaktivieren, können Benutzer die Fähigkeit „SHA256-Sicherheitsvalidierung überschreiben“ in den Windows-Paket-Manager-Einstellungen nicht aktivieren. - Außerkraftsetzung der App-Installer Local Archive Malware Scan aktivieren + Enable Windows Package Manager Local Archive Malware Scan Override Diese Richtlinie steuert die Möglichkeit, Überprüfungen auf Sicherheitsrisiken durch Schadsoftware außer Kraft zu setzen, wenn eine Archivdatei mithilfe eines lokalen Manifests mithilfe der Befehlszeilenargumente installiert wird. Wenn Sie diese Richtlinie aktivieren, können Benutzer die Überprüfung auf Schadsoftware außer Kraft setzen, wenn sie eine lokale Manifestinstallation einer Archivdatei ausführen. Wenn Sie diese Richtlinie deaktivieren, können Benutzer die Schadsoftwareüberprüfung einer Archivdatei bei der Installation mithilfe eines lokalen Manifests nicht außer Kraft setzen. Wenn Sie diese Richtlinie nicht konfigurieren, werden die Windows-Paket-Manager Administratoreinstellungen eingehalten. - Standardquelle für den App-Installer aktivieren + Enable Windows Package Manager Default Source Diese Richtlinie steuert die Standardquelle, die im Windows-Paket-Manager enthalten ist. Wenn Sie diese Einstellung nicht konfigurieren, ist die Standardquelle für den Windows-Paket-Manager verfügbar und kann entfernt werden. @@ -59,7 +59,7 @@ Wenn Sie diese Einstellung nicht konfigurieren, ist die Standardquelle für den Wenn Sie diese Einstellung aktivieren, ist die Standardquelle für den Windows-Paket-Manager verfügbar und kann nicht entfernt werden. Wenn Sie diese Einstellung deaktivieren, ist die Standardquelle für den Windows-Paket-Manager nicht verfügbar. - Microsoft Store-Quelle für den App-Installer aktivieren + Enable Windows Package Manager Microsoft Store Source Diese Richtlinie steuert die Microsoft Store-Quelle, die im Windows-Paket-Manager enthalten ist. Wenn Sie diese Einstellung nicht konfigurieren, ist die Microsoft Store-Quelle für den Windows-Paket-Manager verfügbar und kann entfernt werden. @@ -67,13 +67,13 @@ Wenn Sie diese Einstellung nicht konfigurieren, ist die Microsoft Store-Quelle f Wenn Sie diese Einstellung aktivieren, ist die Microsoft Store-Quelle für den Windows-Paket-Manager verfügbar und kann nicht entfernt werden. Wenn Sie diese Einstellung deaktivieren, ist die Microsoft Store-Quelle für den Windows-Paket-Manager nicht verfügbar. - Intervall für automatische Aktualisierung der App-Installer-Quelle in Minuten festlegen + Intervall für das automatische Aktualisieren der Windows-Paket-Manager-Quelle in Minuten festlegen Diese Richtlinie steuert das Intervall für die automatische Aktualisierung paketbasierter Quellen. Die Standardquelle für Windows-Paket-Manager ist so konfiguriert, dass ein Index der Pakete auf dem lokalen Computer zwischengespeichert wird. Der Index wird heruntergeladen, wenn ein Benutzer einen Befehl aufruft und das Intervall abgelaufen ist. Wenn Sie diese Einstellung deaktivieren oder nicht konfigurieren, wird das Standardintervall oder der in den Windows-Paket-Manager Einstellungen angegebene Wert verwendet. Wenn Sie diese Einstellung aktivieren, wird die angegebene Anzahl von Minuten vom Windows-Paket-Manager verwendet. - Zusätzliche Quellen für den App-Installer aktivieren + Enable Windows Package Manager Additional Sources Diese Richtlinie steuert zusätzliche Quellen, die vom IT-Administrator des Unternehmens bereitgestellt werden. Wenn Sie diese Richtlinie nicht konfigurieren, werden keine zusätzlichen Quellen für den Windows-Paket-Manager konfiguriert. @@ -81,7 +81,7 @@ Wenn Sie diese Richtlinie nicht konfigurieren, werden keine zusätzlichen Quelle Wenn Sie diese Richtlinie aktivieren, werden die zusätzlichen Quellen dem Windows-Paket-Manager hinzugefügt und können nicht entfernt werden. Die Repräsentation für jede zusätzliche Quelle kann aus den installierten Quellen mit „winget source export“ bezogen werden. Wenn Sie diese Richtlinie deaktivieren, können keine zusätzlichen Quellen für den Windows-Paket-Manager konfiguriert werden. - Zulässige Quellen für den App-Installer aktivieren + Enable Windows Package Manager Allowed Sources Diese Richtlinie steuert zusätzliche Quellen, die vom IT-Administrator des Unternehmens zugelassen werden. Wenn Sie diese Richtlinie nicht konfigurieren, können Benutzer zusätzliche Quellen neben den in der Richtlinie konfigurierten hinzufügen oder entfernen. @@ -122,6 +122,20 @@ Wenn Sie diese Einstellung deaktivieren oder nicht konfigurieren, können Benutz Wenn Sie diese Einstellung deaktivieren oder nicht konfigurieren, wird standardmäßig kein Proxy verwendet. Wenn Sie diese Einstellung aktivieren, wird der angegebene Proxy standardmäßig verwendet. + Enable App Installer Allowed Zones for MSIX Packages + Diese Richtlinie steuert, ob App-Installer die Installation von Paketen aus bestimmten URL-Zonen zulässt. Der Ursprung eines Pakets wird durch seinen URI bestimmt und ob ein Mart-of-the-Web (MotW) vorhanden ist. Wenn mehrere URIs beteiligt sind, werden alle berücksichtigt; z. B. bei Verwendung einer .appinstaller-Datei, die umleitungsbezieht. + +Wenn Sie diese Richtlinie aktivieren, können Benutzer MSIX-Pakete gemäß der Konfiguration für jede Zone installieren. + +Wenn Sie diese Richtlinie deaktivieren oder nicht konfigurieren, können Benutzer MSIX-Pakete aus einer beliebigen Zone installieren, mit Ausnahme von "Nicht vertrauenswürdig". + Zulassen + Blockieren + Enable Microsoft SmartScreen checks for MSIX Packages + Diese Richtlinie steuert, ob App-Installer bei der Installation von MSIX-Paketen Microsoft SmartScreen-Überprüfungen durchführt. + +Wenn Sie diese Richtlinie aktivieren oder nicht konfigurieren, wird der Paket-URI vor der Installation mit Microsoft SmartScreen ausgewertet. Diese Überprüfung wird nur für Pakete durchgeführt, die aus dem Internet stammen. + +Wenn Sie diese Option deaktivieren, wird Microsoft SmartScreen vor der Installation eines Pakets nicht abgefragt. @@ -138,6 +152,13 @@ Wenn Sie diese Einstellung aktivieren, wird der angegebene Proxy standardmäßig + + Lokaler Computer + Intranet + Vertrauenswürdige Sites + Internet + Untrusted Sites + diff --git a/Localization/Policies/es-ES/DesktopAppInstaller.adml b/Localization/Policies/es-ES/DesktopAppInstaller.adml index 2b5a602d91..127a903fe6 100644 --- a/Localization/Policies/es-ES/DesktopAppInstaller.adml +++ b/Localization/Policies/es-ES/DesktopAppInstaller.adml @@ -7,51 +7,51 @@ Instalador de aplicaciones de escritorio - Habilitar el instalador de aplicaciones + Habilitar el Administrador de paquetes de Windows Esta directiva controla si los usuarios pueden usar el administrador de paquetes de Windows. Si habilitas o no estableces esta configuración, los usuarios podrán usar el administrador de paquetes de Windows. Si deshabilitas esta configuración, los usuarios no podrán usar el administrador de paquetes de Windows. - Habilitar la configuración del instalador de aplicaciones + Habilitar la configuración del Administrador de paquetes de Windows Esta directiva controla si los usuarios pueden cambiar su configuración. Si habilita o no establece esta configuración, los usuarios podrán cambiar la configuración del administrador de paquetes de Windows. Si deshabilitas esta configuración, los usuarios no podrán cambiar la configuración del administrador de paquetes de Windows. - Habilitar las funciones experimentales del instalador de aplicaciones + Habilitar Administrador de paquetes de Windows características experimentales Esta directiva controla si los usuarios pueden habilitar características experimentales en el administrador de paquetes de Windows. Si habilitas o no configuras esta opción, los usuarios podrán habilitar las características experimentales para el administrador de paquetes de Windows. Si deshabilitas esta configuración, los usuarios no podrán habilitar las características experimentales para el administrador de paquetes de Windows. - Habilitar los archivos de manifiesto locales del instalador de aplicaciones + Habilitar Administrador de paquetes de Windows archivos de manifiesto local Esta directiva controla si los usuarios pueden instalar paquetes con archivos de manifiesto locales. Si habilitas o no configuras esta opción, los usuarios podrán instalar paquetes con manifiestos locales mediante el administrador de paquetes de Windows. Si deshabilitas esta configuración, los usuarios no podrán instalar paquetes con manifiestos locales mediante el administrador de paquetes de Windows. - Habilitación de la omisión de validación de certificados de origen del Instalador de aplicación para Microsoft Store + Habilitar Administrador de paquetes de Windows Microsoft Store omisión de validación de certificado de origen Esta directiva controla si el Administrador de paquetes de Windows validará las coincidencias del hash del certificado de Microsoft Store con un certificado de Microsoft Store conocido al iniciar una conexión con el origen de Microsoft Store. Si habilita esta directiva, el Administrador de paquetes de Windows omitirá la validación del certificado de Microsoft Store. Si deshabilita esta directiva, el Administrador de paquetes de Windows validará que el certificado de Microsoft Store usado es válido y pertenece a Microsoft Store antes de comunicarse con el origen de Microsoft Store. Si no establece esta directiva, se usará la configuración de administrador del Administrador de paquetes de Windows. - Habilitar la anulación del hash del instalador de la aplicación + Habilitar invalidación de hash de Administrador de paquetes de Windows Esta directiva controla si se puede configurar el administrador de paquetes de Windows para que permita revertir la validación de seguridad SHA256 en la configuración. Si habilita o no configura esta directiva, los usuarios podrán habilitar la capacidad de revertir la validación de seguridad SHA256 en la configuración del administrador de paquetes de Windows. Si deshabilita esta directiva, los usuarios no podrán habilitar la capacidad de revertir la validación de seguridad SHA256 en la configuración del administrador de paquetes de Windows. - Habilitación de la omisión de detección de malware de archivos locales del Instalador de aplicación + Habilitar Administrador de paquetes de Windows invalidación del examen de malware de archivo local Esta directiva controla la capacidad de invalidar los exámenes de vulnerabilidades de malware al instalar un archivo de almacenamiento mediante un manifiesto local mediante los argumentos de la línea de comandos. Si habilita esta directiva, los usuarios pueden invalidar el examen de malware al realizar una instalación de manifiesto local de un archivo de almacenamiento. Si deshabilita esta directiva, los usuarios no podrán invalidar el examen de malware de un archivo de almacenamiento al instalarlo mediante un manifiesto local. Si no establece esta directiva, se cumplirá la configuración de administrador de Administrador de paquetes de Windows. - Habilitar el origen predeterminado del instalador de aplicaciones + Habilitar Administrador de paquetes de Windows origen predeterminado Esta directiva controla la fuente predeterminada incluida con el Administrador de paquetes de Windows. Si no configura esta opción, el origen predeterminado para el Administrador de paquetes de Windows estará disponible y podrá eliminarse. @@ -59,7 +59,7 @@ Si no configura esta opción, el origen predeterminado para el Administrador de Si habilita esta configuración, el origen predeterminado para el Administrador de paquetes de Windows estará disponible y no se podrá eliminar. Si desactiva esta configuración, la fuente por defecto para el Administrador de Paquetes de Windows no estará disponible. - Habilitar el instalador de aplicaciones de origen de Microsoft Store + Habilitar Administrador de paquetes de Windows origen de Microsoft Store Esta directiva controla la fuente de la Tienda Microsoft incluida en el Administrador de paquetes de Windows. Si no configura esta opción, el origen de la Tienda Microsoft para el Administrador de paquetes de Windows estará disponible y se podrá elimina. @@ -67,13 +67,13 @@ Si no configura esta opción, el origen de la Tienda Microsoft para el Administr Si habilita esta configuración, el origen de Microsoft Store para el Administrador de paquetes de Windows estará disponible y no se podrá eliminar. Si desactiva esta configuración, el origen de la Tienda Microsoft para el Administrador de paquetes de Windows no estará disponible. - Establecer el intervalo de actualización automática de la fuente del instalador de aplicaciones en minutos + Establecer el intervalo de actualización automática del origen del Administrador de paquetes de Windows en minutos Esta directiva controla el intervalo de actualización automática para orígenes basados en paquetes. El origen predeterminado para Administrador de paquetes de Windows está configurado de forma que un índice de los paquetes se almacena en caché en el equipo local. El índice se descarga cuando un usuario invoca un comando y el intervalo ha pasado. Si deshabilita o no establece esta configuración, se usará el intervalo predeterminado o el valor especificado en la configuración de Administrador de paquetes de Windows. Si habilita esta configuración, el Administrador de paquetes de Windows usará el número de minutos especificado. - Habilitar orígenes adicionales del instalador de aplicaciones + Habilitar Administrador de paquetes de Windows orígenes adicionales Esta directiva controla los orígenes adicionales proporcionados por el administrador de TI de la empresa. Si no configura esta directiva, los orígenes adicionales no se podrán configurar para el Administrador de paquetes de Windows. @@ -81,7 +81,7 @@ Si no configura esta directiva, los orígenes adicionales no se podrán configur Si habilita esta directiva, los orígenes adicionales se agregarán al Administrador de paquetes de Windows y no se podrán eliminar. La representación de cada origen adicional puede obtenerse de las fuentes instaladas mediante "winget source export". Si desactiva esta directiva, no se podrán configurar orígenes adicionales para el Administrador de paquetes de Windows. - Habilitar los orígenes permitidos del instalador de aplicaciones + Habilitar Administrador de paquetes de Windows orígenes permitidos Esta directiva controla los orígenes adicionales permitidos por el administrador de TI de la empresa Si no configura esta directiva, los usuarios podrán agregar o eliminar fuentes adicionales distintas de las configuradas por la directiva. @@ -122,6 +122,20 @@ Si deshabilita o no establece esta configuración, los usuarios no podrán confi Si deshabilita o no establece esta configuración, no se usará ningún proxy de forma predeterminada. Si habilita esta configuración, el proxy especificado se usará de forma predeterminada. + Habilitar Instalador de aplicación zonas permitidas para paquetes MSIX + Esta directiva controla si Instalador de aplicación permite instalar paquetes procedentes de zonas URL específicas. El origen de un paquete está determinado por su URI y si hay presente un Mart-of-the-Web (MotW). Si hay varios URI implicados, se consideran todos; por ejemplo, cuando se usa un archivo .appinstaller que implica redirección. + +Si habilita esta directiva, los usuarios podrán instalar paquetes MSIX según la configuración de cada zona. + +Si deshabilitas o no configuras esta directiva, los usuarios podrán instalar paquetes MSIX desde cualquier zona excepto si no son de confianza. + Permitir + Bloquear + Habilitar las comprobaciones de Microsoft SmartScreen para paquetes MSIX + Esta directiva controla si Instalador de aplicación realiza comprobaciones de SmartScreen de Microsoft al instalar paquetes MSIX. + +Si habilitas o no configuras esta directiva, el URI del paquete se evaluará con Microsoft SmartScreen antes de la instalación. Esta comprobación solo se realiza para los paquetes procedentes de Internet. + +Si lo deshabilita, no se consultará a Microsoft SmartScreen antes de instalar un paquete. @@ -138,6 +152,13 @@ Si habilita esta configuración, el proxy especificado se usará de forma predet + + Equipo local + Intranet + Sitios de confianza + Internet + Sitio que no es de confianza + diff --git a/Localization/Policies/fr-FR/DesktopAppInstaller.adml b/Localization/Policies/fr-FR/DesktopAppInstaller.adml index 97b503e991..b0f5422fe8 100644 --- a/Localization/Policies/fr-FR/DesktopAppInstaller.adml +++ b/Localization/Policies/fr-FR/DesktopAppInstaller.adml @@ -7,51 +7,51 @@ Programme d’installation des applications de bureau - Activer le programme d’installation de l’application + Activer le Gestionnaire de package Windows Cette stratégie contrôle si le gestionnaire de packages Windows peut être utilisé par les utilisateurs. Si vous activez ou ne configurez pas ce paramètre, les utilisateurs peuvent utiliser le gestionnaire de packages Windows. Si vous désactivez ce paramètre, les utilisateurs ne peuvent pas utiliser le gestionnaire de packages Windows. - Activer les paramètres du Programme d’installation de l’application + Activer les paramètres du Gestionnaire de package Windows Cette stratégie contrôle si les utilisateurs peuvent modifier leurs paramètres. Si vous activez ou ne configurez pas ce paramètre, les utilisateurs peuvent modifier les paramètres du gestionnaire de packages Windows. Si vous désactivez ce paramètre, les utilisateurs ne peuvent pas modifier les paramètres du gestionnaire de packages Windows. - Activer les fonctionnalités expérimentales du Programme d’installation de l’application + Enable Windows Package Manager Experimental Features Cette stratégie contrôle si les utilisateurs peuvent activer les fonctionnalités expérimentales dans le gestionnaire de packages Windows. Si vous activez ou ne configurez pas ce paramètre, les utilisateurs peuvent activer des fonctionnalités expérimentales pour le gestionnaire de package Windows. Si vous désactivez ce paramètre, les utilisateurs ne peuvent pas activer les fonctionnalités expérimentales pour le gestionnaire de package Windows. - Activer les fichiers de manifeste locaux du Programme d'installation de l'application + Enable Windows Package Manager Local Manifest Files Cette stratégie contrôle si les utilisateurs peuvent installer des packages avec des fichiers de manifeste locaux. Si vous activez ou ne configurez pas ce paramètre, les utilisateurs peuvent installer des packages avec des manifestes locaux à l’aide du gestionnaire de packages Windows. Si vous désactivez ce paramètre, les utilisateurs ne peuvent pas installer de packages avec des manifestes locaux à l’aide du gestionnaire de packages Windows. - Activer Programme d'installation d'application Microsoft Store contournement de la validation du certificat source + Enable Windows Package Manager Microsoft Store Source Certificate Validation Bypass Cette stratégie contrôle si le Gestionnaire de package Windows validera si les correspondances de hachage de certificat Microsoft Store correspond à un certificat Microsoft Store connu lors de l’initialisation d’une connexion à la source Microsoft Store. Si vous activez cette stratégie, le Gestionnaire de package Windows contourne la validation du certificat Microsoft Store. Si vous désactivez cette stratégie, le Gestionnaire de package Windows vérifie que le certificat Microsoft Store utilisé est valide et appartient au Microsoft Store avant de communiquer avec la source Microsoft Store. Si vous ne configurez pas cette stratégie, les paramètres d’administrateur Gestionnaire de package Windows sont respectés. - Activer le remplacement de code de hachage du Programme d’installation de l’application + Enable Windows Package Manager Hash Override Cette stratégie détermine si les utilisateurs peuvent configurer le Gestionnaire de package Windows ou non pour activer la fonction de remplacement de la validation de sécurité SHA256 dans les paramètres. Si vous activez ou ne configurez pas cette stratégie, les utilisateurs pourront activer la fonction de remplacement la validation de sécurité SHA256 dans les paramètres du Gestionnaire de package Windows. Si vous désactivez cette stratégie, les utilisateurs ne pourront pas activer la fonction de remplacement la validation de sécurité SHA256 dans les paramètres du Gestionnaire de package Windows. - Activer le remplacement de l’analyse des programmes malveillants des archives locales Windows Programme d'installation d'application + Enable Windows Package Manager Local Archive Malware Scan Override Cette stratégie contrôle la possibilité de remplacer les analyses de vulnérabilités de programmes malveillants lors de l’installation d’un fichier d’archive à l’aide d’un manifeste local à l’aide des arguments de ligne de commande. Si vous activez ce paramètre de stratégie, les utilisateurs peuvent remplacer l’analyse des programmes malveillants lors de l’installation d’un manifeste local d’un fichier d’archive. Si vous désactivez cette stratégie, les utilisateurs ne peuvent pas remplacer l’analyse des programmes malveillants d’un fichier d’archive lors de l’installation à l’aide d’un manifeste local. Si vous ne configurez pas cette stratégie, les paramètres d’administrateur Gestionnaire de package Windows sont conformes. - Activer la source par défaut du Programme d'installation d'application + Enable Windows Package Manager Default Source Cette stratégie contrôle la source par défaut incluse dans le Gestionnaire de package Windows. Si vous ne configurez pas ce paramètre, la source par défaut pour le Gestionnaire de package Windows est disponible et peut être supprimée. @@ -59,7 +59,7 @@ Si vous ne configurez pas ce paramètre, la source par défaut pour le Gestionna Si vous activez ce paramètre, la source par défaut pour le Gestionnaire de package Windows est disponible et ne peut pas être supprimée. Si vous désactivez ce paramètre, la source par défaut pour le Gestionnaire de package Windows n’est pas disponible. - Activer la source Microsoft Store du Programme d’installation d’application + Enable Windows Package Manager Microsoft Store Source Cette stratégie contrôle la source du Microsoft Store incluse dans le Gestionnaire de package Windows. Si vous ne configurez pas ce paramètre, la source du Microsoft Store pour le Gestionnaire de package Windows est disponible et peut être supprimée. @@ -67,13 +67,13 @@ Si vous ne configurez pas ce paramètre, la source du Microsoft Store pour le Ge Si vous activez ce paramètre, la source du Microsoft Store pour le Gestionnaire de package Windows est disponible et ne peut pas être supprimée. Si vous désactivez ce paramètre, la source du Microsoft Store pour le Gestionnaire de package Windows n’est pas disponible. - Définir l’intervalle en minutes de mise à jour automatique de source du programme d’installation de l’application + Définir l’intervalle en minutes de la mise à jour automatique source du Gestionnaire de package Windows Cette stratégie contrôle l’intervalle de mise à jour automatique pour les sources basées sur les packages. La source par défaut de Gestionnaire de package Windows est configurée de sorte qu’un index des packages soit mis en cache sur l’ordinateur local. L’index est téléchargé lorsqu’un utilisateur appelle une commande et que l’intervalle est écoulé. Si vous désactivez ou ne configurez pas ce paramètre, l’intervalle par défaut ou la valeur spécifié dans les paramètres de Gestionnaire de package Windows sont utilisés. Si vous activez ce paramètre, le nombre de minutes spécifié est utilisé par le Gestionnaire de package Windows. - Activer les sources supplémentaires du Programme d’installation de l’application + Enable Windows Package Manager Additional Sources Cette stratégie contrôle les sources supplémentaires offertes par l’administrateur informatique de l’entreprise. Si vous ne configurez pas ce paramètre de stratégie, aucune source supplémentaire n’est configurée pour le Gestionnaire de package Windows. @@ -81,7 +81,7 @@ Si vous ne configurez pas ce paramètre de stratégie, aucune source supplément Si vous activez ce paramètre de stratégie, les sources supplémentaires sont ajoutées au Gestionnaire de package Windows et ne peuvent pas être supprimées. La représentation de chaque source supplémentaire peut être obtenue à partir de sources installées à l’aide de « Winget source export ». Si vous désactivez ce paramètre de stratégie, aucune source supplémentaire ne peut être configurée pour le Gestionnaire de package Windows. - Activer les sources autorisées du Programme d’installation de l’application + Enable Windows Package Manager Allowed Sources Cette stratégie contrôle les sources supplémentaires autorisées par l’administrateur informatique de l’entreprise. Si vous ne configurez pas ce paramètre de stratégie, les utilisateurs pourront ajouter ou supprimer des sources supplémentaires autres que celles configurées par la stratégie Si @@ -122,6 +122,20 @@ Si vous désactivez ou ne configurez pas ce paramètre, les utilisateurs ne peuv Si vous désactivez ou ne configurez pas ce paramètre, aucun proxy n’est utilisé par défaut. Si vous activez ce paramètre, le proxy spécifié est utilisé par défaut. + Enable App Installer Allowed Zones for MSIX Packages + Cette stratégie contrôle si Programme d'installation d'application autorise l’installation de packages provenant de zones URL spécifiques. L’origine d’un package est déterminée par son URI et si un Mart-of-the-Web (MotW) est présent. Si plusieurs URI sont impliqués, tous sont pris en compte ; par exemple, lors de l’utilisation d’un fichier .appinstaller qui implique une redirection. + +Si vous activez cette stratégie, les utilisateurs peuvent installer des packages MSIX en fonction de la configuration de chaque zone. + +Si vous désactivez ou ne configurez pas cette stratégie, les utilisateurs peuvent installer des packages MSIX à partir de n’importe quelle zone, sauf pour les packages non approuvés. + Autoriser + Bloquer + Enable Microsoft SmartScreen checks for MSIX Packages + Cette stratégie contrôle si Programme d'installation d'application effectue des vérifications Microsoft SmartScreen lors de l’installation des packages MSIX. + +Si vous activez ou ne configurez pas cette stratégie, l’URI du package est évalué avec Microsoft SmartScreen avant l’installation. Cette case activée est effectuée uniquement pour les packages provenant d’Internet. + +Si vous désactivez, Microsoft SmartScreen n’est pas consulté avant d’installer un package. @@ -138,6 +152,13 @@ Si vous activez ce paramètre, le proxy spécifié est utilisé par défaut.Proxy par défaut + + Ordinateur local + Intranet + Sites de confiance + Internet + Untrusted Sites + diff --git a/Localization/Policies/it-IT/DesktopAppInstaller.adml b/Localization/Policies/it-IT/DesktopAppInstaller.adml index 95fb331f23..a21e27774c 100644 --- a/Localization/Policies/it-IT/DesktopAppInstaller.adml +++ b/Localization/Policies/it-IT/DesktopAppInstaller.adml @@ -7,51 +7,51 @@ Programma di installazione app desktop - Abilita programma di installazione app + Abilita Gestione pacchetti Windows Questo criterio Controlla se Windows Gestione pacchetti può essere utilizzato dagli utenti. Se si Abilita o non si configura questa impostazione, gli utenti potranno utilizzare Windows Gestione pacchetti. Se si disabilita questa impostazione, gli utenti non potranno utilizzare Windows Gestione pacchetti. - Abilita impostazioni del programma di installazione app + Abilita le impostazioni di Gestione pacchetti Windows Questo criterio Controlla se gli utenti possono modificare le impostazioni. Se si Abilita o non si configura questa impostazione, gli utenti potranno modificare le impostazioni di Windows Gestione pacchetti. Se si disabilita questa impostazione, gli utenti non saranno in grado di modificare le impostazioni per Windows Gestione pacchetti. - Abilita funzionalità sperimentali del programma di installazione app + Abilita le funzionalità sperimentali di Gestione pacchetti Windows Questo criterio Controlla se gli utenti possono abilitare le funzionalità sperimentali in Windows Gestione pacchetti. Se si Abilita o non si configura questa impostazione, gli utenti potranno abilitare le funzionalità sperimentali per Windows Gestione pacchetti. Se si disabilita questa impostazione, gli utenti non saranno in grado di abilitare le funzionalità sperimentali per Windows Gestione pacchetti. - Abilita file manifesto locali del programma di installazione app + Abilita i file manifesto locali di Gestione pacchetti Windows Questo criterio Controlla se gli utenti possono installare pacchetti con file di manifesto locali. Se si Abilita o non si configura questa impostazione, gli utenti potranno installare pacchetti con manifesti locali tramite Windows Gestione pacchetti. Se si disabilita questa impostazione, gli utenti non saranno in grado di installare pacchetti con manifesti locali tramite Windows Gestione pacchetti. - Abilita il bypass del certificato di origine del programma di installazione app Microsoft Store + Abilita il bypass di convalida del certificato di Microsoft Store di Gestione pacchetti Windows Questo criterio consente di stabilire se Gestione pacchetti Windows convaliderà la corrispondenza dell'hash del certificato Microsoft Store con un certificato Microsoft Store noto quando si avvia una connessione all'origine Microsoft Store. Se si abilita questo criterio, Gestione pacchetti Windows ignorerà la convalida del certificato Microsoft Store. Se si disabilita questo criterio, Gestione pacchetti Windows convaliderà il certificato Microsoft Store usato affinché sia valido e appartenga a Microsoft Store prima di comunicare con l'origine Microsoft Store. Se non si configura questo criterio, verranno rispettate le impostazioni dell'amministratore di Gestione pacchetti Windows. - Abilita sostituzione hash del programma di installazione app + Abilita l’override dell’hash di Gestione pacchetti Windows Questa impostazione dei criteri consente di specificare se Windows Gestione pacchetti può essere configurato per abilitare la possibilità di ignorare la convalida di sicurezza SHA256 nelle impostazioni. Se si Abilita o non si configura questa impostazione dei criteri, gli utenti potranno abilitare la funzionalità di poter ignorare la convalida della sicurezza SHA256 nelle impostazioni di Windows Gestione pacchetti. Se si disabilita questa impostazione dei criteri, gli utenti non potranno abilitare la funzionalità di ignorare la convalida della sicurezza SHA256 nelle impostazioni di Windows Gestione pacchetti. - Abilita l'override dell’analisi malware dell'archivio locale + Abilita l'override dell'analisi malware dell'archivio locale di Gestione pacchetti Windows Questo criterio consente di controllare la possibilità di eseguire l'override delle analisi di vulnerabilità malware durante l'installazione di un file di archivio usando un manifesto locale usando gli argomenti della riga di comando. Se si abilita questo criterio, gli utenti potranno eseguire l'override dell'analisi antimalware durante l'installazione di un manifesto locale di un file di archivio. Se si disabilita questo criterio, gli utenti non potranno eseguire l'override dell'analisi malware di un file di archivio durante l'installazione con un manifesto locale. Se non si configura questo criterio, le impostazioni dell'amministratore di Gestione pacchetti Windows saranno conformi. - Abilita origine predefinita del programma di installazione app + Abilita l’origine predefinita di Gestione pacchetti Windows Questo criterio controlla l'origine predefinita inclusa in Gestione pacchetti Windows. Se non si configura questa impostazione, l'origine predefinita per il gestore dei pacchetti di Windows sarà disponibile e potrà essere rimossa. @@ -59,7 +59,7 @@ Se non si configura questa impostazione, l'origine predefinita per il gestore de Se si abilita questa impostazione, l'origine predefinita per Windows Gestione pacchetti sarà disponibile e non potrà essere rimossa. Se si disabilita questa impostazione, l'origine predefinita per Windows Gestione pacchetti non sarà disponibile. - Abilita l'origine Microsoft Store del programma di installazione app + Abilita l’origine di Microsoft Store di Gestione pacchetti Windows Questo criterio controlla l'origine Microsoft Store inclusa in Windows Gestione pacchetti. Se non si configura questa impostazione, l'origine Microsoft Store per il gestore dei pacchetti di Windows sarà disponibile e potrà essere rimossa. @@ -67,13 +67,13 @@ Se non si configura questa impostazione, l'origine Microsoft Store per il gestor Se si abilita questa impostazione, l'origine Microsoft Store per Windows Gestione pacchetti sarà disponibile e non potrà essere rimossa. Se si disabilita questa impostazione, l'origine Microsoft Store per Windows Gestione pacchetti non sarà disponibile. - Imposta l'intervallo di aggiornamento automatico dell'origine del programma di installazione app in minuti + Imposta l’intervallo di aggiornamento automatico di origine Gestione pacchetti Windows in minuti Questo criterio controlla l'intervallo di aggiornamento automatico per le origini basate su pacchetto. L'origine predefinita per Gestione pacchetti Windows è configurata in modo che un indice dei pacchetti venga memorizzato nella cache nel computer locale. L'indice viene scaricato quando un utente richiama un comando e l'intervallo è passato. Se si disabilita o non si configura questa impostazione, verrà utilizzato l'intervallo predefinito o il valore specificato nelle impostazioni Gestione pacchetti Windows. Se si abilita questa impostazione, il numero di minuti specificato verrà utilizzato dal Gestione pacchetti Windows. - Abilita altre origini del programma di installazione app + Abilita le origini aggiuntive di Gestione pacchetti Windows Questo criterio controlla le origini aggiuntive fornite dall'amministratore IT dell'organizzazione. Se non si configura questa impostazione dei criteri, non verrà configurata alcuna origine aggiuntiva per Windows Gestione pacchetti. @@ -81,7 +81,7 @@ Se non si configura questa impostazione dei criteri, non verrà configurata alcu Se si Abilita questo criterio, le origini aggiuntive verranno aggiunte a Windows Gestione pacchetti e non potranno essere rimosse. È possibile ottenere la rappresentazione di ogni origine aggiuntiva dalle origini installate usando 'esportazione di origine winget'. Se si disabilita questo criterio, non sarà possibile configurare altre origini per Windows Gestione pacchetti. - Abilita le origini consentite del programma di installazione app + Abilita le origini consentite di Gestione pacchetti Windows Questo criterio controlla le origini aggiuntive fornite dall'amministratore IT dell'organizzazione. Se non si configura questa impostazione dei criteri, gli utenti potranno aggiungere o rimuovere ulteriori origini oltre quelle configurate dal criterio. @@ -122,6 +122,20 @@ Se si disabilita o non si configura questa impostazione, gli utenti non potranno Se si disabilita o non si configura questa impostazione, per impostazione predefinita non verrà utilizzato alcun proxy. Se si abilita questa impostazione, per impostazione predefinita verrà utilizzato il proxy specificato. + Abilita le zone consentite del programma di installazione app per i pacchetti MSIX + Questo criterio controlla se Programma di installazione app consente l'installazione di pacchetti provenienti da aree URL specifiche. L'origine di un pacchetto è determinata dal relativo URI e dalla presenza di un Mart-of-the-Web (MotW). Se sono coinvolti più URI, vengono considerati tutti; ad esempio, quando si utilizza un file con estensione appinstaller che implica il reindirizzamento. + +Se si abilita questo criterio, gli utenti potranno installare i pacchetti MSIX in base alla configurazione per ogni area. + +Se si disabilita o non si configura questo criterio, gli utenti potranno installare pacchetti MSIX da qualsiasi area, ad eccezione di Non attendibili. + Consenti + Blocca + Abilita i controlli di Microsoft SmartScreen per i pacchetti MSIX + Questo criterio controlla se Programma di installazione app esegue controlli Microsoft SmartScreen durante l'installazione dei pacchetti MSIX. + +Se si abilita o non si configura questo criterio, l'URI del pacchetto verrà valutato con Microsoft SmartScreen prima dell'installazione. Questo controllo viene eseguito solo per i pacchetti provenienti da Internet. + +Se si disabilita, Microsoft SmartScreen non verrà avvisato prima di installare un pacchetto. @@ -138,6 +152,13 @@ Se si abilita questa impostazione, per impostazione predefinita verrà utilizzat + + Computer locale + Intranet + Siti attendibili + Internet + Siti non attendibili + diff --git a/Localization/Policies/ja-JP/DesktopAppInstaller.adml b/Localization/Policies/ja-JP/DesktopAppInstaller.adml index 2c31873a8d..3f66d6826b 100644 --- a/Localization/Policies/ja-JP/DesktopAppInstaller.adml +++ b/Localization/Policies/ja-JP/DesktopAppInstaller.adml @@ -7,51 +7,51 @@ デスクトップ アプリ インストーラー - アプリ インストーラーを有効にする + Windows パッケージ マネージャーを有効にする このポリシーでは、ユーザーが Windows パッケージマネージャーを使用できるかどうかを制御します。 この設定を有効にした場合、または構成しなかった場合、ユーザーは Windows パッケージマネージャーを使用できます。 この設定を無効にした場合、ユーザーは Windows パッケージマネージャーを使用できなくなります。 - アプリのインストーラーの設定を有効にする + Windows パッケージ マネージャーを有効にする このポリシーでは、ユーザーが設定を変更できるかどうかを制御します。 この設定を有効にした場合、または構成しなかった場合、ユーザーは Windows パッケージマネージャーの設定を変更することができます。 この設定を無効にした場合、ユーザーは Windows パッケージマネージャーの設定を変更できなくなります。 - アプリ インストーラーの試験的な機能を有効にする + Windows パッケージ マネージャーの試験的な機能を有効にする このポリシーでは、ユーザーが Windows パッケージマネージャーで試験的な機能を有効にできるかどうかを制御します。 この設定を有効にした場合、または構成しなかった場合、ユーザーは Windows パッケージマネージャーに対して実験的な機能を有効にすることができます。 この設定を無効にした場合、ユーザーは Windows パッケージマネージャーの実験的な機能を有効にできなくなります。 - アプリ インストーラーのローカル マニフェスト ファイルを有効にする + Windows パッケージ マネージャーのローカル マニフェスト ファイルを有効にする このポリシーでは、ローカルマニフェストファイルを含むパッケージをユーザーがインストールできるかどうかを制御します。 この設定を有効にした場合、または構成しなかった場合、ユーザーは Windows パッケージマネージャーを使用してローカルのマニフェストを含むパッケージをインストールできます。 この設定を無効にした場合、ユーザーは Windows パッケージマネージャーを使用してローカルのマニフェストを含むパッケージをインストールできなくなります。 - アプリ インストーラーでの Microsoft Store ソースの固定証明書のバイパスを有効にする + Windows パッケージ マネージャーでの Microsoft Store ソースの証明書検証バイパスを有効にする このポリシーでは、Microsoft Store ソースへの接続を開始するときに、Windows パッケージ マネージャーが既知の Microsoft Store 証明書と一致する Microsoft Store 証明書ハッシュを検証するかどうかを制御します。 このポリシーを有効にした場合、Windows パッケージ マネージャーは Microsoft Store 証明書の検証をバイパスします。 このポリシーを無効にした場合、Windows パッケージ マネージャーは、Microsoft Store ソースと通信する前に、使用されている Microsoft Store 証明書が有効であり、Microsoft Store に属していることを検証します。 このポリシーを構成しなかった場合は、Windows パッケージ マネージャー管理者の設定が適用されます。 - アプリ インストーラーのハッシュ上書きを有効にする + Windows パッケージ マネージャーのハッシュ オーバーライドを有効にする このポリシーでは、設定の SHA256 セキュリティ検証を上書きする機能を有効にできるように Windows パッケージ マネージャーを構成できるかどうかを制御します。 このポリシーを有効にした場合、または構成しなかった場合、ユーザーは Windows パッケージ マネージャーの設定で SHA256 セキュリティ検証を上書きする機能を有効にすることができます。 このポリシーを無効にした場合、ユーザーは Windows パッケージ マネージャーの設定で SHA256 セキュリティ検証を上書きする機能を有効することができなくなります。 - アプリ インストーラー ローカル アーカイブ マルウェア スキャンの上書きを有効にする + Windows パッケージ マネージャーでのローカル アーカイブ マルウェア スキャンのオーバーライドを有効にする このポリシーでは、コマンド ライン引数を使用してローカル マニフェストを使用してアーカイブ ファイルをインストールするときに、マルウェアの脆弱性スキャンをオーバーライドする機能を制御します。 このポリシーを有効にした場合、アーカイブ ファイルのローカル マニフェストのインストールを実行するときに、ユーザーはマルウェア スキャンをオーバーライドできます。 このポリシーを無効にすると、ユーザーはローカル マニフェストを使用してインストールするときにアーカイブ ファイルのマルウェア スキャンをオーバーライドできなくなります。 このポリシーを構成しなかった場合は、Windows パッケージ マネージャー管理者の設定が適用されます。 - アプリ インストーラーの既定のソースを有効にする + Windows パッケージ マネージャーの既定のソースを有効にする このポリシーでは、Windows パッケージ マネージャーに含まれている 既定ソースを制御します。 この設定を構成しなかった場合、Windows パッケージ マネージャーの 既定ソースが利用可能になり、削除できるようになります。 @@ -59,7 +59,7 @@ この設定を有効にした場合、Windows パッケージ マネージャーの 既定ソースが利用できるようになり、削除できなくなります。 この設定を無効にした場合、Windows パッケージマ ネージャーの 既定ソースは利用できなくなります。 - アプリ インストーラー Microsoft Store ソースを有効にする + Windows パッケージ マネージャーの Microsoft Store ソースを有効にする このポリシーでは、Windows パッケージ マネージャーに含まれている Microsoft Store ソースを制御します。 この設定を構成しなかった場合、Windows パッケージ マネージャーの Microsoft Store ソースが利用可能になり、削除できるようになります。 @@ -67,13 +67,13 @@ この設定を有効にした場合、Windows パッケージ マネージャーの Microsoft Store ソースが利用できるようになり、削除できなくなります。 この設定を無効にした場合、Windows パッケージマ ネージャーの Microsoft Store ソースは利用できなくなります。 - アプリ インストーラー ソースの自動更新間隔を分単位で設定します + Windows パッケージ マネージャーのソース自動更新間隔を分単位で設定する このポリシーは、パッケージ ベースのソースの自動更新間隔を制御します。Windows パッケージ マネージャーの既定のソースは、パッケージのインデックスがローカル コンピューターにキャッシュされるように構成されています。インデックスは、ユーザーがコマンドを呼び出し、間隔が過ぎたときにダウンロードされます。 この設定を無効にした場合、または構成しなかった場合は、既定の間隔またはWindows パッケージ マネージャー設定で指定された値が使用されます。 この設定を有効にした場合、指定した分数がWindows パッケージ マネージャーで使用されます。 - アプリ インストーラーの追加ソースを有効にする + Windows パッケージ マネージャーの追加のソースを有効にする このポリシーは、エンタープライズIT管理者によって提供される追加のソースを制御します。 このポリシーを構成しない場合、Windows パッケージ マネージャー用に追加のソースは構成されません。 @@ -81,7 +81,7 @@ このポリシーを有効にすると、追加のソースが Windows パッケージ マネージャーに追加され、削除できなくなります。 追加の各ソースの表現は、「wingetsourceexport」を使用してインストールされたソースから取得できます。 このポリシーを無効にすると、Windows パッケージ マネージャーに追加のソースを構成できなくなります。 - アプリ インストーラーの許可されたソースを有効にする + Windows パッケージ マネージャーの許可されたソースを有効にする このポリシーは、エンタープライズ IT 管理者が許可する追加のソースを制御します。 このポリシーを構成しない場合、ユーザーはポリシーで構成されたソース以外のソースを追加または削除できます。 @@ -122,6 +122,20 @@ この設定を無効にした場合、または構成しなかった場合、既定ではプロキシは使用されません。 この設定を有効にした場合、指定したプロキシが既定で使用されます。 + MSIX パッケージアプリ インストーラー許可されたゾーンを有効にする + このポリシーでは、アプリ インストーラーが特定の URL ゾーンからのパッケージのインストールを許可するかどうかを制御します。パッケージの配信元は、その URI と、Mart-of-the-Web (MotW) が存在するかどうかによって決まります。複数の URI が含まれている場合、すべてが考慮されます。たとえば、リダイレクトを含む .appinstaller ファイルを使用する場合などです。 + +このポリシーを有効にした場合、ユーザーは各ゾーンの構成に従って MSIX パッケージをインストールできます。 + +このポリシーを無効にするか、未構成にした場合、ユーザーは信頼されていないゾーン以外のゾーンから MSIX パッケージをインストールできます。 + 許可 + ブロック + MSIX パッケージの Microsoft SmartScreen チェックを有効にする + このポリシーでは、MSIX パッケージのインストール時にアプリ インストーラーが Microsoft SmartScreen チェックを実行するかどうかを制御します。 + +このポリシーを有効にするか、未構成にした場合、インストール前にパッケージ URI が Microsoft SmartScreen で評価されます。このチェックは、インターネットからのパッケージに対してのみ実行されます。 + +無効にした場合、パッケージをインストールする前に Microsoft SmartScreen に問い合わせてください。 @@ -138,6 +152,13 @@ + + ローカル コンピューター + イントラネット + 信頼済みサイト + インターネット + 信頼できないサイト + diff --git a/Localization/Policies/ko-KR/DesktopAppInstaller.adml b/Localization/Policies/ko-KR/DesktopAppInstaller.adml index 9bbc425ce6..e16399ddba 100644 --- a/Localization/Policies/ko-KR/DesktopAppInstaller.adml +++ b/Localization/Policies/ko-KR/DesktopAppInstaller.adml @@ -7,51 +7,51 @@ 데스크톱 앱 설치 관리자 - 앱 설치 관리자 사용 + Windows 패키지 관리자 사용 이 정책은 사용자가 Windows 패키지 관리자를 사용할 수 있는지 여부를 제어합니다. 이 설정을 사용하거나 구성하지 않으면 사용자가 Windows 패키지 관리자를 사용할 수 있습니다. 이 설정을 사용하지 않으면 사용자가 Windows 패키지 관리자를 사용할 수 없습니다. - 앱 설치 관리자 설정 사용 + Windows 패키지 관리자 설정 사용 이 정책은 사용자가 설정을 변경할 수 있는지 여부를 제어합니다. 이 설정을 사용하도록 설정하거나 구성하지 않으면 사용자가 Windows 패키지 관리자의 설정을 변경할 수 있습니다. 이 설정을 사용하지 않으면 사용자가 Windows 패키지 관리자의 설정을 변경할 수 없습니다. - 앱 설치 관리자 실험적 기능 사용 + Windows 패키지 관리자 실험적 기능 사용 이 정책은 사용자가 Windows 패키지 관리자에서 실험적인 기능을 사용하도록 설정할 수 있는지 여부를 제어합니다. 이 설정을 사용하거나 구성하지 않으면 사용자가 Windows 패키지 관리자를 위해 실험적 기능을 사용할 수 있습니다. 이 설정을 사용하지 않도록 설정하면 사용자가 Windows 패키지 관리자를 위해 실험적 기능을 사용할 수 없습니다. - 앱 설치 관리자 로컬 매니페스트 파일 사용 + Windows 패키지 관리자 로컬 매니페스트 파일 사용 이 정책은 사용자가 로컬 매니페스트 파일을 사용하여 패키지를 설치할 수 있는지 여부를 제어합니다. 이 설정을 사용하거나 구성하지 않으면 사용자는 Windows 패키지 관리자를 사용하여 로컬 매니페스트와 함께 패키지를 설치할 수 있습니다. 이 설정을 사용하지 않으면 사용자는 Windows 패키지 관리자를 사용하여 로컬 매니페스트를 통해 패키지를 설치할 수 없습니다. - 앱 설치 관리자 Microsoft Store 원본 인증서 유효성 검사 바이패스 사용 + Windows 패키지 관리자 Microsoft Store 원본 인증서 유효성 검사 바이패스 사용 이 정책은 Windows 패키지 관리자가 Microsoft 저장소 원본에 대한 연결을 시작할 때 알려진 Microsoft Store 인증서와 일치하는 Microsoft 저장소 인증서 해시의 유효성을 검사할지 여부를 제어합니다. 이 정책을 사용하면 Windows 패키지 관리자는 Microsoft 저장소 인증서 유효성 검사를 무시합니다. 이 정책을 사용하지 않으면 Windows 패키지 관리자는 Microsoft Store 원본과 통신하기 전에 사용된 Microsoft 저장소 인증서가 유효하고 Microsoft 저장소에 속하는지 확인합니다. 이 정책을 구성하지 않으면 Windows 패키지 관리자의 관리자 설정이 적용됩니다. - 앱 설치 관리자 해시 재정의 사용 + Windows 패키지 관리자 해시 재정의 사용 이 정책은 설정에서 SHA256 보안 유효성 검사를 재정의하도록 Windows 패키지 관리자를 구성할 수 있는지 여부를 제어합니다. 이 정책을 실행하거나 구성하지 않으면 Windows 패키지 관리자 설정에서 SHA256 보안 유효성 검사를 재정의하는 기능을 사용할 수 있습니다. 이 정책을 실행 중지하면 Windows 패키지 관리자 설정에서 SHA256 보안 유효성 검사를 재정의하는 기능을 사용자가 사용하도록 설정할 수 없습니다. - 앱 설치 관리자 로컬 보관 맬웨어 검사 재정의 사용 + Windows 패키지 관리자 로컬 보관 맬웨어 검사 재정의 사용 이 정책은 명령줄 인수를 사용하여 로컬 매니페스트를 사용하여 보관 파일을 설치할 때 맬웨어 취약성 검사를 재정의하는 기능을 제어합니다. 이 정책을 사용하면 사용자가 보관 파일의 로컬 매니페스트 설치를 수행할 때 맬웨어 검사를 재정의할 수 있습니다. 이 정책을 사용하지 않으면 로컬 매니페스트를 사용하여 설치할 때 사용자가 보관 파일의 맬웨어 검사를 재정의할 수 없습니다. 이 정책을 구성하지 않으면 Windows 패키지 관리자 관리자 설정이 적용됩니다. - 앱 설치 관리자 기본 원본 사용 + Windows 패키지 관리자 기본 원본 사용 이 정책은 Windows 패키지 관리자에 포함된 기본 원본을 제어합니다. 이 설정을 구성하지 않는 경우 Windows 패키지 관리자의 기본 원본을 사용할 수 있으며 제거할 수 있습니다. @@ -59,7 +59,7 @@ 이 설정을 사용하면 Windows 패키지 관리자의 기본 원본을 사용할 수 있으며 제거할 수 없습니다. 이 설정을 사용하지 않도록 설정하면 Windows 패키지 관리자의 기본 원본을 사용할 수 없습니다. - 앱 설치 관리자 Microsoft 스토어 원본 사용 + Windows 패키지 관리자 Microsoft Store 원본 사용 이 정책은 Windows 패키지 관리자에 포함된 Microsoft 스토어 원본을 제어합니다. 이 설정을 구성하지 않는 경우 Windows 패키지 관리자의 Microsoft 스토어 원본을 사용할 수 있으며 제거할 수 있습니다. @@ -67,13 +67,13 @@ 이 설정을 사용하면 Windows 패키지 관리자용 Microsoft 스토어 원본을 사용할 수 있으며 제거할 수 없습니다. 이 설정을 사용 중지하면 Windows 패키지 관리자용 Microsoft 스토어 원본을 사용할 수 없습니다. - 앱 설치 관리자 원본 자동 업데이트 간격(분) 설정 + Windows 패키지 관리자 원본 자동 업데이트 간격(분) 설정 이 정책은 패키지 기반 원본의 자동 업데이트 간격을 제어합니다. 패키지의 인덱스가 로컬 컴퓨터에 캐시되도록 Windows 패키지 관리자 기본 원본이 구성됩니다. 사용자가 명령을 호출하고 간격이 지나면 인덱스가 다운로드됩니다. 이 설정을 사용하지 않거나 구성하지 않으면 Windows 패키지 관리자 설정에 지정된 기본 간격 또는 값이 사용됩니다. 이 설정을 사용하면 지정한 시간(분)이 Windows 패키지 관리자 사용됩니다. - 앱 설치 관리자 추가 원본 사용 + Windows 패키지 관리자 추가 원본 사용 이 정책은 엔터프라이즈 IT 관리자가 제공하는 추가 원본을 제어합니다. 정책을 구성하지 않는 경우 Windows 패키지 관리자에 대해 추가 원본이 구성되지 않습니다. @@ -81,7 +81,7 @@ 정책을 사용하도록 설정하면 추가 원본이 Windows 패키지 관리자에 추가되고 제거할 수 없습니다. 'winget 원본 내보내기'를 사용하여 설치된 원본에서 각 추가 원본에 대한 표현을 얻을 수 있습니다. 이 정책을 사용하지 않도록 설정하는 경우 Windows 패키지 관리자에 대해 추가 원본을 구성할 수 없습니다. - 앱 설치 관리자 허용된 원본 사용 + Windows 패키지 관리자 허용된 원본 사용 이 정책은 엔터프라이즈 IT 관리자가 허용하는 추가 원본을 제어합니다. 이 정책을 구성하지 않는 경우 사용자는 정책에 의해 구성된 원본 외의 다른 원본을 추가하거나 제거할 수 있습니다. @@ -122,6 +122,20 @@ 이 설정을 사용하지 않거나 구성하지 않으면 기본적으로 프록시가 사용되지 않습니다. 이 설정을 사용하면 지정된 프록시가 기본적으로 사용됩니다. + MSIX 패키지에 대해 앱 설치 관리자 허용된 영역 사용 + 이 정책은 앱 설치 관리자 특정 URL 영역에서 시작되는 패키지를 설치할 수 있는지 여부를 제어합니다. 패키지의 원본은 해당 URI에 따라 결정되며 MotW(Mart-of-the-Web)가 있는지 여부를 결정합니다. 여러 URI가 관련된 경우 모두 고려됩니다. 예를 들어 리디렉션과 관련된 .appinstaller 파일을 사용하는 경우 + +이 정책을 사용하면 사용자가 각 영역의 구성에 따라 MSIX 패키지를 설치할 수 있습니다. + +이 정책을 사용하지 않거나 구성하지 않으면 신뢰할 수 없음을 제외한 모든 영역에서 MSIX 패키지를 설치할 수 있습니다. + 허용 + 차단 + MSIX 패키지에 Microsoft SmartScreen 검사 사용 + 이 정책은 MSIX 패키지를 설치할 때 앱 설치 관리자 Microsoft SmartScreen 검사를 수행할지 여부를 제어합니다. + +이 정책을 사용하거나 구성하지 않으면 설치 전에 Microsoft SmartScreen을 사용하여 패키지 URI가 평가됩니다. 이 검사 인터넷에서 가져온 패키지에 대해서만 수행됩니다. + +사용하지 않도록 설정하면 패키지를 설치하기 전에 Microsoft SmartScreen을 참조하지 않습니다. @@ -138,6 +152,13 @@ + + 로컬 컴퓨터 + 인트라넷 + 신뢰할 수 있는 사이트 + 인터넷 + 신뢰할 수 없는 사이트 + diff --git a/Localization/Policies/pt-BR/DesktopAppInstaller.adml b/Localization/Policies/pt-BR/DesktopAppInstaller.adml index d8ad3bb50b..3dfe138475 100644 --- a/Localization/Policies/pt-BR/DesktopAppInstaller.adml +++ b/Localization/Policies/pt-BR/DesktopAppInstaller.adml @@ -7,51 +7,51 @@ Instalador de Aplicativos de Área de Trabalho - Habilitar o Instalador de Aplicativos + Habilitar o Gerenciador de Pacotes do Windows Esta política controla se o Gerenciador de pacotes do Windows pode ser usado por usuários. Se você habilitar ou não definir essa configuração, os usuários poderão usar o Gerenciador de pacotes do Windows. Se você desabilitar essa configuração, os usuários não poderão usar o Gerenciador de pacotes do Windows. - Habilitar as Configurações do Instalador de Aplicativos + Habilitar as Configurações do Gerenciador de Pacotes do Windows Esta política controla se os usuários podem alterar suas configurações. Se você habilitar ou não definir essa configuração, os usuários poderão alterar as configurações do Gerenciador de pacotes do Windows. Se você desabilitar essa configuração, os usuários não poderão alterar configurações para o Gerenciador de pacotes do Windows. - Habilitar os Recursos Experimentais do Instalador de Aplicativos + Habilitar Recursos Experimentais do Gerenciador de Pacotes do Windows Essa política controla se os usuários podem habilitar recursos experimentais no Gerenciador de pacotes do Windows. Se você habilitar ou não definir essa configuração, os usuários poderão habilitar recursos experimentais para o Gerenciador de pacotes do Windows. Se você desabilitar essa configuração, os usuários não poderão habilitar os recursos experimentais do Gerenciador de pacotes do Windows. - Habilitar os Arquivos de Manifesto Local do Instalador de Aplicativos + Habilitar Arquivos de Manifesto Local do Gerenciador de Pacotes do Windows Essa política controla se os usuários podem instalar pacotes com arquivos de manifesto locais. Se você habilitar ou não definir essa configuração, os usuários poderão instalar pacotes com manifestos locais usando o Gerenciador de pacotes do Windows. Se você desabilitar essa configuração, os usuários não poderão instalar pacotes com manifestos locais usando o Gerenciador de pacotes do Windows. - Habilitar Bypass de Validação de Certificado de Origem da Microsoft Store do Instalador de Aplicativos + Habilitar Bypass Gerenciador de Pacotes do Windows Microsoft Store Certificado de Origem Essa política controla se o Gerenciador de Pacotes do Windows validará se o hash do certificado Microsoft Store corresponde a um certificado Microsoft Store conhecido ao iniciar uma conexão com a Origem da Microsoft Store. Se você habilitar essa política, o Gerenciador de Pacotes do Windows ignorará a validação do certificado da Microsoft Store. Se você desabilitar essa política, o Gerenciador de Pacotes do Windows validará se o certificado Microsoft Store usado é válido e pertence ao Microsoft Store antes de se comunicar com a origem da Microsoft Store. Se você não definir essa política, as configurações de administrador do Gerenciador de Pacotes do Windows serão aderidas. - Habilitar a Substituição do Hash do Instalador de Aplicativos + Habilitar a Substituição de Hash do Gerenciador de Pacotes do Windows Esta política controla se o Gerenciador de Pacotes do Windows pode ou não ser configurado para permitir a capacidade de substituição da validação de segurança SHA256 nas configurações. Se você habilitar ou não configurar esta política, os usuários poderão habilitar a capacidade de substituição da validação de segurança SHA256 nas configurações do Gerenciador de Pacotes do Windows. Se você desabilitar esta política, os usuários não poderão habilitar a capacidade de substituição da validação de segurança SHA256 nas configurações do Gerenciador de Pacotes do Windows. - Habilitar Instalador de Aplicativo Verificação de Malware de Arquivo Morto Local + Habilitar Gerenciador de Pacotes do Windows Verificação de Malware de Arquivo Morto Local Esta política controla a capacidade de substituir verificações de vulnerabilidade de malware ao instalar um arquivo morto usando um manifesto local usando os argumentos de linha de comando. Se você habilitar essa política, os usuários poderão substituir a verificação de malware ao executar uma instalação de manifesto local de um arquivo morto. Se você desabilitar essa política, os usuários não poderão substituir a verificação de malware de um arquivo morto durante a instalação usando um manifesto local. Se você não configurar essa política, as configurações Gerenciador de Pacotes do Windows administrador serão aderidas. - Habilitar a Fonte Padrão do Instalador de Aplicativos + Habilitar a Fonte Padrão do Gerenciador de Pacotes do Windows Esta política controla a fonte padrão incluída no Gerenciador de Pacotes do Windows. Se você não definir essa configuração, a fonte padrão do Gerenciador de Pacotes do Windows estará disponível e poderá ser removida. @@ -59,7 +59,7 @@ Se você não definir essa configuração, a fonte padrão do Gerenciador de Pac Se você habilitar essa configuração, a fonte padrão para o Gerenciador de Pacotes do Windows estará disponível e não poderá ser removida. Se você desabilitar esta configuração, a fonte padrão para o Gerenciador de Pacotes do Windows não estará disponível. - Habilitar a Fonte da Microsoft Store do Instalador de Aplicativos + Habilitar a Fonte da Microsoft Store do Gerenciador de Pacotes do Windows Esta política controla a fonte da Microsoft Store incluída com o Gerenciador de Pacotes do Windows. Se você não definir essa configuração, a fonte da Microsoft Store para o Gerenciador do Pacote Windows estará disponível e poderá ser removida. @@ -67,13 +67,13 @@ Se você não definir essa configuração, a fonte da Microsoft Store para o Ger Se você habilitar essa configuração, a fonte da Microsoft Store para o Gerenciador de Pacotes do Windows estará disponível e não poderá ser removida. Se você desabilitar esta configuração, a fonte da Microsoft Store para o Gerenciador de Pacotes do Windows não estará disponível. - Definir o Intervalo de Atualização Automática da Fonte do Instalador de Aplicativo em Minutos + Definir o Intervalo de Atualização Automática da Fonte do Gerenciador de Pacotes do Windows em Minutos Esta política controla o intervalo de atualização automática para origens baseadas em pacote. A fonte padrão para Gerenciador de Pacotes do Windows é configurada de modo que um índice dos pacotes seja armazenado em cache no computador local. O índice é baixado quando um usuário invoca um comando e o intervalo é passado. Se você desabilitar ou não definir essa configuração, o intervalo padrão ou o valor especificado na Gerenciador de Pacotes do Windows configurações serão usadas. Se você habilitar essa configuração, o número de minutos especificado será usado pelo Gerenciador de Pacotes do Windows. - Habilitar as Fontes Adicionais do Instalador de Aplicativos + Habilitar Fontes Adicionais do Gerenciador de Pacotes do Windows Esta política controla as fontes adicionais fornecidas pelo administrador de TI da empresa. Se você não configurar esta política, nenhuma fonte adicional será configurada para o Gerenciador de Pacotes do Windows. @@ -81,7 +81,7 @@ Se você não configurar esta política, nenhuma fonte adicional será configura Se você habilitar essa política, as fontes adicionais serão adicionadas ao Gerenciador de Pacotes do Windows e não poderão ser removidas. A representação de cada fonte adicional poderá ser obtida a partir das fontes instaladas usando a 'exportação de fonte de winget'. Se você desabilitar esta política, nenhuma fonte adicional poderá ser configurada para o Gerenciador de Pacotes do Windows. - Habilitar as Fontes Permitidas do Instalador de Aplicativos + Habilitar Fontes Permitidas do Gerenciador de Pacotes do Windows Esta política controla as fontes adicionais permitidas pelo administrador de TI da empresa. Se você não configurar esta política, os usuários poderão adicionar ou remover fontes adicionais além daquelas configuradas pela política. @@ -122,6 +122,20 @@ Se você desabilitar ou não definir essa configuração, os usuários não pode Se você desabilitar ou não definir essa configuração, nenhum proxy será usado por padrão. Se você habilitar essa configuração, o proxy especificado será usado por padrão. + Habilitar Zonas Permitidas do Instalador de Aplicativo para Pacotes MSIX + Esta política controla se Instalador de Aplicativo permite a instalação de pacotes originados de Zonas de URL específicas. A origem de um pacote é determinada por seu URI e se um Mart-of-the-Web (MotW) está presente. Se vários URIs forem envolvidos, todos eles serão considerados; por exemplo, ao usar um arquivo .appinstaller que envolve redirecionamento. + +Se você habilitar essa política, os usuários poderão instalar pacotes MSIX de acordo com a configuração de cada zona. + +Se você desabilitar ou não configurar esta política, os usuários poderão instalar pacotes MSIX de qualquer zona, exceto por Não Confiável. + Permitir + Bloquear + Habilitar verificações do Microsoft SmartScreen para Pacotes MSIX + Esta política controla se Instalador de Aplicativo verificações do Microsoft SmartScreen ao instalar pacotes MSIX. + +Se você habilitar ou não configurar essa política, o URI do pacote será avaliado com o Microsoft SmartScreen antes da instalação. Este marcar é feito somente para pacotes provenientes da Internet. + +Se você desabilitar, o Microsoft SmartScreen não será consultado antes de instalar um pacote. @@ -138,6 +152,13 @@ Se você habilitar essa configuração, o proxy especificado será usado por pad + + Computador Local + Intranet + Sites Confiáveis + Internet + Sites Não Confiáveis + diff --git a/Localization/Policies/ru-RU/DesktopAppInstaller.adml b/Localization/Policies/ru-RU/DesktopAppInstaller.adml index b7e8caca52..fee746baff 100644 --- a/Localization/Policies/ru-RU/DesktopAppInstaller.adml +++ b/Localization/Policies/ru-RU/DesktopAppInstaller.adml @@ -7,51 +7,51 @@ Установщик классических приложений - Включить Установщик приложений + Включить Диспетчер пакетов Windows Эта политика определяет, могут ли пользователи использовать Диспетчер пакетов Windows. Если включить или не настроить этот параметр, пользователи смогут использовать Диспетчер пакетов Windows. Если отключить этот параметр, пользователи не смогут использовать Диспетчер пакетов Windows. - Включить параметры Установщика приложений + Включить параметры Диспетчера пакетов Windows Эта политика определяет, могут ли пользователи изменять свои параметры. Если включить или не настроить этот параметр, пользователи смогут изменять параметры Диспетчера пакетов Windows. Если отключить этот параметр, пользователи не смогут изменять параметры Диспетчера пакетов Windows. - Включить экспериментальные функции Установщика приложений + Включить экспериментальные функции Диспетчера пакетов Windows Этот параметр политики определяет, могут ли пользователи включать экспериментальные функции в диспетчер пакетов Windows. Если включить или не настроить этот параметр, пользователи смогут включать экспериментальные функции для диспетчер пакетов Windows. Если этот параметр отключен, пользователи не смогут включать экспериментальные функции для диспетчер пакетов Windows. - Включить локальные файлы манифестов Установщика приложений + Включить файлы локальных манифестов Диспетчера пакетов Windows Эта политика определяет, могут ли пользователи устанавливать пакеты с локальными файлами манифестов. Если включить или не настроить этот параметр, пользователи смогут устанавливать пакеты с локальными манифестами с помощью Диспетчера пакетов Windows. Если отключить этот параметр, пользователи не смогут устанавливать пакеты с локальными манифестами с помощью Диспетчера пакетов Windows. - Включение обхода проверки исходного сертификата Microsoft Store для установщика приложений + Включить обход проверки сертификата источника Microsoft Store в Диспетчере пакетов Windows Эта политика определяет, будет ли Диспетчер пакетов Windows проверять соответствие хэша сертификата Microsoft Store известному сертификату Microsoft Store при инициации подключения к источнику Microsoft Store. При включении этой политики диспетчер пакетов Windows будет обходить проверку сертификата Microsoft Store. При отключении этой политики диспетчер пакетов Windows будет проверять принадлежность используемого сертификата Microsoft Store и его действительность, прежде чем связываться с источником Microsoft Store.. Если эта политика не настроена, будут соблюдаться параметры администратора диспетчера пакетов Windows. - Включить переопределение хэша Установщика приложений + Включить переопределение хэша Диспетчера пакетов Windows Этот параметр политики определяет, можно ли настроить Диспетчер пакетов Windows, чтобы включить возможность переопределения параметров проверки безопасности SHA256 в настройках. Если данный параметр политики включен или не настроен, пользователи получат возможность переопределять проверку безопасности SHA256 в параметрах Диспетчера пакетов Windows. Если данный параметр политики отключен, пользователи не смогут переопределять проверку безопасности SHA256 в параметрах Диспетчера пакетов Windows. - Включение блокировки сканирования вредоносных программ в локальном архиве установщика приложений + Включить переопределение сканирования вредоносных программ в локальном архиве Диспетчера пакетов Windows Эта политика управляет возможностью переопределения сканирования уязвимостей вредоносных программ при установке файла архива с использованием локального манифеста с использованием аргументов командной строки. При включении этой политики пользователи смогут переопределять сканирование вредоносных программ при выполнении локальной установки манифеста архивного файла. При отключении этой политики пользователи не смогут переопределять сканирование архивного файла на наличие вредоносных программ при установке с использованием локального манифеста. Если эта политика не настроена, будут соблюдаться параметры администратора диспетчера пакетов Windows. - Включить источник по умолчанию Установщика приложений + Включить источник по умолчанию для Диспетчера пакетов Windows Эта политика управляет источником по умолчанию, входящим в состав Диспетчера пакетов Windows. Если не задать этот параметр, источник по умолчанию для Диспетчера пакетов Windows будет доступен, и его можно будет удалить. @@ -59,7 +59,7 @@ Если включить этот параметр, источник по умолчанию для Диспетчера пакетов Windows будет доступен, и его нельзя будет удалить. Если отключить этот параметр, источник по умолчанию для Диспетчера пакетов Windows будет недоступен. - Включить источник Microsoft Store Установщика приложений + Включить источник Microsoft Store в Диспетчере пакетов Windows Эта политика управляет источником Microsoft Store, входящим в состав Диспетчера пакетов Windows. Если не задать этот параметр, источник Microsoft Store для Диспетчера пакетов Windows будет доступен, и его можно будет удалить. @@ -67,13 +67,13 @@ Если включить этот параметр, источник Microsoft Store для Диспетчера пакетов Windows будет доступен, и его нельзя будет удалить. Если отключить этот параметр, источник Microsoft Store для Диспетчера пакетов Windows будет недоступен. - Задать интервал автоматического обновления источника Установщика приложений в минутах + Задать интервал автоматического обновления источника Диспетчера пакетов Windows в минутах Эта политика управляет интервалом автоматического обновления для источников на основе пакетов. Источник по умолчанию для Диспетчера пакетов Windows настроен таким образом, что индекс пакетов кэшируется на локальном компьютере. Индекс скачивается при вызове команды пользователем и завершении интервала. Если этот параметр отключен или не настроен, будет использоваться интервал по умолчанию или значение, указанное в параметрах Диспетчера пакетов Windows. Если этот параметр включен, указанное число минут будет использоваться Диспетчером пакетов Windows. - Включить дополнительные источники Установщика приложений + Включить дополнительные источники Диспетчера пакетов Windows Эта политика управляет дополнительными источниками, предоставленными ИТ-администратором предприятия. Если не настроить эту политику, дополнительные источники для Диспетчера пакетов Windows не будут настроены. @@ -81,7 +81,7 @@ Если включить эту политику, дополнительные источники будут добавлены в Диспетчер пакетов Windows, и их нельзя будет удалить. Представление для каждого дополнительного источника можно получить из установленных источников с помощью команды "winget source export". Если отключить эту политику, задать дополнительные источники для Диспетчера пакетов Windows будет невозможно. - Включить разрешенные источники Установщика приложений + Включить разрешенные источники Диспетчера пакетов Windows Эта политика управляет дополнительными источниками, разрешенными ИТ-администратором предприятия. Если не настроить эту политику, пользователи смогут добавлять и удалять дополнительные источники помимо заданных в политике. @@ -122,6 +122,20 @@ Если этот параметр отключен или не настроен, по умолчанию прокси-сервер не будет использоваться. Если этот параметр включен, указанный прокси-сервер будет использоваться по умолчанию. + Включить разрешенные зоны Установщика приложений для пакетов MSIX + Эта политика определяет, Установщик приложений ли установка пакетов, полученных из определенных зон URL-адресов. Источник пакета определяется его URI и наличием киоска в Интернете (MotW). Если включено несколько URI, все они считаются; например, при использовании appinstaller-файла, который включает перенаправление. + +Если эта политика включена, пользователи смогут устанавливать пакеты MSIX в соответствии с конфигурацией для каждой зоны. + +Если эта политика отключена или не настроена, пользователи смогут устанавливать пакеты MSIX из любой зоны, кроме ненадежных. + Разрешить + Блокировать + Включить проверки Microsoft SmartScreen для пакетов MSIX + Эта политика определяет, Установщик приложений ли фильтр SmartScreen (Майкрософт) при установке пакетов MSIX. + +Если эта политика включена или не настроена, URI пакета будет проверяться с помощью фильтра SmartScreen (Майкрософт) перед установкой. Эта проверка только для пакетов, поступающих из Интернета. + +Если отключить этот параметр, microsoft SmartScreen не будет проверяться перед установкой пакета. @@ -138,6 +152,13 @@ + + Локальный компьютер + Интрасеть + Надежные сайты + Интернет + Ненадежные сайты + diff --git a/Localization/Policies/zh-CN/DesktopAppInstaller.adml b/Localization/Policies/zh-CN/DesktopAppInstaller.adml index a09e6e4df2..e85544cb98 100644 --- a/Localization/Policies/zh-CN/DesktopAppInstaller.adml +++ b/Localization/Policies/zh-CN/DesktopAppInstaller.adml @@ -7,51 +7,51 @@ 桌面应用安装程序 - 启用应用安装程序 + 启用 Windows 程序包管理器 此策略控制用户是否可以使用 Windows 程序包管理器。 如果启用或未配置此设置,则用户可以使用 Windows 程序包管理器。 如果禁用此设置,则用户将无法使用 Windows 程序包管理器。 - 启用应用安装程序设置 + 启用 Windows 程序包管理器设置 此策略控制用户是否可以更改其设置。 如果启用或未配置此设置,则用户可以更改 Windows 程序包管理器的设置。 如果禁用此设置,则用户将无法更改 Windows 程序包管理器的设置。 - 启用应用安装程序实验性功能 + 启用 Windows 程序包管理器实验性功能 此策略控制用户是否可以在 Windows 程序包管理器中启用实验性功能。 如果启用或未配置此设置,则用户将能够为 Windows 包管理器启用实验性功能。 如果禁用此设置,则用户将无法启用 Windows 包管理器的实验性功能。 - 启用应用安装程序本地清单文件 + 启用 Windows 程序包管理器本地清单文件 此策略控制用户是否可以使用本地清单文件安装程序包。 如果启用或未配置此设置,则用户可以使用 Windows 程序包管理器在本地清单中安装包。 如果禁用此设置,则用户将无法使用 Windows 程序包管理器在本地清单中安装包。 - 启用应用安装程序 Microsoft Store 源证书验证绕过 + 启用Windows 程序包管理器Microsoft Store源证书验证绕过 此策略控制 Windows 程序包管理器在发起与 Microsoft Store 源的连接时是否验证 Microsoft Store 证书哈希与已知的 Microsoft Store 证书的匹配情况。 如果启用此策略,Windows 程序包管理器将绕过 Microsoft Store 证书验证。 如果禁用此策略,则 Windows 程序包管理器在与 Microsoft Store 源通信之前,将验证所使用的 Microsoft Store 证书是否有效且属于 Microsoft Store。 如果未配置此策略,则将遵循 Windows 程序包管理器的管理员设置。 - 启用应用安装程序哈希替代 + 启用 Windows 程序包管理器哈希替代 此策略控制是否可以配置 Windows 程序包管理器,以便在设置中启用覆盖 SHA256 安全验证的能力。 如果启用或未配置此策略,则用户将能够在 Windows 程序包管理器设置中启用覆盖 SHA256 安全验证的能力。 如果禁用此策略,则用户将无法在 Windows 程序包管理器设置中启用覆盖 SHA256 安全验证的能力。 - 启用应用安装程序本地存档恶意软件扫描替代 + 启用Windows 程序包管理器本地存档恶意软件扫描替代 此策略控制在使用命令行参数通过本地清单安装存档文件时替代恶意软件漏洞扫描的能力。 如果启用此策略,则用户可以在对存档文件执行本地清单安装时替代恶意软件扫描。 如果禁用此策略,则在使用本地清单进行安装时,用户将无法替代对存档文件的恶意软件扫描。 如果未配置此策略,则将遵循 Windows 程序包管理器的管理员设置。 - 启用应用安装程序默认源 + 启用 Windows 程序包管理器默认源 此策略控制 Windows 程序包管理器中包含的默认源。 如果未配置此设置,Windows 程序包管理器的默认源将可用并可删除。 @@ -59,7 +59,7 @@ 如果启用此设置,Windows 程序包管理器的默认源将可用,无法删除。 如果禁用此设置,Windows 程序包管理器的默认源将不可用。 - 启用应用安装程序 Microsoft Store 源 + 启用 Windows 程序包管理器 Microsoft Store 源 此策略控制 Windows 程序包管理器中包含的 Microsoft Store 源。 如果未配置此设置,Windows 程序包管理器的 Microsoft Store 源将可用并可删除。 @@ -67,13 +67,13 @@ 如果启用此设置,Windows 程序包管理器的 Microsoft Store 源将可用,无法删除。 如果禁用此设置,Windows 程序包管理器的 Microsoft Store 源将不可用。 - 设置应用安装程序源自动更新间隔(分钟) + 设置 Windows 程序包管理器源自动更新间隔(分钟) 此策略控制基于程序包的源的自动更新间隔。配置Windows 程序包管理器的默认源,以便在本地计算机上缓存包索引。当用户调用命令并且间隔已过时,将下载索引。 如果禁用或未配置此设置,将使用Windows 程序包管理器设置中指定的默认间隔或值。 如果启用此设置,则Windows 程序包管理器将使用指定的分钟数。 - 启用应用安装程序其他源 + 启用 Windows 程序包管理器其他源 此策略控制企业 IT 管理员提供的其他源。 如果未配置此策略,则将不会为 Windows 程序包管理器配置其他源。 @@ -81,7 +81,7 @@ 如果启用此策略,则将向 Windows 程序包管理器添加其他源并且这些源不可删除。可使用“winget source export”从已安装的源获取每个其他源的表示形式。 如果禁用此策略,则不能为 Windows 程序包管理器配置其他源。 - 启用应用安装程序允许的源 + 启用 Windows 程序包管理器允许的源 此策略控制企业 IT 管理员允许的其他源。 如果未配置此策略,用户将能够添加或删除策略配置的源之外的其他源。 @@ -122,6 +122,20 @@ 如果禁用或未配置此设置,则默认情况下不会使用任何代理。 如果启用此设置,则默认情况下将使用指定的代理。 + 为 MSIX 包启用应用安装程序允许的区域 + 此策略控制应用安装程序是否允许安装源自特定 URL 区域的包。包的来源由其 URI 以及是否存在 Mart-of-the-Web (MotW) 来确定。如果涉及多个 URI,则会考虑所有这些 URI;例如,使用涉及重定向的 .appinstaller 文件时。 + +如果启用此策略,则用户将能够根据每个区域的配置安装 MSIX 包。 + +如果禁用或未配置此策略,则用户将能够从除不受信任之外的任何区域安装 MSIX 包。 + 允许 + 阻止 + 为 MSIX 包启用 Microsoft SmartScreen 检查 + 此策略控制应用安装程序在安装 MSIX 包时是否执行Microsoft SmartScreen 检查。 + +如果启用或未配置此策略,则在安装之前,将使用 Microsoft SmartScreen 评估包 URI。此检查仅适用于来自 Internet 的程序包。 + +如果禁用,则在安装包之前,不会咨询Microsoft SmartScreen。 @@ -138,6 +152,13 @@ + + 本地计算机 + Intranet + 受信任的站点 + Internet + 不受信任的站点 + diff --git a/Localization/Policies/zh-TW/DesktopAppInstaller.adml b/Localization/Policies/zh-TW/DesktopAppInstaller.adml index a9d5823cc6..86496f6ff9 100644 --- a/Localization/Policies/zh-TW/DesktopAppInstaller.adml +++ b/Localization/Policies/zh-TW/DesktopAppInstaller.adml @@ -7,51 +7,51 @@ 傳統型應用程式安裝程式 - 啟用應用程式安裝程式 + 啟用 Windows 封裝管理員 此原則可控制使用者是否可以使用 Windows 套件管理員。 如果您啟用或未設定這個設定,使用者將可以使用 Windows 套件管理員。 如果停用此設定,使用者將無法使用 Windows 套件管理員。 - 啟用應用程式安裝程式設定 + 啟用 Windows 封裝管理員設定 此原則可控制使用者是否可以變更其設定。 如果您啟用或未設定這個設定,使用者將可以變更 Windows 套件管理員的設定。 如果停用此設定,使用者將無法變更 Windows 套件管理員的設定。 - 啟用應用程式安裝程式實驗性功能 + 啟用 Windows 封裝管理員實驗性功能 此原則可控制使用者是否能在 Windows 套件管理員中啟用實驗性功能。 如果啟用或未設定此設定,使用者將能夠啟用 Windows 套件管理員的實驗性功能。 如果停用此設定,使用者將無法啟用 Windows 套件管理員的實驗性功能。 - 啟用應用程式安裝程式本機資訊清單檔案 + 啟用 Windows 封裝管理員本機資訊清單檔案 此原則可控制使用者是否能安裝具有本機資訊清單檔案的套件。 如果您啟用或未設定這個設定,使用者將可以使用 Windows 套件管理員來安裝具有本機資訊清單的套件。 若停用此設定,使用者將無法使用 Windows 套件管理員來安裝具有本機資訊清單的套件。 - 啟用應用程式安裝程式 Microsoft Store 來源已憑證驗證旁路 + 啟用 Windows 封裝管理員 Microsoft Store來源憑證驗證略過 此原則可控制 Windows 封裝管理員在起始 Microsoft Store 來源的連線時,是否要驗證與已知 Microsoft Store 憑證相符的 Microsoft Store 憑證雜湊。 如果您啟用這個原則,Windows 封裝管理員將會略過 Microsoft Store 憑證驗證。 如果停用此原則,則 Windows 封裝管理員會在與 Microsoft Store 來源通訊之前,驗證使用的 Microsoft Store 憑證有效且屬於 Microsoft Store。 如果您未設定這個原則,則會遵循 Windows 封裝管理員系統管理員設定。 - 啟用應用程式安裝程式雜湊覆寫 + 啟用 Windows 封裝管理員雜湊覆寫 此原則會控制 Windows 封裝管理員是否可以設定以便啟用在設定中覆寫 SHA256 安全性驗證的能力。 如果您啟用或未設定此原則,使用者就可以在 Windows 封裝管理員設定中啟用覆寫 SHA256 安全性驗證的能力。 如果您停用此原則,使用者就無法在 Windows 封裝管理員設定中啟用覆寫 SHA256 安全性驗證的能力。 - 啟用應用程式安裝程式本機封存惡意程式碼掃描覆寫 + 啟用 Windows 封裝管理員 本機封存惡意代碼掃描覆寫 此原則控制在使用本機資訊清單使用命令列引數安裝封存檔案時,是否可以覆寫惡意程式碼弱點掃描。 如果您啟用這個原則,使用者可以在執行封存檔案的本機資訊清單安裝時覆寫惡意程式碼掃描。 如果您停用這個原則,使用者將無法在使用本機資訊清單安裝時覆寫封存檔案的惡意程式碼掃描。 如果您未設定這個原則,則會遵循Windows 封裝管理員系統管理員設定。 - 啟用應用程式安裝程式預設來源 + 設定 Windows 封裝管理員預設來源 此原則控制 Windows 封裝管理員隨附的預設來源。 如果您未設定此設定,Windows 封裝管理員的預設來源將可供使用,而且可以移除。 @@ -59,7 +59,7 @@ 如果您啟用此設定,Windows 封裝管理員的預設來源將可供使用,且無法移除。 如果您停用此設定,Windows 封裝管理員的預設來源將無法使用。 - 啟用應用程式安裝程式 Microsoft Store 來源 + 啟用 Windows 封裝管理員 Microsoft Store 來源 此原則控制 Windows 封裝管理員隨附的 Microsoft Store 來源。 如果您未設定此設定,Windows 封裝管理員的 Microsoft Store 來源將可供使用,而且可以移除。 @@ -67,13 +67,13 @@ 如果您啟用此設定,Windows 封裝管理員的 Microsoft Store 來源將可供使用,且無法移除。 如果您停用此設定,Windows 封裝管理員的 Microsoft Store 來源將無法使用。 - 設定應用程式安裝程式來源自動更新間隔 (分鐘) + 設定 Windows 封裝管理員來源自動更新間隔 (分鐘) 此原則控制封裝型來源的自動更新間隔時間。Windows 封裝管理員的預設來源設定為本機電腦上快取的套件索引。當使用者調用命令且間隔已過時,下載索引。 如果您停用或不設定此設定,將會使用 Windows 封裝管理員設定中指定的預設間隔或值。 如果您啟用此設定,Windows 封裝管理員將會使用指定的分鐘數。 - 啟用應用程式安裝程式其他來源 + 啟用 Windows 封裝管理員其他來源 此原則控制企業 IT 系統管理員提供的其他來源。 如果您未設定此原則,將不會為 Windows 封裝管理員設定其他來源。 @@ -81,7 +81,7 @@ 如果您啟用此原則,其他來源將會新增到 Windows 封裝管理員,而且無法移除。每個其他來源的標記法都可以使用 'winget 來源匯出' 從已安裝的來源取得。 如果您停用此原則,則 Windows 封裝管理員無法為其他來源進行設定。 - 啟用應用程式安裝程式允許的來源 + 設定 Windows 封裝管理員允許來源 此原則控制企業 IT 系統管理員允許的其他來源。 如果您未設定此原則,使用者將可以新增或移除其他非此原則設定的來源。 @@ -122,6 +122,20 @@ 如果停用或未設定此設定,則預設不會使用任何 Proxy。 如果您啟用這個設定,預設會使用指定的 Proxy。 + 為 MSIX 套件啟用應用程式安裝程式允許的區域 + 此原則控制應用程式安裝程式是否允許安裝來自特定 URL 區域的套件。套件的來源取決於其 URI,以及是否存在 Mart-of the Web (MotW)。如果涉及多個 URI,則會考慮所有 URI;例如,使用涉及重新導向的 .appinstaller 檔案時。 + +如果您啟用這個原則,使用者將可以根據每個區域的設定來安裝 MSIX 套件。 + +如果您停用或未設定這個原則,除了不受信任之外,使用者將可以從任何區域安裝 MSIX 套件。 + 允許 + 阻止 + 啟用 MSIX 套件的 Microsoft SmartScreen 檢查 + 此原則可控制應用程式安裝程式在安裝 MSIX 套件時是否執行Microsoft SmartScreen 檢查。 + +如果啟用或未設定此原則,則會在安裝前使用 Microsoft SmartScreen 評估套件 URI。這項檢查只會針對來自因特網的套件執行。 + +如果停用,Microsoft安裝套件前將不會詢問 SmartScreen。 @@ -138,6 +152,13 @@ + + 本機電腦 + 內部網路 + 信任的網站 + 網際網路 + 未受信任的網站 + diff --git a/Localization/Resources/de-DE/winget.resw b/Localization/Resources/de-DE/winget.resw index 395484dd5a..4d857e5673 100644 --- a/Localization/Resources/de-DE/winget.resw +++ b/Localization/Resources/de-DE/winget.resw @@ -3130,4 +3130,13 @@ Geben Sie eine Option für --source an, um den Vorgang fortzusetzen. Fehler beim Abrufen Microsoft Store Paketlizenz. Das Microsoft Entra-ID-Konto verfügt nicht über die erforderlichen Berechtigungen. + + Der Parameter kann nicht über die Integritätsgrenze hinweg übergeben werden. + + + Das Zero-Byte-Installationsprogramm wurde heruntergeladen. stellen Sie sicher, dass die Netzwerkverbindung ordnungsgemäß funktioniert. + + + Das Zero-Byte-Installationsprogramm wurde heruntergeladen. stellen Sie sicher, dass die Netzwerkverbindung ordnungsgemäß funktioniert. + \ No newline at end of file diff --git a/Localization/Resources/es-ES/winget.resw b/Localization/Resources/es-ES/winget.resw index 605962b98e..056a8b1ecf 100644 --- a/Localization/Resources/es-ES/winget.resw +++ b/Localization/Resources/es-ES/winget.resw @@ -3130,4 +3130,13 @@ Especifique uno de ellos con la opción --source para continuar. No se pudo recuperar Microsoft Store licencia del paquete. La cuenta de id. de Microsoft Entra no tiene el privilegio necesario. + + El parámetro no se puede pasar a través del límite de integridad. + + + Instalador de cero bytes descargado; asegúrese de que la conexión de red funciona correctamente. + + + Instalador de cero bytes descargado; asegúrese de que la conexión de red funciona correctamente. + \ No newline at end of file diff --git a/Localization/Resources/fr-FR/winget.resw b/Localization/Resources/fr-FR/winget.resw index 71f7fed825..e6ee627e21 100644 --- a/Localization/Resources/fr-FR/winget.resw +++ b/Localization/Resources/fr-FR/winget.resw @@ -3130,4 +3130,13 @@ Spécifiez l’un d’entre eux à l’aide de l’option --source pour continue Échec de la récupération de Microsoft Store licence de package. Le compte d’ID Microsoft Entra ne dispose pas des privilèges requis. + + Le paramètre ne peut pas être transmis au-delà de la limite d’intégrité. + + + Programme d’installation zéro octet téléchargé ; vérifiez que votre connexion réseau fonctionne correctement. + + + Programme d’installation zéro octet téléchargé ; vérifiez que votre connexion réseau fonctionne correctement. + \ No newline at end of file diff --git a/Localization/Resources/it-IT/winget.resw b/Localization/Resources/it-IT/winget.resw index 908e00236a..b9c5ea6b4f 100644 --- a/Localization/Resources/it-IT/winget.resw +++ b/Localization/Resources/it-IT/winget.resw @@ -3130,4 +3130,13 @@ Specificarne uno utilizzando l'opzione --source per continuare. Non è stato possibile recuperare Microsoft Store licenza del pacchetto. L'account id Microsoft Entra non dispone dei privilegi necessari. + + Il parametro non può essere passato oltre il limite di integrità. + + + Programma di installazione a zero byte scaricato; verificare che la connessione di rete funzioni correttamente. + + + Programma di installazione a zero byte scaricato; verificare che la connessione di rete funzioni correttamente. + \ No newline at end of file diff --git a/Localization/Resources/ja-JP/winget.resw b/Localization/Resources/ja-JP/winget.resw index e8364c5acf..c95dffa066 100644 --- a/Localization/Resources/ja-JP/winget.resw +++ b/Localization/Resources/ja-JP/winget.resw @@ -3130,4 +3130,13 @@ Microsoft Store パッケージ ライセンスを取得できませんでした。Microsoft Entra ID アカウントに必要な特権がありません。 + + 整合性境界を越えてパラメーターを渡すことはできません。 + + + ゼロ バイト インストーラーをダウンロードしました;ネットワーク接続が正しく動作していることを確認してください。 + + + ゼロ バイト インストーラーをダウンロードしました;ネットワーク接続が正しく動作していることを確認してください。 + \ No newline at end of file diff --git a/Localization/Resources/ko-KR/winget.resw b/Localization/Resources/ko-KR/winget.resw index f8d1bedeaa..6d5042d792 100644 --- a/Localization/Resources/ko-KR/winget.resw +++ b/Localization/Resources/ko-KR/winget.resw @@ -3130,4 +3130,13 @@ Microsoft Store 패키지 라이선스를 검색하지 못했습니다. Microsoft Entra ID 계정에 필요한 권한이 없습니다. + + 무결성 경계를 넘어 매개 변수를 전달할 수 없습니다. + + + 0 바이트 설치 관리자 다운로드됨; 네트워크 연결이 제대로 작동하는지 확인하십시오. + + + 0 바이트 설치 관리자 다운로드됨; 네트워크 연결이 제대로 작동하는지 확인하십시오. + \ No newline at end of file diff --git a/Localization/Resources/pt-BR/winget.resw b/Localization/Resources/pt-BR/winget.resw index 31011b9a02..4b1aaa91fa 100644 --- a/Localization/Resources/pt-BR/winget.resw +++ b/Localization/Resources/pt-BR/winget.resw @@ -3130,4 +3130,13 @@ Especifique um deles usando a opção --source para continuar. Falha ao recuperar a Microsoft Store do pacote. A Microsoft Entra de ID não tem o privilégio necessário. + + O parâmetro não pode ser passado através do limite de integridade. + + + Instalador de zero bytes baixado; verifique se a conexão de rede está funcionando corretamente. + + + Instalador de zero bytes baixado; verifique se a conexão de rede está funcionando corretamente. + \ No newline at end of file diff --git a/Localization/Resources/ru-RU/winget.resw b/Localization/Resources/ru-RU/winget.resw index 1099ce92df..c3e2bf2a22 100644 --- a/Localization/Resources/ru-RU/winget.resw +++ b/Localization/Resources/ru-RU/winget.resw @@ -3130,4 +3130,13 @@ Не удалось получить Microsoft Store пакета. Учетная Microsoft Entra идентификатора учетной записи не имеет необходимых привилегий. + + Параметр нельзя передать через границу целостности. + + + Скачан установщик нулевого байта. Убедитесь, что ваше сетевое подключение работает правильно. + + + Скачан установщик нулевого байта. Убедитесь, что ваше сетевое подключение работает правильно. + \ No newline at end of file diff --git a/Localization/Resources/zh-CN/winget.resw b/Localization/Resources/zh-CN/winget.resw index ab055b7d0a..a217673231 100644 --- a/Localization/Resources/zh-CN/winget.resw +++ b/Localization/Resources/zh-CN/winget.resw @@ -3130,4 +3130,13 @@ 无法检索Microsoft Store包许可证。Microsoft Entra ID 帐户没有所需的权限。 + + 无法跨完整性边界传递参数。 + + + 已下载零字节安装程序;请确保网络连接正常工作。 + + + 已下载零字节安装程序;请确保网络连接正常工作。 + \ No newline at end of file diff --git a/Localization/Resources/zh-TW/winget.resw b/Localization/Resources/zh-TW/winget.resw index 024479ce56..fa1001888d 100644 --- a/Localization/Resources/zh-TW/winget.resw +++ b/Localization/Resources/zh-TW/winget.resw @@ -3130,4 +3130,13 @@ 無法擷取Microsoft Store套件授權。Microsoft Entra識別子帳戶沒有所需的許可權。 + + 參數無法通過完整性邊界。 + + + 已下載零位元組安裝程式;請確認您的網路連線正常運作。 + + + 已下載零位元組安裝程式;請確認您的網路連線正常運作。 + \ No newline at end of file diff --git a/src/AppInstallerCLICore/Resources.h b/src/AppInstallerCLICore/Resources.h index fec47f6f7b..2a827a2b18 100644 --- a/src/AppInstallerCLICore/Resources.h +++ b/src/AppInstallerCLICore/Resources.h @@ -259,6 +259,7 @@ namespace AppInstaller::CLI::Resource WINGET_DEFINE_RESOURCE_STRINGID(FontListCommandShortDescription); WINGET_DEFINE_RESOURCE_STRINGID(FontsInstallLocationUser); WINGET_DEFINE_RESOURCE_STRINGID(FontsInstallLocationMachine); + WINGET_DEFINE_RESOURCE_STRINGID(FontVersion); WINGET_DEFINE_RESOURCE_STRINGID(ForceArgumentDescription); WINGET_DEFINE_RESOURCE_STRINGID(GatedVersionArgumentDescription); WINGET_DEFINE_RESOURCE_STRINGID(GetManifestResultVersionNotFound); diff --git a/src/AppInstallerCLICore/Workflows/FontFlow.cpp b/src/AppInstallerCLICore/Workflows/FontFlow.cpp index 00b7e08a38..55e129f909 100644 --- a/src/AppInstallerCLICore/Workflows/FontFlow.cpp +++ b/src/AppInstallerCLICore/Workflows/FontFlow.cpp @@ -23,10 +23,11 @@ namespace AppInstaller::CLI::Workflow struct InstalledFontFacesTableLine { - InstalledFontFacesTableLine(Utility::LocIndString faceName, Utility::LocIndString familyName, std::filesystem::path filePath) - : FaceName(faceName), FamilyName(familyName), FilePath(filePath) {} + InstalledFontFacesTableLine(Utility::LocIndString faceName, Utility::LocIndString faceVersion, Utility::LocIndString familyName, std::filesystem::path filePath) + : FaceName(faceName), FaceVersion(faceVersion), FamilyName(familyName), FilePath(filePath) {} Utility::LocIndString FaceName; + Utility::LocIndString FaceVersion; Utility::LocIndString FamilyName; std::filesystem::path FilePath; }; @@ -45,7 +46,7 @@ namespace AppInstaller::CLI::Workflow void OutputInstalledFontFacesTable(Execution::Context& context, const std::vector& lines) { - Execution::TableOutput<3> table(context.Reporter, { Resource::String::FontFace, Resource::String::FontFamily, Resource::String::FontFilePaths }); + Execution::TableOutput<4> table(context.Reporter, { Resource::String::FontFace, Resource::String::FontVersion, Resource::String::FontFamily, Resource::String::FontFilePaths }); bool anonymizePath = Settings::User().Get(); @@ -56,7 +57,7 @@ namespace AppInstaller::CLI::Workflow AppInstaller::Runtime::ReplaceProfilePathsWithEnvironmentVariable(line.FilePath); } - table.OutputLine({ line.FaceName, line.FamilyName, line.FilePath.u8string() }); + table.OutputLine({ line.FaceName, line.FaceVersion, line.FamilyName, line.FilePath.u8string() }); } table.Complete(); @@ -89,6 +90,7 @@ namespace AppInstaller::CLI::Workflow { InstalledFontFacesTableLine line( Utility::LocIndString(Utility::ToLower(Utility::ConvertToUTF8(fontFace.Name))), + Utility::LocIndString(Utility::ConvertToUTF8(fontFace.Version)), familyName, filePath.u8string() ); @@ -97,7 +99,7 @@ namespace AppInstaller::CLI::Workflow } else { - InstalledFontFacesTableLine line({}, {}, filePath.u8string()); + InstalledFontFacesTableLine line({}, {}, {}, filePath.u8string()); lines.push_back(std::move(line)); } } diff --git a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw index a7f69d192e..c38d4f6558 100644 --- a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw +++ b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw @@ -3169,4 +3169,7 @@ Please specify one of them using the --source option to proceed. Fonts Install Location (Machine) + + Version + \ No newline at end of file diff --git a/src/AppInstallerCommonCore/Fonts.cpp b/src/AppInstallerCommonCore/Fonts.cpp index 0a9c1b2ea1..09e3034048 100644 --- a/src/AppInstallerCommonCore/Fonts.cpp +++ b/src/AppInstallerCommonCore/Fonts.cpp @@ -80,6 +80,35 @@ namespace AppInstaller::Fonts return GetLocalizedStringFromFont(familyNames); } + std::wstring GetFontFaceVersion(const wil::com_ptr& font) + { + wil::com_ptr fontVersion; + BOOL exists; + THROW_IF_FAILED(font->GetInformationalStrings(DWRITE_INFORMATIONAL_STRING_VERSION_STRINGS, fontVersion.addressof(), &exists)); + if (!exists) + { + return {}; + } + + std::string value = Utility::ConvertToUTF8(GetLocalizedStringFromFont(fontVersion)); + + // Version is returned in the format of 'Version 2.137 ;2017' + // Extract out the parts between 'Version' and ';' + if (Utility::CaseInsensitiveContainsSubstring(value, "Version")) + { + Utility::FindAndReplace(value, "Version", ""); + } + + if (Utility::CaseInsensitiveContainsSubstring(value, ";")) + { + Utility::FindAndReplace(value, ";", ""); + } + + Utility::Trim(value); + std::vector items = Utility::Split(value, ' ', true); + return Utility::ConvertToUTF16(items[0]); + } + wil::com_ptr CreateFontFamily(const wil::com_ptr& collection, UINT32 index) { wil::com_ptr family; @@ -164,6 +193,7 @@ namespace AppInstaller::Fonts FontFace fontFaceEntry; fontFaceEntry.Name = faceName; fontFaceEntry.FilePaths = GetFontFilePaths(fontFace); + fontFaceEntry.Version = GetFontFaceVersion(font); fontFaces.emplace_back(std::move(fontFaceEntry)); } diff --git a/src/AppInstallerCommonCore/Public/winget/Fonts.h b/src/AppInstallerCommonCore/Public/winget/Fonts.h index 1d86ef1efa..2432467540 100644 --- a/src/AppInstallerCommonCore/Public/winget/Fonts.h +++ b/src/AppInstallerCommonCore/Public/winget/Fonts.h @@ -10,14 +10,14 @@ namespace AppInstaller::Fonts { std::wstring Name; std::vector FilePaths; - - // TODO: Add support for font face versions. + std::wstring Version; }; struct FontFamily { std::wstring Name; std::vector Faces; + std::wstring Version; }; /// From d5cc4b64c02a1bf1979f8fcd3844c415240f68c0 Mon Sep 17 00:00:00 2001 From: --global Date: Wed, 23 Oct 2024 13:29:41 -0700 Subject: [PATCH 11/15] save work --- src/AppInstallerCLICore/Resources.h | 2 +- .../Workflows/FontFlow.cpp | 35 ++++++++++++------- .../Shared/Strings/en-us/winget.resw | 6 ++-- src/AppInstallerCommonCore/Fonts.cpp | 8 ++--- 4 files changed, 30 insertions(+), 21 deletions(-) diff --git a/src/AppInstallerCLICore/Resources.h b/src/AppInstallerCLICore/Resources.h index 2a827a2b18..f76001ac10 100644 --- a/src/AppInstallerCLICore/Resources.h +++ b/src/AppInstallerCLICore/Resources.h @@ -250,8 +250,8 @@ namespace AppInstaller::CLI::Resource WINGET_DEFINE_RESOURCE_STRINGID(FlagContainAdjoinedError); WINGET_DEFINE_RESOURCE_STRINGID(FontCommandLongDescription); WINGET_DEFINE_RESOURCE_STRINGID(FontCommandShortDescription); - WINGET_DEFINE_RESOURCE_STRINGID(FontFaceCount); WINGET_DEFINE_RESOURCE_STRINGID(FontFace); + WINGET_DEFINE_RESOURCE_STRINGID(FontFaces); WINGET_DEFINE_RESOURCE_STRINGID(FontFamily); WINGET_DEFINE_RESOURCE_STRINGID(FontFamilyNameArgumentDescription); WINGET_DEFINE_RESOURCE_STRINGID(FontFilePaths); diff --git a/src/AppInstallerCLICore/Workflows/FontFlow.cpp b/src/AppInstallerCLICore/Workflows/FontFlow.cpp index 55e129f909..b250291dac 100644 --- a/src/AppInstallerCLICore/Workflows/FontFlow.cpp +++ b/src/AppInstallerCLICore/Workflows/FontFlow.cpp @@ -23,22 +23,30 @@ namespace AppInstaller::CLI::Workflow struct InstalledFontFacesTableLine { - InstalledFontFacesTableLine(Utility::LocIndString faceName, Utility::LocIndString faceVersion, Utility::LocIndString familyName, std::filesystem::path filePath) - : FaceName(faceName), FaceVersion(faceVersion), FamilyName(familyName), FilePath(filePath) {} + InstalledFontFacesTableLine(Utility::LocIndString familyName, Utility::LocIndString faceName, Utility::LocIndString faceVersion, std::filesystem::path filePath) + : FamilyName(familyName), FaceName(faceName), FaceVersion(faceVersion), FilePath(filePath) {} + Utility::LocIndString FamilyName; Utility::LocIndString FaceName; Utility::LocIndString FaceVersion; - Utility::LocIndString FamilyName; std::filesystem::path FilePath; }; void OutputInstalledFontFamiliesTable(Execution::Context& context, const std::vector& lines) { - Execution::TableOutput<2> table(context.Reporter, { Resource::String::FontFamily, Resource::String::FontFaceCount }); + Execution::TableOutput<4> table(context.Reporter, { Resource::String::FontFamily, Resource::String::FontFaces, Resource::String::FontFamily, Resource::String::FontFaces }); - for (const auto& line : lines) + for (size_t i = 0; i < lines.size(); i += 2) { - table.OutputLine({ line.FamilyName, std::to_string(line.FaceCount) }); + // Displays 2 font families per line for better readability. + if ((i + 1) < lines.size()) + { + table.OutputLine({ lines[i].FamilyName, std::to_string(lines[i].FaceCount), lines[i+1].FamilyName, std::to_string(lines[i+1].FaceCount) }); + } + else + { + table.OutputLine({ lines[i].FamilyName, std::to_string(lines[i].FaceCount), {}, {} }); + } } table.Complete(); @@ -46,7 +54,7 @@ namespace AppInstaller::CLI::Workflow void OutputInstalledFontFacesTable(Execution::Context& context, const std::vector& lines) { - Execution::TableOutput<4> table(context.Reporter, { Resource::String::FontFace, Resource::String::FontVersion, Resource::String::FontFamily, Resource::String::FontFilePaths }); + Execution::TableOutput<4> table(context.Reporter, { Resource::String::FontFamily, Resource::String::FontFace, Resource::String::FontVersion, Resource::String::FontFilePaths }); bool anonymizePath = Settings::User().Get(); @@ -57,7 +65,7 @@ namespace AppInstaller::CLI::Workflow AppInstaller::Runtime::ReplaceProfilePathsWithEnvironmentVariable(line.FilePath); } - table.OutputLine({ line.FaceName, line.FaceVersion, line.FamilyName, line.FilePath.u8string() }); + table.OutputLine({ line.FamilyName, line.FaceName, line.FaceVersion, line.FilePath.u8string() }); } table.Complete(); @@ -68,7 +76,7 @@ namespace AppInstaller::CLI::Workflow { if (context.Args.Contains(Args::Type::Family)) { - // TODO: Utilize font index for better searching capability. + // TODO: Create custom source and search mechanism for fonts. const auto& familyNameArg = context.Args.GetArg(Args::Type::Family); const auto& fontFamily = AppInstaller::Fonts::GetInstalledFontFamily(AppInstaller::Utility::ConvertToUTF16(familyNameArg)); @@ -89,16 +97,17 @@ namespace AppInstaller::CLI::Workflow if (isFirstLine) { InstalledFontFacesTableLine line( + familyName, Utility::LocIndString(Utility::ToLower(Utility::ConvertToUTF8(fontFace.Name))), Utility::LocIndString(Utility::ConvertToUTF8(fontFace.Version)), - familyName, - filePath.u8string() - ); - isFirstLine = false; + filePath.u8string()); + lines.push_back(std::move(line)); + isFirstLine = false; } else { + // Creates a separate row for faces supported by multiple files. InstalledFontFacesTableLine line({}, {}, {}, filePath.u8string()); lines.push_back(std::move(line)); } diff --git a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw index c38d4f6558..6a18482f6f 100644 --- a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw +++ b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw @@ -3142,14 +3142,16 @@ Please specify one of them using the --source option to proceed. Family - - Face Count + + Faces + "Faces" represents the typeface of the font family such as 'Bold' or 'Italic' Filter results by family name Face + "Face" represents the typeface of a font family such as 'Bold' or 'Italic' Paths diff --git a/src/AppInstallerCommonCore/Fonts.cpp b/src/AppInstallerCommonCore/Fonts.cpp index 09e3034048..3f6ffe5689 100644 --- a/src/AppInstallerCommonCore/Fonts.cpp +++ b/src/AppInstallerCommonCore/Fonts.cpp @@ -51,7 +51,7 @@ namespace AppInstaller::Fonts UINT32 index; BOOL exists; - // TODO: Aggregrate available locales and find best alternative locale if preferred locale does not exist. + // TODO: Aggregate available locales and find best alternative locale if preferred locale does not exist. if (FAILED(localizedStringCollection->FindLocaleName(preferredLocale.c_str(), &index, &exists)) || !exists) { index = 0; @@ -92,7 +92,7 @@ namespace AppInstaller::Fonts std::string value = Utility::ConvertToUTF8(GetLocalizedStringFromFont(fontVersion)); - // Version is returned in the format of 'Version 2.137 ;2017' + // Version is returned in the format of ex: 'Version 2.137 ;2017' // Extract out the parts between 'Version' and ';' if (Utility::CaseInsensitiveContainsSubstring(value, "Version")) { @@ -140,13 +140,11 @@ namespace AppInstaller::Fonts wil::com_ptr font; THROW_IF_FAILED(family->GetFont(fontIndex, font.addressof())); - std::wstring faceName = GetFontFaceName(font); - wil::com_ptr fontFace; THROW_IF_FAILED(font->CreateFontFace(fontFace.addressof())); FontFace fontFaceEntry; - fontFaceEntry.Name = faceName; + fontFaceEntry.Name = GetFontFaceName(font); fontFaceEntry.FilePaths = GetFontFilePaths(fontFace); fontFaces.emplace_back(std::move(fontFaceEntry)); } From 0bb6228d8cc789400ab82e6c0c0f4172ca96eedb Mon Sep 17 00:00:00 2001 From: --global Date: Wed, 23 Oct 2024 14:31:46 -0700 Subject: [PATCH 12/15] minor fix --- .../Workflows/FontFlow.cpp | 25 ++++++------------- 1 file changed, 7 insertions(+), 18 deletions(-) diff --git a/src/AppInstallerCLICore/Workflows/FontFlow.cpp b/src/AppInstallerCLICore/Workflows/FontFlow.cpp index b250291dac..13b1e07d97 100644 --- a/src/AppInstallerCLICore/Workflows/FontFlow.cpp +++ b/src/AppInstallerCLICore/Workflows/FontFlow.cpp @@ -91,26 +91,15 @@ namespace AppInstaller::CLI::Workflow for (const auto& fontFace : fontFamily->Faces) { - bool isFirstLine = true; for (const auto& filePath : fontFace.FilePaths) { - if (isFirstLine) - { - InstalledFontFacesTableLine line( - familyName, - Utility::LocIndString(Utility::ToLower(Utility::ConvertToUTF8(fontFace.Name))), - Utility::LocIndString(Utility::ConvertToUTF8(fontFace.Version)), - filePath.u8string()); - - lines.push_back(std::move(line)); - isFirstLine = false; - } - else - { - // Creates a separate row for faces supported by multiple files. - InstalledFontFacesTableLine line({}, {}, {}, filePath.u8string()); - lines.push_back(std::move(line)); - } + InstalledFontFacesTableLine line( + familyName, + Utility::LocIndString(Utility::ToLower(Utility::ConvertToUTF8(fontFace.Name))), + Utility::LocIndString(Utility::ConvertToUTF8(fontFace.Version)), + filePath.u8string()); + + lines.push_back(std::move(line)); } } From 3808a10f00a78cf59e072b4d7f050eab58158a73 Mon Sep 17 00:00:00 2001 From: --global Date: Wed, 23 Oct 2024 15:25:00 -0700 Subject: [PATCH 13/15] refactor Get installed fonts code --- .../Workflows/FontFlow.cpp | 30 ++++---- src/AppInstallerCLITests/Fonts.cpp | 17 ++--- src/AppInstallerCommonCore/Fonts.cpp | 72 ++++++------------- .../Public/winget/Fonts.h | 11 +-- 4 files changed, 51 insertions(+), 79 deletions(-) diff --git a/src/AppInstallerCLICore/Workflows/FontFlow.cpp b/src/AppInstallerCLICore/Workflows/FontFlow.cpp index 13b1e07d97..697a14ba1d 100644 --- a/src/AppInstallerCLICore/Workflows/FontFlow.cpp +++ b/src/AppInstallerCLICore/Workflows/FontFlow.cpp @@ -77,29 +77,33 @@ namespace AppInstaller::CLI::Workflow if (context.Args.Contains(Args::Type::Family)) { // TODO: Create custom source and search mechanism for fonts. - const auto& familyNameArg = context.Args.GetArg(Args::Type::Family); - const auto& fontFamily = AppInstaller::Fonts::GetInstalledFontFamily(AppInstaller::Utility::ConvertToUTF16(familyNameArg)); + const auto& familyNameArg = AppInstaller::Utility::ConvertToUTF16(context.Args.GetArg(Args::Type::Family)); + const auto& fontFamilies = AppInstaller::Fonts::GetInstalledFontFamilies(familyNameArg); - if (!fontFamily.has_value()) + if (fontFamilies.empty()) { context.Reporter.Info() << Resource::String::NoInstalledFontFound << std::endl; return; } - const auto& familyName = Utility::LocIndString(Utility::ConvertToUTF8(fontFamily->Name)); std::vector lines; - for (const auto& fontFace : fontFamily->Faces) + for (const auto& fontFamily : fontFamilies) { - for (const auto& filePath : fontFace.FilePaths) - { - InstalledFontFacesTableLine line( - familyName, - Utility::LocIndString(Utility::ToLower(Utility::ConvertToUTF8(fontFace.Name))), - Utility::LocIndString(Utility::ConvertToUTF8(fontFace.Version)), - filePath.u8string()); + const auto& familyName = Utility::LocIndString(Utility::ConvertToUTF8(fontFamily.Name)); - lines.push_back(std::move(line)); + for (const auto& fontFace : fontFamily.Faces) + { + for (const auto& filePath : fontFace.FilePaths) + { + InstalledFontFacesTableLine line( + familyName, + Utility::LocIndString(Utility::ToLower(Utility::ConvertToUTF8(fontFace.Name))), + Utility::LocIndString(Utility::ConvertToUTF8(fontFace.Version)), + filePath.u8string()); + + lines.push_back(std::move(line)); + } } } diff --git a/src/AppInstallerCLITests/Fonts.cpp b/src/AppInstallerCLITests/Fonts.cpp index 29fbbd4ca9..ecacd03717 100644 --- a/src/AppInstallerCLITests/Fonts.cpp +++ b/src/AppInstallerCLITests/Fonts.cpp @@ -18,16 +18,17 @@ TEST_CASE("GetInstalledFonts", "[fonts]") TEST_CASE("GetSingleFontFamily", "[fonts]") { - std::optional fontFamily; - REQUIRE_NOTHROW(fontFamily = GetInstalledFontFamily(std::wstring(s_testFontName))); - REQUIRE(fontFamily.has_value()); - REQUIRE(AppInstaller::Utility::CaseInsensitiveEquals(fontFamily->Name, s_testFontName)); - REQUIRE(fontFamily->Faces.size() > 0); + std::vector fontFamily; + REQUIRE_NOTHROW(fontFamily = GetInstalledFontFamilies(std::wstring(s_testFontName))); + REQUIRE_FALSE(fontFamily.empty()); + FontFamily singleFontFamily = fontFamily[0]; + REQUIRE(AppInstaller::Utility::CaseInsensitiveEquals(singleFontFamily.Name, s_testFontName)); + REQUIRE(singleFontFamily.Faces.size() > 0); } TEST_CASE("GetInvalidFontFamily", "[fonts]") { - std::optional fontFamily; - REQUIRE_NOTHROW(fontFamily = GetInstalledFontFamily(L"Invalid Font")); - REQUIRE_FALSE(fontFamily.has_value()); + std::vector fontFamily; + REQUIRE_NOTHROW(fontFamily = GetInstalledFontFamilies(L"Invalid Font")); + REQUIRE(fontFamily.empty()); } diff --git a/src/AppInstallerCommonCore/Fonts.cpp b/src/AppInstallerCommonCore/Fonts.cpp index 3f6ffe5689..6a74913dd8 100644 --- a/src/AppInstallerCommonCore/Fonts.cpp +++ b/src/AppInstallerCommonCore/Fonts.cpp @@ -109,28 +109,10 @@ namespace AppInstaller::Fonts return Utility::ConvertToUTF16(items[0]); } - wil::com_ptr CreateFontFamily(const wil::com_ptr& collection, UINT32 index) + FontFamily GetFontFamilyByIndex(const wil::com_ptr& collection, UINT32 index) { wil::com_ptr family; THROW_IF_FAILED(collection->GetFontFamily(index, family.addressof())); - return family; - } - } - - std::vector GetInstalledFontFamilies() - { - wil::com_ptr factory; - THROW_IF_FAILED(DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(factory), factory.put_unknown())); - - wil::com_ptr collection; - THROW_IF_FAILED(factory->GetSystemFontCollection(collection.addressof(), FALSE)); - - UINT32 familyCount = collection->GetFontFamilyCount(); - - std::vector fontFamilies; - for (UINT32 index = 0; index < familyCount; index++) - { - wil::com_ptr family = CreateFontFamily(collection, index); std::wstring familyName = GetFontFamilyName(family); std::vector fontFaces; @@ -145,6 +127,7 @@ namespace AppInstaller::Fonts FontFace fontFaceEntry; fontFaceEntry.Name = GetFontFaceName(font); + fontFaceEntry.Version = GetFontFaceVersion(font); fontFaceEntry.FilePaths = GetFontFilePaths(fontFace); fontFaces.emplace_back(std::move(fontFaceEntry)); } @@ -152,13 +135,11 @@ namespace AppInstaller::Fonts FontFamily fontFamily; fontFamily.Name = std::move(familyName); fontFamily.Faces = std::move(fontFaces); - fontFamilies.emplace_back(std::move(fontFamily)); + return fontFamily; } - - return fontFamilies; } - std::optional GetInstalledFontFamily(const std::wstring& familyName) + std::vector GetInstalledFontFamilies(std::optional familyName) { wil::com_ptr factory; THROW_IF_FAILED(DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(factory), factory.put_unknown())); @@ -166,38 +147,31 @@ namespace AppInstaller::Fonts wil::com_ptr collection; THROW_IF_FAILED(factory->GetSystemFontCollection(collection.addressof(), FALSE)); - UINT32 index; - BOOL exists; - THROW_IF_FAILED(collection->FindFamilyName(familyName.c_str(), &index, &exists)); + std::vector installedFontFamilies; - if (!exists) + if (familyName.has_value()) { - return {}; - } + UINT32 index; + BOOL exists; + THROW_IF_FAILED(collection->FindFamilyName(familyName.value().c_str(), &index, &exists)); - wil::com_ptr family = CreateFontFamily(collection, index); - UINT32 fontCount = family->GetFontCount(); + if (!exists) + { + return {}; + } - std::vector fontFaces; - for (UINT32 fontIndex = 0; fontIndex < fontCount; fontIndex++) + installedFontFamilies.emplace_back(GetFontFamilyByIndex(collection, index)); + } + else { - wil::com_ptr font; - THROW_IF_FAILED(family->GetFont(fontIndex, font.addressof())); - std::wstring faceName = GetFontFaceName(font); - - wil::com_ptr fontFace; - THROW_IF_FAILED(font->CreateFontFace(fontFace.addressof())); - - FontFace fontFaceEntry; - fontFaceEntry.Name = faceName; - fontFaceEntry.FilePaths = GetFontFilePaths(fontFace); - fontFaceEntry.Version = GetFontFaceVersion(font); - fontFaces.emplace_back(std::move(fontFaceEntry)); + UINT32 familyCount = collection->GetFontFamilyCount(); + + for (UINT32 index = 0; index < familyCount; index++) + { + installedFontFamilies.emplace_back(GetFontFamilyByIndex(collection, index)); + } } - FontFamily fontFamily; - fontFamily.Name = GetFontFamilyName(family); - fontFamily.Faces = std::move(fontFaces); - return fontFamily; + return installedFontFamilies; } } diff --git a/src/AppInstallerCommonCore/Public/winget/Fonts.h b/src/AppInstallerCommonCore/Public/winget/Fonts.h index 2432467540..71baf940b9 100644 --- a/src/AppInstallerCommonCore/Public/winget/Fonts.h +++ b/src/AppInstallerCommonCore/Public/winget/Fonts.h @@ -21,15 +21,8 @@ namespace AppInstaller::Fonts }; /// - /// Gets all installed font families on the system. + /// Gets all installed font families on the system. If an exact family name is provided and found, returns the installed font family. /// /// A list of installed font families. - std::vector GetInstalledFontFamilies(); - - /// - /// Gets the installed font family from the provided family name. - /// - /// The font family name. - /// The specified font family if found. - std::optional GetInstalledFontFamily(const std::wstring& familyName); + std::vector GetInstalledFontFamilies(std::optional familyName = {}); } From b1389bb30c0cf6fec8f9848bfb4be00e97a92414 Mon Sep 17 00:00:00 2001 From: --global Date: Fri, 25 Oct 2024 10:52:04 -0700 Subject: [PATCH 14/15] fix open type version --- .../Commands/RootCommand.cpp | 7 --- src/AppInstallerCLICore/Resources.h | 2 - .../Workflows/FontFlow.cpp | 16 ++--- .../Shared/Strings/en-us/winget.resw | 9 +-- src/AppInstallerCLITests/Versions.cpp | 27 ++++++++ src/AppInstallerCommonCore/Fonts.cpp | 62 +++++++++---------- src/AppInstallerCommonCore/Locale.cpp | 12 ++++ .../Public/winget/Fonts.h | 4 +- .../Public/winget/Locale.h | 5 +- .../Public/AppInstallerVersions.h | 16 +++++ src/AppInstallerSharedLib/Versions.cpp | 60 ++++++++++++++++++ 11 files changed, 157 insertions(+), 63 deletions(-) diff --git a/src/AppInstallerCLICore/Commands/RootCommand.cpp b/src/AppInstallerCLICore/Commands/RootCommand.cpp index eee5a33a16..5580efa14a 100644 --- a/src/AppInstallerCLICore/Commands/RootCommand.cpp +++ b/src/AppInstallerCLICore/Commands/RootCommand.cpp @@ -154,13 +154,6 @@ namespace AppInstaller::CLI keyDirectories.OutputLine({ Resource::LocString{ Resource::String::PortableRoot }, Runtime::GetPathTo(Runtime::PathName::PortablePackageMachineRoot, true).u8string() }); keyDirectories.OutputLine({ Resource::LocString{ Resource::String::PortableRoot86 }, Runtime::GetPathTo(Runtime::PathName::PortablePackageMachineRootX86, true).u8string() }); keyDirectories.OutputLine({ Resource::LocString{ Resource::String::InstallerDownloads }, Runtime::GetPathTo(Runtime::PathName::UserProfileDownloads, true).u8string() }); - - if (Settings::ExperimentalFeature::IsEnabled(Settings::ExperimentalFeature::Feature::Font)) - { - keyDirectories.OutputLine({ Resource::LocString{ Resource::String::FontsInstallLocationUser }, Runtime::GetPathTo(Runtime::PathName::FontsUserInstallLocation, true).u8string() }); - keyDirectories.OutputLine({ Resource::LocString{ Resource::String::FontsInstallLocationMachine }, Runtime::GetPathTo(Runtime::PathName::FontsMachineInstallLocation, true).u8string() }); - } - keyDirectories.Complete(); context.Reporter.Info() << std::endl; } diff --git a/src/AppInstallerCLICore/Resources.h b/src/AppInstallerCLICore/Resources.h index f76001ac10..5aa7616509 100644 --- a/src/AppInstallerCLICore/Resources.h +++ b/src/AppInstallerCLICore/Resources.h @@ -257,8 +257,6 @@ namespace AppInstaller::CLI::Resource WINGET_DEFINE_RESOURCE_STRINGID(FontFilePaths); WINGET_DEFINE_RESOURCE_STRINGID(FontListCommandLongDescription); WINGET_DEFINE_RESOURCE_STRINGID(FontListCommandShortDescription); - WINGET_DEFINE_RESOURCE_STRINGID(FontsInstallLocationUser); - WINGET_DEFINE_RESOURCE_STRINGID(FontsInstallLocationMachine); WINGET_DEFINE_RESOURCE_STRINGID(FontVersion); WINGET_DEFINE_RESOURCE_STRINGID(ForceArgumentDescription); WINGET_DEFINE_RESOURCE_STRINGID(GatedVersionArgumentDescription); diff --git a/src/AppInstallerCLICore/Workflows/FontFlow.cpp b/src/AppInstallerCLICore/Workflows/FontFlow.cpp index 697a14ba1d..c414c0fbe0 100644 --- a/src/AppInstallerCLICore/Workflows/FontFlow.cpp +++ b/src/AppInstallerCLICore/Workflows/FontFlow.cpp @@ -34,19 +34,11 @@ namespace AppInstaller::CLI::Workflow void OutputInstalledFontFamiliesTable(Execution::Context& context, const std::vector& lines) { - Execution::TableOutput<4> table(context.Reporter, { Resource::String::FontFamily, Resource::String::FontFaces, Resource::String::FontFamily, Resource::String::FontFaces }); + Execution::TableOutput<2> table(context.Reporter, { Resource::String::FontFamily, Resource::String::FontFaces }); - for (size_t i = 0; i < lines.size(); i += 2) + for (auto line : lines) { - // Displays 2 font families per line for better readability. - if ((i + 1) < lines.size()) - { - table.OutputLine({ lines[i].FamilyName, std::to_string(lines[i].FaceCount), lines[i+1].FamilyName, std::to_string(lines[i+1].FaceCount) }); - } - else - { - table.OutputLine({ lines[i].FamilyName, std::to_string(lines[i].FaceCount), {}, {} }); - } + table.OutputLine({ line.FamilyName, std::to_string(line.FaceCount) }); } table.Complete(); @@ -99,7 +91,7 @@ namespace AppInstaller::CLI::Workflow InstalledFontFacesTableLine line( familyName, Utility::LocIndString(Utility::ToLower(Utility::ConvertToUTF8(fontFace.Name))), - Utility::LocIndString(Utility::ConvertToUTF8(fontFace.Version)), + Utility::LocIndString(fontFace.Version.ToString()), filePath.u8string()); lines.push_back(std::move(line)); diff --git a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw index 6a18482f6f..cd1ffc7d9d 100644 --- a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw +++ b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw @@ -3133,6 +3133,9 @@ Please specify one of them using the --source option to proceed. Parameter cannot be passed across integrity boundary. + + Downloaded zero byte installer; ensure that your network connection is working properly. + Manage fonts @@ -3165,12 +3168,6 @@ Please specify one of them using the --source option to proceed. List all installed fonts, or full details of a specific font. - - Fonts Install Location (User) - - - Fonts Install Location (Machine) - Version diff --git a/src/AppInstallerCLITests/Versions.cpp b/src/AppInstallerCLITests/Versions.cpp index 0988d58074..54975eda49 100644 --- a/src/AppInstallerCLITests/Versions.cpp +++ b/src/AppInstallerCLITests/Versions.cpp @@ -421,3 +421,30 @@ TEST_CASE("SemanticVersion", "[versions]") REQUIRE(version.BuildMetadata() == Version("4.5.6")); REQUIRE(version.PartAt(2).Other == "-beta+4.5.6"); } + +TEST_CASE("OpenTypeFontVersion", "[versions]") +{ + // Valid font version. + OpenTypeFontVersion version = OpenTypeFontVersion("Version 1.234"); + REQUIRE(version.ToString() == "1.234"); + REQUIRE(version.GetParts().size() == 2); + REQUIRE(version.PartAt(0).Integer == 1); + REQUIRE(version.PartAt(1).Integer == 234); + + // Font version with additional metadata. + version = OpenTypeFontVersion("Version 9.876.54 ;2024"); + REQUIRE(version.ToString() == "9.876"); + REQUIRE(version.GetParts().size() == 2); + REQUIRE(version.PartAt(0).Integer == 9); + REQUIRE(version.PartAt(1).Integer == 876); + + // Invalid version. Font version must have at least 2 parts. + REQUIRE_NOTHROW(version = OpenTypeFontVersion("1234567")); + REQUIRE(version.IsUnknown()); + REQUIRE(version.ToString() == "Unknown"); + + // Major and minor parts must have digits. + REQUIRE_NOTHROW(version = OpenTypeFontVersion(" abc.def ")); + REQUIRE(version.IsUnknown()); + REQUIRE(version.ToString() == "Unknown"); +} diff --git a/src/AppInstallerCommonCore/Fonts.cpp b/src/AppInstallerCommonCore/Fonts.cpp index 6a74913dd8..d72caed9a0 100644 --- a/src/AppInstallerCommonCore/Fonts.cpp +++ b/src/AppInstallerCommonCore/Fonts.cpp @@ -10,6 +10,8 @@ namespace AppInstaller::Fonts { namespace { + std::vector preferredLocales = AppInstaller::Locale::GetUserPreferredLanguagesUTF16(); + std::vector GetFontFilePaths(const wil::com_ptr& fontFace) { UINT32 fileCount = 0; @@ -35,9 +37,11 @@ namespace AppInstaller::Fonts THROW_IF_FAILED(localLoader->GetFilePathLengthFromKey(fontFileReferenceKey, fontFileReferenceKeySize, &pathLength)); pathLength += 1; // Account for the trailing null terminator during allocation. - wchar_t* path = new wchar_t[pathLength]; + std::wstring path; + path.resize(pathLength); THROW_IF_FAILED(localLoader->GetFilePathFromKey(fontFileReferenceKey, fontFileReferenceKeySize, &path[0], pathLength)); - filePaths.push_back(std::move(std::wstring(path))); + path.resize(pathLength - 1); // Remove the null char. + filePaths.emplace_back(std::move(path)); } } @@ -46,13 +50,19 @@ namespace AppInstaller::Fonts std::wstring GetLocalizedStringFromFont(const wil::com_ptr& localizedStringCollection) { - std::vector locales = AppInstaller::Locale::GetUserPreferredLanguages(); - std::wstring preferredLocale = Utility::ConvertToUTF16(!locales.empty() ? locales[0] : "en-US"); + UINT32 index = 0; + BOOL exists = false; - UINT32 index; - BOOL exists; - // TODO: Aggregate available locales and find best alternative locale if preferred locale does not exist. - if (FAILED(localizedStringCollection->FindLocaleName(preferredLocale.c_str(), &index, &exists)) || !exists) + for (const auto& locale : preferredLocales) + { + if (FAILED(localizedStringCollection->FindLocaleName(locale.c_str(), &index, &exists)) || exists) + { + break; + } + } + + // If the locale does not exist, resort to the default value at the 0 index. + if (!exists) { index = 0; } @@ -61,9 +71,11 @@ namespace AppInstaller::Fonts THROW_IF_FAILED(localizedStringCollection->GetStringLength(index, &length)); length += 1; // Account for the trailing null terminator during allocation. - wchar_t* localizedString = new wchar_t[length]; - THROW_IF_FAILED(localizedStringCollection->GetString(index, localizedString, length)); - return std::wstring(localizedString); + std::wstring localizedString; + localizedString.resize(length); + THROW_IF_FAILED(localizedStringCollection->GetString(index, &localizedString[0], length)); + localizedString.resize(length - 1); // Remove the null char. + return localizedString; } std::wstring GetFontFaceName(const wil::com_ptr& font) @@ -80,7 +92,7 @@ namespace AppInstaller::Fonts return GetLocalizedStringFromFont(familyNames); } - std::wstring GetFontFaceVersion(const wil::com_ptr& font) + Utility::OpenTypeFontVersion GetFontFaceVersion(const wil::com_ptr& font) { wil::com_ptr fontVersion; BOOL exists; @@ -90,23 +102,9 @@ namespace AppInstaller::Fonts return {}; } - std::string value = Utility::ConvertToUTF8(GetLocalizedStringFromFont(fontVersion)); - - // Version is returned in the format of ex: 'Version 2.137 ;2017' - // Extract out the parts between 'Version' and ';' - if (Utility::CaseInsensitiveContainsSubstring(value, "Version")) - { - Utility::FindAndReplace(value, "Version", ""); - } - - if (Utility::CaseInsensitiveContainsSubstring(value, ";")) - { - Utility::FindAndReplace(value, ";", ""); - } - - Utility::Trim(value); - std::vector items = Utility::Split(value, ' ', true); - return Utility::ConvertToUTF16(items[0]); + std::string value = AppInstaller::Utility::ConvertToUTF8(GetLocalizedStringFromFont(fontVersion)); + Utility::OpenTypeFontVersion openTypeFontVersion { value }; + return openTypeFontVersion; } FontFamily GetFontFamilyByIndex(const wil::com_ptr& collection, UINT32 index) @@ -155,12 +153,10 @@ namespace AppInstaller::Fonts BOOL exists; THROW_IF_FAILED(collection->FindFamilyName(familyName.value().c_str(), &index, &exists)); - if (!exists) + if (exists) { - return {}; + installedFontFamilies.emplace_back(GetFontFamilyByIndex(collection, index)); } - - installedFontFamilies.emplace_back(GetFontFamilyByIndex(collection, index)); } else { diff --git a/src/AppInstallerCommonCore/Locale.cpp b/src/AppInstallerCommonCore/Locale.cpp index c308584226..ae8985910c 100644 --- a/src/AppInstallerCommonCore/Locale.cpp +++ b/src/AppInstallerCommonCore/Locale.cpp @@ -120,6 +120,18 @@ namespace AppInstaller::Locale return result; } + std::vector GetUserPreferredLanguagesUTF16() + { + std::vector result; + + for (const auto& lang : winrt::Windows::System::UserProfile::GlobalizationPreferences::Languages()) + { + result.emplace_back(std::wstring(lang)); + } + + return result; + } + std::string LocaleIdToBcp47Tag(LCID localeId) { WCHAR localeName[MAX_LOCALE_SNAME_LEN] = {0}; diff --git a/src/AppInstallerCommonCore/Public/winget/Fonts.h b/src/AppInstallerCommonCore/Public/winget/Fonts.h index 71baf940b9..c4dfa25e5f 100644 --- a/src/AppInstallerCommonCore/Public/winget/Fonts.h +++ b/src/AppInstallerCommonCore/Public/winget/Fonts.h @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. #pragma once +#include #include #include @@ -10,14 +11,13 @@ namespace AppInstaller::Fonts { std::wstring Name; std::vector FilePaths; - std::wstring Version; + Utility::OpenTypeFontVersion Version; }; struct FontFamily { std::wstring Name; std::vector Faces; - std::wstring Version; }; /// diff --git a/src/AppInstallerCommonCore/Public/winget/Locale.h b/src/AppInstallerCommonCore/Public/winget/Locale.h index f4cd7a2d54..5ae86a8de4 100644 --- a/src/AppInstallerCommonCore/Public/winget/Locale.h +++ b/src/AppInstallerCommonCore/Public/winget/Locale.h @@ -20,6 +20,9 @@ namespace AppInstaller::Locale // Get the list of user Preferred Languages from settings. Returns an empty vector in rare cases of failure. std::vector GetUserPreferredLanguages(); + // Get the list of user Preferred Languages from settings. Returns an empty vector in rare cases of failure. + std::vector GetUserPreferredLanguagesUTF16(); + // Get the bcp47 tag from a locale id. Returns empty string if conversion cannot be performed. std::string LocaleIdToBcp47Tag(LCID localeId); -} \ No newline at end of file +} diff --git a/src/AppInstallerSharedLib/Public/AppInstallerVersions.h b/src/AppInstallerSharedLib/Public/AppInstallerVersions.h index 569a33aa32..9df7cab413 100644 --- a/src/AppInstallerSharedLib/Public/AppInstallerVersions.h +++ b/src/AppInstallerSharedLib/Public/AppInstallerVersions.h @@ -281,4 +281,20 @@ namespace AppInstaller::Utility // Checks if there are overlaps within the list of version ranges bool HasOverlapInVersionRanges(const std::vector& ranges); + + // The OpenType font version. + // The format of this version type is 'Version 1.234 ;567' + // The only part that is of importance is the 'Major.Minor' parts. + // The 'Version' string is typically found at the beginning of the version string. + // Any value after a digit that is not a '.' represents some other meaning. + struct OpenTypeFontVersion : Version + { + OpenTypeFontVersion() = default; + + OpenTypeFontVersion(std::string&& version); + OpenTypeFontVersion(const std::string& version) : + OpenTypeFontVersion(std::string(version)) {} + + void Assign(std::string version, std::string_view splitChars = DefaultSplitChars) override; + }; } diff --git a/src/AppInstallerSharedLib/Versions.cpp b/src/AppInstallerSharedLib/Versions.cpp index 6b02675d1d..2c9972c561 100644 --- a/src/AppInstallerSharedLib/Versions.cpp +++ b/src/AppInstallerSharedLib/Versions.cpp @@ -661,4 +661,64 @@ namespace AppInstaller::Utility return false; } + + OpenTypeFontVersion::OpenTypeFontVersion(std::string&& version) + { + Assign(std::move(version), DefaultSplitChars); + } + + void OpenTypeFontVersion::Assign(std::string version, std::string_view splitChars) + { + // Open type version requires using the default split character + THROW_HR_IF(E_INVALIDARG, splitChars != DefaultSplitChars); + + // Split on default split character. + std::vector parts = Split(version, '.', true); + + std::string majorString; + std::string minorString; + + // Font version must have a "major.minor" part. + if (parts.size() >= 2) + { + // Find first digit and trim all preceding characters. + std::string firstPart = parts[0]; + size_t majorStartIndex = firstPart.find_first_of(s_Digit_Characters); + + if (majorStartIndex != std::string::npos) + { + firstPart.erase(0, majorStartIndex); + } + + size_t majorEndIndex = firstPart.find_last_of(s_Digit_Characters); + majorString = firstPart.substr(0, majorEndIndex + 1); + + // Parse and verify minor part. + std::string secondPart = parts[1]; + size_t endPos = secondPart.find_first_not_of(s_Digit_Characters); + + // If a non-digit character exists, trim off the remainder. + if (endPos != std::string::npos) + { + secondPart.erase(endPos, secondPart.length()); + } + + minorString = secondPart; + } + + // Verify results. + if (!majorString.empty() && !minorString.empty()) + { + m_parts.emplace_back(majorString); + m_parts.emplace_back(minorString); + m_version = Utility::Join(DefaultSplitChars, { majorString, minorString }); + + Trim(); + } + else + { + m_version = s_Version_Part_Unknown; + m_parts.emplace_back(0, std::string{ s_Version_Part_Unknown }); + } + } } From 3eaf6a1628c2f79068a1fc0f17e80f716097c0ff Mon Sep 17 00:00:00 2001 From: --global Date: Sun, 27 Oct 2024 18:01:40 -0700 Subject: [PATCH 15/15] address comments --- .../Workflows/FontFlow.cpp | 6 +- .../Shared/Strings/en-us/winget.resw | 3 + src/AppInstallerCLITests/Fonts.cpp | 9 +- src/AppInstallerCommonCore/Fonts.cpp | 184 +++++++++--------- .../Public/winget/Fonts.h | 25 ++- 5 files changed, 124 insertions(+), 103 deletions(-) diff --git a/src/AppInstallerCLICore/Workflows/FontFlow.cpp b/src/AppInstallerCLICore/Workflows/FontFlow.cpp index c414c0fbe0..ce9bb7a233 100644 --- a/src/AppInstallerCLICore/Workflows/FontFlow.cpp +++ b/src/AppInstallerCLICore/Workflows/FontFlow.cpp @@ -66,11 +66,13 @@ namespace AppInstaller::CLI::Workflow void ReportInstalledFonts(Execution::Context& context) { + Fonts::FontCatalog fontCatalog; + if (context.Args.Contains(Args::Type::Family)) { // TODO: Create custom source and search mechanism for fonts. const auto& familyNameArg = AppInstaller::Utility::ConvertToUTF16(context.Args.GetArg(Args::Type::Family)); - const auto& fontFamilies = AppInstaller::Fonts::GetInstalledFontFamilies(familyNameArg); + const auto& fontFamilies = fontCatalog.GetInstalledFontFamilies(familyNameArg); if (fontFamilies.empty()) { @@ -103,7 +105,7 @@ namespace AppInstaller::CLI::Workflow } else { - const auto& fontFamilies = AppInstaller::Fonts::GetInstalledFontFamilies(); + const auto& fontFamilies = fontCatalog.GetInstalledFontFamilies(); std::vector lines; for (const auto& fontFamily : fontFamilies) diff --git a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw index cd1ffc7d9d..46d093b80c 100644 --- a/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw +++ b/src/AppInstallerCLIPackage/Shared/Strings/en-us/winget.resw @@ -3136,6 +3136,9 @@ Please specify one of them using the --source option to proceed. Downloaded zero byte installer; ensure that your network connection is working properly. + + Downloaded zero byte installer; ensure that your network connection is working properly. + Manage fonts diff --git a/src/AppInstallerCLITests/Fonts.cpp b/src/AppInstallerCLITests/Fonts.cpp index ecacd03717..81a50791e8 100644 --- a/src/AppInstallerCLITests/Fonts.cpp +++ b/src/AppInstallerCLITests/Fonts.cpp @@ -11,15 +11,17 @@ constexpr std::wstring_view s_testFontName = L"Times New Roman"; TEST_CASE("GetInstalledFonts", "[fonts]") { + FontCatalog fontCatalog; std::vector installedFontFamilies; - REQUIRE_NOTHROW(installedFontFamilies = GetInstalledFontFamilies()); + REQUIRE_NOTHROW(installedFontFamilies = fontCatalog.GetInstalledFontFamilies()); REQUIRE(installedFontFamilies.size() > 0); } TEST_CASE("GetSingleFontFamily", "[fonts]") { + FontCatalog fontCatalog; std::vector fontFamily; - REQUIRE_NOTHROW(fontFamily = GetInstalledFontFamilies(std::wstring(s_testFontName))); + REQUIRE_NOTHROW(fontFamily = fontCatalog.GetInstalledFontFamilies(std::wstring(s_testFontName))); REQUIRE_FALSE(fontFamily.empty()); FontFamily singleFontFamily = fontFamily[0]; REQUIRE(AppInstaller::Utility::CaseInsensitiveEquals(singleFontFamily.Name, s_testFontName)); @@ -28,7 +30,8 @@ TEST_CASE("GetSingleFontFamily", "[fonts]") TEST_CASE("GetInvalidFontFamily", "[fonts]") { + FontCatalog fontCatalog; std::vector fontFamily; - REQUIRE_NOTHROW(fontFamily = GetInstalledFontFamilies(L"Invalid Font")); + REQUIRE_NOTHROW(fontFamily = fontCatalog.GetInstalledFontFamilies(L"Invalid Font")); REQUIRE(fontFamily.empty()); } diff --git a/src/AppInstallerCommonCore/Fonts.cpp b/src/AppInstallerCommonCore/Fonts.cpp index d72caed9a0..6f5f328f93 100644 --- a/src/AppInstallerCommonCore/Fonts.cpp +++ b/src/AppInstallerCommonCore/Fonts.cpp @@ -1,7 +1,6 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT License. #include "pch.h" -#include #include #include #include @@ -10,8 +9,6 @@ namespace AppInstaller::Fonts { namespace { - std::vector preferredLocales = AppInstaller::Locale::GetUserPreferredLanguagesUTF16(); - std::vector GetFontFilePaths(const wil::com_ptr& fontFace) { UINT32 fileCount = 0; @@ -47,97 +44,14 @@ namespace AppInstaller::Fonts return filePaths; } + } - std::wstring GetLocalizedStringFromFont(const wil::com_ptr& localizedStringCollection) - { - UINT32 index = 0; - BOOL exists = false; - - for (const auto& locale : preferredLocales) - { - if (FAILED(localizedStringCollection->FindLocaleName(locale.c_str(), &index, &exists)) || exists) - { - break; - } - } - - // If the locale does not exist, resort to the default value at the 0 index. - if (!exists) - { - index = 0; - } - - UINT32 length = 0; - THROW_IF_FAILED(localizedStringCollection->GetStringLength(index, &length)); - length += 1; // Account for the trailing null terminator during allocation. - - std::wstring localizedString; - localizedString.resize(length); - THROW_IF_FAILED(localizedStringCollection->GetString(index, &localizedString[0], length)); - localizedString.resize(length - 1); // Remove the null char. - return localizedString; - } - - std::wstring GetFontFaceName(const wil::com_ptr& font) - { - wil::com_ptr faceNames; - THROW_IF_FAILED(font->GetFaceNames(faceNames.addressof())); - return GetLocalizedStringFromFont(faceNames); - } - - std::wstring GetFontFamilyName(const wil::com_ptr& fontFamily) - { - wil::com_ptr familyNames; - THROW_IF_FAILED(fontFamily->GetFamilyNames(familyNames.addressof())); - return GetLocalizedStringFromFont(familyNames); - } - - Utility::OpenTypeFontVersion GetFontFaceVersion(const wil::com_ptr& font) - { - wil::com_ptr fontVersion; - BOOL exists; - THROW_IF_FAILED(font->GetInformationalStrings(DWRITE_INFORMATIONAL_STRING_VERSION_STRINGS, fontVersion.addressof(), &exists)); - if (!exists) - { - return {}; - } - - std::string value = AppInstaller::Utility::ConvertToUTF8(GetLocalizedStringFromFont(fontVersion)); - Utility::OpenTypeFontVersion openTypeFontVersion { value }; - return openTypeFontVersion; - } - - FontFamily GetFontFamilyByIndex(const wil::com_ptr& collection, UINT32 index) - { - wil::com_ptr family; - THROW_IF_FAILED(collection->GetFontFamily(index, family.addressof())); - std::wstring familyName = GetFontFamilyName(family); - - std::vector fontFaces; - UINT32 fontCount = family->GetFontCount(); - for (UINT32 fontIndex = 0; fontIndex < fontCount; fontIndex++) - { - wil::com_ptr font; - THROW_IF_FAILED(family->GetFont(fontIndex, font.addressof())); - - wil::com_ptr fontFace; - THROW_IF_FAILED(font->CreateFontFace(fontFace.addressof())); - - FontFace fontFaceEntry; - fontFaceEntry.Name = GetFontFaceName(font); - fontFaceEntry.Version = GetFontFaceVersion(font); - fontFaceEntry.FilePaths = GetFontFilePaths(fontFace); - fontFaces.emplace_back(std::move(fontFaceEntry)); - } - - FontFamily fontFamily; - fontFamily.Name = std::move(familyName); - fontFamily.Faces = std::move(fontFaces); - return fontFamily; - } + FontCatalog::FontCatalog() + { + m_preferredLocales = AppInstaller::Locale::GetUserPreferredLanguagesUTF16(); } - std::vector GetInstalledFontFamilies(std::optional familyName) + std::vector FontCatalog::GetInstalledFontFamilies(std::optional familyName) { wil::com_ptr factory; THROW_IF_FAILED(DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(factory), factory.put_unknown())); @@ -170,4 +84,92 @@ namespace AppInstaller::Fonts return installedFontFamilies; } + + std::wstring FontCatalog::GetLocalizedStringFromFont(const wil::com_ptr& localizedStringCollection) + { + UINT32 index = 0; + BOOL exists = false; + + for (const auto& locale : m_preferredLocales) + { + if (SUCCEEDED_LOG(localizedStringCollection->FindLocaleName(locale.c_str(), &index, &exists)) && exists) + { + break; + } + } + + // If the locale does not exist, resort to the default value at the 0 index. + if (!exists) + { + index = 0; + } + + UINT32 length = 0; + THROW_IF_FAILED(localizedStringCollection->GetStringLength(index, &length)); + length += 1; // Account for the trailing null terminator during allocation. + + std::wstring localizedString; + localizedString.resize(length); + THROW_IF_FAILED(localizedStringCollection->GetString(index, &localizedString[0], length)); + localizedString.resize(length - 1); // Remove the null char. + return localizedString; + } + + std::wstring FontCatalog::GetFontFaceName(const wil::com_ptr& font) + { + wil::com_ptr faceNames; + THROW_IF_FAILED(font->GetFaceNames(faceNames.addressof())); + return GetLocalizedStringFromFont(faceNames); + } + + std::wstring FontCatalog::GetFontFamilyName(const wil::com_ptr& fontFamily) + { + wil::com_ptr familyNames; + THROW_IF_FAILED(fontFamily->GetFamilyNames(familyNames.addressof())); + return GetLocalizedStringFromFont(familyNames); + } + + Utility::OpenTypeFontVersion FontCatalog::GetFontFaceVersion(const wil::com_ptr& font) + { + wil::com_ptr fontVersion; + BOOL exists; + THROW_IF_FAILED(font->GetInformationalStrings(DWRITE_INFORMATIONAL_STRING_VERSION_STRINGS, fontVersion.addressof(), &exists)); + if (!exists) + { + return {}; + } + + std::string value = AppInstaller::Utility::ConvertToUTF8(GetLocalizedStringFromFont(fontVersion)); + Utility::OpenTypeFontVersion openTypeFontVersion{ value }; + return openTypeFontVersion; + } + + FontFamily FontCatalog::GetFontFamilyByIndex(const wil::com_ptr& collection, UINT32 index) + { + wil::com_ptr family; + THROW_IF_FAILED(collection->GetFontFamily(index, family.addressof())); + std::wstring familyName = GetFontFamilyName(family); + + std::vector fontFaces; + UINT32 fontCount = family->GetFontCount(); + for (UINT32 fontIndex = 0; fontIndex < fontCount; fontIndex++) + { + wil::com_ptr font; + THROW_IF_FAILED(family->GetFont(fontIndex, font.addressof())); + + wil::com_ptr fontFace; + THROW_IF_FAILED(font->CreateFontFace(fontFace.addressof())); + + FontFace fontFaceEntry; + fontFaceEntry.Name = GetFontFaceName(font); + fontFaceEntry.Version = GetFontFaceVersion(font); + fontFaceEntry.FilePaths = GetFontFilePaths(fontFace); + fontFaces.emplace_back(std::move(fontFaceEntry)); + } + + FontFamily fontFamily; + fontFamily.Name = std::move(familyName); + fontFamily.Faces = std::move(fontFaces); + return fontFamily; + } } diff --git a/src/AppInstallerCommonCore/Public/winget/Fonts.h b/src/AppInstallerCommonCore/Public/winget/Fonts.h index c4dfa25e5f..443dea5f7a 100644 --- a/src/AppInstallerCommonCore/Public/winget/Fonts.h +++ b/src/AppInstallerCommonCore/Public/winget/Fonts.h @@ -2,8 +2,8 @@ // Licensed under the MIT License. #pragma once #include -#include -#include +#include +#include namespace AppInstaller::Fonts { @@ -20,9 +20,20 @@ namespace AppInstaller::Fonts std::vector Faces; }; - /// - /// Gets all installed font families on the system. If an exact family name is provided and found, returns the installed font family. - /// - /// A list of installed font families. - std::vector GetInstalledFontFamilies(std::optional familyName = {}); + struct FontCatalog + { + FontCatalog(); + + // Gets all installed font families on the system. If an exact family name is provided and found, returns the installed font family. + std::vector GetInstalledFontFamilies(std::optional familyName = {}); + + private: + FontFamily GetFontFamilyByIndex(const wil::com_ptr& collection, UINT32 index); + std::wstring GetLocalizedStringFromFont(const wil::com_ptr& localizedStringCollection); + std::wstring GetFontFamilyName(const wil::com_ptr& fontFamily); + std::wstring GetFontFaceName(const wil::com_ptr& font); + Utility::OpenTypeFontVersion GetFontFaceVersion(const wil::com_ptr& font); + + std::vector m_preferredLocales; + }; }