FontPluginSerenity.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. /*
  2. * Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include "FontPluginSerenity.h"
  7. #include <AK/String.h>
  8. #include <LibGfx/Font/FontDatabase.h>
  9. namespace Web::Platform {
  10. FontPluginSerenity::FontPluginSerenity()
  11. {
  12. }
  13. FontPluginSerenity::~FontPluginSerenity() = default;
  14. Gfx::Font& FontPluginSerenity::default_font()
  15. {
  16. return Gfx::FontDatabase::default_font();
  17. }
  18. Gfx::Font& FontPluginSerenity::default_fixed_width_font()
  19. {
  20. return Gfx::FontDatabase::default_fixed_width_font();
  21. }
  22. String FontPluginSerenity::generic_font_name(GenericFont generic_font)
  23. {
  24. // FIXME: Replace hard-coded font names with a relevant call to FontDatabase.
  25. // Currently, we cannot request the default font's name, or request it at a specific size and weight.
  26. // So, hard-coded font names it is.
  27. switch (generic_font) {
  28. case GenericFont::SansSerif:
  29. case GenericFont::UiSansSerif:
  30. case GenericFont::Cursive:
  31. case GenericFont::UiRounded:
  32. return "Katica";
  33. case GenericFont::Monospace:
  34. case GenericFont::UiMonospace:
  35. return "Csilla";
  36. case GenericFont::Serif:
  37. case GenericFont::UiSerif:
  38. return "Roman";
  39. case GenericFont::Fantasy:
  40. return "Comic Book";
  41. case GenericFont::__Count:
  42. VERIFY_NOT_REACHED();
  43. }
  44. VERIFY_NOT_REACHED();
  45. }
  46. }