Skip to content
Search

FreeType:Android:NDK

lastmod 2021-01-02created 2016-06-232 edits

Explains how to use FreeType in the Android NDK.

Using FreeType in the Android NDK

Copy libskia.so from the emulator or device to the local library folder. It seems to differ by version, but in my environment shown here I confirmed that this file contains FreeType.

C:\cygwin\home\Administrator\android-ndk\build\platforms\android-8\arch-arm\usr\lib

Register the added libskia.so file in the Android.mk file.

LOCAL_LDLIBS+=-L$(SYSROOT)/usr/lib -lskia 등등의 방법으로...

Add the FreeType header to the native code and use the functions.

#include <ft2build.h>
#include FT_FREETYPE_H

Using FreeType fonts in the NDK

The Android platform includes the freetype font library, but the ndk does not provide it, so you have to fetch it from the emulator or phone with the pull command. The freetype font library is located at /system/lib/libskia.so.

adb pull /system/lib/libskia.so

Copy the extracted library to the NDK lib folder for the platform. The Android 2.2 library folder in NDK r5 is as follows.

android-ndk-r5b\platforms\android-8\arch-arm\usr\lib\

Edit Android.mk so that libskia.so is linked during JNI compilation.

LOCAL_LDLIBS := -lskia

To use the freetype header files, download the freetype files from the link below. The URL is http://sourceforge.net/projects/freetype/files/.

Extract the archive and copy the header files in the include folder to the NDK include folder (android-ndk-r5b\platforms\android-8\arch-arm\usr\include\). The Android 2.2 header file folder in NDK r5 is as follows.

In the JNI code, add the header files as below and use them.

#include<ft2build.h>
#include FT_FREETYPE_H

See also

Favorite site