HISE Logo Forum
    • Categories
    • Register
    • Login

    How many lines were written?

    Scheduled Pinned Locked Moved Unsolved Scripting
    9 Posts 3 Posters 425 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.
    • Oli UllmannO
      Oli Ullmann
      last edited by

      Hello everyone :-)

      If I use Graphics.drawMultiLineText(), is there any way to find out how many lines the written text needs?

      Thank you very much
      Oli

      A 1 Reply Last reply Reply Quote 0
      • A
        aaronventure @Oli Ullmann
        last edited by

        @Oli-Ullmann since you need to use \n, you can use a string variable which you're then plugging into the method call (as opposed to just writing it directly in the argument) and simply count the number of backslashes in the string

        d.healeyD 1 Reply Last reply Reply Quote 0
        • d.healeyD
          d.healey @aaronventure
          last edited by

          @aaronventure I think with multiline text it automatically splits the text without the need for a return character.

          Libre Wave - Freedom respecting instruments and effects
          My Patreon - HISE tutorials
          YouTube Channel - Public HISE tutorials

          A 1 Reply Last reply Reply Quote 0
          • A
            aaronventure @d.healey
            last edited by

            @d-healey but you can use it, and then use it to count the number of lines.

            d.healeyD 1 Reply Last reply Reply Quote 0
            • d.healeyD
              d.healey @aaronventure
              last edited by d.healey

              @aaronventure But the point of using drawMultilineText is you don't know how many lines you want - you don't know where you need to break, you want it to happen automatically based on the size of the rectangle and font.

              If you're manually putting in line breaks then you don't need to count them because you know how many you have, and you should probably use the markdown renderer instead.

              HiseSnippet 1010.3ocsVstaZbDEdVr2nXZSUiTe.FwufJDEbrM0JpsNFa2fpwAUbRqTUTzvtGXG4YmYyLm01np7.02t9FzdlcACt1xIAoxOVMmqy2dt7sLzZh.myXYAUOeVFvB9xvQyzXRuDgTy5eDK3qBGHbHX4kpNbVlv4fXVPvF+rWQvVaxJ982+zgBkPGAKUwXuwHifSkoRbo1gG7KRk5DQLbtLcEu24f9QFcOixjS3Yiv1rLQzEhovYBuaUBYuT3RXAeaX616tKDsc2chmPG2SPOf82e79c51sy9c1d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ting instruments and effects
              My Patreon - HISE tutorials
              YouTube Channel - Public HISE tutorials

              A Oli UllmannO 2 Replies Last reply Reply Quote 1
              • A
                aaronventure @d.healey
                last edited by

                @d-healey You're completely right, somehow I missed the point.

                Hmm, there's Graphics.getStringWidth(), you can put in your string, get the width and divide it by the text area width. Though it won't break the words properly...

                Maybe you can come up with an algo that loops through the string checking the length word by word, and when the total width at that point becomes more than maxWidth of the text method, then you can guess that it'll break the line at that word, and start counting the string again from that word onward until you get to another point where you have more width than maxWidth.

                1 Reply Last reply Reply Quote 0
                • Oli UllmannO
                  Oli Ullmann @d.healey
                  last edited by

                  @d-healey
                  Thank you. I will try the markdown renderer.

                  @aaronventure
                  There is also Engine.getStringWidth. I had also considered solving the problem with a bit of math. I probably won't be able to avoid it. Thanks for your ideas! :-)

                  d.healeyD A 2 Replies Last reply Reply Quote 0
                  • d.healeyD
                    d.healey @Oli Ullmann
                    last edited by

                    @Oli-Ullmann Perhaps there is another solution, why do you want to know the number of lines?

                    Libre Wave - Freedom respecting instruments and effects
                    My Patreon - HISE tutorials
                    YouTube Channel - Public HISE tutorials

                    1 Reply Last reply Reply Quote 0
                    • A
                      aaronventure @Oli Ullmann
                      last edited by

                      @Oli-Ullmann yes but the Graphics method takes in your current font for accurate string width

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

                      31

                      Online

                      1.8k

                      Users

                      12.0k

                      Topics

                      104.1k

                      Posts