Author Topic: .ttf files  (Read 12906 times)

Lemony Lime

  • Newcomer
  • Posts: 4
  • Karma: +0/-0
    • View Profile
.ttf files
« on: July 03, 2013, 02:03:09 AM »
Hey, just found your forum and signed up. I'm been making games as a hobby for awhile now, but never really had anything too spectacular, because I'm not an artist or musician, and those parts of my games have always been really lacking... which led me to think that maybe a roguelike would be a good thing to try next, since I don't have to worry about those things, and can focus purely on making the game how I want.

I'm working without any graphics whatsoever atm, and need my fonts to be in .ttf format. I'm currently using the font found here which is nice, but it's 8x16, which means that the screen is super stretched vertically. I see this all the time in other roguelikes, of course... but I'm really not a fan of it. I was looking for some sort of 16x16 font, preferably in a .ttf file, if possible. Technically, I can use an image for the fonts, but it'd require some extra work, so I just thought I'd ask and see if anyone knew of anything I could use.

ekolis

  • 7DRL Reviewer
  • Rogueliker
  • *
  • Posts: 186
  • Karma: +0/-0
  • get ye dennis
    • View Profile
    • Ed's home page
    • Email
Re: .ttf files
« Reply #1 on: July 03, 2013, 08:30:31 PM »
Could you perhaps display extra horizontal padding between characters?
The Ed draws near! What dost thou deaux?

>EAT SANDVICH

Lemony Lime

  • Newcomer
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: .ttf files
« Reply #2 on: July 03, 2013, 09:48:48 PM »
Yeah, that's what I'm doing currently, but the way I'm display my towns is like this:
███
███
█_█ (The _ is the front gate.)
Without the extra spacing, they're all right next to each other, and it looks quite nice. So, I definitely can't leave it that way.

ekolis

  • 7DRL Reviewer
  • Rogueliker
  • *
  • Posts: 186
  • Karma: +0/-0
  • get ye dennis
    • View Profile
    • Ed's home page
    • Email
Re: .ttf files
« Reply #3 on: July 04, 2013, 04:03:15 PM »
Maybe you could stretch the font somehow? Like, render it to a bitmap at whatever size you need, and stretch the bitmap?
The Ed draws near! What dost thou deaux?

>EAT SANDVICH

malignatius

  • Newcomer
  • Posts: 42
  • Karma: +0/-0
    • View Profile
    • Email
Re: .ttf files
« Reply #4 on: July 04, 2013, 04:39:22 PM »
Perhaps you could create a font with http://icomoon.io/.?
It's an online tool to create your own vector fonts (with lots of free vectors to select from)

requerent

  • Rogueliker
  • ***
  • Posts: 355
  • Karma: +0/-0
    • View Profile
Re: .ttf files
« Reply #5 on: July 04, 2013, 05:15:51 PM »
I don't get it.

Is it the visual shape of the glyph that bothers you or that it occupies a non-square area of the screen?

You need to handle fore/back color rendering either way- so you'll have a rectangular tile that each glyph is rendered on (logically anyways). You will likely be drawing a rect to handle the background-- if a font isn't the shape you want or it isn't monospaced, you can just center it in he tile. Honestly, it's very little trouble and very much worth it to be able to support multiple .ttfs.

Eben

  • Rogueliker
  • ***
  • Posts: 339
  • Karma: +0/-0
  • Controversializer
    • View Profile
    • SquidPony!
Re: .ttf files
« Reply #6 on: July 04, 2013, 05:56:43 PM »
What language and libs are you using? There's a very good chance that you're struggling to do something that has already been done and you could look at how they did it.

guest509

  • Guest
Re: .ttf files
« Reply #7 on: July 05, 2013, 07:20:45 AM »
What Eben said.

Lemony Lime

  • Newcomer
  • Posts: 4
  • Karma: +0/-0
    • View Profile
Re: .ttf files
« Reply #8 on: July 05, 2013, 10:17:29 PM »
I'm not trying to do anything special within the language, I just wanted a font in which the letters all occupied exactly 16x16 pixels. The only stipulation with the language is that it's required to be a .ttf file. (I'm using Love2D if you're curious... probably an odd choice, but I'm sticking with what I know. lol)
« Last Edit: July 05, 2013, 10:19:30 PM by Lemony Lime »

ekolis

  • 7DRL Reviewer
  • Rogueliker
  • *
  • Posts: 186
  • Karma: +0/-0
  • get ye dennis
    • View Profile
    • Ed's home page
    • Email
Re: .ttf files
« Reply #9 on: July 05, 2013, 11:45:59 PM »
TTF files aren't bitmap fonts, that I know of. They're all vector fonts. So saying that a character would occupy "exactly 16x16 pixels" is rather meaningless. You could look for one with a 1:1 aspect ratio, though... or use padding and/or stretching to make them fit, as I suggested earlier.
The Ed draws near! What dost thou deaux?

>EAT SANDVICH

Eben

  • Rogueliker
  • ***
  • Posts: 339
  • Karma: +0/-0
  • Controversializer
    • View Profile
    • SquidPony!
Re: .ttf files
« Reply #10 on: July 06, 2013, 06:57:17 AM »
Just so you know right away, square fonts look terrible for reading text. Non-square fonts with variable kerning because they've been individually centered in a square also looks terrible for reading text.

With that out of the way, there's http://fontstruct.com/fontstructions/show/zodiac_square made by our own notostraca.

As ekolis said, ttf fonts are vectors (with other stuff too) and aren't any particular size. If you're trying to be able to use unicode characters and stuff you're going to have a lot of sad times ahead dealing with font peculiarities.

If you're using a limited set of characters you'd be much better off using a bitmap font so you get exactly what you're expecting. Since you'll be using for tile display instead of the usual font uses, you can treat it like a sprite sheet and lay down the tiles as needed that way probably.

miki151

  • Rogueliker
  • ***
  • Posts: 264
  • Karma: +0/-0
    • View Profile
Re: .ttf files
« Reply #11 on: July 06, 2013, 09:55:09 AM »
Just draw your world with 16x16 squares, and put your characters in the middle of each square. The library you're using should have a method like text_width that returns width in pixels, so to place an 'a', put it at 8 - text_width("a") / 2, and it will be nicely centered. Adjust the font size so that the characters fit nicely within the squares. Later you or the player can change the font to whatever they like without any worry.
KeeperRL, Dungeon Keeper in roguelike style:
http://keeperrl.com