Files
dl_old/dl/render/dl_font.h
T

63 lines
1.0 KiB
C++

/**
* @file dl_font.h
* @brief 字体解析结构
*
*
* @version 1.0
* @author lveyou
* @date 22-09-11
*
*/
#pragma once
#include "render/dl_image.h"
namespace dl
{
//! 字符信息
struct CharInfo
{
std::size_t _font;
char32_t _ch;
unsigned _size;
unsigned _outline;
bool operator==(const CharInfo& b) const
{
return _font == b._font
&& _ch == b._ch
&& _size == b._size
&& _outline == b._outline;
}
};
struct CharInfoHash
{
//8 + 16 + 8 + 32
size_t operator()(const CharInfo& info) const
{
uint64_t n = ((uint64_t)info._font << 56)
| ((uint64_t)info._size << 40)
| ((uint64_t)info._outline << 32)
| ((uint64_t)info._ch);
return std::hash<uint64_t>()(n);
}
};
//! 字符图像数据
struct CharImage
{
Image* _image;
Image* _imageOutline;
float _bearingX; //! 左侧离 对齐点的距离
float _bearingY; //! 顶部到 基线的距离
float _advance; //! 水平步进
//float _lineSpacing; //! 行间距(和face全局相关)
~CharImage()
{
delete _image;
delete _imageOutline;
}
};
}