From febfc28b633683773bc92777fde290396ca2cdbf Mon Sep 17 00:00:00 2001 From: Phillip Stephens Date: Fri, 23 Dec 2022 21:07:46 -0800 Subject: [PATCH] Finish CRasterFont constructor, has regswaps though --- include/Kyoto/Text/CRasterFont.hpp | 5 +++-- src/Kyoto/Text/CRasterFont.cpp | 23 ++++++++++++++++++++++- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/include/Kyoto/Text/CRasterFont.hpp b/include/Kyoto/Text/CRasterFont.hpp index 5c0406dc..b8cbaa21 100644 --- a/include/Kyoto/Text/CRasterFont.hpp +++ b/include/Kyoto/Text/CRasterFont.hpp @@ -10,9 +10,8 @@ #include "string.h" -class CGlyph; -class CKernPair; class CTexture; +class CDrawStringOptions; class IObjectStore; class CFontInfo { @@ -104,6 +103,8 @@ public: CRasterFont(CInputStream& in, IObjectStore* store); ~CRasterFont(); + EFontMode GetMode() const; + void GetSize(const CDrawStringOptions&, int&, int&, const wchar_t*, int) const; void SetTexture(TToken< CTexture > token) { x80_texture = token; } bool IsFinishedLoading(); diff --git a/src/Kyoto/Text/CRasterFont.cpp b/src/Kyoto/Text/CRasterFont.cpp index e306c455..c00f0585 100644 --- a/src/Kyoto/Text/CRasterFont.cpp +++ b/src/Kyoto/Text/CRasterFont.cpp @@ -16,7 +16,12 @@ CRasterFont::CRasterFont(CInputStream& in, IObjectStore* store) if (version >= 0 && version <= 2) { x4_monoWidth = in.ReadInt32(); x8_monoHeight = in.ReadInt32(); - x8c_baseline = version >= 1 ? in.ReadInt32() : x8_monoHeight; + if (version >= 1) { + x8c_baseline = in.ReadInt32(); + } else { + x8c_baseline = x8_monoHeight; + } + if (version >= 2) { x90_lineMargin = in.ReadInt32(); } @@ -68,6 +73,22 @@ CRasterFont::CRasterFont(CInputStream& in, IObjectStore* store) rstl::sort( xc_glyphs.begin(), xc_glyphs.end(), rstl::default_pair_sorter_finder< rstl::vector< rstl::pair< wchar_t, CGlyph > > >()); + + int kerningCount = in.ReadInt32(); + x1c_kerning.reserve(kerningCount); + + for (int i = 0; i < kerningCount; ++i) { + short first = in.ReadShort(); + short second = in.ReadShort(); + int howMuch = in.ReadInt32(); + x1c_kerning.push_back(CKernPair(first, second, howMuch)); + } + + x0_initialized = true; } } } + +EFontMode CRasterFont::GetMode() const { return x2c_mode; } + +void CRasterFont::GetSize(const CDrawStringOptions&, int&, int&, const wchar_t*, int) const {}