6

I'm not entirely sure this is the best place for this, but I can't think of anywhere better

I've "made" a low resolution font. (bonus points if you know where it's actually from)

The font works fine in gedit: gedit

However, when trying to render the font with SDL_ttf, it mostly works, except for some multibyte unicode characters (notably 'æ' and '') while other non-ASCII characters work fine. But(!), all of these characters work fine with other fonts (I've been using DejaVu Sans)

My Font Dejavu Sans

The fact that other fonts work fine suggest that the code is not to blame, but just in case:

SDL_Surface *surf = TTF_RenderUTF8_Solid(this->font, (const char *)text, col);
if (surf == nullptr) {
    fprintf(stderr, "Rendering text failed (%s)\n", TTF_GetError());
    return;
}

if (surf->format->BitsPerPixel != 8 || surf->format->BytesPerPixel != 1) {
    fprintf(stderr, "Rendering text failed (Wrong surface format)\n");
    return;
}

(text is const uint8*) None of these errors are triggered, obviously

I've noticed that these 2 characters in particular are wider than the rest, could this be to blame?

Per comment below, the font seems to work fine with the SDL_TTF "latin-1" demo:

working in demo

Jongware
  • 22,200
  • 8
  • 54
  • 100
LordAro
  • 1,269
  • 3
  • 18
  • 35
  • 1
    "Some multibyte Unicode characters" is the same as "other non-ASCII characters"? That is, those other characters are also "multibyte Unicode characters"? (The common name, by the way, is "UTF8".) Can you compile, run, and test your font with the demos on https://www.libsdl.org/projects/SDL_ttf? – Jongware Aug 04 '14 at 21:32
  • (OT) The font reminds me heavily of the good old 8-bit days. Your capitals immediately reminded me of Mastertronic's *Spellbound*. – Jongware Aug 04 '14 at 21:40
  • 1
    font seems to work fine in the demos: http://i.imgur.com/yMHuHqM.png (the 'latin-1' program) I guess we can see where the mystery 'unknown' chracter is coming from, a product of using this fontstruct site, i guess (despite me defining my own "undefined" character). So, i've got no idea what's going on... – LordAro Aug 05 '14 at 10:10
  • Unfortunately, one needs to Sign In to download your font, so I cannot test it with my OTF-checking software (to rule out an error inside the font itself). Since you are using UTF8-encoding, can you try that demo as well? – Jongware Aug 05 '14 at 10:28
  • oh, never realised that - have a dropbox link: https://www.dropbox.com/s/82idr33bnlhc8ot/RCT1.zip – LordAro Aug 05 '14 at 11:00
  • and which demo where? i can't see any others... – LordAro Aug 05 '14 at 11:01
  • *not-so-subtle-poke* any further ideas? – LordAro Aug 07 '14 at 16:37
  • The font works fine for me, with the showfont demo included with SDL-ttf. Perhaps it's a version issue? I have SDL-ttf 2.0.11 and freetype 2.5.2. – pdw Aug 10 '14 at 22:32
  • i have SDL_ttf 2.0.12 (iirc, it's just a rebuild for SDL2) and freetype 2.5.3 – LordAro Aug 11 '14 at 07:46
  • 1
    Can you include a minimal compilable example that reproduces the issue? It doesn't seem to be your font or the code you posted. – OmnipotentEntity Aug 13 '14 at 15:06
  • I... i have no idea what was wrong. It works in minimal version, and now of course it works in the main version too. http://i.imgur.com/Hz5gNxf.png Typical. Regardless, thanks for attempting to help guys :) – LordAro Aug 13 '14 at 21:56
  • (OT) Oh, and the answer you were looking for was Roller Coaster Tycoon :) http://freerct.org – LordAro Aug 13 '14 at 21:57
  • So it works with the *exact same code* as in your question? If not, then you might put it in an answer yourself. – Jongware Aug 13 '14 at 22:24
  • Yeah, weird. Maybe I was using the wrong font or something.... ;_; – LordAro Aug 14 '14 at 10:36

1 Answers1

1

I.. I don't know what was wrong. I just tried it again, and it worked fine.

enter image description here

I was so sure I'd checked that I was using the correct font.. Or maybe I changed something when I generated it

Thanks for the help regardless :)

LordAro
  • 1,269
  • 3
  • 18
  • 35