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


C++ FT_Set_Charmap函数代码示例

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


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

示例1: FTRemap

unsigned 
FTRemap(FT_Face face, FTMappingPtr tm, unsigned code)
{
    unsigned index;
    char *name;
    unsigned glyph_index;

    if(tm->mapping) {
        if(tm->named) {
            name = FontEncName(code, tm->mapping);
            if(!name)
                return 0;
            glyph_index = FT_Get_Name_Index(face, name);
            return glyph_index;
        } else {
            index = FontEncRecode(code, tm->mapping) + tm->base;
            FT_Set_Charmap(face, tm->cmap);
            glyph_index = FT_Get_Char_Index(face, index);
            return glyph_index;
        }
    } else {
        if(code < 0x100) {
            index = code;
            FT_Set_Charmap(face, tm->cmap);
            glyph_index = FT_Get_Char_Index(face, index);
            return glyph_index;
        } else
            return 0;
    }
}
开发者ID:aosm,项目名称:X11libs,代码行数:30,代码来源:ftenc.c

示例2: find_cmap

static int
find_cmap(int type, int pid, int eid, FT_Face face)
{
    int i, n, rc;
    FT_CharMap cmap = NULL;

    n = face->num_charmaps;

    switch(type) {
    case FONT_ENCODING_TRUETYPE:  /* specific cmap */
        for(i=0; i<n; i++) {
            cmap = face->charmaps[i];
            if(cmap->platform_id == pid && cmap->encoding_id == eid) {
                rc = FT_Set_Charmap(face, cmap);
                if(rc == 0)
                    return 1;
            }
        }
        break;
    case FONT_ENCODING_UNICODE:   /* any Unicode cmap */
        /* prefer Microsoft Unicode */
        for(i=0; i<n; i++) {
            cmap = face->charmaps[i];
            if(cmap->platform_id == TT_PLATFORM_MICROSOFT &&
               cmap->encoding_id == TT_MS_ID_UNICODE_CS) {
                rc = FT_Set_Charmap(face, cmap);
                if(rc == 0)
                    return 1;
            }
        }
        /* Try Apple Unicode */
        for(i=0; i<n; i++) {
            cmap = face->charmaps[i];
            if(cmap->platform_id == TT_PLATFORM_APPLE_UNICODE) {
                rc = FT_Set_Charmap(face, cmap);
                if(rc == 0)
                    return 1;
            }
        }
        /* ISO Unicode? */
        for(i=0; i<n; i++) {
            cmap = face->charmaps[i];
            if(cmap->platform_id == TT_PLATFORM_ISO) {
                rc = FT_Set_Charmap(face, cmap);
                if(rc == 0)
                    return 1;
            }
        }
        break;
    default:
        return 0;
    }
    return 0;
}
开发者ID:erdincay,项目名称:vcxsrv-linux2windows,代码行数:54,代码来源:mkfontscale.c

示例3: af_indic_metrics_init

  static FT_Error
  af_indic_metrics_init( AF_CJKMetrics  metrics,
                         FT_Face        face )
  {
    /* skip blue zone init in CJK routines */
    FT_CharMap  oldmap = face->charmap;


    metrics->units_per_em = face->units_per_EM;

    if ( FT_Select_Charmap( face, FT_ENCODING_UNICODE ) )
      face->charmap = NULL;
    else
    {
      af_cjk_metrics_init_widths( metrics, face );
#if 0
      /* either need indic specific blue_chars[] or just skip blue zones */
      af_cjk_metrics_init_blues( metrics, face, af_cjk_blue_chars );
#endif
      af_cjk_metrics_check_digits( metrics, face );
    }

    FT_Set_Charmap( face, oldmap );

    return FT_Err_Ok;
  }
开发者ID:Johnny-Martin,项目名称:ComBase,代码行数:26,代码来源:afindic.c

示例4: check_font_contain_text

static gboolean
check_font_contain_text (FT_Face face,
                         const gchar *text)
{
  gunichar *string;
  glong len, idx, map;
  FT_CharMap charmap;
  gboolean retval;

  string = g_utf8_to_ucs4_fast (text, -1, &len);

  for (map = 0; map < face->num_charmaps; map++) {
    charmap = face->charmaps[map];
    FT_Set_Charmap (face, charmap);

    retval = TRUE;

    for (idx = 0; idx < len; idx++) {
      gunichar c = string[idx];

      if (!FT_Get_Char_Index (face, c)) {
        retval = FALSE;
        break;
      }
    }

    if (retval)
      break;
  }

  g_free (string);

  return retval;
}
开发者ID:rkmax,项目名称:gnome-font-viewer,代码行数:34,代码来源:font-thumbnailer.c

