当前位置: 首页>>代码示例>>C++>>正文


C++ FT_Open_Face函数代码示例

本文整理汇总了C++中FT_Open_Face函数的典型用法代码示例。如果您正苦于以下问题:C++ FT_Open_Face函数的具体用法?C++ FT_Open_Face怎么用?C++ FT_Open_Face使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了FT_Open_Face函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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


注:本文中的FT_Open_Face函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。