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

Author Topic: mirroring text  (Read 3522 times)

0 Members and 1 Guest are viewing this topic.

MarsCoreTeam

  • Newbie
  • *
  • Posts: 33
    • View Profile
    • http://www.marsshooter.org
mirroring text
« on: January 17, 2011, 02:01:47 pm »
Hello!

I know, this has been requested multiple times before, but hasn't been implemented yet and we would REALLY appreciate this feature!

The problem:

We are going to support Right-To-Left languages in our project M.A.R.S., like Arabic or Hebrew. These languages need a completely mirrored interface. This would be really easy to achieve by rendering the interface normally but with mirrored text in a mirrored view. So the text would be mirrored twice actually and every thing would look fine.
But mirroring text (negative scale) is impossible. Sadly.
Coding different positions and flipped versions of each widget would be an incredible amount of work, compared to the simple approach described above.

We're using SFML2...

It would be really, really great to have this feature!




EDIT: Added an image. Just to clearify the purpose: This is our mirrored UI, with not-mirrored text. If the text could have been mirrored before, it would still be possible to read it!
Working on the Open Source Project M.A.R.S.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
mirroring text
« Reply #1 on: January 17, 2011, 02:17:01 pm »
Not the cleanest solution, but there's a workaround: render your text to a RenderImage and then display the result with a flipped sprite.
Laurent Gomila - SFML developer

Spidyy

  • Sr. Member
  • ****
  • Posts: 493
    • View Profile
mirroring text
« Reply #2 on: January 17, 2011, 02:53:48 pm »
Another way is to rewrite your own text class, based on the sf::text, and add a flipped option to it.

MarsCoreTeam

  • Newbie
  • *
  • Posts: 33
    • View Profile
    • http://www.marsshooter.org
mirroring text
« Reply #3 on: January 17, 2011, 02:54:29 pm »
Yes, may be possible, but horribly inefficient! The labels are interactive; they change color on hover - so the renderimage has to be created every frame! And every text has different size. One little renderImage for each label... that's slow... and even worse: it's not supported on every graphics card!

Why isn't there a FlipX() method for texts? Would be really useful for reflections, too...
Working on the Open Source Project M.A.R.S.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
mirroring text
« Reply #4 on: January 17, 2011, 03:35:53 pm »
Quote
Yes, may be possible, but horribly inefficient! The labels are interactive; they change color on hover - so the renderimage has to be created every frame! And every text has different size. One little renderImage for each label... that's slow... and even worse: it's not supported on every graphics card!

Well, it doesn't have to be implemented using the worst algorithm ever ;)
The highlighted version can be generated together with the normal version at init, and then switched using SetSubRect.
You don't have to use one RenderImage per label, use a single one and store the resulting sf::Images. You can even group several labels into big images.
Support for render images is really really good, I don't even know if you can still find GPUs that don't support them.
I know it's not a clean solution, it requires some extra work on your side, but I have nothing better to offer (at least after spending a few minutes to think about your problem).
The new drawable system will hopefully allow cleaner solutions for this kind of problem.

Quote
Why isn't there a FlipX() method for texts? Would be really useful for reflections, too...

Because it's complicated to implement, and it impacts consistency of other functions.
Laurent Gomila - SFML developer

MarsCoreTeam

  • Newbie
  • *
  • Posts: 33
    • View Profile
    • http://www.marsshooter.org
mirroring text
« Reply #5 on: January 17, 2011, 07:00:27 pm »
Quote
Well, it doesn't have to be implemented using the worst algorithm ever Wink
The highlighted version can be generated together with the normal version at init, and then switched using SetSubRect.
You don't have to use one RenderImage per label, use a single one and store the resulting sf::Images. You can even group several labels into big images.
Support for render images is really really good, I don't even know if you can still find GPUs that don't support them.
I know it's not a clean solution, it requires some extra work on your side, but I have nothing better to offer (at least after spending a few minutes to think about your problem).
The new drawable system will hopefully allow cleaner solutions for this kind of problem.


Well, in my opinion this work around sounds nearly as complicated as implementing mirrored versions of all widgets...

It's a quite complex interface: It would be really hard to pre-render all possible labels... we've got sliders which display they current value, there are widgets where you can enter text... it's not only hover, it's also pressed, focused, hovered+focused, ...

If there were just a few buttons, this could work... so I think we'll have to find another solution...  :roll:

But anyway... SFML rocks! Thanks a lot for your quick responses!! ;)

Greetings,
Simon.

PS: Just saw it is already on your TODO-list.... maybe one day....
http://www.sfml-dev.org/todo/index.php?do=details&task_id=154

EDIT: btw, is there any way to make a multiline sf::Text (with some '\n' inside) align to a side? E.g. right instead of left?
Working on the Open Source Project M.A.R.S.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
mirroring text
« Reply #6 on: January 18, 2011, 07:49:45 am »
Quote
PS: Just saw it is already on your TODO-list.... maybe one day....
http://www.sfml-dev.org/todo/index.php?do=details&task_id=154

I'm not sure it would be enough to solve your problem. However you can try it and report your feedback, you just have to remove the "if (scale > 0)" conditions in Drawable::SetScale.

Quote
EDIT: btw, is there any way to make a multiline sf::Text (with some '\n' inside) align to a side? E.g. right instead of left?

No. But you can play with sf::Font directly and build your own text class. Everything that sf::Text uses is (should be) available, there's no private detail.
Laurent Gomila - SFML developer