示例5: TTF_New_Memory_Face

TTF_Font* TTF_New_Memory_Face(const FT_Byte* file_base, FT_Long file_size, int ptsize)
	{
	TTF_Font *font = (TTF_Font*)malloc(sizeof *font);
	if (font == NULL)
		E_Exit("TTF: Out of memory");
	memset(font, 0, sizeof(*font));

	if (FT_New_Memory_Face(library, file_base, file_size, 0, &font->face))
		E_Exit("TTF: Couldn't init font");
	FT_Face face = font->face;
	if (!FT_IS_SCALABLE(face))														// Make sure that our font face is scalable (global metrics)
		E_Exit("TTF: Font is not scalable");

	for (int i = 0; i < face->num_charmaps; i++)									// Set charmap for loaded font
		{
		FT_CharMap charmap = face->charmaps[i];
		if (charmap->platform_id == 3 && charmap->encoding_id == 1)					// Windows Unicode
			{
			FT_Set_Charmap(face, charmap);
			break;
			}
		}
 
	TTF_SetCharSize(font, ptsize);
	bool fontOK = false;
	if (!FT_Load_Glyph(face, 0, FT_LOAD_DEFAULT))									// Test pixel mode
		if (!FT_Render_Glyph(font->face->glyph, FT_RENDER_MODE_NORMAL))				// Render the glyph
			if (font->face->glyph->bitmap.pixel_mode == FT_PIXEL_MODE_GRAY)
				fontOK = true;
	if (!fontOK)
		E_Exit("TTF: Font is not 8 bits gray scale");
	return font;
	}
开发者ID:catastrophicanomaly,项目名称:vDosXY3,代码行数:33,代码来源:freetype.cpp

示例6: check_freetypefont

static int check_freetypefont(PackedFile *pf)
{
	FT_Face face;
	FT_GlyphSlot glyph;
	FT_UInt glyph_index;
#if 0
	FT_CharMap charmap;
	FT_CharMap found;
	FT_UShort my_platform_id = TT_PLATFORM_MICROSOFT;
	FT_UShort my_encoding_id = TT_MS_ID_UNICODE_CS;
	int n;
#endif
	int success = 0;

	err = FT_New_Memory_Face(library,
	                         pf->data,
	                         pf->size,
	                         0,
	                         &face);
	if (err) {
		success = 0;
		//XXX error("This is not a valid font");
	}
	else {

#if 0
		for (n = 0; n < face->num_charmaps; n++) {
			charmap = face->charmaps[n];
			if (charmap->platform_id == my_platform_id && charmap->encoding_id == my_encoding_id) {
				found = charmap;
				break;
			}
		}

		if (!found) { return 0; }

		/* now, select the charmap for the face object */
		err = FT_Set_Charmap(face, found);
		if (err) { return 0; }
#endif

		glyph_index = FT_Get_Char_Index(face, 'A');
		err = FT_Load_Glyph(face, glyph_index, FT_LOAD_NO_SCALE | FT_LOAD_NO_BITMAP);
		if (err) {
			success = 0;
		}
		else {
			glyph = face->glyph;
			if (glyph->format == ft_glyph_format_outline) {
				success = 1;
			}
			else {
				//XXX error("Selected Font has no outline data");
				success = 0;
			}
		}
	}
	
	return success;
}
开发者ID:YasirArafath,项目名称:blender-git,代码行数:60,代码来源:freetypefont.c

示例7: selectUnicodeCharmap

    //==============================================================================
    static FTFaceWrapper::Ptr selectUnicodeCharmap (FTFaceWrapper* face)
    {
        if (face != nullptr)
            if (FT_Select_Charmap (face->face, ft_encoding_unicode) != 0)
                FT_Set_Charmap (face->face, face->face->charmaps[0]);

        return face;
    }
开发者ID:RobertoMalatesta,项目名称:juce_emscripten,代码行数:9,代码来源:juce_freetype_Fonts.cpp

示例8: m_ftFace

  Charmap::Charmap(Face * face)
  : m_ftFace(*face->freetype()),
    m_error(0)
  {
    if(!m_ftFace->charmap)  
      m_error = FT_Set_Charmap(m_ftFace, m_ftFace->charmaps[0]);

    m_ftEncoding = m_ftFace->charmap->encoding;
  }
开发者ID:enuuros,项目名称:multitude,代码行数:9,代码来源:Charmap.cpp

示例9: load

/*  See http://www.microsoft.com/typography/otspec/name.htm
    for a list of some possible platform-encoding pairs.
    We're interested in 0-3 aka 3-1 - UCS-2.
    Otherwise, fail. If a font has some unicode map, but lacks
    UCS-2 - it is a broken or irrelevant font. What exactly
    Freetype will select on face load (it promises most wide
    unicode, and if that will be slower that UCS-2 - left as
    an excercise to check. */
