当前位置: 首页>>代码示例>>C++>>正文


C++ FT_Get_Char_Index函数代码示例

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


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

示例1: convertGlyph

/**
 * Converts one single glyph (character, sign) into LFF.
 */
FT_Error convertGlyph(FT_ULong charcode) {
    FT_Error error;
    FT_Glyph glyph;

    // load glyph
    error = FT_Load_Glyph(face,
                          FT_Get_Char_Index(face, charcode),
                          FT_LOAD_NO_BITMAP | FT_LOAD_NO_SCALE);
    if (error) {
        std::cerr << "FT_Load_Glyph: " << FT_StrError(error) << std::endl;
        return error;
    }

    FT_Get_Glyph(face->glyph, &glyph);
    FT_OutlineGlyph og = (FT_OutlineGlyph)glyph;
    if (face->glyph->format != ft_glyph_format_outline) {
        std::cerr << "Not an outline font\n";
    }

    // write glyph header
    if (fpLff) {
        fprintf(fpLff, "\n[#%04X]\n", (unsigned)charcode);
    }

    // trace outline of the glyph
    xMin = 1000.0;
    firstpass = true;
    error = FT_Outline_Decompose(&(og->outline), &funcs, fpLff);
    firstpass = false;
    startcontour = true;
    error = FT_Outline_Decompose(&(og->outline), &funcs, fpLff);
    if (fpLff) {
        fprintf(fpLff, "\n");
    }

    if (error) {
        std::cerr << "FT_Outline_Decompose: " << FT_StrError(error) << std::endl;
    }

    return error;
}
开发者ID:Ngassa,项目名称:LibreCAD,代码行数:44,代码来源:main.cpp

示例2: font_size

void 
font_size(const char *str, int unicode, struct font_context *ctx) {
    FT_Face face = ctx->font;
    FT_UInt glyph_index = FT_Get_Char_Index(face, unicode);
	if (!glyph_index) {
		pf_log("cannot find glyph %d\n", unicode);
        // in android \n can not found, just skip render it
		//exit(1);
        ctx->w = 0;
        return;
	}
    FT_Load_Glyph(face, glyph_index, FT_LOAD_NO_BITMAP);
    
    int err = FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL);
	if (err)
        _fault(err, "render failed");

    FT_GlyphSlot slot = face->glyph;

    ctx->w = slot->advance.x >> 6;
}
开发者ID:lvshaco,项目名称:ejoy2d,代码行数:21,代码来源:winfont.c

示例3: blf_font_count_missing_chars

int blf_font_count_missing_chars(FontBLF *font, const char *str, const size_t len, int *r_tot_chars)
{
	int missing = 0;
	size_t i = 0;

	*r_tot_chars = 0;
	while (i < len) {
		unsigned int c;

		if ((c = str[i]) < 0x80) {
			i++;
		}
		else if ((c = BLI_str_utf8_as_unicode_step(str, &i)) != BLI_UTF8_ERR) {
			if (FT_Get_Char_Index((font)->face, c) == 0) {
				missing++;
			}
		}
		(*r_tot_chars)++;
	}
	return missing;
}
开发者ID:Ichthyostega,项目名称:blender,代码行数:21,代码来源:blf_font.c

示例4: test_get_char_index

