• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ FT_Get_Kerning函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: FT_Get_Char_Index

float 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:PKEuS,项目名称:SFML,代码行数:31,代码来源:Font.cpp


示例2: FT_HAS_KERNING

int  FontFreeType::getHorizontalKerningForChars(unsigned short firstChar, unsigned short secondChar)
{
    if (!_fontRef)
        return 0;

    bool hasKerning = FT_HAS_KERNING( _fontRef );
    
    if (!hasKerning)
        return 0;
    
    // get the ID to the char we need
    int glyph_index1 = FT_Get_Char_Index(_fontRef, firstChar);
    
    if (!glyph_index1)
        return 0;
    
    // get the ID to the char we need
    int glyph_index2 = FT_Get_Char_Index(_fontRef, secondChar);
    
    if (!glyph_index2)
        return 0;
    
    FT_Vector kerning;
    
    if (FT_Get_Kerning( _fontRef, glyph_index1, glyph_index2,  FT_KERNING_DEFAULT,  &kerning ))
        return 0;
    
    return ( kerning.x >> 6 );
}
开发者ID:ADoby,项目名称:Project_Space_Pirate,代码行数:29,代码来源:CCFontFreeType.cpp


示例3: RenderChar

int RenderChar(FT_ULong currentchar, int sx, int sy, int ex, int color)
{
	int row, pitch, bit, x = 0, y = 0;
	FT_UInt glyphindex;
	FT_Vector kerning;
	FTC_Node anode;

	//load char

		if(!(glyphindex = FT_Get_Char_Index(face, currentchar)))
		{
//			printf("<FT_Get_Char_Index for Char \"%c\" failed with Errorcode 0x%.2X>\n", (int)currentchar, error);
			return 0;
		}

		if((error = FTC_SBitCache_Lookup(cache, &desc, glyphindex, &sbit, &anode)))
		{
//			printf("<FTC_SBitCache_Lookup for Char \"%c\" failed with Errorcode 0x%.2X>\n", (int)currentchar, error);
			return 0;
		}

		if(use_kerning)
		{
			FT_Get_Kerning(face, prev_glyphindex, glyphindex, ft_kerning_default, &kerning);

			prev_glyphindex = glyphindex;
			kerning.x >>= 6;
		}
		else kerning.x = 0;
开发者ID:TitanNit,项目名称:tdt,代码行数:29,代码来源:text.c


示例4: FT_Get_Kerning

//------------------------------------------------------------------------
bool font_engine_freetype_base::add_kerning(unsigned first, unsigned second,
        double* x, double* y)
{
    if(m_cur_face && first && second && FT_HAS_KERNING(m_cur_face))
    {
        FT_Vector delta;

        FT_Get_Kerning(m_cur_face, first, second,
                       FT_KERNING_DEFAULT, &delta);

        double dx = int26p6_to_dbl(delta.x);
        double dy = int26p6_to_dbl(delta.y);
        if(m_glyph_rendering == glyph_ren_outline ||
                m_glyph_rendering == glyph_ren_agg_mono ||
                m_glyph_rendering == glyph_ren_agg_gray8)
        {
            m_affine.transform_2x2(&dx, &dy);
        }
        *x += dx;
        *y += dy;

        return true;
    }
    return false;
}
开发者ID:LuaDist,项目名称:gsl-shell,代码行数:26,代码来源:agg_font_freetype.cpp


示例5: FT_Get_Kerning

void FTFace::BuildKerningCache()
{
    FT_Vector kernAdvance;
    kernAdvance.x = 0;
    kernAdvance.y = 0;
    kerningCache = new FTGL_DOUBLE[FTFace::MAX_PRECOMPUTED
				   * FTFace::MAX_PRECOMPUTED * 2];
    for(unsigned int j = 0; j < FTFace::MAX_PRECOMPUTED; j++)
    {
        for(unsigned int i = 0; i < FTFace::MAX_PRECOMPUTED; i++)
        {
            err = FT_Get_Kerning(*ftFace, i, j, ft_kerning_unfitted,
                                 &kernAdvance);
            if(err)
            {
                delete[] kerningCache;
                kerningCache = NULL;
                return;
            }

            kerningCache[2 * (j * FTFace::MAX_PRECOMPUTED + i)] =
                                static_cast<FTGL_DOUBLE>(kernAdvance.x) / 64.0;
            kerningCache[2 * (j * FTFace::MAX_PRECOMPUTED + i) + 1] =
                                static_cast<FTGL_DOUBLE>(kernAdvance.y) / 64.0;
        }
    }
}
开发者ID:szakats,项目名称:bzflag_mirror,代码行数:27,代码来源:FTFace.cpp


示例6: glf_get_string_len

float glf_get_string_len(gl_tex_font_p glf, const char *text, int n)
{
    float x = 0.0;

    if((glf != nullptr) && (glf->ft_face != nullptr))
    {
        uint8_t *nch;
        uint8_t *nch2;
        uint8_t *ch = (uint8_t*)text;
        uint32_t curr_utf32, next_utf32;
        int i;

        nch = utf8_to_utf32(ch, &curr_utf32);
        curr_utf32 = FT_Get_Char_Index(glf->ft_face, curr_utf32);

        for(i = 0; (*ch != 0) && !((n >= 0) && (i >= n)); i++)
        {
            FT_Vector kern;

            nch2 = utf8_to_utf32(nch, &next_utf32);
            next_utf32 = FT_Get_Char_Index(glf->ft_face, next_utf32);
            ch = nch;
            nch = nch2;

            FT_Get_Kerning(glf->ft_face, curr_utf32, next_utf32, FT_KERNING_UNSCALED, &kern);   // kern in 1/64 pixel
            curr_utf32 = next_utf32;
            x += static_cast<GLfloat>(kern.x + glf->glyphs[curr_utf32].advance_x) / 64.0;
        }
    }

    return x;
}
开发者ID:Nate1595,项目名称:OpenTomb,代码行数:32,代码来源:gl_font.cpp


示例7: FTPoint

FTPoint FTFace::KernAdvance(unsigned int index1, unsigned int index2)
{
    FTGL_DOUBLE x, y;

    if(!hasKerningTable || !index1 || !index2)
    {
        return FTPoint(0.0, 0.0);
    }

    if(kerningCache && index1 < FTFace::MAX_PRECOMPUTED
        && index2 < FTFace::MAX_PRECOMPUTED)
    {
        x = kerningCache[2 * (index2 * FTFace::MAX_PRECOMPUTED + index1)];
        y = kerningCache[2 * (index2 * FTFace::MAX_PRECOMPUTED + index1) + 1];
        return FTPoint(x, y);
    }

    FT_Vector kernAdvance;
    kernAdvance.x = kernAdvance.y = 0;

    err = FT_Get_Kerning(*ftFace, index1, index2, ft_kerning_unfitted,
                         &kernAdvance);
    if(err)
    {
        return FTPoint(0.0f, 0.0f);
    }

    x = static_cast<float>(kernAdvance.x) / 64.0f;
    y = static_cast<float>(kernAdvance.y) / 64.0f;

    return FTPoint(x, y);
}
开发者ID:szakats,项目名称:bzflag_mirror,代码行数:32,代码来源:FTFace.cpp


示例8: FT_Get_Kerning

//-----------------------------------------------------------
int ofTrueTypeFont::getKerning(int c, int prevC) const{
    if(useKerning){
        FT_Vector kerning;
        FT_Get_Kerning(face, FT_Get_Char_Index(face, prevC), FT_Get_Char_Index(face, c), FT_KERNING_UNFITTED, &kerning);
        return kerning.x>>6;
    }else{
        return 0;
开发者ID:jvcleave,项目名称:compare,代码行数:8,代码来源:ofTrueTypeFont.cpp


示例9: line_extents

static void line_extents(VGFT_FONT_T *font, VGfloat *x, VGfloat *y, const char *text, int chars_count)
{
   int i;
   int prev_glyph_index = 0;
   if (chars_count == 0) return;

   for (i=0; i < chars_count; i++)
   {
      int glyph_index = FT_Get_Char_Index(font->ft_face, text[i]);
      if (!glyph_index) return;

      if (i != 0)
      {
         FT_Vector kern;
         if (FT_Get_Kerning(font->ft_face, prev_glyph_index, glyph_index,
                            FT_KERNING_DEFAULT, &kern))
         {
            assert(0);
         }
         *x += float_from_26_6(kern.x);
         *y += float_from_26_6(kern.y);
      }
      FT_Load_Glyph(font->ft_face, glyph_index, FT_LOAD_DEFAULT);
      *x += float_from_26_6(font->ft_face->glyph->advance.x);
   }
}
开发者ID:27feet,项目名称:firmware,代码行数:26,代码来源:vgft.c


示例10: lock

osg::Vec2 FreeTypeFont::getKerning(const osgText::FontResolution& fontRes, unsigned int leftcharcode, unsigned int rightcharcode, osgText::KerningType kerningType)
{
    OpenThreads::ScopedLock<OpenThreads::Mutex> lock(FreeTypeLibrary::instance()->getMutex());

    setFontResolution(fontRes);

    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:AlexBobkov,项目名称:OpenSceneGraph,代码行数:33,代码来源:FreeTypeFont.cpp


示例11: FT_Get_Char_Index

GLubyte *app::font::glyph(FT_Int32 flag, int curr, int prev,
                          int& x, int& y, int& w, int& h, int& a, int& k)
{
    FT_Vector kern;

    // Look up the current pair of characters.

    FT_UInt L = FT_Get_Char_Index(face, prev);
    FT_UInt R = FT_Get_Char_Index(face, curr);

    // Get the kerning and glyph sizes.

    FT_Get_Kerning(face, L, R, FT_KERNING_DEFAULT, &kern);
    FT_Load_Glyph (face, R, flag);

    // Convert these values to pixels and return the buffer.

    x = face->glyph->metrics.horiBearingX >> 6;
    y = face->glyph->metrics.horiBearingY >> 6;
    w = face->glyph->metrics.width        >> 6;
    h = face->glyph->metrics.height       >> 6;
    a = face->glyph->advance.x            >> 6;
    k = kern.x                            >> 6;

    return (GLubyte *) face->glyph->bitmap.buffer;
}
开发者ID:rlk,项目名称:thumb,代码行数:26,代码来源:app-font.cpp


示例12: FT_Set_Pixel_Sizes

void 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,代码来源:Font.cpp


示例13: measure_string

//http://www.freetype.org/freetype2/docs/tutorial/step2.html
FT_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,代码来源:TextureText.cpp


示例14: glyph_array_add_text

static cairo_status_t
glyph_array_add_text(glyph_array_t *glyphs, cairo_t *cr, const char *s, double spacing)
{
    cairo_scaled_font_t *scaled_font;
    cairo_status_t status;
    FT_Face face;
    unsigned long charcode;
    unsigned int index;
    cairo_text_extents_t extents;
    const char *p;
    FT_Vector kerning;
    double kern_x;
    int first = TRUE;

    scaled_font = cairo_get_scaled_font (cr);
    status = cairo_scaled_font_status (scaled_font);
    if (status)
	return status;

    face = cairo_ft_scaled_font_lock_face (scaled_font);
    if (face == NULL)
	return CAIRO_STATUS_FONT_TYPE_MISMATCH;

    p = s;
    while (*p)
    {
        charcode = *p;
        index = FT_Get_Char_Index (face, charcode);
        glyphs->glyph_list[glyphs->num_glyphs].index = index;
        if (first) {
            first = FALSE;
            glyphs->glyph_list[glyphs->num_glyphs].x = glyphs->x;
            glyphs->glyph_list[glyphs->num_glyphs].y = glyphs->y;
        } else {
            cairo_glyph_extents (cr, &glyphs->glyph_list[glyphs->num_glyphs - 1], 1, &extents);
            FT_Get_Kerning (face,
                            glyphs->glyph_list[glyphs->num_glyphs - 1].index,
                            glyphs->glyph_list[glyphs->num_glyphs].index,
                            FT_KERNING_UNSCALED,
                            &kerning);
            kern_x = DOUBLE_FROM_26_6(kerning.x);
            glyphs->glyph_list[glyphs->num_glyphs].x =
		glyphs->glyph_list[glyphs->num_glyphs - 1].x + extents.x_advance + kern_x + spacing;
            glyphs->glyph_list[glyphs->num_glyphs].y =
		glyphs->glyph_list[glyphs->num_glyphs - 1].y + extents.y_advance;
	}

	cairo_glyph_extents (cr, &glyphs->glyph_list[glyphs->num_glyphs], 1, &extents);
	glyphs->x = glyphs->glyph_list[glyphs->num_glyphs].x + extents.x_advance + spacing;
	glyphs->y = glyphs->glyph_list[glyphs->num_glyphs].y + extents.y_advance;
	p++;
        glyphs->num_glyphs++;
    }

    cairo_ft_scaled_font_unlock_face (scaled_font);
    return CAIRO_STATUS_SUCCESS;
}
开发者ID:ghub,项目名称:NVprSDK,代码行数:57,代码来源:ft-show-glyphs-positioning.c


示例15: FT_Get_Char_Index

GLvec2 Font::kerning(char prev, char code) const {
    // Returns kerning in units normalized by font size
    FT_Vector delta;
    FT_Face face = (FT_Face)face_;
    FT_UInt prevIndex = FT_Get_Char_Index(face, prev);
    FT_UInt curIndex = FT_Get_Char_Index(face, code);
    FT_Get_Kerning(face, prevIndex, curIndex, FT_KERNING_DEFAULT, &delta);
    return GLvec2((delta.x >> 6)/(GLfloat)size_, (delta.y >> 6)/(GLfloat)size_);
}
开发者ID:mfichman,项目名称:sfr,代码行数:9,代码来源:Font.cpp


示例16: FT_Get_Kerning

//-----------------------------------------------------------
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,代码来源:ofTrueTypeFont.cpp


示例17: assert

int TextureFont::PickCharacter(const char *str, float mouseX, float mouseY) const
{
	assert(str && mouseX >= 0.0f && mouseY >= 0.0f);

	// at the point of the mouse in-box test, the vars have the following values:
	// i1: the index of the character being tested
	// i2: the index of the next character
	// charBytes: the number of bytes used to encode the next character
	// right: the right edge of the box being tested
	// bottom:  the bottom of the box being tested
	// x: the x-coordinate of the next character
	// chr1: the Unicode value of the character being tested
	// chr2: the Unicode value of the next character

	const float lineSpacing = GetHeight()*PARAGRAPH_SPACING;
	Uint32 chr2 = '\n'; // pretend we've just had a new line
	float bottom = GetHeight() - lineSpacing, x = 0.0f;
	int i2 = 0, charBytes = 0;
	do {
		int i1 = i2;
		Uint32 chr1 = chr2;

		// read the next character
		i2 += charBytes;
		charBytes = conv_mb_to_wc(&chr2, &str[i2]);
		assert(!str[i2] || charBytes); // assert valid encoding

		float right;
		if (chr1 == '\n') {
			right = std::numeric_limits<float>::max();
			x = 0.0f;
		} else {
			std::map<Uint32,glfglyph_t>::const_iterator it = m_glyphs.find(chr1);
			assert(it != m_glyphs.end());
			float advance = it->second.advx;

			if (chr2 != '\n' && chr2 != '\0') {
				FT_UInt a = FT_Get_Char_Index(m_face, chr1);
				FT_UInt b = FT_Get_Char_Index(m_face, chr2);
				FT_Vector kern;
				FT_Get_Kerning(m_face, a, b, FT_KERNING_UNFITTED, &kern);
				advance += float(kern.x) / 64.0f;
			}

			right = x + (advance / 2.0f);
			x += advance;
		}

		if ((mouseY < bottom) && (mouseX < right))
			return i1;

		if (chr1 == '\n')
			bottom += lineSpacing;
	} while (charBytes);

	return i2;
}
开发者ID:Thargoid,项目名称:pioneer,代码行数:57,代码来源:TextureFont.cpp


示例18: getKerning

bool getKerning(double &output, FontHandle *font, int unicode1, int unicode2) {
    FT_Vector kerning;
    if (FT_Get_Kerning(font->face, FT_Get_Char_Index(font->face, unicode1), FT_Get_Char_Index(font->face, unicode2), FT_KERNING_UNSCALED, &kerning)) {
        output = 0;
        return false;
    }
    output = kerning.x/64.;
    return true;
}
开发者ID:makepad,项目名称:makepad.github.io,代码行数:9,代码来源:import-font.cpp


示例19:

void
XeTeXFontInst_FT2::getKernPair(LEGlyphID leftGlyph, LEGlyphID rightGlyph, LEPoint &kern) const
{
	FT_Vector	kerning;
	if (FT_Get_Kerning(face, leftGlyph, rightGlyph, FT_KERNING_UNSCALED, &kerning) == 0) {
		kern.fX = kerning.x;
		kern.fY = kerning.y;
	}
	else
		kern.fX = kern.fY = 0;
}
开发者ID:luigiScarso,项目名称:mflua,代码行数:11,代码来源:XeTeXFontInst_FT2.cpp


示例20: draw_chars

static void draw_chars(VGFT_FONT_T *font, const char *text, int char_count, VGbitfield paint_modes, int peek) {
   // Put in first character
   glyph_indices[0] = FT_Get_Char_Index(font->ft_face, text[0]);
   int prev_glyph_index = glyph_indices[0];

   // Calculate glyph_indices and adjustments
   FT_Vector kern;
   int i;
   for (i = 1; i != char_count; ++i) {
      int glyph_index = FT_Get_Char_Index(font->ft_face, text[i]);
      if (!glyph_index) return;
      glyph_indices[i] = glyph_index;

      if (FT_Get_Kerning(font->ft_face, prev_glyph_index, glyph_index,
                         FT_KERNING_DEFAULT, &kern)) {
        assert(0);
      }
      adjustments_x[i - 1] = float_from_26_6(kern.x);
      adjustments_y[i - 1] = float_from_26_6(kern.y);

      prev_glyph_index = glyph_index;
   }

   // Get the last adjustment?
   if (peek) {
      int peek_glyph_index = FT_Get_Char_Index(font->ft_face, text[i]);
      if (!peek_glyph_index) return;
      if (FT_Get_Kerning(font->ft_face, prev_glyph_index, peek_glyph_index,
                         FT_KERNING_DEFAULT, &kern)) {
        assert(0);
      }
      adjustments_x[char_count - 1] = float_from_26_6(kern.x);
      adjustments_y[char_count - 1] = float_from_26_6(kern.y);
   } else {
      adjustments_x[char_count - 1] = 0.0f;
      adjustments_y[char_count - 1] = 0.0f;
   }

   vgDrawGlyphs(font->vg_font, char_count, glyph_indices,
                adjustments_x, adjustments_y, paint_modes, VG_FALSE);
}
开发者ID:chinasaur,项目名称:poptart,代码行数:41,代码来源:vgft.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ FT_Get_Module函数代码示例发布时间:2022-05-30
下一篇:
C++ FT_Get_Glyph函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap