Skip to content

Commit

Permalink
Fix incorrect underlines rendering for empty lines in image editor.
Browse files Browse the repository at this point in the history
Fixes #12807
Closes #12808
  • Loading branch information
bijaykumarpun authored and greyson-signal committed Mar 4, 2023
1 parent b437cb0 commit 5634e98
Showing 1 changed file with 12 additions and 8 deletions.
Expand Up @@ -320,9 +320,9 @@ public void render(@NonNull RendererContext rendererContext) {
rendererContext.canvasMatrix.concat(projectionMatrix);

if (mode == Mode.HIGHLIGHT) {
if(text.isEmpty()){
if (text.isEmpty()) {
modeBounds.setEmpty();
}else{
} else {
modeBounds.set(textBounds.left - HIGHLIGHT_HORIZONTAL_PADDING,
selectionBounds.top - HIGHLIGHT_TOP_PADDING,
textBounds.right + HIGHLIGHT_HORIZONTAL_PADDING,
Expand All @@ -333,13 +333,17 @@ public void render(@NonNull RendererContext rendererContext) {
rendererContext.canvas.drawRoundRect(modeBounds, HIGHLIGHT_CORNER_RADIUS, HIGHLIGHT_CORNER_RADIUS, modePaint);
modePaint.setAlpha(alpha);
} else if (mode == Mode.UNDERLINE) {
modeBounds.set(textBounds.left, selectionBounds.top, textBounds.right, selectionBounds.bottom);
modeBounds.inset(-DimensionUnit.DP.toPixels(2), -DimensionUnit.DP.toPixels(2));
if (text.isEmpty()) {
modeBounds.setEmpty();
} else {
modeBounds.set(textBounds.left, selectionBounds.top, textBounds.right, selectionBounds.bottom);
modeBounds.inset(-DimensionUnit.DP.toPixels(2), -DimensionUnit.DP.toPixels(2));

modeBounds.set(modeBounds.left,
Math.max(modeBounds.top, modeBounds.bottom - DimensionUnit.DP.toPixels(6)),
modeBounds.right,
modeBounds.bottom - DimensionUnit.DP.toPixels(2));
modeBounds.set(modeBounds.left,
Math.max(modeBounds.top, modeBounds.bottom - DimensionUnit.DP.toPixels(6)),
modeBounds.right,
modeBounds.bottom - DimensionUnit.DP.toPixels(2));
}

int alpha = modePaint.getAlpha();
modePaint.setAlpha(rendererContext.getAlpha(alpha));
Expand Down

0 comments on commit 5634e98

Please sign in to comment.