mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 19:57:35 +00:00
LibGfx: Add functions to convert font widths to/from strings
This isn't a "width" in the sense of a fixed-width font, but of the OS/2 width class defined in some font formats.
This commit is contained in:
parent
9f5e105958
commit
98eaa4b044
1 changed files with 30 additions and 0 deletions
|
@ -36,6 +36,18 @@ static constexpr Array<FontStyleMapping, 4> font_slope_names = { {
|
|||
{ 3, "Reclined"sv },
|
||||
} };
|
||||
|
||||
static constexpr Array<FontStyleMapping, 9> font_width_names = { {
|
||||
{ 1, "Ultra Condensed"sv },
|
||||
{ 2, "Extra Condensed"sv },
|
||||
{ 3, "Condensed"sv },
|
||||
{ 4, "Semi Condensed"sv },
|
||||
{ 5, "Normal"sv },
|
||||
{ 6, "Semi Expanded"sv },
|
||||
{ 7, "Expanded"sv },
|
||||
{ 8, "Extra Expanded"sv },
|
||||
{ 9, "Ultra Expanded"sv },
|
||||
} };
|
||||
|
||||
static constexpr StringView weight_to_name(int weight)
|
||||
{
|
||||
for (auto& it : font_weight_names) {
|
||||
|
@ -72,4 +84,22 @@ static constexpr int name_to_slope(StringView name)
|
|||
return {};
|
||||
}
|
||||
|
||||
static constexpr StringView width_to_name(int width)
|
||||
{
|
||||
for (auto& it : font_width_names) {
|
||||
if (it.style == width)
|
||||
return it.name;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
static constexpr int name_to_width(StringView name)
|
||||
{
|
||||
for (auto& it : font_width_names) {
|
||||
if (it.name == name)
|
||||
return it.style;
|
||||
}
|
||||
return {};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue