diff --git a/Runtime/Graphics/Shaders/CTextSupportShader.cpp b/Runtime/Graphics/Shaders/CTextSupportShader.cpp index f0f1eccce..aa095e228 100644 --- a/Runtime/Graphics/Shaders/CTextSupportShader.cpp +++ b/Runtime/Graphics/Shaders/CTextSupportShader.cpp @@ -34,20 +34,29 @@ void CTextSupportShader::CharacterInstance::SetMetrics(const CGlyph& glyph, m_uv[3].assign(glyph.GetEndU(), 1.f - glyph.GetEndV(), layer); } -void CTextSupportShader::ImageInstance::SetMetrics(const zeus::CVector2f& imgSize, +void CTextSupportShader::ImageInstance::SetMetrics(const CFontImageDef& imgDef, const zeus::CVector2i& offset) { + zeus::CVector2f imgSize; + if (imgDef.x4_texs.size()) + { + const CTexture& tex = *imgDef.x4_texs[0].GetObj(); + imgSize.assign(tex.GetWidth() * imgDef.x14_cropFactor.x, + tex.GetHeight() * imgDef.x14_cropFactor.y); + } + zeus::CVector2f cropPad = imgDef.x14_cropFactor * 0.5f; + m_pos[0].assign(offset.x, 0.f, offset.y); - m_uv[0].assign(0.f, 1.f); + m_uv[0].assign(0.5f - cropPad.x, 0.5f + cropPad.y); m_pos[1].assign(offset.x + imgSize.x, 0.f, offset.y); - m_uv[1].assign(1.f, 1.f); + m_uv[1].assign(0.5f + cropPad.x, 0.5f + cropPad.y); m_pos[2].assign(offset.x, 0.f, offset.y + imgSize.y); - m_uv[2].assign(0.f, 0.f); + m_uv[2].assign(0.5f - cropPad.x, 0.5f - cropPad.y); m_pos[3].assign(offset.x + imgSize.x, 0.f, offset.y + imgSize.y); - m_uv[3].assign(1.f, 0.f); + m_uv[3].assign(0.5f + cropPad.x, 0.5f - cropPad.y); } void CTextSupportShader::Shutdown() diff --git a/Runtime/Graphics/Shaders/CTextSupportShader.hpp b/Runtime/Graphics/Shaders/CTextSupportShader.hpp index e49a84f69..31636a8dd 100644 --- a/Runtime/Graphics/Shaders/CTextSupportShader.hpp +++ b/Runtime/Graphics/Shaders/CTextSupportShader.hpp @@ -10,6 +10,7 @@ namespace urde { class CGlyph; class CTextRenderBuffer; +class CFontImageDef; class CTextSupportShader { @@ -48,7 +49,7 @@ class CTextSupportShader zeus::CVector3f m_pos[4]; zeus::CVector2f m_uv[4]; zeus::CColor m_color; - void SetMetrics(const zeus::CVector2f& imgSize, const zeus::CVector2i& offset); + void SetMetrics(const CFontImageDef& imgDef, const zeus::CVector2i& offset); }; static hecl::VertexBufferPool s_CharInsts; diff --git a/Runtime/GuiSys/CFontImageDef.cpp b/Runtime/GuiSys/CFontImageDef.cpp index 179a649c2..58abe8372 100644 --- a/Runtime/GuiSys/CFontImageDef.cpp +++ b/Runtime/GuiSys/CFontImageDef.cpp @@ -5,16 +5,16 @@ namespace urde { CFontImageDef::CFontImageDef(const std::vector>& texs, - float interval, const zeus::CVector2f& vec) -: x0_fps(interval), x14_pointsPerTexel(vec) + float interval, const zeus::CVector2f& cropFactor) +: x0_fps(interval), x14_cropFactor(cropFactor) { x4_texs.reserve(texs.size()); for (const TToken& tok : texs) x4_texs.push_back(tok); } -CFontImageDef::CFontImageDef(const TToken& tex, const zeus::CVector2f& vec) -: x0_fps(0.f), x14_pointsPerTexel(vec) +CFontImageDef::CFontImageDef(const TToken& tex, const zeus::CVector2f& cropFactor) +: x0_fps(0.f), x14_cropFactor(cropFactor) { x4_texs.push_back(tex); } @@ -30,13 +30,13 @@ bool CFontImageDef::IsLoaded() const s32 CFontImageDef::CalculateBaseline() const { const CTexture* tex = x4_texs.front().GetObj(); - return s32(tex->GetHeight() * x14_pointsPerTexel.y) * 2.5f / 3.f; + return s32(tex->GetHeight() * x14_cropFactor.y) * 2.5f / 3.f; } s32 CFontImageDef::CalculateHeight() const { const CTexture* tex = x4_texs.front().GetObj(); - s32 scaledH = tex->GetHeight() * x14_pointsPerTexel.y; + s32 scaledH = tex->GetHeight() * x14_cropFactor.y; return scaledH - (scaledH - CalculateBaseline()); } diff --git a/Runtime/GuiSys/CFontImageDef.hpp b/Runtime/GuiSys/CFontImageDef.hpp index 323e1d250..c2ed78bd2 100644 --- a/Runtime/GuiSys/CFontImageDef.hpp +++ b/Runtime/GuiSys/CFontImageDef.hpp @@ -14,11 +14,11 @@ class CFontImageDef public: float x0_fps; std::vector> x4_texs; - zeus::CVector2f x14_pointsPerTexel; + zeus::CVector2f x14_cropFactor; CFontImageDef(const std::vector>& texs, float fps, - const zeus::CVector2f& vec); - CFontImageDef(const TToken& tex, const zeus::CVector2f& vec); + const zeus::CVector2f& cropFactor); + CFontImageDef(const TToken& tex, const zeus::CVector2f& cropFactor); bool IsLoaded() const; s32 CalculateBaseline() const; s32 CalculateHeight() const; diff --git a/Runtime/GuiSys/CGuiSys.cpp b/Runtime/GuiSys/CGuiSys.cpp index 03e078236..63075311a 100644 --- a/Runtime/GuiSys/CGuiSys.cpp +++ b/Runtime/GuiSys/CGuiSys.cpp @@ -84,12 +84,12 @@ void CGuiSys::ViewportResizeFrame(CGuiFrame* frame) if (vpAspectRatio >= frame->m_aspectConstraint) { hPad = frame->m_aspectConstraint / vpAspectRatio; - vPad = frame->m_aspectConstraint / 1.36f; + vPad = frame->m_aspectConstraint / 1.38f; } else { hPad = 1.f; - vPad = vpAspectRatio / 1.36f; + vPad = vpAspectRatio / 1.38f; } frame->m_aspectTransform = zeus::CTransform::Scale({hPad, 1.f, vPad}); } diff --git a/Runtime/GuiSys/CInstruction.cpp b/Runtime/GuiSys/CInstruction.cpp index 9de7295a7..00012b50d 100644 --- a/Runtime/GuiSys/CInstruction.cpp +++ b/Runtime/GuiSys/CInstruction.cpp @@ -252,11 +252,11 @@ void CImageInstruction::Invoke(CFontRenderState& state, CTextRenderBuffer* buf) zeus::CVector2i coords(state.xd4_curX, y); buf->AddImage(coords, x4_image); } - state.xd4_curX = state.xd4_curX + tex->GetWidth() * x4_image.x14_pointsPerTexel.y; + state.xd4_curX = state.xd4_curX + tex->GetWidth() * x4_image.x14_cropFactor.y; } else { - int scale = state.xdc_currentLineInst->x8_curX - tex->GetWidth() * x4_image.x14_pointsPerTexel.y; + int scale = state.xdc_currentLineInst->x8_curX - tex->GetWidth() * x4_image.x14_cropFactor.y; if (buf) { zeus::CVector2i coords(scale / 2 + state.xd4_curX, state.xd8_curY); diff --git a/Runtime/GuiSys/CTextExecuteBuffer.cpp b/Runtime/GuiSys/CTextExecuteBuffer.cpp index 5961f9892..1586c3b1a 100644 --- a/Runtime/GuiSys/CTextExecuteBuffer.cpp +++ b/Runtime/GuiSys/CTextExecuteBuffer.cpp @@ -387,8 +387,8 @@ void CTextExecuteBuffer::AddImage(const CFontImageDef& image) if (xa0_curBlock) { const CTexture* tex = image.x4_texs[0].GetObj(); - int width = tex->GetWidth() * image.x14_pointsPerTexel.x; - int height = tex->GetHeight() * image.x14_pointsPerTexel.y; + int width = tex->GetWidth() * image.x14_cropFactor.x; + int height = tex->GetHeight() * image.x14_cropFactor.y; if (xa4_curLine->x8_curX + width > xa0_curBlock->xc_blockExtentX && xa4_curLine->x4_wordCount > 0) StartNewLine(); diff --git a/Runtime/GuiSys/CTextParser.cpp b/Runtime/GuiSys/CTextParser.cpp index 657fd294f..11f3559ec 100644 --- a/Runtime/GuiSys/CTextParser.cpp +++ b/Runtime/GuiSys/CTextParser.cpp @@ -250,11 +250,11 @@ CFontImageDef CTextParser::GetImage(const char16_t* str, int len) AdvanceTokenPos(); AdvanceCommaPos(); - float scaleX = u16stof(&iterable[tokenPos]); + float cropX = u16stof(&iterable[tokenPos]); AdvanceTokenPos(); AdvanceCommaPos(); - float scaleY = u16stof(&iterable[tokenPos]); + float cropY = u16stof(&iterable[tokenPos]); AdvanceTokenPos(); std::vector> texs; @@ -267,17 +267,17 @@ CFontImageDef CTextParser::GetImage(const char16_t* str, int len) AdvanceTokenPos(); } while (commaPos != iterable.size()); - return CFontImageDef(texs, interval, zeus::CVector2f(scaleX, scaleY)); + return CFontImageDef(texs, interval, zeus::CVector2f(cropX, cropY)); } else if (BeginsWith(str, len, u"SI")) { /* Scaled single texture */ AdvanceCommaPos(); - float scaleX = u16stof(&iterable[tokenPos]); + float cropX = u16stof(&iterable[tokenPos]); AdvanceTokenPos(); AdvanceCommaPos(); - float scaleY = u16stof(&iterable[tokenPos]); + float cropY = u16stof(&iterable[tokenPos]); AdvanceTokenPos(); AdvanceCommaPos(); @@ -285,7 +285,7 @@ CFontImageDef CTextParser::GetImage(const char16_t* str, int len) GetAssetIdFromString(&iterable[tokenPos])}); AdvanceTokenPos(); - return CFontImageDef(tex, zeus::CVector2f(scaleX, scaleY)); + return CFontImageDef(tex, zeus::CVector2f(cropX, cropY)); } } diff --git a/Runtime/GuiSys/CTextRenderBuffer.cpp b/Runtime/GuiSys/CTextRenderBuffer.cpp index d6c67b8c7..a170bf178 100644 --- a/Runtime/GuiSys/CTextRenderBuffer.cpp +++ b/Runtime/GuiSys/CTextRenderBuffer.cpp @@ -18,15 +18,7 @@ CTextRenderBuffer::CTextRenderBuffer(EMode mode, CGuiWidget::EGuiModelDrawFlags CTextRenderBuffer::BooImage::BooImage(const CFontImageDef& imgDef, const zeus::CVector2i& offset) : m_imageDef(imgDef) { - zeus::CVector2f imgSize; - if (imgDef.x4_texs.size()) - { - const CTexture& tex = *imgDef.x4_texs[0].GetObj(); - imgSize.assign(tex.GetWidth() * imgDef.x14_pointsPerTexel.x, - tex.GetHeight() * imgDef.x14_pointsPerTexel.y); - } - - m_imageData.SetMetrics(imgSize, offset); + m_imageData.SetMetrics(imgDef, offset); } void CTextRenderBuffer::BooPrimitiveMark::SetOpacity(CTextRenderBuffer& rb, float opacity)