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

Author Topic: How can I draw pretty box with .ttf font?  (Read 2835 times)

0 Members and 1 Guest are viewing this topic.

underww

  • Newbie
  • *
  • Posts: 34
    • View Profile
How can I draw pretty box with .ttf font?
« on: February 29, 2016, 08:10:31 pm »
I'm trying to draw a box with sf::text with .ttf font and unicode.
but the result is a bit ugly, here's a screenshot and it's just one text object.
some fonts look better but most fonts don't look good.

I know I can draw a box with sf::Rectangle, but I want to draw it with font for some reason.
and I've tried to turn on/off the font smoothing, but it didn't help.
« Last Edit: February 29, 2016, 08:17:01 pm by underww »

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: How can I draw pretty box with .ttf font?
« Reply #1 on: February 29, 2016, 08:32:02 pm »
What does it mean to draw a pretty box with a font?
Are you attempting to draw a box using box edge-type characters?
Why are you using text instead of other apt methods?
Are you trying to draw ASCII art? (consider this)
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

underww

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: How can I draw pretty box with .ttf font?
« Reply #2 on: February 29, 2016, 10:14:37 pm »
Yes, I'm trying to draw ASCII art with virtual console using SFML
This is what I want to do (the same font and size in notepad)

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: How can I draw pretty box with .ttf font?
« Reply #3 on: February 29, 2016, 11:57:59 pm »
You're right. SFML and Notepad don't render fonts identically.
Sometimes, though, SFML's way might just be better ;)


That said, if you scale up the text inside the program (or just resize the window), gaps can appear between the characters.
Are you rendering at a size where the text's texture's pixels match the window's pixels? If you need to increase its size, try first rendering to a render texture and scaling that.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*

underww

  • Newbie
  • *
  • Posts: 34
    • View Profile
Re: How can I draw pretty box with .ttf font?
« Reply #4 on: March 01, 2016, 01:46:28 am »
Yeah, but box-drawing characters in many fonts don't have the gaps between themselves unlike other symbols.
the fonts I tested also don't have gaps naturally.

I don't scale the text but, the gaps is variable when I change font size.
sometimes it looks perfect with some size, but it doesn't generally.
so I thought it's because of some rendering problem in SFML.