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

C++ FT_Get_Glyph函数代码示例

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

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



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

示例1: img

char_data::char_data(char ch, FT_Face face) : img(){
	// Load The Glyph For Our Character.
	if(FT_Load_Glyph( face, FT_Get_Char_Index( face, ch ), FT_LOAD_DEFAULT ))
		throw std::runtime_error("FT_Load_Glyph failed");

	// Move The Face's Glyph Into A Glyph Object.
	FT_Glyph glyph;
	if(FT_Get_Glyph( face->glyph, &glyph ))
		throw std::runtime_error("FT_Get_Glyph failed");

	// Convert The Glyph To A Bitmap.
	FT_Glyph_To_Bitmap( &glyph, ft_render_mode_normal, 0, 1 );
	FT_BitmapGlyph bitmap_glyph = (FT_BitmapGlyph)glyph;

	FT_Bitmap& bitmap=bitmap_glyph->bitmap;

	advance=face->glyph->advance.x >> 6;
	left= bitmap_glyph->left;
	w=bitmap.width;
	h=bitmap.rows;
	move_up=bitmap_glyph->top;//-bitmap.rows;


	data = new unsigned char[4*w*h];
	for(int y=0;y<h;y++) for(int x=0;x<w;x++) {
		const int my=y;//h-1-y;
		data[4*(x+w*my)]=255;
		data[4*(x+w*my)+1]=255;
		data[4*(x+w*my)+2]=255;
		data[4*(x+w*my)+3]=bitmap.buffer[x+w*y];
	}
	int old_unpack;
	gl_image_from_bytes(img, w, h, (char*)data, GL_BGRA);
}
开发者ID:Zolomon,项目名称:lanarts,代码行数:34,代码来源:font.cpp


示例2: GetGlyphSize

void GetGlyphSize( FT_Face font, int numglyph, int *wi, int *hi )
{
	FT_Glyph glyph;
	FT_BitmapGlyph bmglyph;
	
  //glyph fields:
  /*    width        :: The glyph's width.                                 */
  /*    height       :: The glyph's height.                                */
  /*    horiBearingX :: Horizontal left side bearing.                      */
  /*    horiBearingY :: Horizontal top side bearing.                       */
  /*    horiAdvance  :: Horizontal advance width.                          */
  /*    vertBearingX :: Vertical left side bearing.                        */
  /*    vertBearingY :: Vertical top side bearing.                         */
  /*    vertAdvance  :: Vertical advance height.                           */

	FT_Load_Glyph( font, FT_Get_Char_Index( font, numglyph ), FT_LOAD_DEFAULT );
	FT_Get_Glyph( font->glyph, &glyph );
	FT_Glyph_To_Bitmap( &glyph, ft_render_mode_normal, 0, 1 );
	bmglyph = (FT_BitmapGlyph)glyph;
	FT_Bitmap& bitmap = bmglyph->bitmap;
	//*wi = FTnext_p2( bitmap.width );
	//*hi = FTnext_p2( bitmap.rows );
	*wi = bitmap.width;
	*hi = bitmap.rows;
};
开发者ID:jwginge,项目名称:ojpa,代码行数:25,代码来源:font_create.cpp


示例3: freetype2_get_glyph_size

static FT_Error freetype2_get_glyph_size(PFontFreetype pf,
						 FT_Face face,
						 int glyph_index,
						 int *padvance,
						 int *pascent,
						 int *pdescent)
{
	FT_Error error;
		error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT);
		if (error)
			return error;

		if (padvance)
			*padvance = ROUND_26_6_TO_INT(face->glyph->advance.x);
		if (pascent || pdescent)
		{
			FT_Glyph glyph;
			FT_BBox bbox;

			error = FT_Get_Glyph(face->glyph, &glyph);
			if (error)
				return error;

			FT_Glyph_Get_CBox(glyph, ft_glyph_bbox_pixels, &bbox);

			FT_Done_Glyph(glyph);

			if (pascent)
				*pascent = bbox.yMax;
			if (pdescent)
				*pdescent = -bbox.yMin;
		}

		return 0;
}
开发者ID:eledot,项目名称:libnge2,代码行数:35,代码来源:nge_font_freetype.c


示例4: test_get_cbox

