Skip to content
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

Fix font axes/features settings UI #17164

Merged
merged 5 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions doc/cascadia/profiles.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,7 @@
"description": "Sets the DWrite font features for the given font. For example, { \"ss01\": 1, \"liga\":0 } will enable ss01 and disable ligatures.",
"type": "object",
"patternProperties": {
"^(([A-Za-z0-9]){4})$": {
"^[\\x20-\\x7E]{4}$": {
"type": "integer"
}
},
Expand All @@ -359,7 +359,7 @@
"description": "Sets the DWrite font axes for the given font. For example, { \"wght\": 200 } will set the font weight to 200.",
"type": "object",
"patternProperties": {
"^([A-Za-z]{4})$": {
"^[\\x20-\\x7E]{4}$": {
"type": "number"
}
},
Expand Down
31 changes: 14 additions & 17 deletions src/cascadia/TerminalControl/ControlCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -959,26 +959,23 @@ namespace winrt::Microsoft::Terminal::Control::implementation

if (_renderEngine)
{
std::unordered_map<std::wstring_view, uint32_t> featureMap;
if (const auto fontFeatures = _settings->FontFeatures())
{
featureMap.reserve(fontFeatures.Size());

for (const auto& [tag, param] : fontFeatures)
static constexpr auto cloneMap = [](const IFontFeatureMap& map) {
std::unordered_map<std::wstring_view, float> clone;
if (map)
{
featureMap.emplace(tag, param);
clone.reserve(map.Size());
for (const auto& [tag, param] : map)
{
clone.emplace(tag, param);
}
}
}
std::unordered_map<std::wstring_view, float> axesMap;
if (const auto fontAxes = _settings->FontAxes())
{
axesMap.reserve(fontAxes.Size());
return clone;
};

for (const auto& [axis, value] : fontAxes)
{
axesMap.emplace(axis, value);
}
}
const auto fontFeatures = _settings->FontFeatures();
const auto fontAxes = _settings->FontAxes();
const auto featureMap = cloneMap(fontFeatures);
const auto axesMap = cloneMap(fontAxes);

// TODO: MSFT:20895307 If the font doesn't exist, this doesn't
// actually fail. We need a way to gracefully fallback.
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalControl/ControlSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Licensed under the MIT license.
#include <conattrs.hpp>
#include "ControlAppearance.h"

using IFontFeatureMap = winrt::Windows::Foundation::Collections::IMap<winrt::hstring, uint32_t>;
using IFontFeatureMap = winrt::Windows::Foundation::Collections::IMap<winrt::hstring, float>;
using IFontAxesMap = winrt::Windows::Foundation::Collections::IMap<winrt::hstring, float>;

namespace winrt::Microsoft::Terminal::Control::implementation
Expand Down
2 changes: 1 addition & 1 deletion src/cascadia/TerminalControl/IControlSettings.idl
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ namespace Microsoft.Terminal.Control
Single FontSize { get; };
Windows.UI.Text.FontWeight FontWeight { get; };
String Padding { get; };
Windows.Foundation.Collections.IMap<String, UInt32> FontFeatures { get; };
Windows.Foundation.Collections.IMap<String, Single> FontFeatures { get; };
Windows.Foundation.Collections.IMap<String, Single> FontAxes { get; };
Boolean EnableBuiltinGlyphs { get; };
Boolean EnableColorGlyphs { get; };
Expand Down
Loading
Loading