DrawText

The DrawText struct is used for rendering text with various styles and properties in Makepad. It includes options for geometry, text style, wrapping, and various rendering details.

Properties

decoratenametypedescription
rustmany_instancesOption<ManyInstances>Optional instance data for drawing many text objects.
livegeometryGeometryQuad2DThe geometry used for rendering the text.
livetext_styleTextStyleThe style of the text, including font and size.
livewrapTextWrapSpecifies how text should wrap within its container.
liveignore_newlinesboolDetermines whether newlines in the text should be ignored.
livecombine_spacesboolSpecifies whether multiple consecutive spaces should be combined into one.
livefont_scalef64The scale factor for the font size. Default is 1.0.
livedraw_depthf32The drawing depth for layering text. Default is 1.0.
derefdraw_varsDrawVarsVarious variables used during the drawing process.
livecolorVec4The color of the text.
calcfont_t1Vec2Calculated texture coordinate t1 for the font.
calcfont_t2Vec2Calculated texture coordinate t2 for the font.
calcrect_posVec2Calculated position of the text rectangle.
calcrect_sizeVec2Calculated size of the text rectangle.
calcdraw_clipVec4Calculated clipping area for the text drawing.
calcchar_depthf32Calculated depth for individual characters.
calcdeltaVec2Calculated delta for text positioning.
calcshader_font_sizef32Calculated font size for the shader.
calcadvancef32Calculated advance value for text positioning.

See Vec2

See TextStyle

See TextWrap

See DrawVars

Example

#![allow(unused)]
fn main() {
draw_text: {
    wrap: Word,
    // real font size = font size * font scale
    font_scale: 1.5,
    text_style: {
        // so here font size = 16 * 1.5 = 24
        font_size: 16,
        font: {path: dep("crate://makepad-widgets/resources/IBMPlexSans-SemiBold.ttf")},
        // brightness > 1.0 will make the text brighter
        // < 1.0 will make the text darker
        brightness: 1.0,
    },
    color: #FF0000,
}
}