int
test_get_cbox( btimer_t*  timer,
               FT_Face    face,
               void*      user_data )
{
  FT_Glyph  glyph;
  FT_BBox   bbox;
  int       i, done = 0;


  FT_UNUSED( user_data );

  for ( i = 0; i < face->num_glyphs; i++ )
  {
    if ( FT_Load_Glyph( face, i, load_flags ) )
      continue;

    if ( FT_Get_Glyph( face->glyph, &glyph ) )
      continue;

    TIMER_START( timer );
    FT_Glyph_Get_CBox( glyph, FT_GLYPH_BBOX_PIXELS, &bbox );
    TIMER_STOP( timer );

    FT_Done_Glyph( glyph );
    done++;
  }

  return done;
}
开发者ID:anoopadvaitha,项目名称:lincodelib,代码行数:30,代码来源:ftbench.c


示例5: test_get_glyph

int
test_get_glyph( btimer_t*  timer,
                FT_Face    face,
                void*      user_data )
{
  FT_Glyph  glyph;
  int       i, done = 0;


  FT_UNUSED( user_data );

  for ( i = 0; i < face->num_glyphs; i++ )
  {
    if ( FT_Load_Glyph( face, i, load_flags ) )
      continue;

    TIMER_START( timer );
    if ( !FT_Get_Glyph( face->glyph, &glyph ) )
    {
      FT_Done_Glyph( glyph );
      done++;
    }
    TIMER_STOP( timer );
  }

  return done;
}
开发者ID:anoopadvaitha,项目名称:lincodelib,代码行数:27,代码来源:ftbench.c


示例6: FT_Set_Transform

void text_renderer::prepare_glyphs(glyph_positions const& positions)
{
    FT_Matrix matrix;
    FT_Vector pen;
    FT_Error  error;

    glyphs_.reserve(positions.size());
    for (auto const& glyph_pos : positions)
    {
        glyph_info const& glyph = glyph_pos.glyph;
        glyph.face->set_character_sizes(glyph.format->text_size * scale_factor_); //TODO: Optimize this?

        matrix.xx = static_cast<FT_Fixed>( glyph_pos.rot.cos * 0x10000L);
        matrix.xy = static_cast<FT_Fixed>(-glyph_pos.rot.sin * 0x10000L);
        matrix.yx = static_cast<FT_Fixed>( glyph_pos.rot.sin * 0x10000L);
        matrix.yy = static_cast<FT_Fixed>( glyph_pos.rot.cos * 0x10000L);

        pixel_position pos = glyph_pos.pos + glyph.offset.rotate(glyph_pos.rot);
        pen.x = static_cast<FT_Pos>(pos.x * 64);
        pen.y = static_cast<FT_Pos>(pos.y * 64);

        FT_Face face = glyph.face->get_face();
        FT_Set_Transform(face, &matrix, &pen);

        error = FT_Load_Glyph(face, glyph.glyph_index, FT_LOAD_NO_HINTING);
        if (error) continue;

        FT_Glyph image;
        error = FT_Get_Glyph(face->glyph, &image);
        if (error) continue;

        glyphs_.emplace_back(image, *glyph.format);
    }
}
开发者ID:Airphrame,项目名称:mapnik,代码行数:34,代码来源:renderer.cpp


示例7: BX_CHECK

bool TrueTypeFont::bakeGlyphSubpixel(CodePoint _codePoint, GlyphInfo& _glyphInfo, uint8_t* _outBuffer)
{
	BX_CHECK(m_font != NULL, "TrueTypeFont not initialized");

	_glyphInfo.glyphIndex = FT_Get_Char_Index(m_font->face, _codePoint);

	FT_GlyphSlot slot = m_font->face->glyph;
	FT_Error error = FT_Load_Glyph(m_font->face, _glyphInfo.glyphIndex, FT_LOAD_DEFAULT);
	if (error)
	{
		return false;
	}

	FT_Glyph glyph;
	error = FT_Get_Glyph(slot, &glyph);
	if (error)
	{
		return false;
	}

	error = FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_LCD, 0, 1);
	if (error)
	{
		return false;
	}

	FT_BitmapGlyph bitmap = (FT_BitmapGlyph)glyph;

	glyphInfoInit(_glyphInfo, bitmap, slot, _outBuffer, 3);
	FT_Done_Glyph(glyph);

	return true;
}
开发者ID:0-wiz-0,项目名称:bgfx,代码行数:33,代码来源:font_manager.cpp


示例8: convertFT2Bitmap

