GFontDatabase.h 668 B

123456789101112131415161718192021222324252627282930313233
  1. #pragma once
  2. #include <AK/String.h>
  3. #include <AK/Function.h>
  4. #include <AK/HashMap.h>
  5. class Font;
  6. struct Metadata {
  7. String path;
  8. bool is_fixed_width;
  9. int glyph_height;
  10. };
  11. class GFontDatabase {
  12. public:
  13. static GFontDatabase& the();
  14. RefPtr<Font> get_by_name(const StringView&);
  15. void for_each_font(Function<void(const StringView&)>);
  16. void for_each_fixed_width_font(Function<void(const StringView&)>);
  17. Optional<Metadata> get_metadata_by_name(const StringView& name) const
  18. {
  19. return m_name_to_metadata.get(name);
  20. }
  21. private:
  22. GFontDatabase();
  23. ~GFontDatabase();
  24. HashMap<String, Metadata> m_name_to_metadata;
  25. };