summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibGfx
diff options
context:
space:
mode:
authorthankyouverycool <66646555+thankyouverycool@users.noreply.github.com>2021-11-29 10:33:34 -0500
committerAndreas Kling <kling@serenityos.org>2021-11-30 10:51:51 +0100
commite29abc5395b9846aadbb18a74fb4673ebe37d696 (patch)
tree5c29d84b13c449784607ac6dfc957f7b7339b9b9 /Userland/Libraries/LibGfx
parent541f1de3a81bace0f48f29c04983b93087b7eb9e (diff)
downloadserenity-e29abc5395b9846aadbb18a74fb4673ebe37d696.zip
LibGfx+FontEditor: Consolidate BitmapFont width and height limits
And make them more self-documenting. Previously these constraints were duplicated across multiple files.
Diffstat (limited to 'Userland/Libraries/LibGfx')
-rw-r--r--Userland/Libraries/LibGfx/Font.h6
1 files changed, 5 insertions, 1 deletions
diff --git a/Userland/Libraries/LibGfx/Font.h b/Userland/Libraries/LibGfx/Font.h
index 32facfa1f9..ab2974de52 100644
--- a/Userland/Libraries/LibGfx/Font.h
+++ b/Userland/Libraries/LibGfx/Font.h
@@ -38,10 +38,14 @@ public:
int width() const { return m_size.width(); }
int height() const { return m_size.height(); }
+ static constexpr size_t bytes_per_row() { return sizeof(u32); }
+ static constexpr int max_width() { return bytes_per_row() * 8; }
+ static constexpr int max_height() { return max_width() + bytes_per_row(); }
+
private:
AK::Bitmap bitmap(size_t y) const
{
- return { const_cast<u8*>(m_rows) + sizeof(u32) * (m_start_index + y), sizeof(u32) * 8 };
+ return { const_cast<u8*>(m_rows) + bytes_per_row() * (m_start_index + y), bytes_per_row() * 8 };
}
const u8* m_rows { nullptr };