Skip to content

Commit

Permalink
Overlay: TextArea - draw missing space & deprecate space_width property
Browse files Browse the repository at this point in the history
  • Loading branch information
paroj committed Aug 5, 2023
1 parent f87a07c commit 517f74e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
3 changes: 3 additions & 0 deletions Components/Overlay/src/OgreOverlayTranslator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,9 @@ void ElementTranslator::translate(ScriptCompiler* compiler, const AbstractNodePt
succ = getString(prop->values.front(), &val);
}

if(prop->name == "space_width")
compiler->addError(ScriptCompiler::CE_DEPRECATEDSYMBOL, prop->file, prop->line, prop->name);

if(!succ || !newElement->setParameter(prop->name, val))
compiler->addError(ScriptCompiler::CE_INVALIDPARAMETERS, prop->file, prop->line);
}
Expand Down
18 changes: 11 additions & 7 deletions Components/Overlay/src/OgreTextAreaOverlayElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,11 +245,6 @@ namespace Ogre {
float left = _getDerivedLeft() * 2.0f - 1.0f;
float top = -( (_getDerivedTop() * 2.0f ) - 1.0f );

if(!mSpaceWidth)
{
mSpaceWidth = mFont->getGlyphInfo(UNICODE_SPACE).advance * mCharHeight;
}

// Use iterator
auto iend = decoded.end();
bool newLine = true;
Expand All @@ -267,7 +262,7 @@ namespace Ogre {
{
break;
}
else if (character == UNICODE_SPACE) // space
else if (character == UNICODE_SPACE && mSpaceWidth) // space
{
len += mSpaceWidth * 2.0f * mViewportAspectCoef;
}
Expand Down Expand Up @@ -310,7 +305,7 @@ namespace Ogre {
}
continue;
}
else if (character == UNICODE_SPACE) // space
else if (character == UNICODE_SPACE && mSpaceWidth) // space
{
// Just leave a gap, no tris
left += mSpaceWidth * 2.0f * mViewportAspectCoef;
Expand All @@ -323,6 +318,15 @@ namespace Ogre {
Real horiz_height = glyphInfo.aspectRatio * mViewportAspectCoef ;
const Font::UVRect& uvRect = glyphInfo.uvRect;

if(uvRect.isNull())
{
// Just leave a gap, no tris
left += glyphInfo.advance * mCharHeight * 2.0f * mViewportAspectCoef;
// Also reduce tri count
mRenderOp.vertexData->vertexCount -= 6;
continue;
}

left += glyphInfo.bearing * mCharHeight * 2 * mViewportAspectCoef;

// each vert is (x, y, z, u, v)
Expand Down
Binary file modified Media/packs/SdkTrays.zip
Binary file not shown.

0 comments on commit 517f74e

Please sign in to comment.