本文整理汇总了C++中FT_New_Memory_Face函数的典型用法代码示例。如果您正苦于以下问题:C++ FT_New_Memory_Face函数的具体用法?C++ FT_New_Memory_Face怎么用?C++ FT_New_Memory_Face使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FT_New_Memory_Face函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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,代码来源:font_freetype.c
示例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,代码来源:freetype.cpp
示例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,代码来源:Font.cpp
示例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,代码来源:pdf_fontfile.c
示例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,代码来源:freetypefont.c
示例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,代码来源:kguifont.cpp
示例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,代码来源:font.c
示例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,代码来源:FreeType.cpp
示例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,代码来源:FTFace.cpp
示例10: fz_newfontfrombuffer
fz_error
fz_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,代码来源:res_font.c
示例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,代码来源:FontFace.cpp
示例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,代码来源:FontCustomPlatformData.cpp
示例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,代码来源:gl_font.cpp
示例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,代码来源:CCFontFreeType.cpp
示例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,代码来源:FontDatabase.cpp
示例16: Face_init
static int
Face_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,代码来源:freetype.cpp
示例17: create_face_from_contents
static FT_Face
create_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,代码来源:sushi-font-loader.c
示例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,代码来源:FontLoader.cpp
示例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,代码来源:pdf_fontfile.c
示例20: TA_font_init
FT_Error
TA_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,代码来源:tafont.c
注:本文中的FT_New_Memory_Face函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论