static void convertFT2Bitmap(FT_Face face, char c, FontBitmap& fontBitmap)
{
    if (FT_Load_Glyph(face, FT_Get_Char_Index(face, c), FT_LOAD_DEFAULT))
    {
        fprintf(stderr, "FT_Load_Glyph failed\n");
        return ;
    }

    // Move The Face's Glyph Into A Glyph Object.
    FT_Glyph glyph;
    if (FT_Get_Glyph(face->glyph, &glyph))
    {
        fprintf(stderr, "FT_Get_Glyph failed\n");
        return ;
    }

    // Convert The Glyph To A Bitmap.
    FT_Glyph_To_Bitmap(&glyph, ft_render_mode_normal, 0, 1);
    FT_BitmapGlyph glyphBitmap = (FT_BitmapGlyph)glyph;

    FT_Bitmap& bitmap = glyphBitmap->bitmap;

    fontBitmap.width = bitmap.width;
    fontBitmap.height = bitmap.rows;
    fontBitmap.offsetx = glyphBitmap->left;
    fontBitmap.offsety = glyphBitmap->top - bitmap.rows;

    fprintf(stdout, "%d\n", c);
    fontBitmap.data = new uint8_t [bitmap.width * bitmap.rows];
    memcpy(fontBitmap.data, bitmap.buffer, bitmap.width * bitmap.rows);

    FT_Done_Glyph(glyph);
}
开发者ID:lihw,项目名称:glf,代码行数:33,代码来源:main.cpp


示例9: FT_Load_Glyph

