Files
Renderive/Core/base/Text.h
T
2026-08-02 03:43:39 +08:00

38 lines
875 B
C++

#pragma once
#include <cstdint>
#include <memory>
#include "Bitmask.h"
namespace renderive {
enum class Text_Align : std::uint16_t {
None = 0,
Left = 1 << 0,
Right = 1 << 1,
Horizontal_Center = 1 << 2,
Top = 1 << 3,
Bottom = 1 << 4,
Vertical_Center = 1 << 5,
Center = Horizontal_Center | Vertical_Center
};
struct Font_Face;
struct Font {
std::shared_ptr<Font_Face> face;
double size = 12.0;
int weight = 400;
bool italic = false;
[[nodiscard]] bool valid() const {
return face != nullptr && size > 0.0;
}
};
struct Text_Metrics {
double width{};
double height{};
double ascent{};
double descent{};
double line_gap{};
[[nodiscard]] double line_height() const {
return ascent + descent + line_gap;
}
};
} // namespace renderive
RENDERIVE_ENABLE_BITMASK(renderive::Text_Align)