Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sf::Text::setTracking(int)  (Read 12177 times)

0 Members and 2 Guests are viewing this topic.

SuperV1234

  • SFML Team
  • Full Member
  • *****
  • Posts: 190
    • View Profile
sf::Text::setTracking(int)
« on: October 02, 2014, 03:43:44 pm »
It would be really helpful if we could specify a `tracking` int value in `sf::Text`.
All glyphs would be moved apart from each other by `tracking`.


Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: sf::Text::setTracking(int)
« Reply #1 on: October 02, 2014, 07:41:09 pm »
I think you mean kerning and SFML already allows you to get the kerning from a font.
You can't set it though, so if you want to display fonts more flexibly, you can make your own text class, unless someone has already made one. Try looking on the wiki.

EDIT: Maybe this could help.
« Last Edit: October 02, 2014, 07:44:51 pm by Hapax »
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::Text::setTracking(int)
« Reply #2 on: October 02, 2014, 07:56:07 pm »
I don't think he means kerning, but rather a fixed additional spacing between letters. This would be trivial to implement. The question is: is it really useful?
Laurent Gomila - SFML developer

SuperV1234

  • SFML Team
  • Full Member
  • *****
  • Posts: 190
    • View Profile
Re: sf::Text::setTracking(int)
« Reply #3 on: October 02, 2014, 08:30:00 pm »
Laurent is correct. Tracking is not kerning and it is trivial to implement.

I find it useful because it looks really good when used properly.
A simple example would be a level introduction white screen with a black serif font and an high tracking value.
It just looks nicer.

Another idea that just came in my mind is using tracking to make text expand/shrink in animations.


Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::Text::setTracking(int)
« Reply #4 on: October 02, 2014, 09:18:03 pm »
You're right, it can be used to create some nice effects.

Let's wait for more opinions before creating a task on the tracker (if nobody replies, don't hesitate to bump the thread in a few days).
Laurent Gomila - SFML developer

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: sf::Text::setTracking(int)
« Reply #5 on: October 02, 2014, 09:52:18 pm »
You're right; I had mixed up the two terms as they refer to very similar areas. Still, it could be implemented on top of SFML if required, but it would be useful for SFML to include things such as this  :)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::Text::setTracking(int)
« Reply #6 on: October 02, 2014, 10:21:17 pm »
Quote
Still, it could be implemented on top of SFML if required
Hmm... with one sf::Text instance per letter? :-\
Laurent Gomila - SFML developer

SuperV1234

  • SFML Team
  • Full Member
  • *****
  • Posts: 190
    • View Profile
Re: sf::Text::setTracking(int)
« Reply #7 on: October 02, 2014, 10:28:49 pm »
Quote
Still, it could be implemented on top of SFML if required
Hmm... with one sf::Text instance per letter? :-\

Yeah, that's the issue, unless your reinvent 'sf::Text'.
I propose that the addition of a 'tracking' field would be good enough.

If you wanted SFML users to have more control, though, for the future version you should consider allowing users to pass a functor/lambda during text draw/update that is called on every single glyph, or something like that.

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: sf::Text::setTracking(int)
« Reply #8 on: October 02, 2014, 10:30:45 pm »
I was under the impression that it could be achieved by accessing the glyphs directly, the way sf::Text would, which would end up being a single object. Is that not actually possible?
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::Text::setTracking(int)
« Reply #9 on: October 02, 2014, 10:32:58 pm »
Quote
If you wanted SFML users to have more control, though, for the future version you should consider allowing users to pass a functor/lambda during text draw/update that is called on every single glyph, or something like that.
Yes, we already have something in our todo-list that would allow more flexibility.

Quote
I was under the impression that it could be achieved by accessing the glyphs directly, the way sf::Text would, which would end up being a single object. Is that not actually possible?
So you have to rewrite sf::Text, which is not exactly trivial.
« Last Edit: October 02, 2014, 10:35:44 pm by Laurent »
Laurent Gomila - SFML developer

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: sf::Text::setTracking(int)
« Reply #10 on: October 02, 2014, 10:50:25 pm »
you have to rewrite sf::Text, which is not exactly trivial.
It certainly is not but it's nice to know that it's exposed enough to access it if required  :P

Quote
...functor/lambda...on every single glyph...
Yes, we already have something in our todo-list that would allow more flexibility.
This is good to know. I wastn't suggesting we should be all "re-writing sf::Text"; I think it's much better for SFML to include this stuff. I said this already  ;)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

Phanoo

  • Full Member
  • ***
  • Posts: 136
    • View Profile
Re: sf::Text::setTracking(int)
« Reply #11 on: October 11, 2014, 11:23:50 pm »
of course it's really useful. Why do you think all serious font libraries and languages (like CSS) or programs like GIMP or Photoshop does implement it?. same for a line-spacing function (line height). A pity that it's not already implemented. Same as text-formatting tags (italic, bold, underline, color...)

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: sf::Text::setTracking(int)
« Reply #12 on: October 12, 2014, 12:11:36 am »
I'm very YES about this feature, it's nice, simple and very powerful and useful.

Quote
It certainly is not but it's nice to know that it's exposed enough to access it if required  :P
If it's urgent for you to use that kind of spread out text then it's really straightforward to implement it for yourself.
Just copy Text.hpp and Text.cpp, rename them and slap the modification notice (to comply with point 2. of zlib) and then modify the code (mainly ensureGeometryUpdate function) and there - done.
Or - if feeling adventurous - modify and rebuild SFML-Graphics directly.
Back to C++ gamedev with SFML in May 2023

MarkusFL

  • Newbie
  • *
  • Posts: 1
    • View Profile
    • Email
Re: sf::Text::setTracking(int)
« Reply #13 on: November 24, 2014, 06:00:35 pm »
Yes, it's basic typography thing so I think it should be in.
The function could probably be named setLetterSpacing as in CSS (which makes it more familiar to people who have used that).

Lo-X

  • Hero Member
  • *****
  • Posts: 618
    • View Profile
    • My personal website, with CV, portfolio and projects
Re: sf::Text::setTracking(int)
« Reply #14 on: November 24, 2014, 06:41:01 pm »
I think that could be useful but I don't think setTracking() is a good name. As proposed setLetterSpacing tells more about what it does (need to check what Qt uses).