1
0
Fork 0
mirror of https://github.com/LadybirdBrowser/ladybird.git synced 2025-06-08 05:27:14 +09:00
ladybird/Libraries/LibGfx/Font/UnicodeRange.h
Sam Atkins 3288c71953 LibGfx: Serialize unicode-ranges in uppercase
This matches the behavior of other browsers.
2025-04-07 10:00:21 +01:00

49 lines
1.2 KiB
C++

/*
* Copyright (c) 2022-2023, Sam Atkins <atkinssj@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/Assertions.h>
#include <AK/String.h>
namespace Gfx {
class UnicodeRange {
public:
UnicodeRange(u32 min_code_point, u32 max_code_point)
: m_min_code_point(min_code_point)
, m_max_code_point(max_code_point)
{
VERIFY(min_code_point <= max_code_point);
}
u32 min_code_point() const { return m_min_code_point; }
u32 max_code_point() const { return m_max_code_point; }
bool contains(u32 code_point) const
{
return m_min_code_point <= code_point && code_point <= m_max_code_point;
}
String to_string() const
{
if (m_min_code_point == m_max_code_point)
return MUST(String::formatted("U+{:X}", m_min_code_point));
return MUST(String::formatted("U+{:X}-{:X}", m_min_code_point, m_max_code_point));
}
bool operator==(UnicodeRange const& other) const
{
return m_min_code_point == other.m_min_code_point
&& m_max_code_point == other.m_max_code_point;
}
private:
u32 m_min_code_point;
u32 m_max_code_point;
};
}