| Summary: | SDL_ttf + HarfBuzz | ||
|---|---|---|---|
| Product: | SDL_ttf | Reporter: | Sylvain <sylvain.becker> |
| Component: | misc | Assignee: | Sylvain <sylvain.becker> |
| Status: | ASSIGNED --- | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | 43libsdl, renesd |
| Version: | unspecified | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Attachments: |
SDL_ttf.c + HarfBuzz
Two new APIs to choose the rendering direction + script compilation file for Android Android.mk for HarfBuzz SDL_ttf.c + HarfBuzz SDL_ttf.h + HarfBuzz Android.mk for HarfBuzz 2.3.1 Android.mk for HarfBuzz 2.3.1 Modified Android.mk for SDL_ttf |
||
|
Description
Sylvain
2015-06-30 17:18:34 UTC
Created attachment 2208 [details]
SDL_ttf.c + HarfBuzz
Created attachment 2209 [details]
Two new APIs to choose the rendering direction + script
Created attachment 2210 [details]
compilation file for Android
More information: The file contains also this patch: https://bugzilla.libsdl.org/show_bug.cgi?id=2749 Once you have downloaded the source of HarfBuzz, you need to configure it not to add extra dependencies: ie: ./configure --with-icu=no --with-cairo=no --with-glib=no --with-gobject=no Plus, you need to call "make" once, even if it fails (e.g. on android), so that it generates some internal state machine/automate. Created attachment 2247 [details]
Android.mk for HarfBuzz
Android.mk used to compile HarfBuzz on Android
Created attachment 3722 [details]
SDL_ttf.c + HarfBuzz
Update to use HarfBuzz with latest SDL_ttf.c
Created attachment 3723 [details]
SDL_ttf.h + HarfBuzz
Created attachment 3724 [details]
Android.mk for HarfBuzz 2.3.1
This is the Android.mk to use for Harfbuzz 2.3.1
Created attachment 3725 [details]
Android.mk for HarfBuzz 2.3.1
mark previous ones as obsolete
Created attachment 3726 [details]
Modified Android.mk for SDL_ttf
Is it possible to make this a configure option (disabled by default) so we can merge this and make it an option for people? Ok, I'll add this. So with the source package external/harfbuzz-2.3.1 and a setting in Android.mk to be able to build Just added ! external/harfbuzz-2.3.1 from https://github.com/harfbuzz/harfbuzz/releases with docs, test and ChangeLog It needs an Android.mk and a config.h https://hg.libsdl.org/SDL_ttf/rev/868bbc9fbf4c Maybe we don't need the config.h because there is a HAVE_CONFIG_H, not sure.. SDL_ttf is patch to use harfbuzz https://hg.libsdl.org/SDL_ttf/rev/b357aefce885 Hello. Thanks! We (pygame) are very interested in this, as a lot of users have requested this feature. The pygame issue is here for anyone interested in following along: https://github.com/pygame/pygame/issues/464 Hello, You just need the latest head source of SDL_ttf, and compiles with TTF_USE_HARFBUZZ or SUPPORT_HARFBUZZ for Android. Then pick the right font, set script var (I think sometimes it helps), and renders text. The code is tested on Android, IOS, MacosX, Linux, Windows 10. You maybe need to update your build configuration. Latest version also include assembly optimizations, bug fix, and subpixel positioning. (https://hg.libsdl.org/SDL_ttf/rev/9f46efc0fde2 ) Hello. Thanks for the tips. Some very nice changes coming up in SDL_ttf indeed. What do you mean by "set script var"? I meant TTF_SetScript() to tell harfbuzz the language/script. Ah yes. How does a user know which script to set for a font? Because of the language he want to write. See harfbuzz doc for scripts. He also has to choose his fonts, because not all fonts render all languages. I think HB also has a function to auto detect script. While trying to add RTL to INSTEAD game engine I came across this patch. Since Sylvain has already made a patch and Sam showed the green light for merging it as an option, is there any chance to move this forward? Thanks for spending your (free) time on this. hi thanks, many things were merged in the SDL_ttf head already see https://hg.libsdl.org/SDL_ttf/ https://hg.libsdl.org/SDL_ttf/shortlog (In reply to Sylvain from comment #21) > hi thanks, > many things were merged in the SDL_ttf head already > see > https://hg.libsdl.org/SDL_ttf/ > https://hg.libsdl.org/SDL_ttf/shortlog Would you mind pointing me to the right compile procedure to get the latest SDL_ttf compiled for Linux desktop (not Android) with HarfBuzz support included? I was initially able to compile SDL_ttf with your patch from here (https://discourse.libsdl.org/t/sdl-for-farsi-or-persian-text/25292/7) and by calling TTF_SetDirection( HB_DIRECTION_RTL ) and TTF_SetScript(HB_SCRIPT_ARABIC), and using a ttf font such as DejaVuSans.ttf I could see proper rendered text. However, with the latest changes, no matter what I do I get boxes again. Probably I have messed up things when fighting with cmake and make to enable the feature. The program compiles though, so it means the functions are there but have no effect. Thanks in advance for any tips. Edit the SDL_ttf.c source and set TTF_USE_HARFBUZZ to 1, or define it from upper level. Compile with configure for instance. you need to also provide include and library path to harfbuzz. you still need TTF_SetDirection( HB_DIRECTION_RTL ) and TTF_SetScript(HB_SCRIPT_ARABIC), (In reply to Sylvain from comment #23) > Edit the SDL_ttf.c source and set TTF_USE_HARFBUZZ to 1, or define it from > upper level. > Compile with configure for instance. you need to also provide include and > library path to harfbuzz. sorry, it was my fault. The font in my program was pointing to a wrong file. I changed the SDL_ttf.c and it worked like charm. However, I was unable to set it via configure. Is there any specific configure flag for it? I searched the autotools source files and even tried to define the variable using AC_DEFINE to no avail. sorry there was no configure modification. though you can set some CFLAGS environment variable to set the TTF_USE_HARFBUZZ define. Fell free to submit a patch so it can be enable with configure, but sync with Sam about the usual way to do it. I though I'll let you know that this change is now included in the emscripten-core by default, i.e. TTF_USE_HARFBUZZ is set to 1. Providing `-s USE_SDL_TTF=2` when compiling should be enough to compile C code to WASM with HarfBuzz support. See: https://github.com/emscripten-core/emscripten/commit/1690a5802cd1241adc9714fb7fa2f633d38860dc#diff-874f33563125619a7a5cb567ebe523c59258662d69858d78d24d947b275f9c6cR40 Ok, thanks for heads up! |