VectorFont.h 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. /*
  2. * Copyright (c) 2022, the SerenityOS developers.
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/Noncopyable.h>
  8. #include <AK/RefCounted.h>
  9. #include <LibGfx/Font/Font.h>
  10. #include <LibGfx/Forward.h>
  11. namespace Gfx {
  12. struct ScaledFontMetrics {
  13. float ascender { 0 };
  14. float descender { 0 };
  15. float line_gap { 0 };
  16. float height() const
  17. {
  18. return ascender + descender;
  19. }
  20. };
  21. struct ScaledGlyphMetrics {
  22. float ascender;
  23. float descender;
  24. float advance_width;
  25. float left_side_bearing;
  26. };
  27. class VectorFont : public RefCounted<VectorFont> {
  28. public:
  29. virtual ~VectorFont() { }
  30. virtual ScaledFontMetrics metrics(float x_scale, float y_scale) const = 0;
  31. virtual ScaledGlyphMetrics glyph_metrics(u32 glyph_id, float x_scale, float y_scale, float point_width, float point_height) const = 0;
  32. virtual float glyphs_horizontal_kerning(u32 left_glyph_id, u32 right_glyph_id, float x_scale) const = 0;
  33. virtual RefPtr<Gfx::Bitmap> rasterize_glyph(u32 glyph_id, float x_scale, float y_scale, GlyphSubpixelOffset) const = 0;
  34. virtual u32 glyph_count() const = 0;
  35. virtual u16 units_per_em() const = 0;
  36. virtual u32 glyph_id_for_code_point(u32 code_point) const = 0;
  37. virtual DeprecatedString family() const = 0;
  38. virtual DeprecatedString variant() const = 0;
  39. virtual u16 weight() const = 0;
  40. virtual u16 width() const = 0;
  41. virtual u8 slope() const = 0;
  42. virtual bool is_fixed_width() const = 0;
  43. virtual bool has_color_bitmaps() const = 0;
  44. };
  45. }