HISE Logo Forum
    • Categories
    • Register
    • Login

    Scaling text without squashing it horizontally

    Scheduled Pinned Locked Moved Solved General Questions
    13 Posts 3 Posters 373 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.
    • d.healeyD
      d.healey @cynthasiser
      last edited by

      @cynthasiser If it's in a label change the height of the label. If it's in a paint routine change the height of the area.

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

      C 1 Reply Last reply Reply Quote 0
      • C
        cynthasiser @d.healey
        last edited by cynthasiser

        @d-healey that doesn't change the scaling though? it only changes how much of the text is visible:

        9d5a744b-82d2-4ce9-8d27-98ba677325b0-image.png

        (the example is in a label)

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

          @cynthasiser Post a snippet

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

          C 1 Reply Last reply Reply Quote 0
          • C
            cynthasiser @d.healey
            last edited by

            @d-healey I'm not sure what the snippet would show? It's standard HISE behaviour (at least on my computer) that text boxes try to scale text horizontally but not vertically.

            hise text scaling.gif

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

              @cynthasiser I see the issue. If changing the font size doesn't help you'll need to draw it in a panel instead of using a label.

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

              C 1 Reply Last reply Reply Quote 0
              • C
                cynthasiser @d.healey
                last edited by

                @d-healey

                You get the same horizontal squishing behaviour even in a panel though:

                877a7c18-c218-4d6e-a0b8-f5249794b2b1-image.png

                Updating the font size would work, but I'd have to somehow know exactly how many pixels the text would take up to know if I needed to scale it down.

                e.g.
                If I had a text box that's 200 pixels wide and the sentence "the quick brown fox jumped over the lazy dog" in Arial at 20pt size. Let's pretend this sentence would take up 220 pixels of screen space. I'd want to write a for loop that keeps decreasing the font size until the sentence was less than 200 pixels wide.

                But how would I check the "pixel width" of a given text string in a given font?

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

                  @cynthasiser said in Scaling text without squashing it horizontally:

                  But how would I check the "pixel width" of a given text string in a given font?

                  g.getStringWidth()

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

                  C 1 Reply Last reply Reply Quote 1
                  • C
                    cynthasiser @d.healey
                    last edited by

                    @d-healey ah that's great news, I'll give it a go! thank you!

                    C 1 Reply Last reply Reply Quote 0
                    • C
                      cynthasiser @cynthasiser
                      last edited by

                      @cynthasiser

                      Yep, that's perfect, thanks!

                      96dfa4ec-49c0-4af0-912d-13797aef0ae1-image.png

                      mmprodM 1 Reply Last reply Reply Quote 1
                      • C cynthasiser has marked this topic as solved on
                      • mmprodM
                        mmprod @cynthasiser
                        last edited by

                        @cynthasiser is it possible to make the text add … at the end of the string when the text is too long? Rather than changing size

                        For God so loved the world that he gave his one and only Son, that whoever believes in him shall not perish but have eternal life.
                        John 3:16

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

                          @mmprod Yes, I think if you use drawFittedText it does this

                          Edit, yup that's it

                          HiseSnippet 831.3ocsUstSaCCE1tPPztwzPZO.Q7qvDppEJ2DZZL5kQ0nP0RGh+gbcbZsHwtJ1AnZhGk8Nt2fsiiaokQEWpzhpR74l8WOmuywsSjTlRISP3BcFNfgvu0wenP2uZeBWfZVCgemSKhRyRbspNZ3.hRwBPX7Be0n.meQT1yu+7QjHhfxlnBgNWxorS3wb8DssO7a7nnFj.VGd7TdW4vlTonpLRlB3YAmRnAD5UjdrSIF2x4fNln5ivezoKoaIBMLbmM6tWXoJat8lc6VInBno6t6u+9gaWlr8V6RoH7R0C3ZYhulnYJXSORFLzuu7Fg8.Nmq3ciXFgxHe3jspQU6yiBZON4nPH7hsmjpVvlp9fSKd.+d8SRYuOyf6jHlNogy8TPp7q.R3ofzhVHspiOMgOPOwhAOuwoo.pfgDn1LMTr9hx8KrSUI3gPWLlbEqQBHbeDd6TpzFtvq0OnPAn9nztWSRbaSDrnxtexcbj8X5px3ARAH3sl07ZlXrKKpX51PBR+cYplKXdgoBplKEd8VuvOKj2rmDX6z84JydchjRhNRlJBTdliNeg78L6gkd3Y+nJdSetlYL2qXPB4lFbslEzgcK.gNG2z2E94eVq5tcpeQm01vkrg6ZQrPMrrbwRYux166V+fw3wUJNUpYmI7xvUg6J39ulBCmoMSlHQFEwRloYCYO4oBzSjF2kkrAjeiRY26HTbeHiYoWFigZKLS4nTzTv0mMfMRtgLJvvDLqeL+BMpxBq9QyZDMwP4FoC7a.KQyMvAWicMzjaIf4cpwTWokCx7cDc.9GnyrtxX5ogRf3vQurikdftEgcvWBm0PyBur4DOhdCMVxfzHh9gcal4PiL.IzGPwMzXghqGN8bpWQKXomrE7kBwUcZy0z9yFi4lAFgT8+CLNZv0JN0CCYT8D.tnSiKl2oTOywa6260hnS3lh7oow9PqKkAmt.J8JS8NmgtYkKYjMY.elHHS3OvyHikMx3QFKO1HJlPSjWRssQlQiKmoAvjH6pi7vcXfraYTVq0z44XXR8klaJldqdTfaNuAt07FXk4Mvsm2.2YdCb24Mv8d9.MWj9kTsL111fPsZWOaVDFWWP.FXFaE8WP469lt
                          

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

                          mmprodM 1 Reply Last reply Reply Quote 0
                          • mmprodM
                            mmprod @d.healey
                            last edited by

                            @d-healey awesome, thank you

                            For God so loved the world that he gave his one and only Son, that whoever believes in him shall not perish but have eternal life.
                            John 3:16

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

                            45

                            Online

                            1.7k

                            Users

                            11.7k

                            Topics

                            102.0k

                            Posts