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

Fixed DirectX RTL text issue where it'd be over other text / offscreen #1873

Merged
merged 8 commits into from
Jul 10, 2019
16 changes: 12 additions & 4 deletions src/renderer/dx/CustomTextLayout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,16 @@ CustomTextLayout::CustomTextLayout(IDWriteFactory2* const factory,
glyphRunDescription.stringLength = run.textLength;
glyphRunDescription.textPosition = run.textStart;

// Calculate the position *after* drawing, this will be used if we're in RTL.
miniksa marked this conversation as resolved.
Show resolved Hide resolved
// Original comment:
miniksa marked this conversation as resolved.
Show resolved Hide resolved
// Shift origin to the right for the next run based on the amount of space consumed.
auto postOriginX = std::accumulate(_glyphAdvances.begin() + run.glyphStart,
schorrm marked this conversation as resolved.
Show resolved Hide resolved
_glyphAdvances.begin() + run.glyphStart + run.glyphCount,
mutableOrigin.x);

if (WI_IsFlagSet(glyphRun.bidiLevel, 1))
miniksa marked this conversation as resolved.
Show resolved Hide resolved
mutableOrigin.x = postOriginX;

// Try to draw it
RETURN_IF_FAILED(renderer->DrawGlyphRun(clientDrawingContext,
mutableOrigin.x,
Expand All @@ -507,10 +517,8 @@ CustomTextLayout::CustomTextLayout(IDWriteFactory2* const factory,
&glyphRunDescription,
nullptr));

// Shift origin to the right for the next run based on the amount of space consumed.
mutableOrigin.x = std::accumulate(_glyphAdvances.begin() + run.glyphStart,
_glyphAdvances.begin() + run.glyphStart + run.glyphCount,
mutableOrigin.x);
mutableOrigin.x = postOriginX;

}
}
CATCH_RETURN();
Expand Down