mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 14:27:35 +00:00
LibWeb+LibGfx: Move UnicodeRange from LibWeb to LibGfx
In upcoming changes UnicodeRange is going to be used in LibGfx in a class that represents font cascade list.
This commit is contained in:
parent
0d03257e69
commit
f50bf00814
8 changed files with 20 additions and 22 deletions
43
Userland/Libraries/LibGfx/Font/UnicodeRange.h
Normal file
43
Userland/Libraries/LibGfx/Font/UnicodeRange.h
Normal file
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* 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));
|
||||
}
|
||||
|
||||
private:
|
||||
u32 m_min_code_point;
|
||||
u32 m_max_code_point;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue