FT_Init_FreeType( FT_Library *alibrary ) { FT_Error error; FT_Memory memory; /* First of all, allocate a new system object -- this function is part */ /* of the system-specific component, i.e. `ftsystem.c'. */ memory = FT_New_Memory(); if ( !memory ) { FT_ERROR(( "FT_Init_FreeType: cannot find memory manager\n" )); return FT_Err_Unimplemented_Feature; } /* build a library out of it, then fill it with the set of */ /* default drivers. */ error = FT_New_Library( memory, alibrary ); if ( !error ) { (*alibrary)->version_major = FREETYPE_MAJOR; (*alibrary)->version_minor = FREETYPE_MINOR; (*alibrary)->version_patch = FREETYPE_PATCH; FT_Add_Default_Modules( *alibrary ); } return error; }
FT_Init_FreeType_2(FT_Library* alibrary, FT_MemoryRec_* memoryRec) { FT_Error error; FT_Memory memory; memory = (FT_Memory)memoryRec->alloc(memoryRec, sizeof(*memory)); if(memory) *memory = *memoryRec; else { //FT_ERROR(( "FT_Init_FreeType: cannot find memory manager\n" )); return FT_Err_Unimplemented_Feature; } error = FT_New_Library(memory, alibrary); if(error) FT_Done_Memory(memory); else { (*alibrary)->version_major = FREETYPE_MAJOR; (*alibrary)->version_minor = FREETYPE_MINOR; (*alibrary)->version_patch = FREETYPE_PATCH; FT_Add_Default_Modules(*alibrary); } return error; }
font_library::font_library() : library_(nullptr), memory_(new FT_MemoryRec_) { memory_->alloc = _Alloc_Func; memory_->free = _Free_Func; memory_->realloc = _Realloc_Func; FT_Error error = FT_New_Library(&*memory_, &library_); if (error) throw std::runtime_error("can not initialize FreeType2 library"); FT_Add_Default_Modules(library_); #if ((FREETYPE_MAJOR*1000 + FREETYPE_MINOR)*1000 >= 2008000) FT_Set_Default_Properties(library_); #endif if (!std::getenv("FREETYPE_PROPERTIES") && version() >= compact_version(2, 7, 0)) { FT_UInt interpreter_version = 35; error = FT_Property_Set(library_, "truetype", "interpreter-version", &interpreter_version ); if (error) { MAPNIK_LOG_WARN(font_library) << "FreeType: Error setting interpreter-version=35"; } } }
FT_Init_FreeType( FT_Library *alibrary ) { FT_Error error; FT_Memory memory; /* First of all, allocate a new system object -- this function is part */ /* of the system-specific component, i.e. `ftsystem.c'. */ memory = FT_New_Memory(); if ( !memory ) { FT_ERROR(( "FT_Init_FreeType: cannot find memory manager\n" )); return FT_THROW( Unimplemented_Feature ); } /* build a library out of it, then fill it with the set of */ /* default drivers. */ error = FT_New_Library( memory, alibrary ); if ( error ) FT_Done_Memory( memory ); else FT_Add_Default_Modules( *alibrary ); return error; }
font_library::font_library() : library_(nullptr), memory_(new FT_MemoryRec_) { memory_->alloc = _Alloc_Func; memory_->free = _Free_Func; memory_->realloc = _Realloc_Func; FT_Error error = FT_New_Library(&*memory_, &library_); if (error) throw std::runtime_error("can not initialize FreeType2 library"); FT_Add_Default_Modules(library_); }
bool fsLowLevelAPI::createFreeType() { s_memory = static_cast<FT_Memory>(fsMalloc(sizeof(*s_memory))); s_memory->user = NULL; s_memory->alloc = myMalloc; s_memory->free = myFree; s_memory->realloc = myRealloc; if (FT_New_Library(s_memory, &s_freetype)) { fsFree(s_memory); return false; } FT_Add_Default_Modules(s_freetype); return true; }