mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 10:57:34 +00:00
LibGfx: Convert FontStyleMappings to Arrays
This will let us neatly ensure capacities, do unchecked appends, and iterate by size() on FontEditor's models.
This commit is contained in:
parent
8dda4e4ab5
commit
e4ab9a799d
1 changed files with 18 additions and 24 deletions
|
@ -12,35 +12,29 @@
|
||||||
namespace Gfx {
|
namespace Gfx {
|
||||||
|
|
||||||
struct FontStyleMapping {
|
struct FontStyleMapping {
|
||||||
// NOTE: __builtin_strlen required to make this work at compile time.
|
|
||||||
constexpr FontStyleMapping(int s, char const* n)
|
|
||||||
: style(s)
|
|
||||||
, name(StringView { n, __builtin_strlen(n) })
|
|
||||||
{
|
|
||||||
}
|
|
||||||
int style { 0 };
|
int style { 0 };
|
||||||
StringView name;
|
StringView name;
|
||||||
};
|
};
|
||||||
|
|
||||||
static constexpr FontStyleMapping font_weight_names[] = {
|
static constexpr Array<FontStyleMapping, 10> font_weight_names = { {
|
||||||
{ 100, "Thin" },
|
{ 100, "Thin"sv },
|
||||||
{ 200, "Extra Light" },
|
{ 200, "Extra Light"sv },
|
||||||
{ 300, "Light" },
|
{ 300, "Light"sv },
|
||||||
{ 400, "Regular" },
|
{ 400, "Regular"sv },
|
||||||
{ 500, "Medium" },
|
{ 500, "Medium"sv },
|
||||||
{ 600, "Semi Bold" },
|
{ 600, "Semi Bold"sv },
|
||||||
{ 700, "Bold" },
|
{ 700, "Bold"sv },
|
||||||
{ 800, "Extra Bold" },
|
{ 800, "Extra Bold"sv },
|
||||||
{ 900, "Black" },
|
{ 900, "Black"sv },
|
||||||
{ 950, "Extra Black" },
|
{ 950, "Extra Black"sv },
|
||||||
};
|
} };
|
||||||
|
|
||||||
static constexpr FontStyleMapping font_slope_names[] = {
|
static constexpr Array<FontStyleMapping, 4> font_slope_names = { {
|
||||||
{ 0, "Regular" },
|
{ 0, "Regular"sv },
|
||||||
{ 1, "Italic" },
|
{ 1, "Italic"sv },
|
||||||
{ 2, "Oblique" },
|
{ 2, "Oblique"sv },
|
||||||
{ 3, "Reclined" }
|
{ 3, "Reclined"sv },
|
||||||
};
|
} };
|
||||||
|
|
||||||
static constexpr StringView weight_to_name(int weight)
|
static constexpr StringView weight_to_name(int weight)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue