Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Overlay: TextArea - draw missing space & deprecate space_width property #2910

Merged
merged 1 commit into from
Aug 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.