Font kerning

HidetoKoudanshi

  • Posts: 112
I've got a rather swoopy cursive font I'd like to use in my projects but when I import it, the letters are too far apart due to those long swoops. In regular use in say, a word processor, the lowercase letters tuck up under next to the upper case letters, resting underneath the swirly, swoopy curves this font has. In Stencyl, the outer edge of the swoops is considered to be the full size of the letter and thus all letters are spaced accordingly.

Is that something that can be done now or with work in time? I'd like to be able to shorten or length the kerning, or distance between letters, so they could even overlap if I wanted.
If I ever commission you for code work, please know that I understand how commissioning works. You must get paid first before you will code anything for me. Only once you are paid the agreed-upon price, will you begin coding for me. I respect artists and coders. You deserve to be paid for your hard efforts.

Stevetheipad

  • Posts: 1304
I'd like to see this be an option.

Photics

  • *
  • Posts: 719
Is that something that can be done now or with work in time? I'd like to be able to shorten or length the kerning, or distance between letters, so they could even overlap if I wanted.

It can be done with loops. Basically, you'd use "display text" for each letter and position the letters manually. You'd use the loop counter to grab each letter. (The "Character at Position" block would be used.)

I used individual actors with BOT to display numbers. That let me place each digit exactly where I wanted.
Michael Garofalohttp://photics.com – Author of The Interactive Stencyl Textbook 8)

Jon

  • *
  • Posts: 17516
This isn't supported yet in the new bitmap font editor, but "negative" spacing could achieve what you want. Photics' solution, if paired up with a little logic to automate that positioning upfront, is probably the best way to handle it right now.

Formal kerning where you specify two adjoining characters and specific spacing for that pair isn't supported in the font engine we're using though.

HidetoKoudanshi

  • Posts: 112
I completely understand. Then Photics' idea sounds reasonable. What's a good way to automate that, as you suggest?

« Last Edit: April 02, 2014, 09:33:25 pm by HidetoKoudanshi »
If I ever commission you for code work, please know that I understand how commissioning works. You must get paid first before you will code anything for me. Only once you are paid the agreed-upon price, will you begin coding for me. I respect artists and coders. You deserve to be paid for your hard efforts.

gamegirlxl

  • Posts: 716
I completely understand. Then Photics' idea sounds reasonable. What's a good way to automate that, as you suggest?
...you specify two adjoining characters and specific spacing for that pair...
You should first make a list of special spaces, and then you could have something like:

draw 1st character
loop "string.length" times:
draw "that character" at x: function,y: whatever

You could make x ask a function what it should do.  It would give the string and the current position of the next letter, and it would see if the previous and next letter have a special relationship in the list, and it would return how far away the next character should be.

I'm glossing over many many details, but that's a basic idea.  You could also make images of text and avoid all this.

HidetoKoudanshi

  • Posts: 112
I think turning this swoopy font into images might cause the same problem as they couldn't overlap, yeah? The images would butt up against each other and that's as close as they could get to one another.
If I ever commission you for code work, please know that I understand how commissioning works. You must get paid first before you will code anything for me. Only once you are paid the agreed-upon price, will you begin coding for me. I respect artists and coders. You deserve to be paid for your hard efforts.

gamegirlxl

  • Posts: 716
No, I meant ONE image, where you write your sentence in Paint or something that "kerns".  This only works when the text isn't dynamic.

Jon

  • *
  • Posts: 17516
No, I meant ONE image, where you write your sentence in Paint or something that "kerns".  This only works when the text isn't dynamic.

As hacky as this sounds, a bunch of games do this, and it works well if it's for static stuff.

captaincomic

  • *
  • Posts: 6109
Starting with 3.2, the font spacing can be set with a little code:
Code: [Select]
_Font.setLetterSpacing(10)

BlackHole19

  • *
  • Posts: 21
Hello,

sorry to go back this post that dates a little ...

Or insert this code please?

Whenever I create a writing from a ttf, the spacing between the letters is very important, I would like to reduce it ...

Thank you very much good day.

LIBERADO

  • *
  • Posts: 2582
@BlackHole19, a block to change the font spacing was added to Stencyl Build 9439
   
For a lower Build, install the Drawing Utils Extension and use this block:

;) Best Regards.
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

BlackHole19

  • *
  • Posts: 21
Thank you so much Liberado, I hope you are well.

The extension looks great!

Actually I have a version of Stencyl 9328 and on another pc 9300, the installation is done correctly and the new blocks appear.

However, I receive an error message when I test the game "Encountered errors while building your game"

I tested 3.2+ and also to see 3.1 the error is the same.

Maybe an idea of the problem?

LIBERADO

  • *
  • Posts: 2582
Weird. The extension should work well in both versions, b9300 and b9328
I often use that block without problems.
   
Try this: Run > Clean Project
   
I guess you know that you must select also the font in that block.
Also, take into account that the block should be placed inside a drawing event.
I'm spanish, excuse me for my bad English.
I'm not a private teacher. Please, post your questions in the public forum.

BlackHole19

  • *
  • Posts: 21
Yes on this side, I used the block spacing correctly and also cleaned the project.

In case I attached the log file.

Error Line 2850, maybe a path problem no ?

Thank you.