Repository: microsoft/terminal
File: src/cascadia/TerminalSettingsEditor/Profiles.cpp (C++)

Code before:
        const auto startingDirCheckboxTooltip{ ToolTipService::GetToolTip(StartingDirectoryUseParentCheckbox()) };
        Automation::AutomationProperties::SetFullDescription(StartingDirectoryUseParentCheckbox(), unbox_value<hstring>(startingDirCheckboxTooltip));

        const auto backgroundImgCheckboxTooltip{ ToolTipService::GetToolTip(UseDesktopImageCheckBox()) };
        Automation::AutomationProperties::SetFullDescription(UseDesktopImageCheckBox(), unbox_value<hstring>(backgroundImgCheckboxTooltip));

        Automation::AutomationProperties::SetName(DeleteButton(), RS_(L"Profile_DeleteButton/Text"));

        if (!_FontList)
        {
            _UpdateFontList();
        }
    }

    void Profiles::_UpdateFontList()
    try
    {
        // initialize font list
        _FontList = single_threaded_observable_vector<hstring>();

        // get a DWriteFactory
        ::IUnknown* unknownFactory;
        THROW_IF_FAILED(DWriteCreateFactory(
            DWRITE_FACTORY_TYPE_SHARED,
            __uuidof(::IDWriteFactory),
            &unknownFactory));

        ::IDWriteFactory* dwriteFactory;
        THROW_IF_FAILED(unknownFactory->QueryInterface(&dwriteFactory));

        com_ptr<::IDWriteFactory> factory{};
        factory.attach(dwriteFactory);

        // get the font collection; subscribe to updates
        com_ptr<::IDWriteFontCollection> fontCollection;
        THROW_IF_FAILED(factory->GetSystemFontCollection(fontCollection.put(), TRUE));

        for (UINT32 i = 0; i < fontCollection->GetFontFamilyCount(); ++i)
        {
            try
            {
                // get the font
                com_ptr<::IDWriteFontFamily> fontFamily;
                THROW_IF_FAILED(fontCollection->GetFontFamily(i, fontFamily.put()));

                // get the font's localized names
                com_ptr<::IDWriteLocalizedStrings> localizedFamilyNames;
                THROW_IF_FAILED(fontFamily->GetFamilyNames(localizedFamilyNames.put()));

                // use our current locale to find the correct name
                BOOL exists{ FALSE };

Review comment (suggestion):
You might be able to make this simpler: https://docs.microsoft.com/en-us/windows/uwp/cpp-and-winrt-apis/consume-com

```c++
com_ptr<::IDWriteFactory> dwriteFactory;
DWriteCreateFactory(
    DWRITE_FACTORY_TYPE_SHARED,
    __uuidof(dwriteFactory),
    reinterpret_cast<IUnknown**>(dwriteFactory.put()));
```

something like that

Code after:
    IObservableVector<Editor::Font> ProfileViewModel::CompleteFontList() const noexcept
    {
        return _FontList;
    }

    IObservableVector<Editor::Font> ProfileViewModel::MonospaceFontList() const noexcept
    {
        return _MonospaceFontList;
    }

    // Method Description:
    // - Searches through our list of monospace fonts to determine if the settings model's current font face is a monospace font
    // - NOTE: This is information stored from DWrite in _UpdateFontList()
    bool ProfileViewModel::UsingMonospaceFont() const noexcept
    {
        bool result{ false };
        const auto currentFont{ FontFace() };
        for (const auto& font : _MonospaceFontList)
        {
            if (font.LocalizedName() == currentFont)
            {
                result = true;
            }
        }
        return result;
    }

    // Method Description:
    // - Determines whether we should show the list of all the fonts, or we should just show monospace fonts
    bool ProfileViewModel::ShowAllFonts() const noexcept
    {
        // - _ShowAllFonts is directly bound to the checkbox. So this is the user set value.
        // - If we are not using a monospace font, show all of the fonts so that the ComboBox is still properly bound
        return _ShowAllFonts || !UsingMonospaceFont();
    }

    void ProfileViewModel::ShowAllFonts(const bool& value)
    {
        if (_ShowAllFonts != value)
        {
            _ShowAllFonts = value;
            _NotifyChanges(L"ShowAllFonts");
        }
    }

    bool ProfileViewModel::CanDeleteProfile() const
    {
        const auto guid{ Guid() };
        if (IsBaseLayer())
        {
            return false;