srctree

Robin Linden parent 74199108 a447a4f9
gfx/sfml: Don't try to use fonts that don't support ASCII

inlinesplit
gfx/sfml_canvas.cpp added: 9, removed: 4, total 5
@@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: 2022-2023 Robin Lindén <dev@robinlinden.eu>
// SPDX-FileCopyrightText: 2022-2024 Robin Lindén <dev@robinlinden.eu>
// SPDX-FileCopyrightText: 2022 Mikael Larsson <c.mikael.larsson@gmail.com>
//
// SPDX-License-Identifier: BSD-2-Clause
@@ -34,7 +34,6 @@
#include <string>
#include <string_view>
#include <system_error>
#include <utility>
 
using namespace std::literals;
 
@@ -74,7 +73,13 @@ sf::Font load_fallback_font() {
std::shared_ptr<type::SfmlFont const> find_font(type::SfmlType &type, std::span<gfx::Font const> font_families) {
for (auto const &family : font_families) {
if (auto font = type.font(family.font)) {
return std::static_pointer_cast<type::SfmlFont const>(*std::move(font));
auto sf_font = std::static_pointer_cast<type::SfmlFont const>(*font);
if (!sf_font->sf_font().hasGlyph('A')) {
spdlog::warn("Font '{}' does not have an 'A' glyph", family.font);
continue;
}
 
return sf_font;
}
}