Giter Club home page Giter Club logo

Comments (4)

vlauffer avatar vlauffer commented on July 22, 2024

The WrappedText widget can take a height parameter (widget doc)

If you set it to your desired height you should be good to go.

This might throw off the centering of the text, but here's your code with some padding. Note: was using the CG-pixel-3x5-mono font.

def display_error(msg):

    return render.Root(
        child = render.Row(
            children = [
                render.Box(
                    width = 20, 
                    height = 32, 
                    color = "#000",
                    child = render.Image(
                        src = ERROR_ICON, 
                        width = 16, 
                        height = 16
                    )
                ),
                render.Box(
                    child = render.Padding(
                        pad = (0,10,0,0),
                        child = render.WrappedText(
                            height = 32,
                            content = msg, 
                            color = "#FFF", 
                            linespacing = 1,                        
                            font = "CG-pixel-3x5-mono",
                        )
                    ),
                ),               
            ],
        ),
    )

Hope this helps! If it doesn't work plz lmk

from pixlet.

LukiLeu avatar LukiLeu commented on July 22, 2024

Hi @vlauffer
Thanks for your response. I was aware of the height parameter, and I agree with you that it works with that parameter. And as you suggested, with some padding, one might get also the centering correct.
However, this approach does not solve the bug that produces the erroneus output. While your approach works, it still requires manual fine tuning. I would therefore say, your approach is a workaround until that bug is fixed.

from pixlet.

vlauffer avatar vlauffer commented on July 22, 2024

@LukiLeu just realized you mentioned the height parameter in the very first sentence of the original post (facepalm) my bad. I see what you mean now though. I'm pretty interested in finding out why the text gets cut off without a set height, and why setting height relocates the text to the top instead of center...

I'm very new to Go and Starlark but I'm gonna try to figure out why this happens.

adding these links here incase I lose them:

wrappedtext doc, DrawStringWrapped function, font metrics

from pixlet.

LukiLeu avatar LukiLeu commented on July 22, 2024

My guess is, that the linespacing is not added to an internal calculated height and only the bare height of the font multiplied with the nunber of lines is used

from pixlet.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.