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

C++ FT_Get_Char_Index函数代码示例

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

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



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


示例16: ass_font_get_asc_desc

/**
 * \brief Get maximal font ascender and descender.
 * \param ch character code
 * The values are extracted from the font face that provides glyphs for the given character
 **/
void ass_font_get_asc_desc(ASS_Font *font, uint32_t ch, int *asc,
                           int *desc)
{
    int i;
    for (i = 0; i < font->n_faces; ++i) {
        FT_Face face = font->faces[i];
        TT_OS2 *os2 = FT_Get_Sfnt_Table(face, ft_sfnt_os2);
        if (FT_Get_Char_Index(face, ass_font_index_magic(face, ch))) {
            int y_scale = face->size->metrics.y_scale;
            if (os2) {
                *asc = FT_MulFix((short)os2->usWinAscent, y_scale);
                *desc = FT_MulFix((short)os2->usWinDescent, y_scale);
            } else {
                *asc = FT_MulFix(face->ascender, y_scale);
                *desc = FT_MulFix(-face->descender, y_scale);
            }
            return;
        }
    }

    *asc = *desc = 0;
}
开发者ID:mwgoldsmith,项目名称:ass,代码行数:27,代码来源:ass_font.c


示例17: font_makeChar

static int font_makeChar( glFontStash *stsh, font_char_t *c, uint32_t ch )
{
   FT_Bitmap bitmap;
   FT_GlyphSlot slot;
   FT_UInt glyph_index;
   int w,h;

   slot = stsh->face->glyph; /* Small shortcut. */

   /* Get glyph index. */
   glyph_index = FT_Get_Char_Index( stsh->face, ch );

   /* Load the glyph. */
   if (FT_Load_Glyph( stsh->face, glyph_index, FT_LOAD_RENDER | FT_LOAD_NO_BITMAP | FT_LOAD_TARGET_NORMAL)) {
      WARN(_("FT_Load_Glyph failed."));
      return -1;
   }

   bitmap = slot->bitmap; /* to simplify */
   if (bitmap.pixel_mode != FT_PIXEL_MODE_GRAY)
      WARN(_("Font '%s' not using FT_PIXEL_MODE_GRAY!"), stsh->fontname);

   /* need the POT wrapping for opengl */
   w = bitmap.width;
   h = bitmap.rows;

   /* Store data. */
   c->data = malloc( sizeof(GLubyte) * w*h );
   memcpy( c->data, bitmap.buffer, sizeof(GLubyte) * w*h );
   c->w     = w;
   c->h     = h;
   c->off_x = slot->bitmap_left;
   c->off_y = slot->bitmap_top;
   c->adv_x = (GLfloat)slot->advance.x / 64.;
   c->adv_y = (GLfloat)slot->advance.y / 64.;

   return 0;
}
开发者ID:nenau,项目名称:naev,代码行数:38,代码来源:font.c


示例18: FT_Get_Char_Index

bool GlyphString::loadGlyphImages(bool useGlyphIndices, bool keepXAdvance)
{

    for (int i = 0; i < mSize; ++i) {
        int glyphIndex;
        if (useGlyphIndices)
            glyphIndex = mGlyphIndices[i];
        else
            glyphIndex = FT_Get_Char_Index(mFace, mCodePoints[i]);

        if (FT_Load_Glyph(mFace, glyphIndex, 0))
            continue;
        if (FT_Render_Glyph(mFace->glyph, FT_RENDER_MODE_NORMAL))
            continue;

        FT_Bitmap bmp = mFace->glyph->bitmap;

        mGlyphIndices[i] = glyphIndex;
        mGeometries[i].top = mFace->glyph->bitmap_top;
        mGeometries[i].left = mFace->glyph->bitmap_left;
        if (!keepXAdvance)
            mGeometries[i].xAdvance = mFace->glyph->advance.x / 64;

        mImages[i] = QImage(bmp.width, bmp.rows, QImage::Format_ARGB32);

        for (int ii = 0; ii < bmp.width; ++ii)
        {
            for (int jj = 0; jj < bmp.rows; ++jj)
                mImages[i].setPixel(ii, jj, qRgba(mFaceColor.red(),
                                                  mFaceColor.green(),
                                                  mFaceColor.blue(),
                                                  bmp.buffer[jj * bmp.pitch + ii]));
        }

    }

    return true;
}
开发者ID:asmaAL-Bahanta,项目名称:BidiRenderer,代码行数:38,代码来源:glyph_string.cpp


示例19: renderGlyph

void renderGlyph(SDL_Surface *screen, char glyph)
{
	SDL_FillRect(screen, NULL, 0x00000000);
	int error;
   int glyph_index = FT_Get_Char_Index( face, glyph);
   error = FT_Load_Glyph( face, glyph_index, 0 ); // Load 'A' glyph with default parameters (0)
   if(error)
   {
      exit(0);
   }

   error = FT_Render_Glyph( face->glyph, FT_RENDER_MODE_NORMAL ); // Can haz bitmap?

   if(error)
   {
      exit(0); // no can haz bitmap :|
   }

	int i, j;
	for(i = 0; i<face->glyph->bitmap.rows;i++)
		for(j = 0;j<face->glyph->bitmap.width;j++)
			put_pixel(screen,face->glyph->bitmap.buffer[i*face->glyph->bitmap.pitch+j],j,i);
}
开发者ID:ElFeesho,项目名称:OldCProjects,代码行数:23,代码来源:main.c


示例20: Java_sun_font_FreetypeFontScaler_getGlyphCodeNative

/*
 * Class:     sun_font_FreetypeFontScaler
 * Method:    getGlyphCodeNative
 * Signature: (C)I
 */
JNIEXPORT jint JNICALL
Java_sun_font_FreetypeFontScaler_getGlyphCodeNative(
        JNIEnv *env, jobject scaler,
        jobject font2D, jlong pScaler, jchar charCode) {

    FTScalerInfo* scalerInfo = (FTScalerInfo *) jlong_to_ptr(pScaler);
    int errCode;

    if (scaler == NULL || scalerInfo->face == NULL) { /* bad/null scaler */
        invalidateJavaScaler(env, scaler, scalerInfo);
        return 0;
    }

    /* Freetype functions *may* cause callback to java
       that can use cached values. Make sure our cache is up to date.
       Scaler context is not important here, can use NULL. */
    errCode = setupFTContext(env, font2D, scalerInfo, NULL);
    if (errCode) {
        return 0;
    }

    return FT_Get_Char_Index(scalerInfo->face, charCode);
}
开发者ID:krichter722,项目名称:jdk9-jdk9-jdk,代码行数:28,代码来源:freetypeScaler.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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