metaforce/DataSpec/DNACommon/FONT.hpp

129 lines
3.6 KiB
C++
Raw Normal View History

2016-03-09 08:54:28 +00:00
#ifndef __COMMON_FONT_HPP__
#define __COMMON_FONT_HPP__
#include "PAK.hpp"
#include "athena/FileWriter.hpp"
2017-12-29 08:08:12 +00:00
namespace DataSpec::DNAFont
2016-03-09 08:54:28 +00:00
{
2018-02-22 07:24:51 +00:00
struct GlyphRect : BigDNA
2016-03-09 08:54:28 +00:00
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
2016-03-09 08:54:28 +00:00
Value<float> left;
Value<float> top;
Value<float> right;
Value<float> bottom;
};
2018-02-22 07:24:51 +00:00
struct IGlyph : BigDNAV
2016-03-09 08:54:28 +00:00
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
2016-03-09 08:54:28 +00:00
Value<atUint16> m_character;
GlyphRect m_glyphRect;
atUint16 character() const { return m_character; }
float left() const { return m_glyphRect.left; }
float top() const { return m_glyphRect.top; }
float right() const { return m_glyphRect.right; }
float bottom() const { return m_glyphRect.bottom; }
GlyphRect rect() const { return m_glyphRect; }
virtual int layer() { return 0; }
virtual atInt32 leftPadding() const=0;
virtual atInt32 advance() const =0;
virtual atInt32 rightPadding() const=0;
virtual atInt32 width() const=0;
virtual atInt32 height() const=0;
virtual atInt32 baseline() const=0;
virtual atInt32 kerningIndex() const =0;
};
struct GlyphMP1 : IGlyph
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
AT_DECL_DNAV
2016-03-09 08:54:28 +00:00
Value<atInt32> m_leftPadding;
Value<atInt32> m_advance;
Value<atInt32> m_rightPadding;
Value<atInt32> m_width;
Value<atInt32> m_height;
Value<atInt32> m_baseline;
Value<atInt32> m_kerningIndex;
atInt32 leftPadding() const { return m_leftPadding; }
atInt32 advance() const { return m_advance; }
atInt32 rightPadding() const { return m_rightPadding; }
atInt32 width() const { return m_width; }
atInt32 height() const { return m_height; }
atInt32 baseline() const { return m_baseline; }
atInt32 kerningIndex() const { return m_kerningIndex; }
};
struct GlyphMP2 : IGlyph
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
AT_DECL_DNAV
2016-03-09 08:54:28 +00:00
Value<atInt8> m_layer;
Value<atInt8> m_leftPadding;
Value<atInt8> m_advance;
Value<atInt8> m_rightPadding;
Value<atInt8> m_width;
Value<atInt8> m_height;
Value<atInt8> m_baseline;
Value<atInt16> m_kerningIndex;
atInt32 layer() const { return m_layer; }
atInt32 leftPadding() const { return m_leftPadding; }
atInt32 advance() const { return m_advance; }
atInt32 rightPadding() const { return m_rightPadding; }
atInt32 width() const { return m_width; }
atInt32 height() const { return m_height; }
atInt32 baseline() const { return m_baseline; }
atInt32 kerningIndex() const { return m_kerningIndex; }
};
2018-02-22 07:24:51 +00:00
struct KerningInfo : BigDNA
2016-03-09 08:54:28 +00:00
{
2018-02-22 07:24:51 +00:00
AT_DECL_DNA_YAML
2016-03-09 08:54:28 +00:00
Value<atUint16> thisChar;
Value<atUint16> nextChar;
Value<atInt32> adjust;
};
template <class IDType>
2018-02-22 07:24:51 +00:00
struct AT_SPECIALIZE_PARMS(DataSpec::UniqueID32, DataSpec::UniqueID64) FONT : BigDNA
2016-03-09 08:54:28 +00:00
{
2018-02-22 07:24:51 +00:00
AT_DECL_EXPLICIT_DNA_YAML
AT_SUBDECL_DNA
2016-03-09 08:54:28 +00:00
Value<atUint32> version;
Value<atUint32> unknown1;
Value<atInt32> lineHeight;
Value<atInt32> verticalOffset;
Value<atInt32> lineMargin;
Value<bool> unknown2;
Value<bool> unknown3;
Value<atUint32> unknown4;
Value<atUint32> fontSize; // in points
String<-1> name;
IDType textureId;
Value<atUint32> textureFormat;
Value<atUint32> glyphCount;
std::vector<std::unique_ptr<IGlyph>> glyphs;
Value<atUint32> kerningInfoCount;
Vector<KerningInfo, DNA_COUNT(kerningInfoCount)> kerningInfo;
2016-10-02 22:41:36 +00:00
void gatherDependencies(std::vector<hecl::ProjectPath>& pathsOut) const
{
g_curSpec->flattenDependencies(textureId, pathsOut);
}
2016-03-09 08:54:28 +00:00
};
template <class IDType>
bool ExtractFONT(PAKEntryReadStream& rs, const hecl::ProjectPath& outPath);
template <class IDType>
bool WriteFONT(const FONT<IDType>& font, const hecl::ProjectPath& outPath);
}
#endif // __COMMON_FONT_HPP__