# Truncate text in the beginning instead of at the end

**URL:** <https://openrndr.discourse.group/t/truncate-text-in-the-beginning-instead-of-at-the-end/760>\
**Category:** Beginners\
**Created:** [October 11, 2025, 9:31am UTC](https://openrndr.discourse.group/t/truncate-text-in-the-beginning-instead-of-at-the-end/760 "2025-10-11T09:31:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![woodwindblues](https://avatars.discourse-cdn.com/v4/letter/w/ba8739/32.png) [@woodwindblues](https://openrndr.discourse.group/u/woodwindblues)\
**Post date:** [October 11, 2025, 9:31am UTC](https://openrndr.discourse.group/t/truncate-text-in-the-beginning-instead-of-at-the-end/760/1 "2025-10-11T09:31:08Z")

</div>

Hello everyone!

I am working on a small visualization for a installation. Part of it is a continuously growing text. I didn’t have any problems setting up a `writer` with a `box` to render the text into. However, when the text grows to long it gets truncated at the end. I tried setting `verticalAlign` to `1.0`, but even then the text gets truncated at the end when the box is full.

Is there any way to truncate the text at the beginning instead, so that new additions to the text are always visible?

---

<div class="post-metadata">

**Author:** ![abe](https://yyz2.discourse-cdn.com/free1/user_avatar/openrndr.discourse.group/abe/32/700_2.png) [@abe](https://openrndr.discourse.group/u/abe)\
**Post date:** [October 11, 2025, 4:41pm UTC](https://openrndr.discourse.group/t/truncate-text-in-the-beginning-instead-of-at-the-end/760/2 "2025-10-11T16:41:26Z")

</div>

Hi hi! Nice to see you back 🙂 Would it work to avoid drawing everything except the last lines?

If you have the lines in a list, you could do `list.takeLast(10)`or similar.

```kotlin
import org.openrndr.application
import org.openrndr.color.ColorRGBa
import org.openrndr.draw.loadFont
import org.openrndr.extra.textwriter.writer
import org.openrndr.math.Vector2
import org.openrndr.shape.Rectangle

fun main() = application {
    configure {
        width = 380
        height = 380
    }
    program {
        val area = Rectangle(40.0, 40.0, 300.0, 300.0)
        val font = loadFont("data/fonts/default.otf", 24.0)
        val lines = mutableListOf("")
        extend {
            drawer.clear(ColorRGBa.PINK)
            drawer.fill = null
            drawer.rectangle(area.movedBy(Vector2(-5.0, 0.0)))

            drawer.fontMap = font
            drawer.fill = ColorRGBa.BLACK

            if (lines.last().length > 25) {
                lines.add("")
            } else {
                lines[lines.lastIndex] += "[-]+ (){}".random()
            }

            writer {
                box = area
                // draw only the last 12 lines
                lines.takeLast(12).forEach {
                    newLine()
                    text(it)
                }
            }
        }
    }
}

```

---

<div class="post-metadata">

**Author:** ![woodwindblues](https://avatars.discourse-cdn.com/v4/letter/w/ba8739/32.png) [@woodwindblues](https://openrndr.discourse.group/u/woodwindblues)\
**Post date:** [October 12, 2025, 2:01pm UTC](https://openrndr.discourse.group/t/truncate-text-in-the-beginning-instead-of-at-the-end/760/3 "2025-10-12T14:01:01Z")

</div>

Ah yes, that works! Thank you!
