HISE Logo Forum
    • Categories
    • Register
    • Login

    Get text length in pixels?

    Scheduled Pinned Locked Moved Scripting
    3 Posts 2 Posters 145 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • T
      tomekslesicki
      last edited by

      I'm wondering if it's possible to get a reference to a length of text rendered on a panel?

      So in this case:

      g.drawAlignedText("Hello world", [0,0, this.getWidth(), this.getHeight()], "left");
      

      ...get to calculate the length of the "Hello world" text, and use that reference elsewhere?

      Christoph HartC 1 Reply Last reply Reply Quote 0
      • Christoph HartC
        Christoph Hart @tomekslesicki
        last edited by

        const var s = Engine.getStringWidth("Hello world", "Comic Sans MS", 15.0, 0.05);
        
        Console.print(s);
        

        Link Preview Image
        HISE | Scripting | Engine

        An API class for accessing global properties.

        favicon

        (docs.hise.audio)

        T 1 Reply Last reply Reply Quote 3
        • T
          tomekslesicki @Christoph Hart
          last edited by

          @Christoph-Hart perfect, thank you!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post

          25

          Online

          1.8k

          Users

          12.0k

          Topics

          104.8k

          Posts