int force_ucs2_charmap(FT_Face ftf) {
    for(int i = 0; i < ftf->num_charmaps; i++)
        if ((  (ftf->charmaps[i]->platform_id == 0)
            && (ftf->charmaps[i]->encoding_id == 3))
           || ((ftf->charmaps[i]->platform_id == 3)
            && (ftf->charmaps[i]->encoding_id == 1)))
                return FT_Set_Charmap(ftf, ftf->charmaps[i]);
    return -1;
}
开发者ID:aaronkennedy,项目名称:ex-sdl-freetype-harfbuzz,代码行数:17,代码来源:ex-sdl-freetype-harfbuzz.c

示例10: force_ucs2_charmap

/*  See http://www.microsoft.com/typography/otspec/name.htm for a list of some
    possible platform-encoding pairs.  We're interested in 0-3 aka 3-1 - UCS-2.
    Otherwise, fail. If a font has some unicode map, but lacks UCS-2 - it is a
    broken or irrelevant font. What exactly Freetype will select on face load
    (it promises most wide unicode, and if that will be slower that UCS-2 -
    left as an excercise to check. */
int force_ucs2_charmap( FT_Face face )
{
    int i;
    for(i = 0; i < face->num_charmaps; i++)
        if( ((face->charmaps[i]->platform_id == 0) && (face->charmaps[i]->encoding_id == 3))
         || ((face->charmaps[i]->platform_id == 3) && (face->charmaps[i]->encoding_id == 1)) )
            return FT_Set_Charmap( face, face->charmaps[i] );
    return -1;
}
开发者ID:JacobHensley,项目名称:GLEW-Graphics,代码行数:15,代码来源:harfbuzz-texture.c

示例11: LoadCharsMaps

// load and store charsmaps
static void LoadCharsMaps(GFont2D& Font, const FT_Face Face) {

	GUInt32 i, numMaps;
	FT_ULong charCode;
	FT_UInt glyphIndex;
	FT_Error err;
	FT_CharMap *maps;
	FT_CharMap map;
	GEncodedChar encodedChar;
	GCharMap tmpMap;
	
	numMaps = Face->num_charmaps;
	maps = Face->charmaps;

	for (i = 0; i < numMaps; i++) {
		map = maps[i];
		err = FT_Set_Charmap(Face, map);
		if (err == 0) {
			// get first (valid) char code
			charCode = FT_Get_First_Char(Face, &glyphIndex);
			// if glyphIndex is 0, it means that charmap is empty
			if (glyphIndex != 0) {
				tmpMap.CharMap.clear();
				// store encoding informations
				tmpMap.PlatformID = map->platform_id;
				tmpMap.EncodingID = map->encoding_id;
				switch (map->encoding) {
					case FT_ENCODING_MS_SYMBOL: tmpMap.Encoding = G_ENCODING_MS_SYMBOL;
					case FT_ENCODING_UNICODE: tmpMap.Encoding = G_ENCODING_UNICODE;
					case FT_ENCODING_SJIS: tmpMap.Encoding = G_ENCODING_SJIS;
					case FT_ENCODING_GB2312: tmpMap.Encoding = G_ENCODING_GB2312;
					case FT_ENCODING_BIG5: tmpMap.Encoding = G_ENCODING_BIG5;
					case FT_ENCODING_WANSUNG: tmpMap.Encoding = G_ENCODING_WANSUNG;
					case FT_ENCODING_JOHAB: tmpMap.Encoding = G_ENCODING_JOHAB;
					case FT_ENCODING_ADOBE_STANDARD: tmpMap.Encoding = G_ENCODING_ADOBE_STANDARD;
					case FT_ENCODING_ADOBE_EXPERT: tmpMap.Encoding = G_ENCODING_ADOBE_EXPERT;
					case FT_ENCODING_ADOBE_CUSTOM: tmpMap.Encoding = G_ENCODING_ADOBE_CUSTOM;
					case FT_ENCODING_ADOBE_LATIN_1: tmpMap.Encoding = G_ENCODING_ADOBE_LATIN_1;
					case FT_ENCODING_OLD_LATIN_2: tmpMap.Encoding = G_ENCODING_OLD_LATIN_2;
					case FT_ENCODING_APPLE_ROMAN: tmpMap.Encoding = G_ENCODING_APPLE_ROMAN;
					default:
						tmpMap.Encoding = G_ENCODING_NONE;
				}
				while (glyphIndex != 0) {

					encodedChar.CharCode = (GUInt32)charCode;
					encodedChar.GlyphIndex = (GUInt32)(glyphIndex - 0);
					tmpMap.CharMap.push_back(encodedChar);
					charCode = FT_Get_Next_Char(Face, charCode, &glyphIndex);
				}
				// add the loaded charmap to the font
				Font.AddCharMap(tmpMap);
			}
		}
	}
}
开发者ID:BackupTheBerlios,项目名称:amanith-svn,代码行数:57,代码来源:gfontsimpexp.cpp

