instead-launcher-android
instead-launcher-android copied to clipboard
Building with the latest SDL_ttf
Hi there,
I am trying to build the app with the latest version of SDL_ttf with HarfBuzz flag set. I can build the app normally, but not with the latest version. So far I have tried the following and failed.
After running ./gradlew downloadDependencies
, I replaced the contents of SDL2_ttf/SDL2_ttf
folder with the latest copy of SDL2_ttf and then took the following steps.
First I tried to use the Android.mk
inside the SDL2_ttf directory. So I changed the main app/src/main/cpp/CMakeLists.txt
and added add_subdirectory( SDL2_ttf/SDL2_ttf )
to it. I also manually modifed the Android.mk
and set SUPPORT_HARFBUZZ
to true
. The app builds but apparently the HarfBuzz support is missing.
Then I tried to modify app/src/main/cpp/SDL2_ttf/CMakeLists.txt
and add the necessary cmake code to build harfbuzz (which is included in the source tree of the latest SDL_ttf):
include_directories( "${HARFBUZZ_DIR}/src/" )
include_directories( "${HARFBUZZ_DIR}/src/hb-ucdn/" )
add_definitions("-DTTF_USE_HARFBUZZ=1")
add_definitions("-DHAVE_UCDN=1")
set( SOURCES
"${HARFBUZZ_DIR}/src/hb-blob.cc"
"${HARFBUZZ_DIR}/src/hb-buffer-serialize.cc"
"${HARFBUZZ_DIR}/src/hb-face.cc"
"${HARFBUZZ_DIR}/src/hb-ot-tag.cc"
"${HARFBUZZ_DIR}/src/hb-buffer.cc"
"${HARFBUZZ_DIR}/src/hb-font.cc"
"${HARFBUZZ_DIR}/src/hb-common.cc"
"${HARFBUZZ_DIR}/src/hb-set.cc"
"${HARFBUZZ_DIR}/src/hb-shape-plan.cc"
"${HARFBUZZ_DIR}/src/hb-ot-font.cc"
"${HARFBUZZ_DIR}/src/hb-shaper.cc"
"${HARFBUZZ_DIR}/src/hb-unicode.cc"
"${HARFBUZZ_DIR}/src/hb-ot-shape.cc"
"${HARFBUZZ_DIR}/src/hb-ot-face.cc"
"${HARFBUZZ_DIR}/src/hb-shape.cc"
"${HARFBUZZ_DIR}/src/hb-static.cc"
"${HARFBUZZ_DIR}/src/hb-warning.cc"
"${HARFBUZZ_DIR}/src/hb-ot-shape-complex-default.cc"
"${HARFBUZZ_DIR}/src/hb-ot-layout.cc"
"${HARFBUZZ_DIR}/src/hb-ot-math.cc"
"${HARFBUZZ_DIR}/src/hb-ot-map.cc"
"${HARFBUZZ_DIR}/src/hb-ot-shape-complex-arabic.cc"
"${HARFBUZZ_DIR}/src/hb-ot-shape-complex-hangul.cc"
"${HARFBUZZ_DIR}/src/hb-ot-shape-complex-hebrew.cc"
"${HARFBUZZ_DIR}/src/hb-ot-shape-complex-indic.cc"
"${HARFBUZZ_DIR}/src/hb-ot-shape-complex-indic-table.cc"
"${HARFBUZZ_DIR}/src/hb-ot-shape-complex-khmer.cc"
"${HARFBUZZ_DIR}/src/hb-ot-shape-complex-myanmar.cc"
"${HARFBUZZ_DIR}/src/hb-ot-shape-complex-thai.cc"
"${HARFBUZZ_DIR}/src/hb-ot-shape-complex-use.cc"
"${HARFBUZZ_DIR}/src/hb-ot-shape-complex-use-table.cc"
"${HARFBUZZ_DIR}/src/hb-ot-shape-normalize.cc"
"${HARFBUZZ_DIR}/src/hb-fallback-shape.cc"
"${HARFBUZZ_DIR}/src/hb-ot-shape-fallback.cc"
"${HARFBUZZ_DIR}/src/hb-ot-shape-complex-vowel-constraints.cc"
"${HARFBUZZ_DIR}/src/hb-ot-var.cc"
"${HARFBUZZ_DIR}/src/hb-ot-cff1-table.cc"
"${HARFBUZZ_DIR}/src/hb-ot-cff2-table.cc"
"${HARFBUZZ_DIR}/src/hb-ft.cc"
"${HARFBUZZ_DIR}/src/hb-ucdn.cc"
"${HARFBUZZ_DIR}/src/hb-ucdn/ucdn.c"
"${HARFBUZZ_DIR}/src/hb-aat-layout.cc"
"${HARFBUZZ_DIR}/src/hb-aat-map.cc" )
add_library( harfbuzz STATIC ${SOURCES} )
#----------------
# Build SDL_ttf
#----------------
add_library( SDL2_ttf SHARED SDL2_ttf/SDL_ttf.c )
target_link_libraries( SDL2_ttf
SDL2
freetype
harfbuzz)
This didn't work either. I made a dummy PR just to demonstrate the changes. This is necessary in order to be able to proceed with our short discussion over INSTEAD.
I'd appreciate any feedback on this.
Thanks.
Meanwhile I managed to compile the launcher with HarfBuzz support and it works as expected. See my PR #12. I guess still some cleanup is necessary:
- Fetch appropriate version of SDL2_ttf during download (I asked on SDL forum for a new release)
- Fetch appropriate version of Instead during download
- Patch INSTEAD, instead of using GLib (I can make a patch for this, or perhaps if I get some time I can remove the GLib support from INSTEAD alltogether)
The first two points are not a problem: we can simply download the source of a specific commit, instead of the release version (for example, following this link https://hg.libsdl.org/SDL_ttf/archive/35ce6ce66b80.tar.gz)
It's more complicated with Glib: I can't just take some of the sources from it, since there is an LGPL license, and I have MIT.
I can try to compile Glib as a shared library, but then the apk size will increase by 0.5 megabytes in google play (and 2 megabytes in f-droid). It would be better to do without Glib. What are you using it for?
The first two points are not a problem: we can simply download the source of a specific commit, instead of the release version (for example, following this link https://hg.libsdl.org/SDL_ttf/archive/35ce6ce66b80.tar.gz)
Great! I didn't know it is possible.
It's more complicated with Glib: I can't just take some of the sources from it, since there is an LGPL license, and I have MIT.
Correct, that is not the right thing to do.
What are you using it for?
It contains a few functions that use the unicode tables to figure out the script (e.g. Latin, Cyrillic, etc) of a given charachter and whether it is a number, letter or both.
I guess all of these are possible only with HarfBuzz itself or even just with raw unicode data. All of them are lookup-based.
- Auto generated file: gscripttable.h
- Auto generated file: gunichartables.h
- Definitions: gunicode.h
- Functions: guniprops.c
I basically call the following four functions:
- g_unichar_get_script
- g_unichar_isalnum
- g_unichar_isalpha
- g_unichar_isdigit
HarfBuzz contains simliar tables, for example this one.
Edit: add list of functions.
I guess all of these are possible only with HarfBuzz itself or even just with raw unicode data.
It would be nice to get rid of Glib. If you can use HarfBuzz for this, then it would be better for Android assembly to use it (if we are going to compile it anyway).