int
test_get_char_index( btimer_t*  timer,
                     FT_Face    face,
                     void*      user_data )
{
  bcharset_t*  charset = (bcharset_t*)user_data;
  int          i, done = 0;


  TIMER_START( timer );

  for ( i = 0; i < charset->size; i++ )
  {
    if ( FT_Get_Char_Index(face, charset->code[i]) )
      done++;
  }

  TIMER_STOP( timer );

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

示例5: FT_Load_Char

	void Glyph::Load(FT_Library& library, FT_Face face, FT_ULong charcode, bool hinting)
	{
		int flags = FT_LOAD_DEFAULT;

		if (hinting)
			flags |= FT_LOAD_FORCE_AUTOHINT;
		else
			flags |= FT_LOAD_NO_HINTING | FT_LOAD_NO_AUTOHINT;

		_error = FT_Load_Char(face, charcode, flags);
		if (_error)
			return;

		_error = FT_Load_Glyph(face, FT_Get_Char_Index(face, charcode), flags);
		if (_error)
			return;

		_error = FT_Get_Glyph(face->glyph, &_glyph);
		if (_error)
			return;
	}
开发者ID:victor-timoshin,项目名称:SWAY-GameFramework,代码行数:21,代码来源:Glyph.cpp

示例6: renderFont

int renderFont(void)
{
	FT_Library library; 
	FT_Face face; /* handle to face object */  
	int fontSize = 8;

	//load library:
	int error = FT_Init_FreeType( &library );
	if ( error ) 
		return -1;

	error = FT_Init_FreeType( &library ); 
	if ( error ) 
		return -2;
	
	error = FT_New_Face( library, "FreeSans.ttf", 0, &face ); 
	if ( error == FT_Err_Unknown_File_Format )
		return -3;
	else if ( error )
		return -4;

	error = FT_Set_Pixel_Sizes( face,	/* handle to face object */  
								0,		/* pixel_width */  
								fontSize ); /* pixel_height */ 
	if(error)
		return -5;

	for(char charcode = 'a'; charcode < 'f'; charcode++)
	{
		FT_UInt glyph_index = FT_Get_Char_Index( face, charcode ); 
		error = FT_Load_Glyph( face, glyph_index, 
								0 ); /* load flags */ 
		
		error = FT_Render_Glyph( face->glyph, FT_RENDER_MODE_MONO);
		printSlot(stdout, face->glyph, fontSize);
	}

	slot2bmp("dump.bmp", face->glyph, fontSize);
	return 0;
}
开发者ID:playwithfree,项目名称:squeezed,代码行数:40,代码来源:render.cpp

示例7: RenderChar

// Freetype - RenderChar
int RenderChar(FT_ULong currentchar, int sx, int sy, int ex, unsigned char *color)
{
	if (currentchar == 32) return;

#ifdef FB8BIT
		int bpp=1;
#else
		int bpp=4;
#endif		
		
	int row, pitch, bit, x = 0, y = 0;
	FT_UInt glyphindex;
	FT_Vector kerning;
	FT_Error error;
	int tmpcolor;

	if(!(glyphindex = FT_Get_Char_Index(face, currentchar)))
	{
		printf("Freetype <FT_Get_Char_Index> fuer Zeichen %x \"%c\" fehlgeschlagen\n", (int)currentchar,(int)currentchar);
		return 0;
	}

#if ((defined(FREETYPE_MAJOR)) && (((FREETYPE_MAJOR == 2) && (((FREETYPE_MINOR == 1) && (FREETYPE_PATCH >= 9)) || (FREETYPE_MINOR > 1))) || (FREETYPE_MAJOR > 2)))
	FTC_Node anode;
	if((error = FTC_SBitCache_Lookup(cache, &desc, glyphindex, &sbit, &anode)))
#else
	if((error = FTC_SBit_Cache_Lookup(cache, &desc, glyphindex, &sbit)))
#endif
	{
		printf("Freetype <FTC_SBitCache_Lookup> fuer Zeichen %x \"%c\" fehlgeschlagen. Fehler: 0x%.2X>\n", (int)currentchar,(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
开发者ID:GWARDAR,项目名称:OpenPLi-1,代码行数:41,代码来源:render.c

示例8: combine

const Glyph& Font::getGlyph(Uint32 codePoint, unsigned int characterSize, bool bold, float outlineThickness) const
{
    // Get the page corresponding to the character size
    GlyphTable& glyphs = m_pages[characterSize].glyphs;

    // Build the key by combining the glyph index (based on code point), bold flag, and outline thickness
    Uint64 key = combine(outlineThickness, bold, FT_Get_Char_Index(static_cast<FT_Face>(m_face), codePoint));

    // Search the glyph into the cache
    GlyphTable::const_iterator it = glyphs.find(key);
    if (it != glyphs.end())
    {
        // Found: just return it
        return it->second;
    }
    else
    {
        // Not found: we have to load it
        Glyph glyph = loadGlyph(codePoint, characterSize, bold, outlineThickness);
        return glyphs.emplace(key, glyph).first->second;
    }
}
开发者ID:PKEuS,项目名称:SFML,代码行数:22,代码来源:Font.cpp

示例9: FT_New_Face

void Font::LoadFont(const char * filename, Float size)
{
	baseSize = size;
	//baseSize /= 16.0;

	FT_Face face;

	FT_New_Face(FreeType, filename, 0, &face);
	FT_Set_Char_Size(face, 16 * baseSize, 16 * baseSize, 300, 300); 

	FT_GlyphSlot slot = face->glyph;

	for (uint8 i = 0; i < 128; i++)
	{
		FT_Load_Glyph(face, FT_Get_Char_Index(face, i), FT_LOAD_DEFAULT);
		FT_Render_Glyph(slot, FT_RENDER_MODE_NORMAL);

		width[i] = slot->advance.x >> 6;

		LoadCharacter(face, i);
	}
}
开发者ID:Dingf,项目名称:Paper-TD,代码行数:22,代码来源:font.cpp

示例10: FT_Get_Char_Index

void FontRenderer::print(const wchar_t* _str, euint32 _num_chars, vptr _target, euint32 _x, euint32 _y, euint32 _w)
{
    FT_GlyphSlot slot = m_ft_face->glyph;
    FT_UInt glyph_index;
    FT_UInt error;

    euint32 n;
    m_char_ptr = 0;
    for ( n = 0; n < _num_chars; n++ )
    {
        glyph_index = FT_Get_Char_Index( m_ft_face, _str[n] );

        error = FT_Load_Glyph( m_ft_face, glyph_index, FT_LOAD_DEFAULT );

        if ( error )
        {
            continue;
        }

        /// 加粗函数 FT_Outline_Embolden( &m_ft_face->glyph->outline, 100 );

        error = FT_Render_Glyph( m_ft_face->glyph, FT_RENDER_MODE_NORMAL );

        if ( error )
        {
            continue;
        }

        draw_text( &slot->bitmap, _target, _x, _y, _w);
        if (0xff00 & _str[n])
        {
            m_char_ptr += m_pixel_size;
        }
        else
        {
            m_char_ptr += m_pixel_size/2;
        }
    }
}
开发者ID:rodrigobmg,项目名称:v-engine,代码行数:39,代码来源:font_renderer.cpp

示例11: FT_Get_Char_Index

Size FontEngine_Freetype::get_size(const std::string &text, int pos)
{
	FT_UInt glyph_index;

	// Get glyph index
	glyph_index = FT_Get_Char_Index(face, text[pos]);

	// Load glyph image
	FT_Error error = FT_Load_Glyph(face, glyph_index, FT_LOAD_DEFAULT );
	if (error) return Size(0,0);

	FT_Glyph glyph;
	FT_BBox bbox;
	FT_Get_Glyph(face->glyph, &glyph);
	FT_Glyph_Get_CBox( glyph, FT_GLYPH_BBOX_PIXELS, &bbox );

	int y = bbox.yMax + bbox.yMin;	// Include the whitespace, to match the windows GetTextExtentPoint32()

	int x = int(face->glyph->advance.x / 64.0f);

	return (Size(x,y));
}
开发者ID:wbyang1985,项目名称:ClanLib,代码行数:22,代码来源:font_engine_freetype.cpp

示例12: FT_Set_Pixel_Sizes

//// begin font_metric private member methods
void xlui::font_metric::calculate() {
	uint32_t *rt = _text.toUCS4(_text);
	FT_GlyphSlot slot = _font_face->glyph;


	int32_t result = FT_Set_Pixel_Sizes(_font_face, 0, _font.get_size());
	if (result == 0) {
		for(uint32_t i = 0; i < _text.get_character_count(); ++i) {
			FT_UInt glyph_index = FT_Get_Char_Index(_font_face, rt[i]);
			FT_Load_Glyph(_font_face, glyph_index, FT_LOAD_DEFAULT);
			uint32_t h = _font_face->glyph->metrics.horiBearingY >> 6;

			if(h > _max_height) {
				_max_height = h;
			}
			_width += _font_face->glyph->metrics.horiAdvance;
		}
	}

	_width >>= 6;
	delete[] rt;
}
开发者ID:Ayandorias,项目名称:xlui,代码行数:23,代码来源:font_metric_x_window.cpp

示例13: freetype_render_glyph

void freetype_render_glyph(unsigned charcode)
{
    FT_Error error;
    unsigned glyph_index;

    glyph_index = FT_Get_Char_Index(face, charcode);
    assert(glyph_index != 0);

    error = FT_Load_Glyph(face, glyph_index, FT_LOAD_NO_BITMAP);
    abort_on_error("FreeType", error);

    #ifdef FT_CONFIG_OPTION_SUBPIXEL_RENDERING
    printf("Subpixel rendering is enabled.\n");
    #endif

    if(face->glyph->format != FT_GLYPH_FORMAT_BITMAP)
    {
        printf("Glyph is not bitmap. Rendering...\n");
        error = FT_Render_Glyph(face->glyph, FT_RENDER_MODE_NORMAL);
        abort_on_error("FreeType", error);
    }
}
开发者ID:n2liquid,项目名称:cgrecipes,代码行数:22,代码来源:text_test.c

示例14: get_ft2_text_width

uint32_t get_ft2_text_width(wchar_t *text, struct ft2_source *srcdata)
{
    FT_GlyphSlot slot = srcdata->font_face->glyph;
    FT_UInt glyph_index = 0;
    uint32_t w = 0, max_w = 0;

    if (!text)
        return 0;

    for (uint32_t i = 0; i < (uint32_t)wcslen(text); i++) {
        glyph_index = FT_Get_Char_Index(srcdata->font_face, text[i]);
        FT_Load_Glyph(srcdata->font_face, glyph_index, FT_LOAD_DEFAULT);

        if (text[i] == L'\n') w = 0;
        else {
            w += slot->advance.x >> 6;
            if (w > max_w) max_w = w;
        }
    }

    return max_w;
}
开发者ID:jmcarman,项目名称:obs-studio,代码行数:22,代码来源:text-functionality.c

示例15: assert

void kGUIFace::CalcHeight(unsigned int size)
{
	unsigned int c;
	static char largechars[]={"QWpqjy"};
	int glyph_index,above,below,maxabove,maxbelow;

	assert(size<=MAXFONTSIZE,"Size to large!");

	/* -1,-1 = not calculated yet */
	if(m_pixabove[size]!=-1 || m_pixbelow[size]!=-1)
		return;

	maxabove=0;
	maxbelow=0;
	kGUI::SelectFont(this,size);

	for(c=0;c<sizeof(largechars);++c)
	{
		glyph_index = FT_Get_Char_Index( m_ftface, largechars[c] );
		if(glyph_index>0)
		{
			if(FT_Load_Glyph(m_ftface, glyph_index, FT_LOAD_DEFAULT)==0)
			{
				if(FT_Render_Glyph( m_ftface->glyph, ft_render_mode_normal )==0)
				{
					above=m_ftface->glyph->bitmap_top;
					below=m_ftface->glyph->bitmap.rows-above;

					if(above>maxabove)
						maxabove=above;
					if(below>maxbelow)
						maxbelow=below;
				}
			}
		}
	}
	m_pixabove[size]=maxabove;
	m_pixbelow[size]=maxbelow;
}
开发者ID:CarlHuff,项目名称:kgui,代码行数:39,代码来源:kguifont.cpp


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