115 lines
1.8 KiB
C++
115 lines
1.8 KiB
C++
#include "ehs/io/Glyph.h"
|
|
|
|
namespace ehs
|
|
{
|
|
Glyph::Glyph()
|
|
: code(0)
|
|
{
|
|
}
|
|
|
|
Glyph::Glyph(Serializer<>& ser)
|
|
: code(ser.Read<Char_32>()), pos(ser.ReadVec2<UInt_64>()), scale(ser.ReadVec2<UInt_64>()),
|
|
uv(ser.ReadRect<float>()), bearing(ser.ReadVec2<Int_64>()), advance(ser.ReadVec2<UInt_64>())
|
|
{
|
|
}
|
|
|
|
Glyph::Glyph(const Char_32 code)
|
|
: code(code)
|
|
{
|
|
}
|
|
|
|
Glyph::Glyph(const Glyph& glyph)
|
|
: code(glyph.code), pos(glyph.pos), scale(glyph.scale), uv(glyph.uv), bearing(glyph.bearing), advance(glyph.advance)
|
|
{
|
|
}
|
|
|
|
Glyph& Glyph::operator=(const Glyph& glyph)
|
|
{
|
|
if (this == &glyph)
|
|
return *this;
|
|
|
|
code = glyph.code;
|
|
pos = glyph.pos;
|
|
scale = glyph.scale;
|
|
uv = glyph.uv;
|
|
bearing = glyph.bearing;
|
|
advance = glyph.advance;
|
|
|
|
return *this;
|
|
}
|
|
|
|
bool Glyph::operator==(const Glyph& glyph) const
|
|
{
|
|
return code == glyph.code;
|
|
}
|
|
|
|
bool Glyph::operator!=(const Glyph& glyph) const
|
|
{
|
|
return code != glyph.code;
|
|
}
|
|
|
|
Char_32 Glyph::GetCode() const
|
|
{
|
|
return code;
|
|
}
|
|
|
|
void Glyph::SetPos(const Vec2_u64& newPos)
|
|
{
|
|
pos = newPos;
|
|
}
|
|
|
|
Vec2_u64 Glyph::GetPos() const
|
|
{
|
|
return pos;
|
|
}
|
|
|
|
void Glyph::SetScale(const Vec2_u64& newScale)
|
|
{
|
|
scale = newScale;
|
|
}
|
|
|
|
Vec2_u64 Glyph::GetScale() const
|
|
{
|
|
return scale;
|
|
}
|
|
|
|
void Glyph::SetUV(const Rect_f& newUV)
|
|
{
|
|
uv = newUV;
|
|
}
|
|
|
|
Rect_f Glyph::GetUV() const
|
|
{
|
|
return uv;
|
|
}
|
|
|
|
void Glyph::SetBearing(const Vec2_64& newBearing)
|
|
{
|
|
bearing = newBearing;
|
|
}
|
|
|
|
Vec2_32 Glyph::GetBearing() const
|
|
{
|
|
return bearing;
|
|
}
|
|
|
|
void Glyph::SetAdvance(const Vec2_64& newAdvance)
|
|
{
|
|
advance = newAdvance;
|
|
}
|
|
|
|
Vec2_32 Glyph::GetAdvance() const
|
|
{
|
|
return advance;
|
|
}
|
|
|
|
void Glyph::Serialize(Serializer<>& ser) const
|
|
{
|
|
ser.Write(code);
|
|
ser.WriteVec2(pos);
|
|
ser.WriteVec2(scale);
|
|
ser.WriteRect(uv);
|
|
ser.WriteVec2(bearing);
|
|
ser.WriteVec2(advance);
|
|
}
|
|
} |