示例12: initialize_face

void initialize_face(FT_Face* face, FT_Library* library, int height, const char* filename) {
	int error;

	fprintf(stderr,"Loading %s... ", filename);
	error = FT_New_Face( *library, filename, 0, face );
	if ( error == FT_Err_Unknown_File_Format ) {
		fprintf(stderr,"Error opening font file\n");
		exit(1);
	} else
	if ( error ) {
		fprintf(stderr,"another error code means that the font file could not \nbe opened or read, or simply that it is broken...");
	}

	FT_CharMap  found = 0;
	int n;
	for (n = 0; n < (*face)->num_charmaps; n++ ) {
		FT_CharMap  charmap = (*face)->charmaps[n];
#ifndef TTF2C
		printf("platform_id:%d  encoding_id:%d\n", charmap->platform_id, charmap->encoding_id);
#endif
		found = charmap;
		if ( charmap->platform_id == 3/*my_platform_id*/ && charmap->encoding_id == 1/*my_encoding_id*/ ) {
// #ifndef TTF2C
// 			fprintf(stderr,"found charmap\n");
// #endif
			break;
		}
	}

	if ( !found ) {
		fprintf(stderr,"Encoding not found\n");
		exit(1);
	}

	/* now, select the charmap for the face object */
	error = FT_Set_Charmap( *face, found );
	if ( error ) {
		fprintf(stderr,"Error setting encoding\n");
		exit(1);
	}

	int width  = 0;

	error = FT_Set_Char_Size((*face), 0, height*64, 72, 72);

	error = FT_Set_Pixel_Sizes((*face), 0, height);

	if (error) {
		fprintf(stderr,"(fixed size) ");
// 		exit(1);
	}
	
	fprintf(stderr,"ok\n");
}
开发者ID:sgh,项目名称:aos,代码行数:54,代码来源:ttf2c.c

示例13: ftFace

FTCharmap::FTCharmap( FTFace* face)
    :   ftFace( *(face->Face())),
        err(0)
{
    if( !ftFace->charmap)
    {
        err = FT_Set_Charmap( ftFace, ftFace->charmaps[0]);
    }

    ftEncoding = ftFace->charmap->encoding;
}
开发者ID:bowlofstew,项目名称:Aquaria,代码行数:11,代码来源:FTCharmap.cpp

示例14: libaroma_font_set_ucs2

/*
 * Function    : libaroma_font_set_ucs2
 * Return Value: int
 * Descriptions: set ucs2 charmap for fontface
 */
int libaroma_font_set_ucs2(
    FT_Face ftf) {
  int i;
  for (i = 0; i < ftf->num_charmaps; i++) {
    if ((  (ftf->charmaps[i]->platform_id == 0)
           && (ftf->charmaps[i]->encoding_id == 3))
        || ((ftf->charmaps[i]->platform_id == 3)
            && (ftf->charmaps[i]->encoding_id == 1))) {
      return FT_Set_Charmap(ftf, ftf->charmaps[i]);
    }
  }
  return -1;
} /* End of libaroma_font_set_ucs2 */
开发者ID:Ever-Never,项目名称:libaroma,代码行数:18,代码来源:font_freetype.c

示例15: charmap_magic

/**
 * Select Microfost Unicode CharMap, if the font has one.
 * Otherwise, let FreeType decide.
 */
static void charmap_magic(FT_Face face)
{
	int i;
	for (i = 0; i < face->num_charmaps; ++i) {
		FT_CharMap cmap = face->charmaps[i];
		unsigned pid = cmap->platform_id;
		unsigned eid = cmap->encoding_id;
		if (pid == 3 /*microsoft*/ && (eid == 1 /*unicode bmp*/ || eid == 10 /*full unicode*/)) {
			FT_Set_Charmap(face, cmap);
			return;
		}
	}

	if (!face->charmap) {
		if (face->num_charmaps == 0) {
			mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_NoCharmaps);
			return;
		}
		mp_msg(MSGT_ASS, MSGL_WARN, MSGTR_LIBASS_NoCharmapAutodetected);
		FT_Set_Charmap(face, face->charmaps[0]);
		return;
	}
}
开发者ID:tokyovigilante,项目名称:libass-fork,代码行数:27,代码来源:ass_font.c


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