SDL2_ttf 2.0.18 PRERELEASE!

SDL_ttf 2.0.18 is now available as a PRERELEASE build!
http://www.libsdl.org/tmp/SDL_ttf/

Changes in this build:

  • Added support for Signed Distance Field rendering with TTF_SetFontSDF() and TTF_GetFontSDF()
  • Added optional DPI-scaling of fonts, with the following new functions:
    TTF_OpenFontDPI()
    TTF_OpenFontIndexDPI()
    TTF_OpenFontDPIRW()
    TTF_OpenFontIndexDPIRW()
    TTF_SetFontSizeDPI()
  • Added 32-bit character support with:
    TTF_GlyphIsProvided32()
    TTF_GlyphMetrics32()
    TTF_RenderGlyph32_Solid()
    TTF_RenderGlyph32_Shaded()
    TTF_RenderGlyph32_Blended()
    TTF_GetFontKerningSizeGlyphs32()
  • Added functions to set direction and script when using Harfbuzz:
    TTF_SetDirection()
    TTF_SetScript()
  • Added extended API for text measurement:
    TTF_MeasureText()
    TTF_MeasureUTF8()
    TTF_MeasureUNICODE()
  • Added TTF_SetFontSize() to set font size dynamically
  • Added ā€˜Shadedā€™ and ā€˜Solidā€™ text wrapped functions:
    TTF_RenderText_Solid_Wrapped()
    TTF_RenderUTF8_Solid_Wrapped()
    TTF_RenderUNICODE_Solid_Wrapped()
    TTF_RenderText_Shaded_Wrapped()
    TTF_RenderUTF8_Shaded_Wrapped()
    TTF_RenderUNICODE_Shaded_Wrapped()
  • Added TTF_HINTING_LIGHT_SUBPIXEL for better results at small text sizes at a performance cost

Please report any bugs or regressions here:

Cheers!

3 Likes

Wow, this looks like a really nice feature packed release!

Iā€™ve been playing around with the wrapped text functions, and Iā€™m concerned about how they handle small wrap values.

At wrap length 0, the text renders as a single line, and newline characters are still rendered as unknown characters. I expected this to behave like the normal text rendering functions but newline aware.

With a positive but very small wrap length, the text doesnā€™t fully show up. Or parts of letters might show up. I expected this to allocate at least enough space to put at least one character of the input string on each line.

Thereā€™s quite a difference from 2.0.15 in how text is rendered, in Windows at least; 2.0.18 is considerably more bold. Is this expected?

ttf_compare

@rtrussel
Maybe create a separate issue.
Just try with latest and
It seems like size == 16 to me ?
I got the same difference when switching from Hinting mono vs none.
(ā€œmonoā€ would look like the 2.0.15, whereas 2.0.18 looks ā€œnoneā€).

12 points = 16 pixels (at nominal 96 DPI).

I think itā€™s probably a FreeType issue rather than SDL2_ttf. My 2.0.15 is using FreeType 2.4.12 (itā€™s a separate DLL) whereas 2.0.18 seems to have FreeType statically linked. I donā€™t know how to discover the version, because seemingly ā€˜FT_Library_Version()ā€™ isnā€™t exported.

I got the same difference when switching from Hinting mono vs none

Thanks, Iā€™ll try that.

The pre-release build has been updated with a few bug fixes and new functions TTF_GetFreeTypeVersion() and TTF_GetHarfBuzzVersion()

Whereā€™s the documentation for these functions? I canā€™t find any mention of them at the ā€˜officialā€™ documentation site.

Good question, but those docs are from 2005, so itā€™s not surprising theyā€™re outdated

1 Like

Oh. They are the ones I have always used, Iā€™m not aware of anything newer (it could be of course that until recently there were no changes to the public API that needed the docs to be updated).

Can someone share example how to use SDF font with SDL_TTF and TTF_SetFontSDF() and TTF_GetFontSDF()?

@akk0rd87 hereā€™s some example here : SDL/testgles2_sdf.c at main Ā· libsdl-org/SDL Ā· GitHub

Thanks! Will check it.

It can be used only with openGLES2? Is there support for metal and other backends?

@akk0rd87 you can use with metal and other but you need to write platform specific code ā€¦

Hello,
any chance to load a oft font ?

Thanks

You mean otf? I believe you can already.

yes, how ? because in the docs says you cant.

Where does it say that?

Have you tried it?

SDL2_ttf can definitely load OTF fonts.