这篇教程C++ FT_HAS_KERNING函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中FT_HAS_KERNING函数的典型用法代码示例。如果您正苦于以下问题:C++ FT_HAS_KERNING函数的具体用法?C++ FT_HAS_KERNING怎么用?C++ FT_HAS_KERNING使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了FT_HAS_KERNING函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: numGlyphsFTFace::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; } numGlyphs = (*ftFace)->num_glyphs; hasKerningTable = (FT_HAS_KERNING((*ftFace)) != 0); if(hasKerningTable && precomputeKerning) { BuildKerningCache(); }}
开发者ID:UIKit0,项目名称:ftgles-1,代码行数:28,
示例2: getKerningfloat Font::getKerning(Uint32 first, Uint32 second, unsigned int characterSize) const{ // Special case where first or second is 0 (null character) if (first == 0 || second == 0) return 0.f; FT_Face face = static_cast<FT_Face>(m_face); if (face && FT_HAS_KERNING(face) && setCurrentSize(characterSize)) { // Convert the characters to indices FT_UInt index1 = FT_Get_Char_Index(face, first); FT_UInt index2 = FT_Get_Char_Index(face, second); // Get the kerning vector FT_Vector kerning; FT_Get_Kerning(face, index1, index2, FT_KERNING_DEFAULT, &kerning); // X advance is already in pixels for bitmap fonts if (!FT_IS_SCALABLE(face)) return static_cast<float>(kerning.x); // Return the X advance return static_cast<float>(kerning.x) / static_cast<float>(1 << 6); } else { // Invalid font, or no kerning return 0.f; }}
开发者ID:42bottles,项目名称:SFML,代码行数:31,
示例3: FT_HAS_KERNINGint FontFreeType::getHorizontalKerningForChars(unsigned short firstChar, unsigned short secondChar) const{ if (!_fontRef) return 0; bool hasKerning = FT_HAS_KERNING( _fontRef ) != 0; if (!hasKerning) return 0; // get the ID to the char we need int glyphIndex1 = FT_Get_Char_Index(_fontRef, firstChar); if (!glyphIndex1) return 0; // get the ID to the char we need int glyphIndex2 = FT_Get_Char_Index(_fontRef, secondChar); if (!glyphIndex2) return 0; FT_Vector kerning; if (FT_Get_Kerning( _fontRef, glyphIndex1, glyphIndex2, FT_KERNING_DEFAULT, &kerning)) return 0; return (kerning.x >> 6);}
开发者ID:0x0c,项目名称:cocos2d-x,代码行数:29,
示例4: lockosg::Vec2 FreeTypeFont::getKerning(unsigned int leftcharcode,unsigned int rightcharcode, osgText::KerningType kerningType){ OpenThreads::ScopedLock<OpenThreads::Mutex> lock(FreeTypeLibrary::instance()->getMutex()); if (!FT_HAS_KERNING(_face) || (kerningType == osgText::KERNING_NONE)) return osg::Vec2(0.0f,0.0f); FT_Kerning_Mode mode = (kerningType==osgText::KERNING_DEFAULT) ? ft_kerning_default : ft_kerning_unfitted; // convert character code to glyph index FT_UInt left = FT_Get_Char_Index( _face, leftcharcode ); FT_UInt right = FT_Get_Char_Index( _face, rightcharcode ); // get the kerning distances. FT_Vector kerning; FT_Error error = FT_Get_Kerning( _face, // handle to face object left, // left glyph index right, // right glyph index mode, // kerning mode &kerning ); // target vector if (error) { OSG_WARN << "FT_Get_Kerning(...) returned error code " <<std::hex<<error<<std::dec<< std::endl; return osg::Vec2(0.0f,0.0f); } float coord_scale = getCoordScale(); return osg::Vec2((float)kerning.x*coord_scale,(float)kerning.y*coord_scale);}
开发者ID:Kurdakov,项目名称:emscripten_OSG,代码行数:31,
示例5: FT_Set_Pixel_Sizesvoid Font::draw(IScene* scene, const char* text, glm::mat4 transform, float font_size, glm::vec3 color){ FT_Set_Pixel_Sizes(m_font_face, font_size, font_size); glUseProgram(TEXT_PROGRAM); checkGLError(); glm::vec3 pen(0, 0, 0); char prev = 0; bool kern = FT_HAS_KERNING(m_font_face); for(const char* i = text; i[0]; ++i) { FT_UInt index = FT_Get_Char_Index(m_font_face, i[0]); Glyph glyph = renderGlyph(i[0], font_size); if(prev && kern && i) { FT_Vector delta; FT_Get_Kerning(m_font_face, prev, index, FT_KERNING_DEFAULT, &delta); pen.x += delta.x * scene->getDPU(); //fprintf(stderr, "%ld/n", delta.x); } if(i[0] == '/n') { pen.x = 0; pen.y += font_size; prev = 0; continue; } else if(i[0] == ' ' || glyph.id == 0) { pen.x += font_size; prev = 0; continue; } glUniform3f(m_color_uniform, color.x, color.y, color.z); glm::vec3 offset(glyph.bearing.x, -glyph.bearing.y, 0.0f); glm::mat4 mvp = scene->getActiveProjectionMatrix() * scene->getActiveViewMatrix() * transform * glm::translate(glm::mat4(1), -(pen + offset) * scene->getDPU()) * glm::scale(glm::mat4(1), glm::vec3(glyph.dimensions.x * scene->getDPU(), glyph.dimensions.y * scene->getDPU(), 1.0f)); //fprintf(stderr, "Result: %f, %f, %f, %f/n", glyph.dimensions.x, glyph.dimensions.y, glyph.dimensions.x * scene->getDPU(), glyph.dimensions.y * scene->getDPU()); glUniformMatrix4fv(m_transform_uniform, 1, GL_FALSE, &mvp[0][0]); glEnableVertexAttribArray(m_vertex_position); glBindBuffer(GL_ARRAY_BUFFER, QUAD_BUFFER); glVertexAttribPointer(m_vertex_position, 3, GL_FLOAT, GL_FALSE, 0, (void*)0); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, glyph.texture); glUniform1i(m_texture_uniform, 0); checkGLError(); glDrawArrays(GL_TRIANGLES, 0, 6); checkGLError(); glDisableVertexAttribArray(m_vertex_position); pen.x += glyph.advance; //fprintf(stderr, "(%d)/n", (int)glyph.advance); prev = index; }}
开发者ID:Df458,项目名称:DFEngine,代码行数:59,
示例6: measure_string//http://www.freetype.org/freetype2/docs/tutorial/step2.htmlFT_Error measure_string(FT_Face face, std::string text, int size, Vector2i* size_out){ int pos_x = 0; bool use_kerning = FT_HAS_KERNING(face) ? true : false; FT_UInt prev_glyph_index = 0; FT_BBox text_bb; text_bb.xMax = 0; text_bb.xMin = 0; text_bb.yMax = 0; text_bb.yMin = 0; FT_Error error; error = FT_Set_Char_Size(face, 0, size * 64, 72, 72); for(unsigned int i = 0; i < text.length(); i++) { FT_UInt glyph_index = FT_Get_Char_Index(face, text.c_str()[i]); if(use_kerning && prev_glyph_index) { FT_Vector delta; FT_Get_Kerning(face, prev_glyph_index, glyph_index, FT_KERNING_DEFAULT, &delta); pos_x += delta.x >> 6; } prev_glyph_index = glyph_index; if(error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT) != FT_Err_Ok) { Log::Error(__FILE__, "Unable to load glyph %d", glyph_index); return error; } FT_Glyph glyph; if(error = FT_Get_Glyph(face->glyph, &glyph) != FT_Err_Ok) { Log::Error(__FILE__, "Unable to get glyph %d", glyph_index); } FT_BBox bb; FT_Glyph_Get_CBox(glyph, ft_glyph_bbox_pixels, &bb); bb.xMax += pos_x; bb.xMin += pos_x; pos_x += glyph->advance.x >> 16; //Grow overall bounding box if(bb.xMax > text_bb.xMax) text_bb.xMax = bb.xMax; if(bb.yMax > text_bb.yMax) text_bb.yMax = bb.yMax; if(bb.xMin < text_bb.xMin) text_bb.xMin = bb.xMin; if(bb.yMin < text_bb.yMin) text_bb.yMin = bb.yMin; FT_Done_Glyph(glyph); }
开发者ID:danishcake,项目名称:CrossPlatformDefense,代码行数:60,
示例7: FT_HAS_KERNING/** * Default constructor for the FreeTypeGX class. * * @param textureFormat Optional format (GX_TF_*) of the texture as defined by the libogc gx.h header file. If not specified default value is GX_TF_RGBA8. * @param vertexIndex Optional vertex format index (GX_VTXFMT*) of the glyph textures as defined by the libogc gx.h header file. If not specified default value is GX_VTXFMT1. */FreeTypeGX::FreeTypeGX(FT_UInt pixelSize, uint8_t textureFormat, uint8_t vertexIndex){ this->textureFormat = textureFormat; this->setVertexFormat(vertexIndex); this->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE); this->ftPointSize = pixelSize; this->ftKerningEnabled = FT_HAS_KERNING(ftFace);}
开发者ID:clobber,项目名称:wii7800,代码行数:14,
示例8: getKerning//-----------------------------------------------------------int ofTrueTypeFont::getKerning(uint32_t c, uint32_t prevC) const{ if(FT_HAS_KERNING( face )){ FT_Vector kerning; FT_Get_Kerning(face.get(), FT_Get_Char_Index(face.get(), c), FT_Get_Char_Index(face.get(), prevC), FT_KERNING_UNFITTED, &kerning); return kerning.x * fontUnitScale; }else{ return 0; }}
开发者ID:anwar-hegazy,项目名称:openFrameworks,代码行数:10,
示例9: Java_com_badlogic_gdx_graphics_g2d_freetype_FreeType_hasKerningJNIEXPORT jboolean JNICALL Java_com_badlogic_gdx_graphics_g2d_freetype_FreeType_hasKerning(JNIEnv* env, jclass clazz, jlong face) {//@line:656 return FT_HAS_KERNING(((FT_Face)face)); }
开发者ID:0302zq,项目名称:libgdx,代码行数:9,
示例10: FT_HAS_KERNING/** * Default constructor for the FreeTypeGX class. * * @param vertexIndex Optional vertex format index (GX_VTXFMT*) of the glyph textures as defined by the libogc gx.h header file. If not specified default value is GX_VTXFMT1. */FreeTypeGX::FreeTypeGX(FT_UInt pixelSize, uint8_t vertexIndex) { this->setVertexFormat(vertexIndex); this->setCompatibilityMode(FTGX_COMPATIBILITY_DEFAULT_TEVOP_GX_PASSCLR | FTGX_COMPATIBILITY_DEFAULT_VTXDESC_GX_NONE); this->ftPointSize = pixelSize; this->ftKerningEnabled = FT_HAS_KERNING(ftFace); if (glyphData == NULL) glyphData = (uint8_t *) malloc(256 * 256 * 4);}
开发者ID:LibXenonProject,项目名称:snes9x-gx,代码行数:14,
示例11: setKerningEnabled/** * Enables or disables kerning of the output text. * * This routine enables or disables kerning of the output text only if kerning is supported by the font. * Note that by default kerning is enabled if it is supported by the font. * * @param enabled The enabled state of the font kerning. * @return The resultant enabled state of the font kerning. */bool FreeTypeGX::setKerningEnabled(bool enabled) { if(!enabled) { return this->ftKerningEnabled = false; } if(FT_HAS_KERNING(this->ftFace)) { return this->ftKerningEnabled = true; } return false;}
开发者ID:N4u,项目名称:WiiCraft,代码行数:20,
示例12: FT_Init_FreeTypeFont::Font(u32 Size, const char *Font_Path, Minimum *min){ FontColor = COLOR_BLACK; FontSize = Size; Lenght = 0; m = min; FT_Init_FreeType(&library); FT_New_Face(library,Font_Path,0,&face); FT_Stroker_New(library,&stroker); Kerning = FT_HAS_KERNING(face); FT_Set_Pixel_Sizes(face,0,FontSize); font=0;}
开发者ID:roman5566,项目名称:NoRSX,代码行数:12,
示例13: add_kerningvoid gfx_font_adapter::add_kerning(unsigned int first, unsigned int second, scalar* x, scalar* y){ if (m_impl->font && first && second && FT_HAS_KERNING(m_impl->font)) { FT_Vector delta; FT_Get_Kerning(m_impl->font, first, second, FT_KERNING_DEFAULT, &delta); scalar dx = int26p6_to_flt(delta.x); scalar dy = int26p6_to_flt(delta.y); if (m_impl->font->glyph->format != FT_GLYPH_FORMAT_BITMAP) m_impl->matrix.transform_2x2(&dx, &dy); *x += dx; *y += dy; }}
开发者ID:corefan,项目名称:img_picasso,代码行数:13,
示例14: glyphstring_createstatic void glyphstring_create(FT_Face face, Text *text, FT_Glyph *glyph_string, FT_Vector *pos){ const uint8_t *string = text->string; FT_Bool has_kerning; FT_UInt glyph_index, previous; FT_Vector pen, delta; uint32_t charcode; int i; has_kerning = FT_HAS_KERNING(face); previous = 0; i = 0; pen.x = pen.y = 0; while (string[0] != '/0') { charcode = utf8_next(&string); glyph_index = FT_Get_Char_Index(face, charcode); if (has_kerning && previous && glyph_index) FT_Get_Kerning(face, previous, glyph_index, FT_KERNING_DEFAULT, &delta); else delta.x = 0; if (glyph_index == 0) log_err("Glyph for character U+%X missing/n", charcode); if (FT_Load_Glyph(face, glyph_index, FT_LOAD_RENDER) != 0) { log_err("Error loading glyph for character U+%X/n", charcode); continue; } if (FT_Get_Glyph(face->glyph, &glyph_string[i]) != 0) { log_err("Error copying glyph for character U+%X/n", charcode); continue; } pen.x += delta.x; pos[i] = pen; pen.x += face->glyph->advance.x; pen.y += face->glyph->advance.y; previous = glyph_index; i++; } text->num_glyphs = i;}
开发者ID:kaspermeerts,项目名称:kosmos,代码行数:51,
示例15: ts::Vector2i ts::resources::impl::Font_face::kerning(utf8::uint32_t first, utf8::uint32_t second, std::uint32_t character_size){ if (first && second && FT_HAS_KERNING(face)) { set_character_size(character_size); auto first_index = FT_Get_Char_Index(face, first); auto second_index = FT_Get_Char_Index(face, second); FT_Vector kerning; FT_Get_Kerning(face, first_index, second_index, FT_KERNING_DEFAULT, &kerning); return Vector2i(kerning.x >> 6, kerning.y >> 6); }
开发者ID:mnewhouse,项目名称:tspp,代码行数:14,
示例16: numGlyphsFTFace::FTFace (const char* fontFilePath) : numGlyphs(0), fontEncodingList(0), err(0) { const FT_Long DEFAULT_FACE_INDEX = 0; ftFace = new FT_Face; err = FT_New_Face (*FTLibrary::Instance().GetLibrary(), fontFilePath, DEFAULT_FACE_INDEX, ftFace); if (err) { Message ("error FT_New_Face"); delete ftFace; ftFace = 0; } else { numGlyphs = (*ftFace)->num_glyphs; hasKerningTable = FT_HAS_KERNING((*ftFace)) != 0; }}
开发者ID:pseuudonym404,项目名称:tuxracer-touch,代码行数:15,
示例17: FT_New_Memory_Face/** * Loads and processes a specified true type font buffer to a specific point size. * * This routine takes a precompiled true type font buffer and loads the necessary processed data into memory. This routine should be called before drawText will succeed. * * @param fontBuffer A pointer in memory to a precompiled true type font buffer. * @param bufferSize Size of the true type font buffer in bytes. * @param pointSize The desired point size this wrapper's configured font face. * @param cacheAll Optional flag to specify if all font characters should be cached when the class object is created. If specified as false the characters only become cached the first time they are used. If not specified default value is false. */uint16_t FreeTypeGX::loadFont(uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll) { this->unloadFont(); this->ftPointSize = pointSize; FT_New_Memory_Face(this->ftLibrary, (FT_Byte *)fontBuffer, bufferSize, 0, &this->ftFace); FT_Set_Pixel_Sizes(this->ftFace, 0, this->ftPointSize); this->ftSlot = this->ftFace->glyph; this->ftKerningEnabled = FT_HAS_KERNING(this->ftFace); if (cacheAll) { return this->cacheGlyphDataComplete(); } return 0;}
开发者ID:Cyganet,项目名称:wiicoverflow,代码行数:26,
示例18: say_font_get_kerningsize_t say_font_get_kerning(say_font *font, uint32_t first, uint32_t second, size_t size) { if (first == 0 || second == 0) return 0; if (font->face && FT_HAS_KERNING(font->face) && say_font_set_size(font, size)) { size_t first_index = FT_Get_Char_Index(font->face, first); size_t sec_index = FT_Get_Char_Index(font->face, second); FT_Vector kerning; FT_Get_Kerning(font->face, first_index, sec_index, FT_KERNING_DEFAULT, &kerning); return kerning.x >> 6; }
开发者ID:Spooner,项目名称:ray,代码行数:16,
示例19: FT_HAS_KERNINGvoid rtText::ConvertStringToTex(std::wstring str, unsigned char *&texMemory, Rec &texBoundingBox) { FT_GlyphSlot slot = fFontFace->glyph; /* a small shortcut */ FT_UInt glyph_index; FT_Bool use_kerning = FT_HAS_KERNING(fFontFace); FT_UInt previous; int pen_x, pen_y; FT_Vector delta; int baseY; bool error = false; // todo: 加入转义解析 // 第一趟:确定包围盒大小 pen_x = pen_y = 0; //任意基点 previous = 0; int xMin, xMax, yMin, yMax; xMin = xMax = yMin = yMax = 0; for (int n = 0; n < str.length(); n++) { /* convert character code to glyph index */ glyph_index = FT_Get_Char_Index(fFontFace, str[n]); /* retrieve kerning distance and move pen position */ if (use_kerning && previous && glyph_index) { FT_Get_Kerning(fFontFace, previous, glyph_index, FT_KERNING_DEFAULT, &delta); pen_x += delta.x >> 6; } /* load glyph image into the slot (erase previous one) */ error = FT_Load_Glyph(fFontFace, glyph_index, FT_LOAD_RENDER); if (error) continue; /* ignore errors */ // a single glyph bouncing box is given by the following: // xMin = pen_x + slot->bitmap_left, yMax = pen_y + slot->bitmap_top; // xMax = xMin + slot->bitmap.width, yMin = yMax - slot->bitmap.rows; // grow overall string bouncing box xMin = std::min(pen_x + slot->bitmap_left, xMin); xMax = std::max(pen_x + slot->bitmap_left + slot->bitmap.width, xMax); yMin = std::min(pen_y + slot->bitmap_top - slot->bitmap.rows, yMin); yMax = std::max(pen_y + slot->bitmap_top, yMax); /* increment pen position */ pen_x += slot->advance.x >> 6; /* record current glyph index */ previous = glyph_index; }
开发者ID:dchneric,项目名称:RayMarchingCodeGenInGLSL,代码行数:43,
示例20: kernAdvance void kernAdvance(Font font, unsigned int index1, unsigned int index2, float& x, float& y) { x=0.0f; y=0.0f; if (FT_HAS_KERNING(font->ftFace) && index1 && index2) { FT_Vector kernAdvance; kernAdvance.x = kernAdvance.y = 0; FT_Error err = FT_Get_Kerning(font->ftFace, index1, index2, ft_kerning_unfitted, &kernAdvance); if (!err) { x = static_cast<float>(kernAdvance.x)/64.0f; y = static_cast<float>(kernAdvance.y)/64.0f; } } }
开发者ID:EgoIncarnate,项目名称:Infinity,代码行数:19,
示例21: ass_font_get_kerning/** * /brief Get kerning for the pair of glyphs. **/FT_Vector ass_font_get_kerning(ass_font_t* font, uint32_t c1, uint32_t c2){ FT_Vector v = {0, 0}; int i; for (i = 0; i < font->n_faces; ++i) { FT_Face face = font->faces[i]; int i1 = FT_Get_Char_Index(face, c1); int i2 = FT_Get_Char_Index(face, c2); if (i1 && i2) { if (FT_HAS_KERNING(face)) FT_Get_Kerning(face, i1, i2, FT_KERNING_DEFAULT, &v); return v; } if (i1 || i2) // these glyphs are from different font faces, no kerning information return v; } return v;}
开发者ID:tokyovigilante,项目名称:libass-fork,代码行数:22,
示例22: FT_Done_Facebool Font::Load(const std::string& Filename){ if (FT_New_Face(mLibrary, Filename.c_str(), 0, &mFace) != 0) return false; //We only support scalable Unicode fonts if (!mFace->charmap || !FT_IS_SCALABLE(mFace)) { FT_Done_Face(mFace); return false; } mFilename = Filename; if (FT_HAS_KERNING(mFace)) mHaveKerning = true; return true;}
开发者ID:dorgonman,项目名称:DEP,代码行数:19,
示例23: DrawTextstatic unsigned int DrawText(const wchar_t *string, unsigned int fontSize, void *buffer) { unsigned int error = 0; int penX = 0; int penY = fontSize; FT_GlyphSlot slot = ftFace->glyph; FT_UInt glyphIndex = 0; FT_UInt previousGlyph = 0; FT_Bool hasKerning = FT_HAS_KERNING(ftFace); /* Convert the string to UTF32 */ //size_t length = strlen(string); const wchar_t *utf32 = string;//(wchar_t*)malloc(length * sizeof(wchar_t)); size_t length = wcslen(utf32);//mbstowcs(utf32, string, length); /* Loop over each character, drawing it on to the buffer, until the * end of the string is reached, or until the pixel width is too wide */ unsigned int loop = 0; for (loop = 0; loop < length; ++loop) { glyphIndex = FT_Get_Char_Index(ftFace, utf32[ loop ]); /* To the best of my knowledge, none of the other freetype * implementations use kerning, so my method ends up looking * slightly better :) */ if (hasKerning && previousGlyph && glyphIndex) { FT_Vector delta; FT_Get_Kerning(ftFace, previousGlyph, glyphIndex, FT_KERNING_DEFAULT, &delta); penX += delta.x >> 6; } error = FT_Load_Glyph(ftFace, glyphIndex, FT_LOAD_RENDER); if (error) { /* Whoops, something went wrong trying to load the glyph * for this character... you should handle this better */ continue; } if (BlitGlyph(&slot->bitmap, penX + slot->bitmap_left, penY - slot->bitmap_top, buffer) == true) { /* The glyph was successfully blitted to the buffer, move the pen forwards */ penX += slot->advance.x >> 6; previousGlyph = glyphIndex; } else {
开发者ID:PaulWagener,项目名称:WiiVNC,代码行数:42,
示例24: KernAdvanceFTPoint FTFace::KernAdvance( unsigned int index1, unsigned int index2){ float x, y; x = y = 0.0f; if( FT_HAS_KERNING((*ftFace)) && index1 && index2) { FT_Vector kernAdvance; kernAdvance.x = kernAdvance.y = 0; err = FT_Get_Kerning( *ftFace, index1, index2, ft_kerning_unfitted, &kernAdvance); if( !err) { x = static_cast<float>( kernAdvance.x) / 64.0f; y = static_cast<float>( kernAdvance.y) / 64.0f; } } return FTPoint( x, y, 0.0);}
开发者ID:CJFocke,项目名称:vsxu,代码行数:20,
示例25: GetKerningint Font::GetKerning(Uint32 first, Uint32 second, unsigned int characterSize) const{ // Special case where first or second is 0 (null character) if (first == 0 || second == 0) return 0; FT_Face face = static_cast<FT_Face>(myFace); if (face && FT_HAS_KERNING(face) && SetCurrentSize(characterSize)) { // Convert the characters to indices FT_UInt index1 = FT_Get_Char_Index(face, first); FT_UInt index2 = FT_Get_Char_Index(face, second); // Get the kerning vector FT_Vector kerning; FT_Get_Kerning(face, index1, index2, FT_KERNING_DEFAULT, &kerning); // Return the X advance return kerning.x >> 6; }
开发者ID:vidjogamer,项目名称:SFML,代码行数:21,
示例26: FT_New_Memory_Face/** * Loads and processes a specified true type font buffer to a specific point size. * * This routine takes a precompiled true type font buffer and loads the necessary processed data into memory. This routine should be called before drawText will succeed. * * @param fontBuffer A pointer in memory to a precompiled true type font buffer. * @param bufferSize Size of the true type font buffer in bytes. * @param pointSize The desired point size this wrapper's configured font face. * @param cacheAll Optional flag to specify if all font characters should be cached when the class object is created. If specified as false the characters only become cached the first time they are used. If not specified default value is false. */uint16_t FreeTypeGX::loadFont(uint8_t* fontBuffer, FT_Long bufferSize, FT_UInt pointSize, bool cacheAll) { uint16_t numCached = 0; this->unloadFont(); this->ftFontBuffer = (FT_Byte *)fontBuffer; this->ftFontBufferSize = bufferSize; this->ftPointSize = pointSize; FT_New_Memory_Face(this->ftLibrary, this->ftFontBuffer, this->ftFontBufferSize, 0, &this->ftFace); FT_Set_Pixel_Sizes(this->ftFace, 0, this->ftPointSize); this->ftKerningEnabled = FT_HAS_KERNING(this->ftFace); this->ftAscender = this->ftPointSize * this->ftFace->ascender / this->ftFace->units_per_EM; this->ftDescender = this->ftPointSize * this->ftFace->descender / this->ftFace->units_per_EM; if (cacheAll) { numCached = this->cacheGlyphDataComplete(); } return numCached;}
开发者ID:N4u,项目名称:WiiCraft,代码行数:31,
注:本文中的FT_HAS_KERNING函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ FT_Init_FreeType函数代码示例 C++ FT_Glyph_To_Bitmap函数代码示例 |