mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 23:17:45 +00:00
LibGUI: Allow GUI::FilePicker to show only fixed-width fonts
This is useful when you really only want something monospaced. :^)
This commit is contained in:
parent
ddaa526769
commit
7e40c7cf99
2 changed files with 11 additions and 2 deletions
|
@ -35,8 +35,9 @@
|
||||||
|
|
||||||
namespace GUI {
|
namespace GUI {
|
||||||
|
|
||||||
FontPicker::FontPicker(Window* parent_window, const Gfx::Font* current_font)
|
FontPicker::FontPicker(Window* parent_window, const Gfx::Font* current_font, bool fixed_width_only)
|
||||||
: Dialog(parent_window)
|
: Dialog(parent_window)
|
||||||
|
, m_fixed_width_only(fixed_width_only)
|
||||||
{
|
{
|
||||||
set_title("Font picker");
|
set_title("Font picker");
|
||||||
resize(540, 300);
|
resize(540, 300);
|
||||||
|
@ -53,6 +54,8 @@ FontPicker::FontPicker(Window* parent_window, const Gfx::Font* current_font)
|
||||||
|
|
||||||
HashTable<String> families;
|
HashTable<String> families;
|
||||||
Gfx::FontDatabase::the().for_each_font([&](auto& font) {
|
Gfx::FontDatabase::the().for_each_font([&](auto& font) {
|
||||||
|
if (m_fixed_width_only && !font.is_fixed_width())
|
||||||
|
return;
|
||||||
families.set(font.family());
|
families.set(font.family());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -65,6 +68,8 @@ FontPicker::FontPicker(Window* parent_window, const Gfx::Font* current_font)
|
||||||
m_family = index.data().to_string();
|
m_family = index.data().to_string();
|
||||||
HashTable<int> weights;
|
HashTable<int> weights;
|
||||||
Gfx::FontDatabase::the().for_each_font([&](auto& font) {
|
Gfx::FontDatabase::the().for_each_font([&](auto& font) {
|
||||||
|
if (m_fixed_width_only && !font.is_fixed_width())
|
||||||
|
return;
|
||||||
if (font.family() == m_family.value())
|
if (font.family() == m_family.value())
|
||||||
weights.set(font.weight());
|
weights.set(font.weight());
|
||||||
});
|
});
|
||||||
|
@ -88,6 +93,8 @@ FontPicker::FontPicker(Window* parent_window, const Gfx::Font* current_font)
|
||||||
m_sizes.clear();
|
m_sizes.clear();
|
||||||
Optional<size_t> index_of_old_size_in_new_list;
|
Optional<size_t> index_of_old_size_in_new_list;
|
||||||
Gfx::FontDatabase::the().for_each_font([&](auto& font) {
|
Gfx::FontDatabase::the().for_each_font([&](auto& font) {
|
||||||
|
if (m_fixed_width_only && !font.is_fixed_width())
|
||||||
|
return;
|
||||||
if (font.family() == m_family.value() && font.weight() == m_weight.value()) {
|
if (font.family() == m_family.value() && font.weight() == m_weight.value()) {
|
||||||
if (m_size.has_value() && m_size.value() == font.presentation_size())
|
if (m_size.has_value() && m_size.value() == font.presentation_size())
|
||||||
index_of_old_size_in_new_list = m_sizes.size();
|
index_of_old_size_in_new_list = m_sizes.size();
|
||||||
|
|
|
@ -41,10 +41,12 @@ public:
|
||||||
void set_font(const Gfx::Font*);
|
void set_font(const Gfx::Font*);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FontPicker(Window* parent_window = nullptr, const Gfx::Font* current_font = nullptr);
|
FontPicker(Window* parent_window = nullptr, const Gfx::Font* current_font = nullptr, bool fixed_width_only = false);
|
||||||
|
|
||||||
void update_sample_label();
|
void update_sample_label();
|
||||||
|
|
||||||
|
const bool m_fixed_width_only;
|
||||||
|
|
||||||
RefPtr<Gfx::Font> m_font;
|
RefPtr<Gfx::Font> m_font;
|
||||||
|
|
||||||
RefPtr<ListView> m_family_list_view;
|
RefPtr<ListView> m_family_list_view;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue