您当前的位置:首页 > IT编程 > C++
| C语言 | Java | VB | VC | python | Android | TensorFlow | C++ | oracle | 学术与代码 | cnn卷积神经网络 | gnn | 图像修复 | Keras | 数据集 | Neo4j | 自然语言处理 | 深度学习 | 医学CAD | 医学影像 | 超参数 | pointnet | pytorch | 异常检测 | Transformers | 情感分类 | 知识图谱 |

自学教程:C++ FT_New_Memory_Face函数代码示例

51自学网 2021-06-01 20:44:30
  C++
这篇教程C++ FT_New_Memory_Face函数代码示例写得很实用,希望能帮到您。

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

在下文中一共展示了FT_New_Memory_Face函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: libaroma_font

/* * Function    : libaroma_font * Return Value: byte * Descriptions: load new font */byte libaroma_font(    byte fontid,    LIBAROMA_STREAMP stream) {  if (!stream) {    ALOGW("libaroma_font stream not found");    return 0;  }    if (fontid >= _LIBAROMA_FONT_MAX_FACE) {    ALOGW("libaroma_font fontid(%i)>=%i",      fontid, _LIBAROMA_FONT_MAX_FACE);    return 0;  }    /* thread safe */  _libaroma_font_lock(1);    /* load face */  FT_Face tmp_face;  if (FT_New_Memory_Face(_libaroma_font_instance,       stream->data,      stream->size,      0,      &tmp_face) == 0) {    /* set default face size */    int def_size = libaroma_font_size_px(2);        if (FT_Set_Pixel_Sizes(tmp_face, 0, def_size) == 0) {      /* save it */      libaroma_font_free(fontid);      _libaroma_font_faces[fontid].size   = def_size;      _libaroma_font_faces[fontid].id     = fontid;      _libaroma_font_faces[fontid].face   = tmp_face;      _libaroma_font_faces[fontid].stream = stream;      _libaroma_font_faces[fontid].cache  =        libaroma_iarray(libaroma_font_freecache_cb);            /* force ucs2 */      libaroma_font_set_ucs2(_libaroma_font_faces[fontid].face);            /* init harfbuzz */      _libaroma_font_hb_init(fontid);            /* unlock */      _libaroma_font_lock(0);      ALOGV("font loaded %ibytes (%s)", stream->size, stream->uri);      return 1;    }    else {      ALOGW("libaroma_font libaroma_font_set_size error");      FT_Done_Face(tmp_face);    }  }  else {    ALOGW("libaroma_font FT_New_Memory_Face Error");    libaroma_stream_close(stream);  }  _libaroma_font_lock(0);  return 0;} /* End of libaroma_font */
开发者ID:sub77-bkp,项目名称:libaroma,代码行数:65,


示例2: TTF_New_Memory_Face

TTF_Font* TTF_New_Memory_Face(const FT_Byte* file_base, FT_Long file_size, int ptsize)	{	TTF_Font *font = (TTF_Font*)malloc(sizeof *font);	if (font == NULL)		E_Exit("TTF: Out of memory");	memset(font, 0, sizeof(*font));	if (FT_New_Memory_Face(library, file_base, file_size, 0, &font->face))		E_Exit("TTF: Couldn't init font");	FT_Face face = font->face;	if (!FT_IS_SCALABLE(face))														// Make sure that our font face is scalable (global metrics)		E_Exit("TTF: Font is not scalable");	for (int i = 0; i < face->num_charmaps; i++)									// Set charmap for loaded font		{		FT_CharMap charmap = face->charmaps[i];		if (charmap->platform_id == 3 && charmap->encoding_id == 1)					// Windows Unicode			{			FT_Set_Charmap(face, charmap);			break;			}		} 	TTF_SetCharSize(font, ptsize);	bool fontOK = false;	if (!FT_Load_Glyph(face, 0, FT_LOAD_DEFAULT))									// Test pixel mode		if (!FT_Render_Glyph(font->face->glyph, FT_RENDER_MODE_NORMAL))				// Render the glyph			if (font->face->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_GRAY)				fontOK = true;	if (!fontOK)		E_Exit("TTF: Font is not 8 bits gray scale");	return font;	}
开发者ID:catastrophicanomaly,项目名称:vDosXY3,代码行数:33,


示例3: _isReady

Font::Font(const int& data_index)	: _isReady(false){	if (FT_Init_FreeType(&_freeType)) {		ax::Error("Could not init freetype library.");		FT_Done_FreeType(_freeType);	}	else {		if (data_index > 1) {			ax::Error("Only two default font buffer.");			FT_Done_FreeType(_freeType);		}		else {			FT_Error err				= FT_New_Memory_Face(_freeType, GetDefaultFontData(data_index),					GetDefaultFontDataSize(data_index), 0, &_face);			if (err) {				ax::Error("Could not open font index", data_index);				FT_Done_FreeType(_freeType);			}			else {				_isReady = true;				SetFontSize(12);//				glGenTextures(1, &_texture);			}		}	}}
开发者ID:axlib,项目名称:OpenAX,代码行数:31,


示例4: pdf_loadembeddedfont

fz_error *pdf_loadembeddedfont(pdf_font *font, pdf_xref *xref, fz_obj *stmref){	fz_error *error;	int fterr;	FT_Face face;	fz_buffer *buf;	error = initfontlibs();	if (error)		return fz_rethrow(error, "cannot init font libraries");	pdf_logfont("load embedded font/n");	error = pdf_loadstream(&buf, xref, fz_tonum(stmref), fz_togen(stmref));	if (error)		return fz_rethrow(error, "cannot load font stream");	fterr = FT_New_Memory_Face(ftlib, buf->rp, buf->wp - buf->rp, 0, &face);	if (fterr)	{		fz_dropbuffer(buf);		return fz_throw("freetype: cannot load embedded font: %s", ft_errstr(fterr));	}	font->ftface = face;	font->fontdata = buf;	return fz_okay;}
开发者ID:lgchmomo,项目名称:mupdf,代码行数:30,


示例5: FT_New_Memory_Face

static VChar *objchr_to_ftvfontdata(VFont *vfont, FT_ULong charcode){	VChar *che;	/* Freetype2 */	FT_Face face;	/* Load the font to memory */	if (vfont->temp_pf) {		err = FT_New_Memory_Face(library,		                         vfont->temp_pf->data,		                         vfont->temp_pf->size,		                         0,		                         &face);		if (err) {			return NULL;		}	}	else {		err = TRUE;		return NULL;	}	/* Read the char */	che = freetypechar_to_vchar(face, charcode, vfont->data);	/* And everything went ok */	return che;}
开发者ID:YasirArafath,项目名称:blender-git,代码行数:29,


示例6: AddFontDir

void kGUI::AddFontDir(const char *path){	unsigned int i,n;	kGUIDir dir;	unsigned long fontfilesize;	unsigned char *mem;	kGUIFontFileInfo *ffi;	FT_Face ftface;	dir.LoadDir(path,false,true,"ttf");	n=dir.GetNumFiles();	for(i=0;i<n;++i)	{		mem=kGUI::LoadFile(dir.GetFilename(i),&fontfilesize);		if(mem)		{			if(FT_New_Memory_Face( kGUIFont::GetLibrary(),									mem,			/* first byte in memory */									fontfilesize,	/* size in bytes */									0,				/* face_index */									&ftface )==0)			{				/* make a name for this font */				ffi=kGUIFont::m_ffilist.GetEntryPtr(kGUIFont::m_ffinumentries++);								ffi->SetFilename(dir.GetFilename(i));				ffi->SetFacename(ftface->family_name);				ffi->SetStyle(ftface->style_name);				kGUI::Trace("Font fn='%s',face='%s',style='%s'/n",ffi->GetFilename()->GetString(),ffi->GetFacename()->GetString(),ffi->GetStyle()->GetString());			}			delete []mem;		}	}}
开发者ID:CarlHuff,项目名称:kgui,代码行数:34,


示例7: fz_new_font_from_memory

fz_font *fz_new_font_from_memory(fz_context *ctx, char *name, unsigned char *data, int len, int index, int use_glyph_bbox){	FT_Face face;	fz_font *font;	int fterr;	fz_keep_freetype(ctx);	fz_lock(ctx, FZ_LOCK_FREETYPE);	fterr = FT_New_Memory_Face(ctx->font->ftlib, data, len, index, &face);	fz_unlock(ctx, FZ_LOCK_FREETYPE);	if (fterr)	{		fz_drop_freetype(ctx);		fz_throw(ctx, FZ_ERROR_GENERIC, "freetype: cannot load font: %s", ft_error_string(fterr));	}	if (!name)		name = face->family_name;	font = fz_new_font(ctx, name, use_glyph_bbox, face->num_glyphs);	font->ft_face = face;	fz_set_font_bbox(ctx, font,		(float) face->bbox.xMin / face->units_per_EM,		(float) face->bbox.yMin / face->units_per_EM,		(float) face->bbox.xMax / face->units_per_EM,		(float) face->bbox.yMax / face->units_per_EM);	return font;}
开发者ID:chrox,项目名称:libk2pdfopt,代码行数:31,


示例8: MPQFile

	void font_data::init(const std::string& fname, unsigned int _h, bool fromMPQ)	{		h = _h;		if (FT_Init_FreeType(&_library))		{			LogError << "FT_Init_FreeType failed" << std::endl;			throw std::runtime_error("FT_Init_FreeType failed");		}		bool failed;		if (fromMPQ)		{			_mpqFile = new MPQFile(fname);			failed = FT_New_Memory_Face(_library, _mpqFile->get<FT_Byte>(0), _mpqFile->getSize(), 0, &_face) != 0;		}		else		{			failed = FT_New_Face(_library, fname.c_str(), 0, &_face) != 0;		}		if (failed)		{			LogError << "FT_New_Face failed (there is probably a problem with your font file)" << std::endl;			throw std::runtime_error("FT_New_Face failed (there is probably a problem with your font file)");		}		// For some twisted reason, Freetype measures font size in terms of 1/64ths of pixels.		FT_Set_Char_Size(_face, h << 6, h << 6, 72, 72);	}
开发者ID:Deamon87,项目名称:Noggit3Fork,代码行数:30,


示例9: numGlyphs

FTFace::FTFace(const unsigned char *pBufferBytes, size_t bufferSizeInBytes,               bool precomputeKerning):   numGlyphs(0),    fontEncodingList(0),    kerningCache(0),    err(0){    const FT_Long DEFAULT_FACE_INDEX = 0;    ftFace = new FT_Face;    err = FT_New_Memory_Face(*FTLibrary::Instance().GetLibrary(),                             (FT_Byte const *)pBufferBytes, (FT_Long)bufferSizeInBytes,                             DEFAULT_FACE_INDEX, ftFace);    if(err)    {        delete ftFace;        ftFace = 0;        return;    }    FTCleanup::Instance()->RegisterObject(&ftFace);    numGlyphs = (*ftFace)->num_glyphs;    hasKerningTable = (FT_HAS_KERNING((*ftFace)) != 0);    if(hasKerningTable && precomputeKerning)    {        BuildKerningCache();    }}
开发者ID:CombustibleLemonade,项目名称:AI,代码行数:30,


示例10: fz_newfontfrombuffer

fz_errorfz_newfontfrombuffer(fz_font **fontp, unsigned char *data, int len, int index){	fz_error error;	fz_font *font;	int fterr;	error = fz_initfreetype();	if (error)		return fz_rethrow(error, "cannot init freetype library");	font = fz_newfont();	fterr = FT_New_Memory_Face(fz_ftlib, data, len, index, (FT_Face*)&font->ftface);	if (fterr)	{		fz_free(font);		return fz_throw("freetype: cannot load font: %s", ft_errorstring(fterr));	}	/* SumatraPDF */	font->_data = data;	font->_data_len = len;	*fontp = font;	return fz_okay;}
开发者ID:MaChao5,项目名称:pdfviewer-win32,代码行数:27,


示例11: load_font

void load_font(caStack* stack){    caValue* filename = circa_input(stack, 0);    FontFace* font = new FontFace();    circa_read_file_with_stack(stack, circa_string(filename), &font->rawData);    if (circa_is_null(&font->rawData))        return circa_output_error(stack, "Failed to load file");        if (!g_ftLibraryInitialized) {        FT_Init_FreeType(&g_ftLibrary);        g_ftLibraryInitialized = true;    }        int error = FT_New_Memory_Face(g_ftLibrary,                   (FT_Byte*) circa_blob(&font->rawData),                   circa_blob_size(&font->rawData),                   0,                   &font->ftFace);    if (error)        return circa_output_error(stack, "FT_New_Memory_Face failed");    font->cairoFace = cairo_ft_font_face_create_for_ft_face(font->ftFace, 0);    caValue* out = circa_set_default_output(stack, 0);    circa_set_native_ptr(circa_index(out, 0), font, FontFaceRelease);}
开发者ID:ShenTensen,项目名称:circa,代码行数:29,


示例12: createFontCustomPlatformData

FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer){    ASSERT_ARG(buffer, buffer);    int error;    static FT_Library library = 0;    if (!library) {        error = FT_Init_FreeType(&library);        if (error) {            library = 0;            return 0;        }    }    FT_Face face;    error = FT_New_Memory_Face(library, reinterpret_cast<const FT_Byte*>(buffer->data()), buffer->size(), 0, &face);    if (error)        return 0;    buffer->ref();    cairo_font_face_t* fontFace = cairo_ft_font_face_create_for_ft_face(face, 0);    static cairo_user_data_key_t bufferKey;    cairo_font_face_set_user_data(fontFace, &bufferKey, buffer, releaseData);    return new FontCustomPlatformData(fontFace);}
开发者ID:325116067,项目名称:semc-qsd8x50,代码行数:28,


示例13: glf_create_font_mem

/** * Creates gl texture font from true type font; * @param ft_library: base font library; * @param face_data: pointer to the buffer with font file content; DO NOT FREE that pointer otherway using FT_Face prevets to crash; * @param face_data_size: size of buffer with font file content; * @param font_size: size of font glyph? * @return pointer to the gl_tex_font_s structure; */gl_tex_font_p glf_create_font_mem(FT_Library ft_library, void *face_data, size_t face_data_size, uint16_t font_size){    if(ft_library != nullptr)    {        gl_tex_font_p glf = static_cast<gl_tex_font_p>(malloc(sizeof(gl_tex_font_t)));        glf->ft_face = nullptr;        if(FT_New_Memory_Face(ft_library, static_cast<const FT_Byte*>(face_data), face_data_size, 0, &glf->ft_face))        {            free(glf);            return nullptr;        }        glf->glyphs_count = glf->ft_face->num_glyphs;        glf->glyphs = static_cast<char_info_p>(malloc(glf->glyphs_count * sizeof(char_info_t)));        glGetIntegerv(GL_MAX_TEXTURE_SIZE, &glf->gl_max_tex_width);        glf->gl_tex_width = glf->gl_max_tex_width;        glf->gl_tex_indexes = nullptr;        glf->gl_tex_indexes_count = 0;        glf->gl_real_tex_indexes_count = 0;        glf_resize(glf, font_size);        FT_Select_Charmap(glf->ft_face, FT_ENCODING_UNICODE);        return glf;    }    return nullptr;}
开发者ID:Nate1595,项目名称:OpenTomb,代码行数:37,


示例14: createFontObject

bool FontFreeType::createFontObject(const std::string &fontName, int fontSize){    int dpi = 72;        int len = 0;    unsigned char* data = FileUtils::getInstance()->getFileData(fontName.c_str(), "rb", (unsigned long *)(&len));        if (!data)        return false;        // create the new face    FT_Face face;        // create the face from the data    if (FT_New_Memory_Face(getFTLibrary(), data, len, 0, &face ))        return false;        //we want to use unicode    if (FT_Select_Charmap(face, FT_ENCODING_UNICODE))        return false;        // set the requested font size	int fontSizePoints = (int)(64.f * fontSize);	if (FT_Set_Char_Size(face, fontSizePoints, fontSizePoints, dpi, dpi))        return false;        // store the face globally    _fontRef = face;        // save font name locally    _fontName = fontName;        // done and good    return true;}
开发者ID:0x0c,项目名称:cocos2d-x,代码行数:35,


示例15: FT_New_Memory_Face

// Loads a FreeType face from memory.void* FontDatabase::LoadFace(const byte* data, int data_length, const String& source, bool local_data){	FT_Face face = NULL;	int error = FT_New_Memory_Face(ft_library, (const FT_Byte*) data, data_length, 0, &face);	if (error != 0)	{		Log::Message(Log::LT_ERROR, "FreeType error %d while loading face from %s.", error, source.CString());		if (local_data)			delete[] data;		return NULL;	}	// Initialise the character mapping on the face.	if (face->charmap == NULL)	{		FT_Select_Charmap(face, FT_ENCODING_APPLE_ROMAN);		if (face->charmap == NULL)		{			Log::Message(Log::LT_ERROR, "Font face (from %s) does not contain a Unicode or Apple Roman character map.", source.CString());			FT_Done_Face(face);			if (local_data)				delete[] data;			return NULL;		}	}	return face;}
开发者ID:AlexKordic,项目名称:libRocket,代码行数:31,


示例16: Face_init

static intFace_init(Face *self, PyObject *args, PyObject *kwds){    FT_Error error = 0;    char *data;    Py_ssize_t sz;    PyObject *ft;    if (!PyArg_ParseTuple(args, "Os#", &ft, &data, &sz)) return -1;    Py_BEGIN_ALLOW_THREADS;    error = FT_New_Memory_Face( ( (FreeType*)ft )->library,            (const FT_Byte*)data, (FT_Long)sz, 0, &self->face);    Py_END_ALLOW_THREADS;    if (error) {        self->face = NULL;        if ( error == FT_Err_Unknown_File_Format || error == FT_Err_Invalid_Stream_Operation)            PyErr_SetString(FreeTypeError, "Not a supported font format");        else            PyErr_Format(FreeTypeError, "Failed to initialize the Font with error: 0x%x", error);        return -1;    }    self->library = ft;    Py_XINCREF(ft);    self->data = PySequence_GetItem(args, 1);    return 0;}
开发者ID:089git,项目名称:calibre,代码行数:28,


示例17: create_face_from_contents

static FT_Facecreate_face_from_contents (FontLoadJob *job,                           gchar **contents,                           GError **error){  FT_Error ft_error;  FT_Face retval;  ft_error = FT_New_Memory_Face (job->library,                                 (const FT_Byte *) job->face_contents,                                 (FT_Long) job->face_length,                                 job->face_index,                                 &retval);  if (ft_error != 0) {    g_set_error_literal (error, G_IO_ERROR, 0,                         "Unable to read the font face file");    retval = NULL;    g_free (job->face_contents);  } else {    *contents = job->face_contents;  }  return retval;}
开发者ID:rkmax,项目名称:gnome-font-viewer,代码行数:25,


示例18: FT_New_Memory_Face

/////////////////////////////////////////////////////////////// Load the font from a file in memory////////////////////////////////////////////////////////////bool FontLoader::LoadFontFromMemory(const char* Data, std::size_t SizeInBytes, unsigned int CharSize, std::wstring Charset, Font& LoadedFont){    // Check if Freetype is correctly initialized    if (!myLibrary)    {        std::cerr << "Failed to load font from memory, FreeType has not been initialized" << std::endl;        return false;    }    // Create a new font face from the specified memory data    FT_Face FontFace;    FT_Error Error = FT_New_Memory_Face(myLibrary, reinterpret_cast<const FT_Byte*>(Data), static_cast<FT_Long>(SizeInBytes), 0, &FontFace);    if (Error)    {        std::cerr << "Failed to load font from memory (" << GetErrorDesc(Error) << ")" << std::endl;        return false;    }    // Create the bitmap font    Error = CreateBitmapFont(FontFace, CharSize, Charset, LoadedFont);    if (Error)        std::cerr << "Failed to load font from memory (" << GetErrorDesc(Error) << ")" << std::endl;    // Delete the font    FT_Done_Face(FontFace);    return Error == 0;}
开发者ID:fu7mu4,项目名称:entonetics,代码行数:31,


示例19: pdf_loadbuiltinfont

fz_error *pdf_loadbuiltinfont(pdf_font *font, char *fontname){	fz_error *error;	unsigned char *data;	unsigned int len;	int fterr;	int i;	error = initfontlibs();	if (error)		return fz_rethrow(error, "cannot init font libraries");	for (i = 0; i < 15; i++)		if (!strcmp(fontname, basefonts[i].name))			goto found;	return fz_throw("cannot find font: %s", fontname);found:	pdf_logfont("load builtin font %s/n", fontname);	data = (unsigned char *) basefonts[i].cff;	len = *basefonts[i].len;	fterr = FT_New_Memory_Face(ftlib, data, len, 0, (FT_Face*)&font->ftface);	if (fterr)		return fz_throw("freetype: cannot load font: %s", ft_errstr(fterr));	return fz_okay;}
开发者ID:lgchmomo,项目名称:mupdf,代码行数:31,


示例20: TA_font_init

FT_ErrorTA_font_init(FONT* font){    FT_Error error;    FT_Face f;    FT_Int major, minor, patch;    error = FT_Init_FreeType(&font->lib);    if (error)        return error;    /* assure correct FreeType version to avoid using the wrong DLL */    FT_Library_Version(font->lib, &major, &minor, &patch);    if (((major*1000 + minor)*1000 + patch) < 2004005)        return TA_Err_Invalid_FreeType_Version;    /* get number of faces (i.e. subfonts) */    error = FT_New_Memory_Face(font->lib,                               font->in_buf,                               (FT_Long)font->in_len,                               -1,                               &f);    if (error)        return error;    font->num_sfnts = f->num_faces;    FT_Done_Face(f);    /* it is a TTC if we have more than a single subfont */    font->sfnts = (SFNT*)calloc(1, (size_t)font->num_sfnts * sizeof (SFNT));    if (!font->sfnts)        return FT_Err_Out_Of_Memory;    return TA_Err_Ok;}
开发者ID:goldcome,项目名称:ttfautohint,代码行数:35,


示例21: pdf_loadembeddedfont

fz_error *pdf_loadembeddedfont(pdf_font *font, pdf_xref *xref, fz_obj *stmref){	fz_error *error;	int fterr;	FT_Face face;	fz_buffer *buf;	error = initfontlibs();	if (error)		return error;	pdf_logfont("load embedded font/n");	error = pdf_loadstream(&buf, xref, fz_tonum(stmref), fz_togen(stmref));	if (error)		return error;	fterr = FT_New_Memory_Face(ftlib, buf->rp, buf->wp - buf->rp, 0, &face);	if (fterr) {		fz_free(buf);		return fz_throw("freetype could not load embedded font: %s", pdf_fterrorstring(fterr));	}	font->ftface = face;	font->fontdata = buf;	return nil;}
开发者ID:wzhsunn,项目名称:SumatraPDF_0.6_Source,代码行数:30,


示例22: FT_New_Memory_Face

FontBLF *blf_font_new_from_mem(const char *name, const unsigned char *mem, int mem_size){	FontBLF *font;	FT_Error err;	font = (FontBLF *)MEM_callocN(sizeof(FontBLF), "blf_font_new_from_mem");	err = FT_New_Memory_Face(ft_lib, mem, mem_size, 0, &font->face);	if (err) {		MEM_freeN(font);		return NULL;	}	err = FT_Select_Charmap(font->face, ft_encoding_unicode);	if (err) {		printf("Can't set the unicode character map!/n");		FT_Done_Face(font->face);		MEM_freeN(font);		return NULL;	}	font->name = BLI_strdup(name);	font->filename = NULL;	blf_font_fill(font);	return font;}
开发者ID:Ichthyostega,项目名称:blender,代码行数:25,


示例23: check_freetypefont

static int check_freetypefont(PackedFile *pf){	FT_Face face;	FT_GlyphSlot glyph;	FT_UInt glyph_index;#if 0	FT_CharMap charmap;	FT_CharMap found;	FT_UShort my_platform_id = TT_PLATFORM_MICROSOFT;	FT_UShort my_encoding_id = TT_MS_ID_UNICODE_CS;	int n;#endif	int success = 0;	err = FT_New_Memory_Face(library,	                         pf->data,	                         pf->size,	                         0,	                         &face);	if (err) {		success = 0;		//XXX error("This is not a valid font");	}	else {#if 0		for (n = 0; n < face->num_charmaps; n++) {			charmap = face->charmaps[n];			if (charmap->platform_id == my_platform_id && charmap->encoding_id == my_encoding_id) {				found = charmap;				break;			}		}		if (!found) { return 0; }		/* now, select the charmap for the face object */		err = FT_Set_Charmap(face, found);		if (err) { return 0; }#endif		glyph_index = FT_Get_Char_Index(face, 'A');		err = FT_Load_Glyph(face, glyph_index, FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP);		if (err) {			success = 0;		}		else {			glyph = face->glyph;			if (glyph->format == ft_glyph_format_outline) {				success = 1;			}			else {				//XXX error("Selected Font has no outline data");				success = 0;			}		}	}		return success;}
开发者ID:YasirArafath,项目名称:blender-git,代码行数:60,


示例24: glf_create_font_mem

/** * Creates gl texture font from true type font; * @param ft_library: base font library; * @param face_data: pointer to the buffer with font file content; DO NOT FREE that pointer otherway using FT_Face prevets to crash; * @param face_data_size: size of buffer with font file content; * @param font_size: size of font glyph? * @return pointer to the gl_tex_font_s structure; */gl_tex_font_p glf_create_font_mem(void *face_data, size_t face_data_size, uint16_t font_size){    if(g_ft_library)    {        gl_tex_font_p glf = (gl_tex_font_p)malloc(sizeof(gl_tex_font_t));        glf->ft_face = NULL;        if(FT_New_Memory_Face(g_ft_library, (const FT_Byte*)face_data, face_data_size, 0, (FT_Face*)&glf->ft_face))        {            free(glf);            return NULL;        }        glf->glyphs_count = ((FT_Face)glf->ft_face)->num_glyphs;        glf->glyphs = (char_info_p)malloc(glf->glyphs_count * sizeof(char_info_t));        qglGetIntegerv(GL_MAX_TEXTURE_SIZE, &glf->gl_max_tex_width);        glf->gl_tex_width = glf->gl_max_tex_width;        glf->gl_tex_indexes = NULL;        glf->gl_tex_indexes_count = 0;        glf->gl_real_tex_indexes_count = 0;        glf_resize(glf, font_size);        FT_Select_Charmap(glf->ft_face, FT_ENCODING_UNICODE);        return glf;    }    return NULL;}
开发者ID:teacoffee2017,项目名称:OpenTomb,代码行数:37,


示例25: LogDebug

Font * FontCache::Create(const res::path & font, FontFile & file, unsigned int size) {		if(!file.data) {		LogDebug("loading file " << font);		file.data = resources->readAlloc(font, file.size);		if(!file.data) {			return NULL;		}	}		LogDebug("creating font " << font << " @ " << size);		FT_Face face;	const FT_Byte * data = reinterpret_cast<const FT_Byte *>(file.data);	FT_Error error = FT_New_Memory_Face(g_FTLibrary, data, file.size, 0, &face);	if(error == FT_Err_Unknown_File_Format) {		// the font file's format is unsupported		LogError << "Font creation error: FT_Err_Unknown_File_Format";		return NULL;	} else if(error) {		// ... another error code means that the font file could not		// ... be opened or read, or simply that it is broken...		return NULL;	}		// Windows default is 96dpi	// Freetype default is 72dpi	error = FT_Set_Char_Size(face, 0, size * 64, 64, 64);	if(error) {		return NULL;	}		return new Font(font, size, face);}
开发者ID:temojin,项目名称:ArxLibertatis,代码行数:34,


示例26: create_font_freetype_buf

PFont create_font_freetype_buf(const char* buf,int bsize, int height,int disp){	PFontFreetype pf;	//FT_Error error;	/* allocate font structure */	pf = (PFontFreetype) malloc(sizeof(FontFreetype));	memset(pf,0,sizeof(FontFreetype));	if (!pf) {		return NULL;	}	FT_Init_FreeType( &pf->library );	FT_New_Memory_Face( pf->library, (const unsigned char *)buf,bsize, 0, &pf->face );	FT_Set_Char_Size( pf->face,height<< 6, height << 6, 96, 96);	pf->procs = &freetype2_procs;	pf->size = height;	pf->disp = disp==0?DISPLAY_PIXEL_FORMAT_5551:disp;	pf->r = 0;	pf->g = 0;	pf->a = 0;	pf->encodingBuf.datalen = 2048;	pf->encodingBuf.data = (char*)malloc(pf->encodingBuf.datalen);	memset(pf->encodingBuf.data,0,pf->encodingBuf.datalen);	memset(pf->alpha_table,0,256);	return (PFont)pf;}
开发者ID:eledot,项目名称:libnge2,代码行数:27,


示例27: trace

void CocoFontsCache::add(std::string name, FONT_STYLE style, const char* filename){	trace("CocoFontsCache::add(%s)", name.c_str());	CocoFontsCache ff(name, style);	if(fonts.find(ff) != fonts.end()) return;	CocoAssetFile* file = CocoAssetFile::open(filename);	if(!file) return;	switch(file->mime)	{		case CocoAssetFile::MIME::FONT_TTF:		{			FT_Face ftFace;			int er = 0;			if((er = FT_New_Memory_Face(ftLibrary, (const FT_Byte*)file->getData(), file->getLength(), 0, &ftFace)))			{				trace("Could not load FreeType Face(%d)!", er);			}			fonts.insert(std::pair<CocoFontsCache, FT_Face>(ff, ftFace));			break;		}		default:			trace("Unsupported font type!/n");			return;	}}
开发者ID:Czou,项目名称:Coconut2D,代码行数:25,


示例28: FT_New_Memory_Face

face_ptr freetype_engine::create_face(std::string const& family_name){    std::map<std::string, std::pair<int,std::string> >::const_iterator itr;    itr = name2file_.find(family_name);    if (itr != name2file_.end())    {        FT_Face face;        std::map<std::string,std::string>::const_iterator mem_font_itr = memory_fonts_.find(itr->second.second);        if (mem_font_itr != memory_fonts_.end()) // memory font        {            FT_Error error = FT_New_Memory_Face(library_,                                                reinterpret_cast<FT_Byte const*>(mem_font_itr->second.c_str()),                                                static_cast<FT_Long>(mem_font_itr->second.size()), // size                                                itr->second.first, // face index                                                &face);            if (!error) return std::make_shared<font_face>(face);        }        else        {            // load font into memory#ifdef MAPNIK_THREADSAFE            mapnik::scoped_lock lock(mutex_);#endif            std::ifstream is(itr->second.second.c_str() , std::ios::binary);            std::string buffer((std::istreambuf_iterator<char>(is)),                               std::istreambuf_iterator<char>());            std::pair<std::map<std::string,std::string>::iterator,bool> result                = memory_fonts_.insert(std::make_pair(itr->second.second, buffer));            FT_Error error = FT_New_Memory_Face (library_,                                                 reinterpret_cast<FT_Byte const*>(result.first->second.c_str()),                                                 static_cast<FT_Long>(buffer.size()),                                                 itr->second.first,                                                 &face);            if (!error) return std::make_shared<font_face>(face);            else            {                // we can't load font, erase it.                memory_fonts_.erase(result.first);            }        }    }    return face_ptr();}
开发者ID:FlavioFalcao,项目名称:mapnik,代码行数:47,



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


C++ FT_Open_Face函数代码示例
C++ FT_New_Face函数代码示例
万事OK自学网:51自学网_软件自学网_CAD自学网自学excel、自学PS、自学CAD、自学C语言、自学css3实例,是一个通过网络自主学习工作技能的自学平台,网友喜欢的软件自学网站。