Browse Source

LibGfx: Add Font::point_size()

This returns the font size in pt instead of px.
Andreas Kling 2 năm trước cách đây
mục cha
commit
a4927f523b

+ 2 - 0
Userland/Libraries/LibGfx/Font/BitmapFont.h

@@ -39,6 +39,8 @@ public:
     u8* rows() { return m_rows; }
     u8* widths() { return m_glyph_widths; }
 
+    virtual float point_size() const override { return m_presentation_size; }
+
     u8 presentation_size() const override { return m_presentation_size; }
     void set_presentation_size(u8 size) { m_presentation_size = size; }
 

+ 3 - 0
Userland/Libraries/LibGfx/Font/Font.h

@@ -161,6 +161,9 @@ public:
     virtual u8 presentation_size() const = 0;
     virtual u8 slope() const = 0;
 
+    // Font point size (distance between ascender and descender).
+    virtual float point_size() const = 0;
+
     // Font pixel size (distance between ascender and descender).
     virtual float pixel_size() const = 0;
 

+ 5 - 0
Userland/Libraries/LibGfx/Font/ScaledFont.cpp

@@ -163,4 +163,9 @@ int ScaledFont::pixel_size_rounded_up() const
     return m_pixel_size_rounded_up;
 }
 
+float ScaledFont::point_size() const
+{
+    return m_point_height;
+}
+
 }

+ 1 - 0
Userland/Libraries/LibGfx/Font/ScaledFont.h

@@ -36,6 +36,7 @@ public:
     virtual NonnullRefPtr<Font> clone() const override { return MUST(try_clone()); } // FIXME: clone() should not need to be implemented
     virtual ErrorOr<NonnullRefPtr<Font>> try_clone() const override { return const_cast<ScaledFont&>(*this); }
     virtual u8 presentation_size() const override { return m_point_height; }
+    virtual float point_size() const override;
     virtual float pixel_size() const override;
     virtual int pixel_size_rounded_up() const override;
     virtual Gfx::FontPixelMetrics pixel_metrics() const override;