Beispiel #1
0
IFACEMETHODIMP CanvasTextFormatFactory::GetSystemFontFamiliesFromLocaleList(
    IVectorView<HSTRING>* localeList,
    uint32_t* valueCount,
    HSTRING** valueElements)
{
    return ExceptionBoundary(
        [&]
        {
            CheckInPointer(valueCount);
            CheckAndClearOutPointer(valueElements);
            
            auto factory = CustomFontManager::GetInstance()->GetSharedFactory();

            ComPtr<IDWriteFontCollection> systemFontCollection;
            ThrowIfFailed(factory->GetSystemFontCollection(&systemFontCollection));

            uint32_t familyCount = systemFontCollection->GetFontFamilyCount();

            ComArray<HSTRING> stringArray(familyCount);

            for (uint32_t i = 0; i < familyCount; ++i)
            {
                ComPtr<IDWriteFontFamily> fontFamily;
                ThrowIfFailed(systemFontCollection->GetFontFamily(i, &fontFamily));

                ComPtr<IDWriteLocalizedStrings> familyNames;
                ThrowIfFailed(fontFamily->GetFamilyNames(&familyNames));

                WinString familyName = GetFamilyName(familyNames, localeList);
                familyName.CopyTo(&stringArray[i]);
            }

            stringArray.Detach(valueCount, valueElements);
        });
}
Beispiel #2
0
static void SetFrom(HSTRING* outputValue, WinString const& value)
{
    value.CopyTo(outputValue);
}