Skip to content

Hope to provide an example of the WinGet Font COM API call can be provided #5894

@Gaoyifei1011

Description

@Gaoyifei1011

Relevant area(s)

WinGet CLI, COM API

Description of the new feature / enhancement

        PackageManager packageManager = WinGetFactoryHelper.CreatePackageManager();
            PackageCatalogReference packageCatalogReference = packageManager.GetPredefinedPackageCatalog(PredefinedPackageCatalog.OpenWindowsCatalogFont);
            ConnectResult connectResult = packageCatalogReference.Connect();
            FindPackagesOptions findPackagesOptions = WinGetFactoryHelper.CreateFindPackagesOptions();
            PackageMatchFilter packageMatchFilter = WinGetFactoryHelper.CreatePackageMatchFilter();
            packageMatchFilter.Field = PackageMatchField.Name;
            packageMatchFilter.Value = "ryanoasis.CaskaydiaCove";
            packageMatchFilter.Option = PackageFieldMatchOption.StartsWithCaseInsensitive;
            findPackagesOptions.Selectors.Add(packageMatchFilter);
            FindPackagesResult findPackagesResult = connectResult.PackageCatalog.FindPackages(findPackagesOptions);
            int count = findPackagesResult.Matches.Count;
            for (int index = 0; index < findPackagesResult.Matches.Count; index++)
            {
                MatchResult matchItem = findPackagesResult.Matches[index];

                if (matchItem.CatalogPackage is CatalogPackage catalogPackage && catalogPackage.Id is not null)
                {
                    Debug.WriteLine(catalogPackage.Id);
                    Debug.WriteLine(catalogPackage.Name);
                }
            }

我尝试使用上面的代码搜索 WinGet font 中的字体,但列表返回的内容为空。而且我在 WinGet 仓库中并没有找到与 Font 相关的代码示例,希望 WinGet 的仓库维护者能解答一下疑惑,并增加相关的代码调用示例。

----------------------------------------

I tried to search for the font in WinGet font using the above code, but the content returned by the list was empty. Moreover, I did not find any code examples related to Font in the WinGet repository. I hope the repository maintainer of WinGet can clear up the confusion and add relevant code call examples.

ConsoleApp1.zip

Proposed technical implementation details

None

Metadata

Metadata

Assignees

Labels

Area-COM-APIIssue related to COM APIIssue-FeatureThis is a feature request for the Windows Package Manager client.

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions