diff --git a/src/libs/freetype/lv_freetype.c b/src/libs/freetype/lv_freetype.c index bb665ebc9..2e6b61b57 100755 --- a/src/libs/freetype/lv_freetype.c +++ b/src/libs/freetype/lv_freetype.c @@ -40,10 +40,6 @@ typedef struct { /********************** * STATIC PROTOTYPES **********************/ -static FT_Error lv_freetype_face_requester(FTC_FaceID face_id, - FT_Library library, - FT_Pointer req_data, - FT_Face * aface); static void lv_freetype_cleanup(lv_freetype_context_t * ctx); static FTC_FaceID lv_freetype_req_face_id(lv_freetype_context_t * ctx, const char * pathname); static void lv_freetype_drop_face_id(lv_freetype_context_t * ctx, FTC_FaceID face_id); @@ -66,7 +62,7 @@ static lv_cache_compare_res_t cache_node_cache_compare_cb(const lv_freetype_cach * GLOBAL FUNCTIONS **********************/ -lv_result_t lv_freetype_init(uint32_t max_faces, uint32_t max_sizes, uint32_t max_kilobytes) +lv_result_t lv_freetype_init(void) { if(ft_ctx) { LV_LOG_WARN("freetype already initialized"); @@ -89,26 +85,6 @@ lv_result_t lv_freetype_init(uint32_t max_faces, uint32_t max_sizes, uint32_t ma return LV_RESULT_INVALID; } - error = FTC_Manager_New(ctx->library, - max_faces, - max_sizes, - max_kilobytes * 1024, - lv_freetype_face_requester, - NULL, - &ctx->cache_manager); - if(error) { - FT_ERROR_MSG("FTC_Manager_New", error); - lv_freetype_cleanup(ctx); - return LV_RESULT_INVALID; - } - - error = FTC_CMapCache_New(ctx->cache_manager, &ctx->cmap_cache); - if(error) { - FT_ERROR_MSG("FTC_CMapCache_New", error); - lv_freetype_cleanup(ctx); - return LV_RESULT_INVALID; - } - _lv_ll_init(&ctx->face_id_ll, sizeof(face_id_node_t)); lv_cache_ops_t ops = { @@ -221,27 +197,6 @@ lv_freetype_context_t * lv_freetype_get_context(void) return LV_GLOBAL_DEFAULT()->ft_context; } -FT_Size lv_freetype_lookup_size(const lv_freetype_font_dsc_t * dsc) -{ - FT_Error error; - lv_freetype_context_t * ctx = dsc->context; - - FT_Size ft_size; - struct FTC_ScalerRec_ scaler; - scaler.face_id = dsc->face_id; - scaler.width = dsc->size; - scaler.height = dsc->size; - scaler.pixel = 1; - error = FTC_Manager_LookupSize(ctx->cache_manager, &scaler, &ft_size); - - if(error) { - FT_ERROR_MSG("FTC_Manager_LookupSize", error); - return NULL; - } - - return ft_size; -} - void lv_freetype_italic_transform(FT_Face face) { LV_ASSERT_NULL(face); @@ -310,24 +265,6 @@ static void freetype_on_font_set_cbs(lv_freetype_font_dsc_t * dsc) } } -static FT_Error lv_freetype_face_requester(FTC_FaceID face_id, - FT_Library library, - FT_Pointer req_data, - FT_Face * aface) -{ - LV_UNUSED(library); - LV_UNUSED(req_data); - - const char * pathname = lv_freetype_get_pathname(face_id); - - FT_Error error = FT_New_Face(library, pathname, 0, aface); - if(error) { - FT_ERROR_MSG("FT_New_Face", error); - LV_LOG_ERROR("error pathname = %s", pathname); - } - return error; -} - static void lv_freetype_cleanup(lv_freetype_context_t * ctx) { LV_ASSERT_NULL(ctx); @@ -336,11 +273,6 @@ static void lv_freetype_cleanup(lv_freetype_context_t * ctx) ctx->cache_node_cache = NULL; } - if(ctx->cache_manager) { - FTC_Manager_Done(ctx->cache_manager); - ctx->cache_manager = NULL; - } - if(ctx->library) { FT_Done_FreeType(ctx->library); ctx->library = NULL; @@ -401,7 +333,6 @@ static void lv_freetype_drop_face_id(lv_freetype_context_t * ctx, FTC_FaceID fac if(node->ref_cnt == 0) { LV_LOG_INFO("drop face_id: %s", node->pathname); _lv_ll_remove(ll_p, node); - FTC_Manager_RemoveFaceID(ctx->cache_manager, face_id); lv_free(node->pathname); lv_free(node); } diff --git a/src/libs/freetype/lv_freetype.h b/src/libs/freetype/lv_freetype.h index eed28a37e..f1b7627c7 100755 --- a/src/libs/freetype/lv_freetype.h +++ b/src/libs/freetype/lv_freetype.h @@ -76,13 +76,9 @@ typedef struct { /** * Initialize the freetype library. - * @param max_faces Maximum number of opened FT_Face objects managed by this cache instance. Use 0 for defaults. - * @param max_sizes Maximum number of opened FT_Size objects managed by this cache instance. Use 0 for defaults. - * @param max_kilobytes Maximum number of kilobytes to use for cached data nodes. Use 0 for defaults. - * Note that this value does not account for managed FT_Face and FT_Size objects. * @return LV_RESULT_OK on success, otherwise LV_RESULT_INVALID. */ -lv_result_t lv_freetype_init(uint32_t max_faces, uint32_t max_sizes, uint32_t max_kilobytes); +lv_result_t lv_freetype_init(void); /** * Uninitialize the freetype library diff --git a/src/libs/freetype/lv_freetype_glyph.c b/src/libs/freetype/lv_freetype_glyph.c index 949aa9cb1..341b300c4 100644 --- a/src/libs/freetype/lv_freetype_glyph.c +++ b/src/libs/freetype/lv_freetype_glyph.c @@ -130,8 +130,7 @@ static bool freetype_glyph_create_cb(lv_freetype_glyph_cache_data_t * data, void lv_font_glyph_dsc_t * dsc_out = &data->glyph_dsc; FT_Face face = dsc->cache_node->face; - FT_UInt charmap_index = FT_Get_Charmap_Index(face->charmap); - FT_UInt glyph_index = FTC_CMapCache_Lookup(dsc->context->cmap_cache, dsc->face_id, charmap_index, data->unicode); + FT_UInt glyph_index = FT_Get_Char_Index(face, data->unicode); FT_Set_Pixel_Sizes(face, 0, dsc->size); error = FT_Load_Glyph(face, glyph_index, FT_LOAD_COMPUTE_METRICS | FT_LOAD_NO_BITMAP); diff --git a/src/libs/freetype/lv_freetype_image.c b/src/libs/freetype/lv_freetype_image.c index f1ef689e3..60be3be1f 100755 --- a/src/libs/freetype/lv_freetype_image.c +++ b/src/libs/freetype/lv_freetype_image.c @@ -87,8 +87,7 @@ static const void * freetype_get_glyph_bitmap_cb(lv_font_glyph_dsc_t * g_dsc, LV_ASSERT_FREETYPE_FONT_DSC(dsc); FT_Face face = dsc->cache_node->face; - FT_UInt charmap_index = FT_Get_Charmap_Index(face->charmap); - FT_UInt glyph_index = FTC_CMapCache_Lookup(dsc->context->cmap_cache, dsc->face_id, charmap_index, unicode_letter); + FT_UInt glyph_index = FT_Get_Char_Index(face, unicode_letter); lv_cache_t * cache = dsc->cache_node->draw_data_cache; diff --git a/src/libs/freetype/lv_freetype_outline.c b/src/libs/freetype/lv_freetype_outline.c index 6bff04b08..acc9b2866 100755 --- a/src/libs/freetype/lv_freetype_outline.c +++ b/src/libs/freetype/lv_freetype_outline.c @@ -187,8 +187,8 @@ static lv_cache_entry_t * lv_freetype_outline_lookup(lv_freetype_font_dsc_t * ds { lv_freetype_cache_node_t * cache_node = dsc->cache_node; - FT_UInt charmap_index = FT_Get_Charmap_Index(cache_node->face->charmap); - FT_UInt glyph_index = FTC_CMapCache_Lookup(dsc->context->cmap_cache, dsc->face_id, charmap_index, unicode_letter); + FT_Face face = cache_node->face; + FT_UInt glyph_index = FT_Get_Char_Index(face, unicode_letter); lv_freetype_outline_node_t tmp_node; tmp_node.glyph_index = glyph_index; diff --git a/src/libs/freetype/lv_freetype_private.h b/src/libs/freetype/lv_freetype_private.h index 817daf0a5..c3dd296c5 100755 --- a/src/libs/freetype/lv_freetype_private.h +++ b/src/libs/freetype/lv_freetype_private.h @@ -80,8 +80,6 @@ struct _lv_freetype_cache_node_t { typedef struct _lv_freetype_context_t { FT_Library library; - FTC_Manager cache_manager; - FTC_CMapCache cmap_cache; lv_ll_t face_id_ll; lv_event_cb_t event_cb; diff --git a/src/lv_init.c b/src/lv_init.c index 7049f4e3f..9f89e4799 100644 --- a/src/lv_init.c +++ b/src/lv_init.c @@ -297,7 +297,7 @@ void lv_init(void) #if LV_USE_FREETYPE /*Init freetype library*/ # if LV_FREETYPE_CACHE_SIZE >= 0 - lv_freetype_init(LV_FREETYPE_CACHE_FT_FACES, LV_FREETYPE_CACHE_FT_SIZES, LV_FREETYPE_CACHE_SIZE); + lv_freetype_init(); # else lv_freetype_init(0, 0, 0); # endif