diff --git a/h2d/RenderContext.hx b/h2d/RenderContext.hx index 86a1413bef..8389b4832d 100644 --- a/h2d/RenderContext.hx +++ b/h2d/RenderContext.hx @@ -544,10 +544,22 @@ class RenderContext extends h3d.impl.RenderContext { var ry1 = x * fb.x + y * fb.y + fb.z; var rx2 = x2 * fa.x + y2 * fa.y + fa.z; var ry2 = x2 * fb.x + y2 * fb.y + fb.z; - x = rx1; - y = ry1; - w = rx2 - rx1; - h = ry2 - ry1; + // The filter matrix lands in the filter texture's own pixels (it already + // carries the filter's resolution), but measured from the filtered + // object's origin, while the texture starts at the (xMin, yMin) it was + // pushed with (Object.drawFilters) - which pushTarget folded into + // viewX/viewY. Measured from the scene viewport instead, the zone sat + // that far off (a blur's boundsExtend, 2px up and left) and scaled + // a second time by the viewport. + var startX = -(viewX + 1) / viewA; + var startY = -(viewY + 1) / viewD; + engine.setRenderZone( + Std.int(rx1 - startX + 1e-10), + Std.int(ry1 - startY + 1e-10), + Std.int(rx2 - rx1 + 1e-10), + Std.int(ry2 - ry1 + 1e-10) + ); + return; } engine.setRenderZone( diff --git a/h2d/Text.hx b/h2d/Text.hx index 34e1c42310..6f064cd345 100644 --- a/h2d/Text.hx +++ b/h2d/Text.hx @@ -352,6 +352,8 @@ class Text extends Drawable { } else { maxWidth -= afterData; } + if (maxWidth <= 2) + return text; if ( font == null ) font = this.font; var lines = []; var x = leftMargin; @@ -385,7 +387,7 @@ class Text extends Drawable { x += esize; prevChar = cc; if( lineBreak ) { - if( x > maxWidth && lastBreak >= 0 && (!trimTrailingSpaces || !font.charset.isSpace(cc) || startX > maxWidth) ) { + if( x > maxWidth && lastBreak >= lastPos && (!trimTrailingSpaces || !font.charset.isSpace(cc) || startX > maxWidth) ) { i = lastBreak; x = lastBreakX; flushLine(i + 1); diff --git a/h2d/TextInput.hx b/h2d/TextInput.hx index 316a1d35b5..1b8127b955 100644 --- a/h2d/TextInput.hx +++ b/h2d/TextInput.hx @@ -289,11 +289,11 @@ class TextInput extends Text { return; case K.C if (K.isDown(K.CTRL)): if( text != "" && selectionRange != null ) { - hxd.System.setClipboardText(text.substr(selectionRange.start, selectionRange.length)); + hxd.System.setClipboardText(getSelectedText()); } case K.X if (K.isDown(K.CTRL)): if( text != "" && selectionRange != null ) { - if(hxd.System.setClipboardText(text.substr(selectionRange.start, selectionRange.length))) { + if(hxd.System.setClipboardText(getSelectedText())) { if( !canEdit ) return; beforeChange(); cutSelection(); @@ -435,9 +435,13 @@ class TextInput extends Text { if (cursorIndex >= len) { return len; } + // ret walks the text itself, so it stops at the end of the TEXT: getTextLength + // is the expanded length, longer than the text by one per inserted line break, + // and bounding a text position with it runs past the end. + var max = text.length; var ret = getTextPos(cursorIndex); - while (ret < len && isWordLimit(ret)) ret++; - while (ret < len && !isWordLimit(ret)) ret++; + while (ret < max && isWordLimit(ret)) ret++; + while (ret < max && !isWordLimit(ret)) ret++; return getCursorPos(ret); }