bool TTBMFont::addFontGlyph(int fontnum,FT_UInt glyphIndex,wchar32_t chr) {
	FT_Error error;
	FT_Face face=fontFaces_[fontnum].face;
	error = FT_Load_Glyph(face, glyphIndex, FT_LOAD_DEFAULT);
	if (error)
		return false;

	int top, left, width, height;
	if (face->glyph->format == FT_GLYPH_FORMAT_OUTLINE) {
		FT_BBox bbox;
		if (stroker) {
			FT_Glyph glyph;
			error = FT_Get_Glyph(face->glyph, &glyph);
			if (error)
				return false;
			error = FT_Glyph_StrokeBorder(&glyph, stroker, false, true);
			if (error)
				return false;
			FT_OutlineGlyph oGlyph = reinterpret_cast<FT_OutlineGlyph>(glyph);
			FT_Outline_Get_CBox(&oGlyph->outline, &bbox);
			FT_Done_Glyph(glyph);
		}
		else
			FT_Outline_Get_CBox(&face->glyph->outline, &bbox);

		bbox.xMin &= ~63;
		bbox.yMin &= ~63;
		bbox.xMax = (bbox.xMax + 63) & ~63;
		bbox.yMax = (bbox.yMax + 63) & ~63;

		width = (bbox.xMax - bbox.xMin) >> 6;
		height = (bbox.yMax - bbox.yMin) >> 6;
		top = bbox.yMax >> 6;
		left = bbox.xMin >> 6;
	} else if (face->glyph->format == FT_GLYPH_FORMAT_BITMAP) {
开发者ID:gideros,项目名称:gideros,代码行数:35,代码来源:ttbmfont.cpp


示例10: FT_Select_Size

void text_renderer::prepare_glyphs(glyph_positions const& positions)
{
    FT_Matrix matrix;
    FT_Vector pen;
    FT_Error  error;

    glyphs_.clear();
    glyphs_.reserve(positions.size());

    for (auto const& glyph_pos : positions)
    {
        glyph_info const& glyph = glyph_pos.glyph;
        FT_Int32 load_flags = FT_LOAD_DEFAULT | FT_LOAD_NO_HINTING;

        FT_Face face = glyph.face->get_face();
        if (glyph.face->is_color())
        {
            load_flags |= FT_LOAD_COLOR ;
            if (face->num_fixed_sizes > 0)
            {
                int scaled_size = static_cast<int>(glyph.format->text_size * scale_factor_);
                int best_match = 0;
                int diff = std::abs(scaled_size - face->available_sizes[0].width);
                for (int i = 1; i < face->num_fixed_sizes; ++i)
                {
                    int ndiff = std::abs(scaled_size - face->available_sizes[i].height);
                    if (ndiff < diff)
                    {
                        best_match = i;
                        diff = ndiff;
                    }
                }
                error = FT_Select_Size(face, best_match);
            }
        }
        else
        {
            glyph.face->set_character_sizes(glyph.format->text_size * scale_factor_);
        }

        double size = glyph.format->text_size * scale_factor_;
        matrix.xx = static_cast<FT_Fixed>( glyph_pos.rot.cos * 0x10000L);
        matrix.xy = static_cast<FT_Fixed>(-glyph_pos.rot.sin * 0x10000L);
        matrix.yx = static_cast<FT_Fixed>( glyph_pos.rot.sin * 0x10000L);
        matrix.yy = static_cast<FT_Fixed>( glyph_pos.rot.cos * 0x10000L);

        pixel_position pos = glyph_pos.pos + glyph.offset.rotate(glyph_pos.rot);
        pen.x = static_cast<FT_Pos>(pos.x * 64);
        pen.y = static_cast<FT_Pos>(pos.y * 64);

        FT_Set_Transform(face, &matrix, &pen);
        error = FT_Load_Glyph(face, glyph.glyph_index, load_flags);
        if (error) continue;
        FT_Glyph image;
        error = FT_Get_Glyph(face->glyph, &image);
        if (error) continue;
        box2d<double> bbox(0, glyph_pos.glyph.ymin(), glyph_pos.glyph.advance(), glyph_pos.glyph.ymax());
        glyphs_.emplace_back(image, *glyph.format, pos, glyph_pos.rot, size, bbox);
    }
}
开发者ID:CartoDB,项目名称:mapnik,代码行数:60,代码来源:renderer.cpp


示例11: FT_Get_Char_Index

ZGlyph ZFont::create_glyph(wchar_t character)
{
    FT_Error error = 0;
    FT_Face face = _impl->face;
    
    unsigned glyph_index = FT_Get_Char_Index(face, character);
    error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT);
    if (error != 0) {
        ZException ex(ZENGINE_EXCEPTION_CODE);
        ex.extra_info = ZUtil::format("Font %p failed to load glyph for character '%c'", this, character);
        throw ex;
    }
    
    FT_Glyph freetype_glyph;
    error = FT_Get_Glyph(face->glyph, &freetype_glyph);
    if (error != 0) {
        ZException ex(ZENGINE_EXCEPTION_CODE);
        ex.extra_info = ZUtil::format("Font %p failed to get glyph for character '%c'", this, character);
        throw ex;
    }
    
    FT_Glyph_To_Bitmap(&freetype_glyph, FT_RENDER_MODE_NORMAL, 0, 1);
    FT_BitmapGlyph bitmap_glyph = (FT_BitmapGlyph)freetype_glyph;
    FT_Bitmap bitmap = bitmap_glyph->bitmap;
    
    int width = bitmap.width;
    int height = bitmap.rows;
    size_t bitmap_length = width * height;
    ZDataRef bitmap_data = std::make_shared<ZData>(bitmap.buffer, bitmap_length);
    
    ZGlyph glyph = {
        .character = character,
        .size = { float(width), float(height) },
        .advance = ZSize2D{face->glyph->advance.x / 64.f, face->glyph->advance.y / 64.f},
        .insets = ZEdgeInsets{(float)bitmap_glyph->top, (float)bitmap_glyph->left, 0.f, 0.f},
开发者ID:zanneth,项目名称:ZGE,代码行数:35,代码来源:font.cpp


示例12: FT_Load_Glyph

//-------------------------------------------------------------------------------------------------------
StringManager::BChar* StringManager::_LoadChar(wchar_t wchar)
{
    //参考http://my.unix-center.net/~Simon_fu/?p=385
    bool space = false;
    if( L' ' == wchar )
    {
        space = true;
        wchar = L'_';
    }
    FT_Load_Glyph(m_FT_Face,  FT_Get_Char_Index( m_FT_Face, wchar ), FT_LOAD_DEFAULT);//FT_LOAD_FORCE_AUTOHINT| FT_LOAD_TARGET_NORMAL);

    //得到字模
    FT_Glyph glyph;
    FT_Get_Glyph( m_FT_Face->glyph, &glyph );
    //转化成位图
    FT_Render_Glyph( m_FT_Face->glyph,   FT_RENDER_MODE_LCD );

    FT_Glyph_To_Bitmap( &glyph, ft_render_mode_normal, 0, 1 );
    FT_BitmapGlyph bitmap_glyph = (FT_BitmapGlyph)glyph;
    //取道位图数据
    FT_Bitmap& bitmap=bitmap_glyph->bitmap;

    //重新计算数据
    float scale = static_cast<float>(bitmap.rows) / static_cast<float>(m_FT_Face->glyph->metrics.height);//计算文本高宽缩放到bitmap高宽的缩放比
    int beginY =  Math::Ceil( m_FT_Face->glyph->metrics.horiBearingY * scale );//y偏移

    //FT_Done_Glyph(glyph);
    vector2d size = vector2d(bitmap.width, bitmap.rows);
    return NEW BChar(beginY, size, glyph, space);
}
开发者ID:RichardOpenGL,项目名称:Bohge_Engine,代码行数:31,代码来源:Bfont.cpp


示例13: va_start

void Font::Printf(u32 x, u32 y,const char *a, ...){
	char text[1024];
	va_list va;
	va_start(va, a);
	vsnprintf(text, sizeof text, a, va);
	va_end(va);
	
	size_t len = strlen(a);
	if(len>0){
		len=strlen(text);
		vec.x = 0;
		vec.y = FontSize;
		FT_GlyphSlot slot = face->glyph;
		FT_UInt glyph_index = 0;
		FT_UInt previous_glyph = 0;
		Kerning = FT_HAS_KERNING(face);

		for(unsigned int i=0;i<len;i++){
			glyph_index = FT_Get_Char_Index(face, text[i]);
			if(Kerning && previous_glyph && glyph_index){
				FT_Vector delta;
				FT_Get_Kerning(face, previous_glyph, glyph_index, FT_KERNING_DEFAULT, &delta);
				vec.x += delta.x >> 6;
			}
			FT_Load_Glyph(face, glyph_index,FT_LOAD_RENDER);
			FT_Get_Glyph(face->glyph, &glyph);
			FT_Glyph_StrokeBorder(&glyph,stroker,0,0);
			FontDrawBitmap(&slot->bitmap,vec.x + slot->bitmap_left + x, (vec.y - slot->bitmap_top + y -FontSize));
			previous_glyph = glyph_index;
			vec.x += slot->advance.x >> 6;
			vec.y += slot->advance.y >> 6;
			FT_Done_Glyph(glyph);
		}
开发者ID:roman5566,项目名称:NoRSX,代码行数:33,代码来源:Font.cpp


示例14: glyph_to_bitmap

CAMLprim value glyph_to_bitmap(value glyph)
{
  CAMLparam1(glyph);
  CAMLlocal2(block, buffer);
  FT_GlyphSlot   slot;
  FT_Glyph       g;
  FT_BitmapGlyph bm;
  size_t         pitch;
  size_t         new_pitch;
  int i;

  slot = *(FT_GlyphSlot *)Data_custom_val(glyph);

  if (FT_Get_Glyph(slot, &g))
    failwith("glyph_to_bitmap");

  if (g->format != FT_GLYPH_FORMAT_BITMAP)
  {
    if (FT_Glyph_To_Bitmap(&g, FT_RENDER_MODE_MONO, 0, 1))
    {
      FT_Done_Glyph(g);
      failwith("glyph_to_bitmap");
    }
  }

  bm = (FT_BitmapGlyph)g;

  pitch     = abs(bm->bitmap.pitch);
  new_pitch = (bm->bitmap.width + 7) / 8;

  block  = alloc_tuple(6);
  buffer = alloc_string(bm->bitmap.rows * new_pitch);

  if (bm->bitmap.pitch >= 0)
  {
    for (i = 0; i < bm->bitmap.rows; i++)
      memcpy(String_val(buffer) + i * new_pitch,
             bm->bitmap.buffer + i * pitch,
             new_pitch);
  }
  else
  {
    for (i = 0; i < bm->bitmap.rows; i++)
      memcpy(String_val(buffer) + i * new_pitch,
             bm->bitmap.buffer + (bm->bitmap.rows - i) * pitch,
             new_pitch);
  }

  Store_field(block, 0, Val_int(bm->left));
  Store_field(block, 1, Val_int(bm->top));
  Store_field(block, 2, Val_int(bm->bitmap.rows));
  Store_field(block, 3, Val_int(bm->bitmap.width));
  Store_field(block, 4, Val_int(new_pitch));
  Store_field(block, 5, buffer);

  FT_Done_Glyph(g);

  CAMLreturn(block);
};
开发者ID:BackupTheBerlios,项目名称:ant,代码行数:59,代码来源:freetype-stubs.c


示例15: 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


示例16: ftFloatTo266

Object* Font::getGlyph (char code, const Vec2 &offset)
{
  FT_Error ftErr;
  FT_Glyph ftGlyph;
  FT_OutlineGlyph ftOutlineGlyph;

  //Set glyph size
  FT_F26Dot6 sz = ftFloatTo266( size );
  ftErr = FT_Set_Char_Size( ftFace, sz, sz, 72, 72 );
  if (ftErr)
  {
    std::cout << "Error while setting char size!" << std::endl;
    return NULL;
  }

  //Load glyph data into font face
  FT_UInt ftGlyphIndex = FT_Get_Char_Index( ftFace, (FT_ULong)code );
  ftErr = FT_Load_Glyph( ftFace, ftGlyphIndex, FT_LOAD_DEFAULT );
  if (ftErr)
  {
    std::cout << "Error while loading glyph!" << std::endl;
    return NULL;
  }

  //Get glyph from glyph slot of font face
  ftErr = FT_Get_Glyph( ftFace->glyph, &ftGlyph );
  if (ftErr)
  {
    std::cout << "Error while getting glyph from slot!" << std::endl;
    return NULL;
  }

  //Cast glyph to outline glyph
  ftOutlineGlyph = (FT_OutlineGlyph) ftGlyph;
  if (ftGlyph->format != FT_GLYPH_FORMAT_OUTLINE)
  {
    std::cout << "Error while casting glyph to outline glyph!" << std::endl;
    return NULL;
  }

  //Construct outline
  FT_Outline_Funcs ftFuncs;
  ftFuncs.move_to = ftMoveTo;
  ftFuncs.line_to = ftLineTo;
  ftFuncs.conic_to = ftQuadTo;
  ftFuncs.cubic_to = ftCubicTo;
  ftFuncs.shift = 0;
  ftFuncs.delta = 0;
  
  Object *object = new Object;
  this->object = object;
  this->offset = offset;
  ftErr = FT_Outline_Decompose( &ftOutlineGlyph->outline, &ftFuncs, this );

  //Cleanup
  FT_Done_Glyph( ftGlyph );
  return object;
}
开发者ID:ileben,项目名称:RAVG,代码行数:58,代码来源:rvgFont.cpp


示例17: FT_Get_Char_Index

void CBitmapFont::generateGlyph(U32 ch){
	S32 pad = 3;
	FT_GlyphSlot  slot = mFace->glyph;
	FT_Glyph glyph;
    FT_UInt glyph_index;

	glyph_index = FT_Get_Char_Index( mFace, (FT_ULong)ch );

	FT_Load_Glyph( mFace, glyph_index, FT_LOAD_DEFAULT);
	FT_Get_Glyph( slot, &glyph);

	FT_Glyph_To_Bitmap(&glyph, ft_render_mode_normal, 0 ,1);

	FT_BitmapGlyph bitmap = (FT_BitmapGlyph)glyph;
	FT_Bitmap* source = &bitmap->bitmap;


	S32 srcWidth = source->width;
	S32 srcHeight = source->rows;
	S32 srcPitch = source->pitch;

	S32 dstWidth = srcWidth;
	S32 dstHeight = srcHeight;
	S32 dstPitch = srcPitch;

	FT_BBox bbox;
	FT_Glyph_Get_CBox( glyph, ft_glyph_bbox_pixels, &bbox);

	unsigned char *src = source->buffer;

	if(pen.x + srcWidth >= mTextureSize){
		pen.x = 0;
		pen.y += (getFontSize() * 64.0f / dpi) + pad;
	}

	glBindTexture(GL_TEXTURE_2D, curTex);checkGLError();
	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);checkGLError();
	glTexSubImage2D(GL_TEXTURE_2D, 0, 
		pen.x, pen.y,
		srcWidth, srcHeight,
		GL_ALPHA, GL_UNSIGNED_BYTE, src); checkGLError();

	CTexCoord start(pen);
	start /= mTextureSize;
	CTexCoord end(pen.x + srcWidth, pen.y + srcHeight);
	end /= mTextureSize;
	//CVector2 pos(slot->bitmap_left, slot->bitmap_top);
	CVector2 pos(bitmap->left, srcHeight - bitmap->top);
	CVector2 size(srcWidth, srcHeight);
	CVector2 advance(slot->advance.x >> 6, slot->advance.y >> 6);
	
	mGlyphs[glyph_index] = new CBitmapGlyph(curTex, start, end, pos, size, advance);

	pen.x += srcWidth + pad;

	FT_Done_Glyph(glyph);
}
开发者ID:harkal,项目名称:sylphis3d,代码行数:57,代码来源:font.cpp


示例18: draw_bezier_outline

void draw_bezier_outline(DiaPsRenderer *renderer,
			 int dpi_x,
			 FT_Face face,
			 FT_UInt glyph_index,
			 double pos_x,
			 double pos_y
			 )
{
  FT_Int load_flags = FT_LOAD_DEFAULT|FT_LOAD_NO_BITMAP;
  FT_Glyph glyph;
  FT_Error error;
  gchar px_buf[G_ASCII_DTOSTR_BUF_SIZE];
  gchar py_buf[G_ASCII_DTOSTR_BUF_SIZE];
  gchar d1_buf[G_ASCII_DTOSTR_BUF_SIZE];
  gchar d2_buf[G_ASCII_DTOSTR_BUF_SIZE];

  /* Need to transform */

  /* Output outline */
  FT_Outline_Funcs outlinefunc = 
    {
      paps_move_to,
      paps_line_to,
      paps_conic_to,
      paps_cubic_to
    };
  OutlineInfo outline_info;

  outline_info.glyph_origin.x = pos_x;
  outline_info.glyph_origin.y = pos_y;
  outline_info.dpi = dpi_x;
  outline_info.OUT = renderer->file;

  fprintf(renderer->file, 
	  "gsave %s %s translate %s %s scale\n",
	  g_ascii_formatd(px_buf, sizeof(px_buf), "%f", pos_x),
	  g_ascii_formatd(py_buf, sizeof(py_buf), "%f", pos_y),
	  g_ascii_formatd(d1_buf, sizeof(d1_buf), "%f", 2.54/72.0),
	  g_ascii_formatd(d2_buf, sizeof(d2_buf), "%f", -2.54/72.0) );
  fprintf(renderer->file, "start_ol\n");

  if ((error=FT_Load_Glyph(face, glyph_index, load_flags))) {
    fprintf(stderr, "Can't load glyph: %d\n", error);
    return;
  }
  if ((error=FT_Get_Glyph (face->glyph, &glyph))) {
    fprintf(stderr, "Can't get glyph: %d\n", error);
    FT_Done_Glyph (glyph);
    return;
  }
  if (face->glyph->format == FT_GLYPH_FORMAT_OUTLINE)
    FT_Outline_Decompose (&(((FT_OutlineGlyph)glyph)->outline),
                          &outlinefunc, &outline_info);
  fprintf(renderer->file, "end_ol grestore \n");
  
  FT_Done_Glyph (glyph);
}
开发者ID:brunetton,项目名称:dia,代码行数:57,代码来源:diapsft2renderer.c


示例19: loadGlyph

void loadGlyph(char letter)
{
   int glyph_index = FT_Get_Char_Index( face, letter);

   FT_Load_Glyph(face,glyph_index,FT_LOAD_RENDER);
   
   FT_Render_Glyph(face->glyph,FT_RENDER_MODE_NORMAL);

   FT_Get_Glyph(face->glyph,(FT_Glyph *) &glyphs[letter -32]);
}
开发者ID:Lalaland,项目名称:Asteroids,代码行数:10,代码来源:util.cpp


示例20: aft_cacheglyph

//*
//* Cache Readed Glyph
//*
byte aft_cacheglyph(AFTFACEP f, long id) {
    if (!aft_initialized) return 0;
    if (f==NULL) return 0;
    if (f->cache_n<id) return 0;

    if (!f->cache[id].init) {
        FT_Get_Glyph(f->face->glyph, &f->cache[id].g);
        f->cache[id].w    = f->face->glyph->advance.x >> 6;
        f->cache[id].init = 1;
    }
开发者ID:sembre,项目名称:AROMA-Installer,代码行数:13,代码来源:aroma_freetype.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ FT_Get_Kerning函数代码示例发布时间:2022-05-30
下一篇:
C++ FT_Get_Char_Index函数代码示例发布时间: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