本文整理汇总了C++中FT_Open_Face函数的典型用法代码示例。如果您正苦于以下问题:C++ FT_Open_Face函数的具体用法?C++ FT_Open_Face怎么用?C++ FT_Open_Face使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FT_Open_Face函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: FT_New_Face_From_FSRef
FT_New_Face_From_FSRef( FT_Library library,
const FSRef* ref,
FT_Long face_index,
FT_Face* aface )
{
FT_Error error;
FT_Open_Args args;
OSErr err;
UInt8 pathname[PATH_MAX];
/* check of `library' and `aface' delayed to */
/* `FT_New_Face_From_Resource' */
if ( !ref )
return FT_THROW( Invalid_Argument );
err = FSRefMakePath( ref, pathname, sizeof ( pathname ) );
if ( err )
error = FT_THROW( Cannot_Open_Resource );
error = FT_New_Face_From_Resource( library, pathname, face_index, aface );
if ( error || *aface )
return error;
/* fallback to datafork font */
args.flags = FT_OPEN_PATHNAME;
args.pathname = (char*)pathname;
return FT_Open_Face( library, &args, face_index, aface );
}
开发者ID:ImageMagick,项目名称:ttf,代码行数:31,代码来源:ftmac.c
示例2: FT_EXPORT_DEF
FT_EXPORT_DEF( FT_Error ) FT_New_Face( FT_Library library,
const char* pathname,
FT_Long face_index,
FT_Face *aface )
{
FT_Open_Args args;
FSSpec spec;
OSType file_type;
/* test for valid `library' and `aface' delayed to FT_Open_Face() */
if ( !pathname )
return FT_Err_Invalid_Argument;
if ( file_spec_from_path( pathname, &spec ) )
return FT_Err_Invalid_Argument;
file_type = get_file_type( &spec );
if ( file_type == 'FFIL' || file_type == 'tfil' )
return FT_New_Face_From_Suitcase( library, &spec, face_index, aface );
else if ( file_type == 'LWFN' )
return FT_New_Face_From_LWFN( library, &spec, face_index, aface );
else
{
args.flags = ft_open_pathname;
args.pathname = (char*)pathname;
return FT_Open_Face( library, &args, face_index, aface );
}
}
开发者ID:Joincheng,项目名称:lithtech,代码行数:30,代码来源:ftmac.c
示例3: FT_New_Face
FT_New_Face( FT_Library library,
const char* pathname,
FT_Long face_index,
FT_Face* aface )
{
FT_Open_Args args;
FT_Error error;
/* test for valid `library' and `aface' delayed to FT_Open_Face() */
if ( !pathname )
return FT_Err_Invalid_Argument;
error = FT_Err_Ok;
*aface = NULL;
/* try resourcefork based font: LWFN, FFIL */
error = FT_New_Face_From_Resource( library, (UInt8 *)pathname,
face_index, aface );
if ( error != 0 || *aface != NULL )
return error;
/* let it fall through to normal loader (.ttf, .otf, etc.) */
args.flags = FT_OPEN_PATHNAME;
args.pathname = (char*)pathname;
return FT_Open_Face( library, &args, face_index, aface );
}
开发者ID:32767,项目名称:libgdx,代码行数:27,代码来源:ftmac.c
示例4: LoadFromFile
//-----------------------------------------------------------------------------
// Load a TrueType font into memory. We care about the curves that define
// the letter shapes, and about the mappings that determine which glyph goes
// with which character.
//-----------------------------------------------------------------------------
bool TtfFont::LoadFromFile(FT_Library fontLibrary, bool nameOnly) {
FT_Open_Args args = {};
args.flags = FT_OPEN_PATHNAME;
args.pathname = &fontFile[0]; // FT_String is char* for historical reasons
// We don't use ssfopen() here to let freetype do its own memory management.
// This is OK because on Linux/OS X we just delegate to fopen and on Windows
// we only look into C:\Windows\Fonts, which has a known short path.
if(int fterr = FT_Open_Face(fontLibrary, &args, 0, &fontFace)) {
dbp("freetype: loading font from file '%s' failed: %s",
fontFile.c_str(), ft_error_string(fterr));
return false;
}
if(int fterr = FT_Select_Charmap(fontFace, FT_ENCODING_UNICODE)) {
dbp("freetype: loading unicode CMap for file '%s' failed: %s",
fontFile.c_str(), ft_error_string(fterr));
FT_Done_Face(fontFace);
return false;
}
name = std::string(fontFace->family_name) +
" (" + std::string(fontFace->style_name) + ")";
if(nameOnly) {
FT_Done_Face(fontFace);
fontFace = NULL;
}
return true;
}
开发者ID:Kenzu,项目名称:solvespace,代码行数:36,代码来源:ttf.cpp
示例5: FT_New_Face_From_FSRef
FT_New_Face_From_FSRef( FT_Library library,
const FSRef* ref,
FT_Long face_index,
FT_Face* aface )
{
FT_Error error;
FT_Open_Args args;
OSErr err;
UInt8 pathname[PATH_MAX];
if ( !ref )
return FT_Err_Invalid_Argument;
err = FSRefMakePath( ref, pathname, sizeof ( pathname ) );
if ( err )
error = FT_Err_Cannot_Open_Resource;
error = FT_New_Face_From_Resource( library, pathname, face_index, aface );
if ( error != 0 || *aface != NULL )
return error;
/* fallback to datafork font */
args.flags = FT_OPEN_PATHNAME;
args.pathname = (char*)pathname;
return FT_Open_Face( library, &args, face_index, aface );
}
开发者ID:32767,项目名称:libgdx,代码行数:27,代码来源:ftmac.c
示例6: face_requester
FT_Error face_requester(FTC_FaceID face_id, FT_Library library, FT_Pointer request_data, FT_Face *aface)
{
FT_Open_Args args = {};
args.flags = FT_OPEN_STREAM;
args.stream = font_mgr_instance.lookup_stream(face_id);
return FT_Open_Face(library, &args, font_mgr_instance.lookup_face_index(face_id), aface);
}
开发者ID:Artoria2e5,项目名称:GDJ,代码行数:8,代码来源:freetype.cpp
示例7: constructor_impl
/*************************************************************************
Function to do real work of constructor
*************************************************************************/
void Font_FreeType::constructor_impl(const String& name, const String& fontname, const String& resourceGroup, uint size, bool antiAliase, bool encrypted)
{
String errMsg;
FontDataStream* fontDataStream =
FontManager::getSingleton().getFontDataStream(fontname, resourceGroup, encrypted);
// create face using input font
FT_Open_Args args;
args.flags = FT_OPEN_STREAM;
args.stream = &(fontDataStream->d_streamRec);
if (FT_Open_Face(d_impldat->library, &args, 0, &d_impldat->fontFace) == 0)
{
// check that default Unicode character map is available
if (d_impldat->fontFace->charmap != NULL)
{
try
{
d_name = name;
d_ptSize = size;
d_antiAliase = antiAliase;
// reprepare font datas.
resetFontFaces();
// prepare underline image
createUnderlineImage();
return;
}
catch(...)
{
FT_Done_Face(d_impldat->fontFace);
// re-throw
throw;
}
}
// missing Unicode character map
else
{
FT_Done_Face(d_impldat->fontFace);
errMsg = (utf8*)"Font_FreeType::constructor_impl - The source font '" + fontname +"' does not have a Unicode charmap, and cannot be used.";
}
}
// failed to create face (a problem with the font file?)
else
{
errMsg = (utf8*)"Font_FreeType::constructor_impl - An error occurred while trying to create a FreeType face from source font '" + fontname + "'.";
}
throw GenericException(errMsg);
}
开发者ID:gitrider,项目名称:wxsj2,代码行数:61,代码来源:CEGUIFont_FreeType.cpp
示例8: cleanup
bool Font::loadFromStream(InputStream& stream)
{
// Cleanup the previous resources
cleanup();
m_refCount = new int(1);
// Initialize FreeType
// Note: we initialize FreeType for every font instance in order to avoid having a single
// global manager that would create a lot of issues regarding creation and destruction order.
FT_Library library;
if (FT_Init_FreeType(&library) != 0)
{
err() << "Failed to load font from stream (failed to initialize FreeType)" << std::endl;
return false;
}
m_library = library;
// Prepare a wrapper for our stream, that we'll pass to FreeType callbacks
FT_StreamRec* rec = new FT_StreamRec;
std::memset(rec, 0, sizeof(*rec));
rec->base = NULL;
rec->size = static_cast<unsigned long>(stream.getSize());
rec->pos = 0;
rec->descriptor.pointer = &stream;
rec->read = &read;
rec->close = &close;
// Setup the FreeType callbacks that will read our stream
FT_Open_Args args;
args.flags = FT_OPEN_STREAM;
args.stream = rec;
args.driver = 0;
// Load the new font face from the specified stream
FT_Face face;
if (FT_Open_Face(static_cast<FT_Library>(m_library), &args, 0, &face) != 0)
{
err() << "Failed to load font from stream (failed to create the font face)" << std::endl;
return false;
}
// Select the unicode character map
if (FT_Select_Charmap(face, FT_ENCODING_UNICODE) != 0)
{
err() << "Failed to load font from stream (failed to set the Unicode character set)" << std::endl;
return false;
}
// Store the loaded font in our ugly void* :)
m_face = face;
m_streamRec = rec;
return true;
}
开发者ID:decultured,项目名称:SFML,代码行数:54,代码来源:Font.cpp
示例9: FontManager
bool CWin32Font::Create(const char *windowsFontName, int tall, int weight, int blur, int scanlines, int flags)
{
FT_Library library = FontManager().GetFTLibrary();
if (!library)
return false;
const unsigned char *file = FontManager().GetFontFile(windowsFontName);
if (!file)
{
m_szName = UTL_INVAL_SYMBOL;
return false;
}
FT_Face face;
FT_Open_Args args;
args.flags = FT_OPEN_MEMORY | FT_OPEN_DRIVER;
args.memory_base = file + sizeof(int);
args.memory_size = *((const int *)file);
args.stream = NULL;
args.driver = FT_Get_Module(library, "truetype");
if (FT_Open_Face(library, &args, 0, &face))
{
m_szName = UTL_INVAL_SYMBOL;
return false;
}
m_FTFace = face;
m_szName = windowsFontName;
m_iTall = tall;
m_iFlags = flags & WIN32FONT_FLAGS_MASK;
m_iScanLines = scanlines;
m_iBlur = blur;
m_iDropShadowOffset = (flags & vgui::ISurface::FONTFLAG_DROPSHADOW) ? 1 : 0;
m_iOutlineSize = (flags & vgui::ISurface::FONTFLAG_OUTLINE) ? 1 : 0;
m_bRotary = (flags & vgui::ISurface::FONTFLAG_ROTARY) ? 1 : 0;
m_bAdditive = (flags & vgui::ISurface::FONTFLAG_ADDITIVE) ? 1 : 0;
tall <<= 6;
FT_Set_Char_Size(face, tall, tall, 72, 72);
float scale = ((float)(face->size->metrics.ascender) * (1.0f / 64.0f)) / (float)(face->ascender);
m_iBaseline = (int)(ceilf((float)(face->bbox.yMax) * scale));
m_iHeight = m_iBaseline + (int)(ceilf((float)(-face->bbox.yMin) * scale)) + m_iDropShadowOffset + (m_iOutlineSize << 1);
m_iMaxCharWidth = (face->size->metrics.max_advance + 127) >> 6;
m_iAscent = (int)(ceilf((float)(face->ascender) * scale));
m_rgiBitmapSize[0] = m_iMaxCharWidth + (m_iOutlineSize << 1);
m_rgiBitmapSize[1] = m_iHeight;
return true;
}
开发者ID:TrentSterling,项目名称:D0G,代码行数:52,代码来源:Win32Font_android.cpp
示例10: sizeof
NSFonts::IFontFile* NSFonts::IFontManager::LoadFontFile(NSFonts::CLibrary& library, NSFonts::IFontStream* pStreamI, int lFaceIndex)
{
CFontStream* pStream = (CFontStream*)pStreamI;
FT_Open_Args oOpenArgs;
oOpenArgs.flags = FT_OPEN_MEMORY | FT_OPEN_PARAMS;
oOpenArgs.memory_base = pStream->m_pData;
oOpenArgs.memory_size = pStream->m_lSize;
FT_Parameter *pParams = (FT_Parameter *)::malloc( sizeof(FT_Parameter) * 4 );
pParams[0].tag = FT_MAKE_TAG( 'i', 'g', 'p', 'f' );
pParams[0].data = NULL;
pParams[1].tag = FT_MAKE_TAG( 'i', 'g', 'p', 's' );
pParams[1].data = NULL;
pParams[2].tag = FT_PARAM_TAG_IGNORE_PREFERRED_FAMILY;
pParams[2].data = NULL;
pParams[3].tag = FT_PARAM_TAG_IGNORE_PREFERRED_SUBFAMILY;
pParams[3].data = NULL;
oOpenArgs.params = pParams;
oOpenArgs.num_params = 4;
FT_Face pFace;
if ( FT_Open_Face( library.m_internal->m_library, &oOpenArgs, lFaceIndex, &pFace ) )
return NULL;
::free(pParams);
CFontFile* pFont = new CFontFile();
pFont->m_lFaceIndex = lFaceIndex;
pFont->m_lUnits_Per_Em = pFace->units_per_EM;
pFont->m_lAscender = pFace->ascender;
pFont->m_lDescender = pFace->descender;
pFont->m_lLineHeight = pFace->height;
pFont->m_nNum_charmaps = pFace->num_charmaps;
pFont->m_pFace = pFace;
pFont->LoadDefaultCharAndSymbolicCmapIndex();
if (FT_Set_Char_Size(pFace, 0, (FT_F26Dot6)(pFont->m_dSize * 64), 0, 0))
{
FT_Done_Face(pFace);
delete pFont;
return NULL;
}
pFont->ResetTextMatrix();
pFont->ResetFontMatrix();
return pFont;
}
开发者ID:ONLYOFFICE,项目名称:core,代码行数:52,代码来源:FontManager.cpp
示例11: FT_New_Face_From_FSSpec
FT_New_Face_From_FSSpec( FT_Library library,
const FSSpec* spec,
FT_Long face_index,
FT_Face* aface )
{
#if HAVE_FSREF
FSRef ref;
if ( !spec || FSpMakeFSRef( spec, &ref ) != noErr )
return FT_THROW( Invalid_Argument );
else
return FT_New_Face_From_FSRef( library, &ref, face_index, aface );
#elif HAVE_FSSPEC
FT_Error error;
FT_Open_Args args;
OSErr err;
UInt8 pathname[PATH_MAX];
if ( !spec )
return FT_THROW( Invalid_Argument );
err = FT_FSpMakePath( spec, pathname, sizeof ( pathname ) );
if ( err )
error = FT_ERR( Cannot_Open_Resource );
error = FT_New_Face_From_Resource( library, pathname, face_index, aface );
if ( error || *aface )
return error;
/* fallback to datafork font */
args.flags = FT_OPEN_PATHNAME;
args.pathname = (char*)pathname;
return FT_Open_Face( library, &args, face_index, aface );
#else
FT_UNUSED( library );
FT_UNUSED( spec );
FT_UNUSED( face_index );
FT_UNUSED( aface );
return FT_THROW( Unimplemented_Feature );
#endif /* HAVE_FSREF, HAVE_FSSPEC */
}
开发者ID:Wafflespeanut,项目名称:gecko-dev,代码行数:52,代码来源:ftmac.c
示例12: ref_ft_face
static SkFaceRec* ref_ft_face(uint32_t fontID) {
SkFaceRec* rec = gFaceRecHead;
while (rec) {
if (rec->fFontID == fontID) {
SkASSERT(rec->fFace);
rec->fRefCnt += 1;
return rec;
}
rec = rec->fNext;
}
SkStream* strm = SkFontHost::OpenStream(fontID);
if (NULL == strm) {
SkDEBUGF(("SkFontHost::OpenStream failed opening %x\n", fontID));
sk_throw();
return 0;
}
// this passes ownership of strm to the rec
rec = SkNEW_ARGS(SkFaceRec, (strm, fontID));
FT_Open_Args args;
memset(&args, 0, sizeof(args));
const void* memoryBase = strm->getMemoryBase();
if (NULL != memoryBase) {
//printf("mmap(%s)\n", keyString.c_str());
args.flags = FT_OPEN_MEMORY;
args.memory_base = (const FT_Byte*)memoryBase;
args.memory_size = strm->getLength();
} else {
//printf("fopen(%s)\n", keyString.c_str());
args.flags = FT_OPEN_STREAM;
args.stream = &rec->fFTStream;
}
FT_Error err = FT_Open_Face(gFTLibrary, &args, 0, &rec->fFace);
if (err) { // bad filename, try the default font
fprintf(stderr, "ERROR: unable to open font '%x'\n", fontID);
SkDELETE(rec);
sk_throw();
return 0;
} else {
SkASSERT(rec->fFace);
//fprintf(stderr, "Opened font '%s'\n", filename.c_str());
rec->fNext = gFaceRecHead;
gFaceRecHead = rec;
rec->fRefCnt = 1;
return rec;
}
}
开发者ID:edrikL,项目名称:gears,代码行数:52,代码来源:SkFontHost_FreeType.cpp
示例13: _PGFT_face_request
/*********************************************************
*
* Font loading
*
* TODO:
* - Loading from rwops, existing files, etc
*
*********************************************************/
static FT_Error
_PGFT_face_request(FTC_FaceID face_id, FT_Library library,
FT_Pointer request_data, FT_Face *aface)
{
PgFaceId *id = (PgFaceId *)face_id;
FT_Error error;
Py_BEGIN_ALLOW_THREADS;
error = FT_Open_Face(library, &id->open_args, id->face_index, aface);
Py_END_ALLOW_THREADS;
return error;
}
开发者ID:atizo,项目名称:pygame,代码行数:21,代码来源:ft_wrap.c
示例14: openFace
static FT_Error openFace(char* filename, FT_Long index, FT_Face* aface)
{
FT_Open_Args args = {
FT_OPEN_STREAM,
0,0, /* memory_base, memory_size */
0, /* filename */
makeFTStream(filename), /* stream */
0, /* driver */
0, /* extra params */
0 /* params */
};
return FT_Open_Face(ftlib, &args, index, aface);
}
开发者ID:amineas,项目名称:libGK,代码行数:13,代码来源:fonts.c
示例15: New_Face
FT_Error New_Face( FT_Library library,
FT_StreamRec& stream,
FT_Long face_index,
FT_Face *aface ) {
FT_Open_Args args;
args.pathname = 0;
args.flags = FT_OPEN_STREAM;
args.stream = &stream;
return FT_Open_Face( library, &args, face_index, aface );
}
开发者ID:Try,项目名称:Tempest,代码行数:13,代码来源:font.cpp
示例16: FT_New_Xfs_Face
static FT_Error FT_New_Xfs_Face(FT_Library library, const char * pathname, FT_Long face_index, FT_Face * aface)
{
FT_Open_Args args;
if(!pathname)
return -1;
args.flags = FT_OPEN_STREAM;
args.pathname = (char *)pathname;
args.stream = FT_New_Xfs_Stream(pathname);
return FT_Open_Face(library, &args, face_index, aface);
}
开发者ID:IngenicC,项目名称:xboot,代码行数:13,代码来源:l-font.c
示例17: lock
FT_Byte* FreeTypeLibrary::getFace(std::istream &fontstream, unsigned int index, FT_Face &face)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(getMutex());
FT_Open_Args args;
std::streampos start = fontstream.tellg();
fontstream.seekg(0, std::ios::end);
std::streampos end = fontstream.tellg();
fontstream.seekg(start, std::ios::beg);
std::streampos length = end - start;
/* empty stream into memory, open that, and keep the pointer in a FreeTypeFont for cleanup */
FT_Byte *buffer = new FT_Byte[static_cast<int>(length)];
fontstream.read(reinterpret_cast<char*>(buffer), length);
if (!fontstream || (static_cast<std::streampos>(fontstream.gcount()) != length))
{
OSG_WARN << " .... the font file could not be read from its stream" << std::endl;
if (buffer)
delete[] buffer;
return 0;
}
args.flags = FT_OPEN_MEMORY;
args.memory_base = buffer;
args.memory_size = length;
FT_Error error = FT_Open_Face(_ftlibrary, &args, index, &face);
if (error == FT_Err_Unknown_File_Format)
{
OSG_WARN << " .... the font file could be opened and read, but it appears" << std::endl;
OSG_WARN << " .... that its font format is unsupported" << std::endl;
return 0;
}
else if (error)
{
OSG_WARN << " .... another error code means that the font file could not" << std::endl;
OSG_WARN << " .... be opened, read or simply that it is broken..." << std::endl;
return 0;
}
//
// GT: Fix to handle symbol fonts in MS Windows
//
verifyCharacterMap(face);
return buffer;
}
开发者ID:hyyh619,项目名称:OpenSceneGraph-3.4.0,代码行数:51,代码来源:FreeTypeLibrary.cpp
示例18: FT_Done_Face
bool FreeTypeSysFontData::OpenFaceByIndex(int index)
{
if(m_ftFace) {
FT_Done_Face(m_ftFace);
m_ftFace = NULL;
}
FT_Open_Args args = { 0 };
args.flags = FT_OPEN_STREAM;
args.stream = &m_ftStream;
// FreeType 偱埖偊傞偐丠
return (FT_Open_Face(freetype_library, &args, index, &m_ftFace) == 0);
}
开发者ID:dirtycold,项目名称:mactype,代码行数:14,代码来源:fteng.cpp
示例19: open_face_from_buffer
/* Create a new FT_Face given a buffer and a driver name. */
static FT_Error
open_face_from_buffer( FT_Library library,
FT_Byte* base,
FT_ULong size,
FT_Long face_index,
char* driver_name,
FT_Face* aface )
{
FT_Open_Args args;
FT_Error error;
FT_Stream stream;
FT_Memory memory = library->memory;
error = new_memory_stream( library,
base,
size,
memory_stream_close,
&stream );
if ( error )
{
FT_FREE( base );
return error;
}
args.flags = FT_OPEN_STREAM;
args.stream = stream;
if ( driver_name )
{
args.flags = args.flags | FT_OPEN_DRIVER;
args.driver = FT_Get_Module( library, driver_name );
}
/* At this point, face_index has served its purpose; */
/* whoever calls this function has already used it to */
/* locate the correct font data. We should not propagate */
/* this index to FT_Open_Face() (unless it is negative). */
if ( face_index > 0 )
face_index = 0;
error = FT_Open_Face( library, &args, face_index, aface );
if ( error == FT_Err_Ok )
(*aface)->face_flags &= ~FT_FACE_FLAG_EXTERNAL_STREAM;
else
FT_Stream_Free( stream, 0 );
return error;
}
开发者ID:gorlak,项目名称:panda3d-thirdparty,代码行数:50,代码来源:ftmac.c
示例20: memset
FT_Face Lib::open(const std::string& filename)
{
FT_Stream stream = ft::open_stream(m_ft, filename);
FT_Open_Args args;
memset(&args, 0, sizeof(args));
args.flags = FT_OPEN_STREAM;
args.stream = stream;
LOG(VERBOSE) << "FT: Loading font '" << filename << "'\n";
FT_Face face = nullptr;
FT_Error err = FT_Open_Face(m_ft, &args, 0, &face);
if (!err)
FT_Select_Charmap(face, FT_ENCODING_UNICODE);
return face;
}
开发者ID:pseudogames,项目名称:aseprite,代码行数:16,代码来源:lib.cpp
注:本文中的FT_Open_Face函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论