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

Author Topic: Shifting italic style text  (Read 2186 times)

0 Members and 1 Guest are viewing this topic.

double_trouble

  • Newbie
  • *
  • Posts: 3
    • View Profile
Shifting italic style text
« on: November 08, 2017, 09:08:28 pm »
Hello!
My program solves the task of creating multiple images from background and text. I use sf::Font, sf::Texture, sf::Text and sf::RenderTexture. The problem is that I need to shift the letters in italic fonts until they become straight (I mean loaded italic fonts, not modifyed by SFML). So, is there the way to do it?
Thanks for attention.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Shifting italic style text
« Reply #1 on: November 08, 2017, 09:47:46 pm »
I have no idea what you're trying to do and what you're asking. Maybe it's just me, maybe not. In any case, providing more details (a more detailed description, some code to show what you tried, and maybe even a drawing of what you want to do) may be helpful :)
Laurent Gomila - SFML developer

double_trouble

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Shifting italic style text
« Reply #2 on: November 08, 2017, 10:02:45 pm »
Hm, in another words, when we take regular style text and do text.setStyle(sf::Text::Italic), the text shifts to 12 degrees to the right and I need the reverse operation: shift italic back to regular.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Shifting italic style text
« Reply #3 on: November 08, 2017, 10:12:10 pm »
I see. I have no idea why you want to do that, but anyway. You might have some results (or not) with a shear matrix (see sf::Transform, but you'll have to build it manually since there's no helper function for shearing).
Laurent Gomila - SFML developer

double_trouble

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Shifting italic style text
« Reply #4 on: November 08, 2017, 11:00:19 pm »
Ok, but the problem is not in shifting itself, is there any ways to find the angle of slope?
It is called "italic angle" here https://developer.apple.com/library/content/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/Art/textpg_intro_2x.png
« Last Edit: November 08, 2017, 11:05:08 pm by double_trouble »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10998
    • View Profile
    • development blog
    • Email
Re: Shifting italic style text
« Reply #5 on: November 09, 2017, 12:30:45 am »
So why do you "need" to do this?

SFML doesn't expose such information. It might not even have it as it may be using real italic fonts to begin with.

Anyways, italic is not just rotation a letter for specific angle, that would look quite weird, instead letters get shifted into a specific direction.
Notice how the two "pillars" of the small letter "n" stay on the baseline (n[/n]). If rotated the letter they would not align at the same baseline.
As such it's not a rotation and more of some kind of skewing that happens.
« Last Edit: November 09, 2017, 12:33:31 am by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

achpile

  • Full Member
  • ***
  • Posts: 231
    • View Profile
    • Achpile's homepage
    • Email
Re: Shifting italic style text
« Reply #6 on: November 09, 2017, 06:43:51 am »
Hm, in another words, when we take regular style text and do text.setStyle(sf::Text::Italic), the text shifts to 12 degrees to the right and I need the reverse operation: shift italic back to regular.

Is that what you want?

text.setStyle(sf::Text::Regular)
 

or this

text.setStyle(text.getStyle() ^ sf::Text::Italic)