HISE Logo Forum
    • Categories
    • Register
    • Login

    Text Kerning / Character Spacing?

    Scheduled Pinned Locked Moved General Questions
    12 Posts 2 Posters 597 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.
    • E
      ericchesek
      last edited by

      Hi all,

      Is there control over the space between each character when using drawText in a paint routine?

      Thanks!

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

        @ericchesek Use g.setFontWithSpacing()

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

        E 1 Reply Last reply Reply Quote 1
        • E
          ericchesek @d.healey
          last edited by

          @d-healey Excellent! Now if I want to get the width of that text, getStringWidth doesn't work anymore. Is there an alternative for that?

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

            @ericchesek g.getStringWidth()?

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

            E 1 Reply Last reply Reply Quote 0
            • E
              ericchesek @d.healey
              last edited by

              @d-healey Are you suggesting to keep using that, or asking for clarification? I am using g.getStringWidth("TEXT"); after setting the font using g.setFontWithSpacing(). The value of g.getStringWidth stays the same as if the spacing was set to 0.

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

                @ericchesek I was asking for clarification because there is also Engine.getStringWidth() - don't know if that will work...

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

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

                  Actually g.getStringWidth() works here

                  HiseSnippet 862.3ocsV01aSCCD1taAQKuHPhe.Q8SYRSUsvXLIDhw5KPEcqkkwFeC4k3lXMG6nXmsUglD+j4e.bNN8M1z1nRjOTk6dty9wmetK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ecting instruments and effects
                  My Patreon - HISE tutorials
                  YouTube Channel - Public HISE tutorials

                  E 1 Reply Last reply Reply Quote 1
                  • E
                    ericchesek @d.healey
                    last edited by

                    @d-healey Oops. You are right. Something else must be wrong in my code. Thanks!
                    I'm off to debug. :)

                    1 Reply Last reply Reply Quote 0
                    • E
                      ericchesek
                      last edited by ericchesek

                      I see the source of my confusion.
                      Using g.setFontWithSpacing(font, size, spacing); results in a length of spacing at the end of the string.

                      For example, if I write
                      g.getStringWidth("TEXT");
                      I expect TEXT's width and spacing (shown with underscores) to be calculated as T_E_X_T.
                      Instead, it is calculated as T_E_X_T_.

                      So using
                      g.drawAlignedText("TEXT", [0, 0, this.getWidth(), this.getHeight()], "centred"); doesn't actually center the text due to that kerning offset.

                      1 Reply Last reply Reply Quote 1
                      • E
                        ericchesek
                        last edited by

                        Might anyone know how to calculate that extra bit of kerning so I can account for it?

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

                          @ericchesek Perhaps calculate the width of 1 space separately and deduct it from the total width?

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

                          E 1 Reply Last reply Reply Quote 1
                          • E
                            ericchesek @d.healey
                            last edited by

                            @d-healey Hmm this might work for monospace fonts, but I get different results based on getting the string width of a space or any character. I don't see why the kerning adds a space at the end of a string. I don't think this is common.

                            Maybe Christoph can provide some insight? @Christoph-Hart

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

                            43

                            Online

                            1.7k

                            Users

                            11.7k

                            Topics

                            101.9k

                            Posts