FreeType的FT_Request_Size()崩溃在Android [英] Freetype FT_Request_Size() crashes on Android

查看:372
本文介绍了FreeType的FT_Request_Size()崩溃在Android的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在Android和任何时候,我尝试使用FT_Set_Char_Size编译的FreeType 2.4.2(),它会在FT_Request_Size()函数ftobjs.c文件在该行崩溃

I've compiled freetype 2.4.2 on android and any time I try to use FT_Set_Char_Size() it will crash in the ftobjs.c file in the FT_Request_Size() function at this line

error = clazz->request_size( face->size, req );    //line 2832

我的code工作完全正常在Windows,Linux,Mac上,IPhone和iPad。但这里是这笔交易。
我有完全相同的问题,在同一地点同一坠毁在Windows(VC ++),直到我编的FreeType与/ ZA禁用语言扩展。

My code works perfectly fine on Windows, Linux, Mac, IPhone and IPad. But here is the deal. I was having the exact same issue, same crash at the same spot on Windows (vc++) until I compiled freetype with /Za "Disable Language Extensions".

所以我pretty确保它的FreeType是如何被编译在Android所导致崩溃。
我抬头一看如何禁用语言扩展在Android上都无济于事。

So I'm pretty sure it's how freetype is being compiled on Android that is causing the crash. I've looked up how to Disable Language Extensions on android with no avail.

这里是我的FreeType的文件Android.mk

here is my Android.mk file for freetype

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_C_INCLUDES += \
    $(LOCAL_PATH)/builds \
    $(LOCAL_PATH)/include

LOCAL_SRC_FILES:= \
    src/base/ftbbox.c \
    src/base/ftbitmap.c \
    src/base/ftglyph.c \
    src/base/ftstroke.c \
    src/base/ftxf86.c \
    src/base/ftbase.c \
    src/base/ftsystem.c \
    src/base/ftinit.c \
    src/base/ftgasp.c \
    src/raster/raster.c \
    src/sfnt/sfnt.c \
    src/smooth/smooth.c \
    src/autofit/autofit.c \
    src/truetype/truetype.c \
    src/cff/cff.c \
    src/psnames/psnames.c \
    src/pshinter/pshinter.c \
    src/type1/type1.c \
    src/cid/type1cid.c \
    src/pfr/pfr.c \
    src/type42/type42.c \
    src/winfonts/winfnt.c \
    src/pcf/pcf.c \
    src/psaux/psaux.c \
    src/bdf/bdf.c \
    src/gzip/ftgzip.c \
    src/lzw/ftlzw.c

LOCAL_CFLAGS += -DFT2_BUILD_LIBRARY
LOCAL_MODULE := freetype
LOCAL_LDLIBS := -ldl -llog

include $(BUILD_STATIC_LIBRARY)

我的整个项目可以在这里找到。

My full project can be found here

    http://digitalknob.googlecode.com

它编译罚款,我没有得到任何错误。在崩溃时,我使用FT_Set_Char_Size()。快把我逼疯了几天,现在:P任何帮助是如此之大的AP preciated。

It compiles fine and I get no errors. Just the crash when I use FT_Set_Char_Size(). Driving me crazy for a few days now :P Any help is so greatly appreciated.

推荐答案

下面就是答案。原来,整个时间加载字体文件了.apk文件,因为它在技术上是COM pressed的问题。随着SDL,我们使用SDL_RWops加载.apk文件资产文件夹中的字体文件。我们加载字体文件到使用ftgles OpenGLES。完整的例子可以在 www.digitalknob.com

Here is the answer. It turns out the problem the whole time was loading the font file out of the .apk file since it is technically compressed. With SDL, We use SDL_RWops to load the font file within the assets folder of the .apk file. We load the font file into OpenGLES using ftgles. Full example can be found at www.digitalknob.com

SDL_RWops *file = SDL_RWFromFile(filename, "rb"); 

unsigned long fileLen; 
SDL_RWseek(file,0,SEEK_END); 
fileLen=SDL_RWtell(file); 
SDL_RWseek(file,0,SEEK_SET); 

//Allocate memory 
buffer=(unsigned char *)malloc(fileLen+1); 
if (!buffer){ 
   printf("Memory error!\n"); 
   SDL_RWclose(file); 
   return; 
} 

//Read file contents into buffer 
SDL_RWread(file, buffer, fileLen, 1); 
SDL_RWclose(file); 

texture_font = new FTGLTextureFont(buffer, fileLen); 
texture_font->FaceSize(18); 

//don't forget to free your buffer later.
//free(buffer);

如果您不使用SDL,你需要的zlib或东西来访问字体文件。

If your not using SDL, you'll need zlib or something to access the font file.

这篇关于FreeType的FT_Request_Size()崩溃在Android的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