-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Font Install #5042
base: master
Are you sure you want to change the base?
Font Install #5042
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
void FontInstallCommand::Complete(Execution::Context& context, Args::Type valueType) const | ||
{ | ||
UNREFERENCED_PARAMETER(valueType); | ||
context.Reporter.Error() << Resource::String::PendingWorkError << std::endl; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this still result in PowerShell giving the filesystem as options when tabbing? If not, probably better to just have a comment and not fail.
if (scope == Manifest::ScopeEnum::Machine) | ||
{ | ||
m_installLocation = Runtime::GetPathTo(Runtime::PathName::FontsMachineInstallLocation); | ||
m_key = Registry::Key::OpenIfExists(HKEY_LOCAL_MACHINE, std::wstring{ s_FontsPathSubkey }, 0, KEY_WRITE ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know that the chances of this (and the user scope one) not existing are basically none, but we should still protect ourselves in the case that it does not. At a minimum the code should raise an error, but the proper thing to do would be to create the key so that the install can proceed.
const auto& fileName = filePath.filename(); | ||
const auto& destinationPath = m_installLocation / fileName; | ||
|
||
AICLI_LOG(CLI, Info, << "Getting Font title"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AICLI_LOG(CLI, Info, << "Getting Font title"); | |
AICLI_LOG(CLI, Verbose, << "Getting Font title"); |
|
||
if (IsTrueTypeFont(fontFile.FileType)) | ||
{ | ||
title += s_TrueType; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this necessary, or just following convention?
AICLI_LOG(CLI, Info, << "Creating font subkey with name: " << AppInstaller::Utility::ConvertToUTF8(title)); | ||
if (m_scope == Manifest::ScopeEnum::Machine) | ||
{ | ||
m_key.SetValue(title, fileName, REG_SZ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it truly always a 1:1 registry value to file?
// This should be extremely common, but just in case fall back to the older name style. | ||
if (filename.has_stem() && ((filename.wstring().size() + installerExtension.size()) < MAX_PATH)) | ||
// Default to URI for fonts since fonts can have multiple file extensions. | ||
if (installer->BaseInstallerType != InstallerTypeEnum::Font) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please create a semantic function rather than a direct comparison. Or instead handle returning an empty value from GetInstallerFileExtension
as meaning "don't attempt to add an extension".
} | ||
else | ||
{ | ||
AICLI_LOG(CLI, Warning, << "Font file is supported: " << file); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AICLI_LOG(CLI, Warning, << "Font file is supported: " << file); | |
AICLI_LOG(CLI, Verbose, << "Font file is supported: " << file); |
|
||
context.Reporter.Info() << Resource::String::InstallFlowStartingPackageInstall << std::endl; | ||
|
||
Manifest::ScopeEnum scope = AppInstaller::Manifest::ConvertToScopeEnum(context.Args.GetArg(Execution::Args::Type::InstallScope)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handle InstallScope
not being supplied?
FontInstaller fontInstaller = FontInstaller(scope); | ||
|
||
fontInstaller.Install(fontFiles); | ||
context.Add<Execution::Data::OperationReturnCode>(ERROR_SUCCESS); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
context.Add<Execution::Data::OperationReturnCode>(ERROR_SUCCESS); | |
context.Add<Execution::Data::OperationReturnCode>(S_OK); |
HRESULT > Win32 error code
@@ -222,6 +222,8 @@ namespace AppInstaller | |||
WINGET_HRESULT_INFO(APPINSTALLER_CLI_ERROR_SFSCLIENT_PACKAGE_NOT_SUPPORTED, "The Microsoft Store package does not support download."), | |||
WINGET_HRESULT_INFO(APPINSTALLER_CLI_ERROR_LICENSING_API_FAILED_FORBIDDEN, "Failed to retrieve Microsoft Store package license. The Microsoft Entra Id account does not have the required privilege."), | |||
WINGET_HRESULT_INFO(APPINSTALLER_CLI_ERROR_INSTALLER_ZERO_BYTE_FILE, "Downloaded zero byte installer; ensure that your network connection is working properly."), | |||
WINGET_HRESULT_INFO(APPINSTALLER_CLI_ERROR_FONT_INSTALL_FAILED, "Failed to install font package"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I have also been told many times, there is also an .md file with the errors.
Related to: #392, #4842
Changes:
Adds Support for installing a font.
FontInstaller
that does two things based on the scope. place the file in the fonts directory, and writes the subkey entry in the Fonts Registry based on the title of the file.IsFontSupported
function that calls upon the Dwrite Analyze function to determine if the system can support installing the font. In the flow, if this fails, we error out with no way to override.font install
command but currently only supports installing from a local manifest. This means that the same font manifest will work for regularinstall
.Tests:
Microsoft Reviewers: Open in CodeFlow