本文整理汇总了C++中FcPatternGetString函数的典型用法代码示例。如果您正苦于以下问题:C++ FcPatternGetString函数的具体用法?C++ FcPatternGetString怎么用?C++ FcPatternGetString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了FcPatternGetString函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: FcPatternBuild
std::string FontConfig::match_font(const std::string &typeface_name, const FontDescription &desc) const
{
FcPattern * fc_pattern = nullptr;
FcPattern * fc_match = nullptr;
try
{
int weight = static_cast<int>(desc.get_weight());
// Build font matching pattern.
fc_pattern = FcPatternBuild(nullptr,
FC_FAMILY, FcTypeString, typeface_name.c_str(),
FC_PIXEL_SIZE, FcTypeDouble, (double)std::abs(desc.get_height()),
FC_WEIGHT, FcTypeInteger, (weight > 0) ? (int)(weight * (FC_WEIGHT_HEAVY / 900.0)) : FC_WEIGHT_NORMAL,
FC_SLANT, FcTypeInteger, (desc.get_style() == clan::FontStyle::italic) ? FC_SLANT_ITALIC : ((desc.get_style() == clan::FontStyle::oblique) ? FC_SLANT_OBLIQUE : FC_SLANT_ROMAN),
FC_SPACING, FcTypeInteger, FC_PROPORTIONAL,
(char*) nullptr
);
if (!fc_pattern)
{
throw Exception("CL_FontConfig: Building FontConfig pattern failed.");
}
// Execute any needed param substitutions required by the system config.
if (FcTrue != FcConfigSubstitute(fc_config, fc_pattern, FcMatchPattern))
{
throw Exception("CL_FontConfig: Font config substitutions failed.");
}
// Supply default values for underspecified font patterns. Never fails.
FcDefaultSubstitute(fc_pattern);
// Find best match for pattern and extract filename.
FcResult match_result; // Doesn't appear to be actually updated.
fc_match = FcFontMatch(fc_config, fc_pattern, &match_result);
FcChar8 * fc_font_file_path = nullptr;
if (FcResultMatch != FcPatternGetString(fc_match, FC_FILE, 0, &fc_font_file_path))
{
throw Exception("CL_FontConfig: Could not resolve font pattern to a font file.");
}
// Release resources and return results.
std::string cl_font_file_path((char*)fc_font_file_path);
FcPatternDestroy(fc_match);
FcPatternDestroy(fc_pattern);
return cl_font_file_path;
}
catch (...)
{
// If any exceptions thrown, ensure fontconfig resources are released.
if (fc_match) FcPatternDestroy(fc_match);
if (fc_pattern) FcPatternDestroy(fc_pattern);
throw;
}
}
开发者ID:ArtHome12,项目名称:ClanLib,代码行数:54,代码来源:font_config.cpp
示例2: family
FontFileLister::CollectionResult FontConfigFontFileLister::GetFontPaths(std::string const& facename, int bold, bool italic, std::set<wxUniChar> const& characters) {
CollectionResult ret;
std::string family(facename);
if (family[0] == '@')
family.erase(0, 1);
boost::to_lower(family);
int weight = bold == 0 ? 80 :
bold == 1 ? 200 :
bold;
int slant = italic ? 110 : 0;
// Create a fontconfig pattern to match the desired weight/slant
agi::scoped_holder<FcPattern*> pat(FcPatternCreate(), FcPatternDestroy);
if (!pat) return ret;
FcPatternAddBool(pat, FC_OUTLINE, true);
FcPatternAddInteger(pat, FC_SLANT, slant);
FcPatternAddInteger(pat, FC_WEIGHT, weight);
FcDefaultSubstitute(pat);
if (!FcConfigSubstitute(config, pat, FcMatchPattern)) return ret;
// Create a font set with only correctly named fonts
// This is needed because the patterns returned by font matching only
// include the first family and fullname, so we can't always verify that
// we got the actual font we were asking for after the fact
agi::scoped_holder<FcFontSet*> fset(FcFontSetCreate(), FcFontSetDestroy);
find_font(FcConfigGetFonts(config, FcSetApplication), fset, family);
find_font(FcConfigGetFonts(config, FcSetSystem), fset, family);
// Get the best match from fontconfig
FcResult result;
FcFontSet *sets[] = { (FcFontSet*)fset };
agi::scoped_holder<FcPattern*> match(FcFontSetMatch(config, sets, 1, pat, &result), FcPatternDestroy);
if (!match)
return ret;
FcChar8 *file;
if(FcPatternGetString(match, FC_FILE, 0, &file) != FcResultMatch)
return ret;
FcCharSet *charset;
if (FcPatternGetCharSet(match, FC_CHARSET, 0, &charset) == FcResultMatch) {
for (wxUniChar chr : characters) {
if (!FcCharSetHasChar(charset, chr))
ret.missing += chr;
}
}
ret.paths.emplace_back((const char *)file);
return ret;
}
开发者ID:Leinad4Mind,项目名称:Aegisub,代码行数:54,代码来源:font_file_lister_fontconfig.cpp
示例3:
std::string
XeTeXFontMgr_FC::getPlatformFontDesc(PlatformFontRef font) const
{
std::string path;
FcChar8* s;
if (FcPatternGetString(font, FC_FILE, 0, (FcChar8**)&s) == FcResultMatch)
path = (char*)s;
else
path = "[unknown]";
return path;
}
开发者ID:clerkma,项目名称:texlive-mobile,代码行数:11,代码来源:XeTeXFontMgr_FC.cpp
示例4: ASSERT
// This method just need to bypass the cache as we could register our alternative font.
// This is a pity but is required to have asian fonts working.
PassRefPtr<SimpleFontData> FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
{
// Avoid copying FontPlatformData.
RefPtr<FontPlatformData> primaryFontPlatformData = font.primaryFont()->m_font;
// Check if the cache was already filled.
if (fallbacks.contains(&font)) {
ASSERT(primaryFontPlatformData->m_fallbacks);
FontFallbackCache::iterator it = fallbacks.find(&font);
return it->second;
}
if (!primaryFontPlatformData->m_fallbacks) {
FcResult fresult;
primaryFontPlatformData->m_fallbacks = FcFontSort(NULL, primaryFontPlatformData->m_pattern, FcTrue, NULL, &fresult);
}
FcFontSet* fs = primaryFontPlatformData->m_fallbacks;
for (int i = 0; i < fs->nfont; i++) {
FcPattern* fin = FcFontRenderPrepare(0, primaryFontPlatformData->m_pattern, fs->fonts[i]);
FcChar8* fc_filename;
if (FcPatternGetString(fin, FC_FILE, 0, &fc_filename) != FcResultMatch)
continue;
char* filename = (char *) fc_filename; // Use C cast as FcChar is a fontconfig type.
int id;
if (FcPatternGetInteger(fin, FC_INDEX, 0, &id) != FcResultMatch)
continue;
FT_Face face;
if (FT_Error error = FT_New_Face(FontPlatformData::m_library, filename, id, &face)) {
printf("FT_New_Face failed for filename = %s with FT_Error = %d\n", filename, error);
continue;
}
// FIXME: is it really necessary ?
FT_Set_Pixel_Sizes(face, 0, static_cast<uint> (font.fontDescription().computedSize()));
RefPtr<FontPlatformData> platformData = adoptRef(new FontPlatformData(face, font.fontDescription().computedPixelSize(), false, false));
platformData->m_pattern = fin;
if (platformData->containsCharacters(characters, length)) {
RefPtr<SimpleFontData> fontData = adoptRef(new SimpleFontData(platformData.get()));
fallbacks.add(&font, fontData);
return fontData;
}
}
// Fallback: use the font in the main cache.
RefPtr<SimpleFontData> fontData = getCachedFontData(font.fontDescription(), font.family().family());
return fontData;
}
开发者ID:acss,项目名称:owb-mirror,代码行数:56,代码来源:BCFontCacheFreetype.cpp
示例5: family_info
static void family_info(const FcPattern *pattern, family_info_t *fi)
{
FcChar8 *str;
fi->fontformat[0] = '\0';
fi->capability[0] = '\0';
fi->foundry[0] = '\0';
if (FcPatternGetString(pattern, FC_FONTFORMAT, 0, &str) == FcResultMatch)
snprintf(fi->fontformat, FONTFORMAT_MAX, "%s", str);
if (FcPatternGetString(pattern, FC_CAPABILITY, 0, &str) == FcResultMatch)
snprintf(fi->capability, CAPABILITY_MAX, "%s", str);
if (FcPatternGetString(pattern, FC_FOUNDRY, 0, &str) == FcResultMatch)
if (strcmp((char *)str, "unknown") != 0)
snprintf(fi->foundry, FOUNDRY_MAX, "%s", str);
return;
}
开发者ID:pgajdos,项目名称:fontinfo,代码行数:21,代码来源:fcinfo.c
示例6: fcinfo_get_translated_string
FcResult fcinfo_get_translated_string(const FcPattern *pattern,
const char *object,
const FcChar8 *lang, FcChar8 **s)
{
FcChar8 *l;
int n;
FcResult r;
const char *lang_object;
if (strcmp(object, FC_FAMILY) == 0)
lang_object = FC_FAMILYLANG;
else if (strcmp(object, FC_STYLE) == 0)
lang_object = FC_STYLELANG;
else if (strcmp(object, FC_FULLNAME))
lang_object = FC_FULLNAMELANG;
else
{
fprintf(stderr, "fcinfo_get_translated_string():"
" no translatable string\n");
exit (1);
}
if (FcPatternGetString(pattern, lang_object, 0, &l) != FcResultMatch)
{
/* no *_LANG element */
return FcPatternGetString(pattern, object, 0, s);
}
n = 0;
while ((r = FcPatternGetString(pattern, lang_object, n, &l)) == FcResultMatch)
if (FcStrCmp(l, lang) == 0)
break;
else
n++;
if (r != FcResultMatch)
n = 0; /* no lang found */
return FcPatternGetString(pattern, object, n, s);
}
开发者ID:pgajdos,项目名称:fontinfo,代码行数:40,代码来源:fcinfo.c
示例7: Rcairo_set_font
void Rcairo_set_font(int i, const char *fcname){
FcFontSet *fs;
FcPattern *pat, *match;
FcResult result;
FcChar8 *file;
int j;
if (Rcairo_fonts[i].face != NULL){
cairo_font_face_destroy(Rcairo_fonts[i].face);
Rcairo_fonts[i].face = NULL;
}
pat = FcNameParse((FcChar8 *)fcname);
if (!pat){
error("Problem with font config library in Rcairo_set_font\n");
return;
}
FcConfigSubstitute (0, pat, FcMatchPattern);
FcDefaultSubstitute (pat);
fs = FcFontSetCreate ();
match = FcFontMatch (0, pat, &result);
FcPatternDestroy (pat);
if (match) {
FcFontSetAdd (fs, match);
} else {
error("No font found in Rcairo_set_font");
FcFontSetDestroy (fs);
return;
}
/* should be at least one font face in fontset */
if (fs) {
for (j = 0; j < fs->nfont; j++) {
/* Need to make sure a real font file exists */
if (FcPatternGetString (fs->fonts[j], FC_FILE, 0, &file) == FcResultMatch){
Rcairo_fonts[i].face = Rcairo_set_font_face(i,(const char *)file);
break;
}
}
FcFontSetDestroy (fs);
Rcairo_fonts[i].updated = 1;
} else {
error("No font found Rcairo_set_font");
}
}
开发者ID:s-u,项目名称:Cairo,代码行数:49,代码来源:cairotalk.c
示例8: find_font
const std::string find_font(const char* name) {
std::string font_file;
FcConfig* config = FcInitLoadConfigAndFonts();
FcPattern* pattern = FcNameParse((const FcChar8*) (name));
FcConfigSubstitute(config, pattern, FcMatchPattern);
FcDefaultSubstitute(pattern);
FcPattern* font = FcFontMatch(config, pattern, NULL);
if (font) {
FcChar8* file = NULL;
if (FcPatternGetString(font, FC_FILE, 0, &file) == FcResultMatch)
font_file = std::string((char*) file);
FcPatternDestroy(font);
}
FcPatternDestroy(pattern);
return font_file;
}
开发者ID:Shawn1292,项目名称:GLXOSD,代码行数:16,代码来源:osdinstance.cpp
示例9: match_fullname
/**
* \brief Case-insensitive match ASS/SSA font family against full name. (also
* known as "name for humans")
*
* \param lib library instance
* \param priv fontconfig instance
* \param family font fullname
* \param bold weight attribute
* \param italic italic attribute
* \return font set
*/
static FcFontSet *
match_fullname(ASS_Library *lib, FCInstance *priv, const char *family,
unsigned bold, unsigned italic)
{
FcFontSet *sets[2];
FcFontSet *result = FcFontSetCreate();
int nsets = 0;
int i, fi;
if (!result)
return NULL;
if ((sets[nsets] = FcConfigGetFonts(priv->config, FcSetSystem)))
nsets++;
if ((sets[nsets] = FcConfigGetFonts(priv->config, FcSetApplication)))
nsets++;
// Run over font sets and patterns and try to match against full name
for (i = 0; i < nsets; i++) {
FcFontSet *set = sets[i];
for (fi = 0; fi < set->nfont; fi++) {
FcPattern *pat = set->fonts[fi];
char *fullname;
int pi = 0, at;
FcBool ol;
while (FcPatternGetString(pat, FC_FULLNAME, pi++,
(FcChar8 **) &fullname) == FcResultMatch) {
if (FcPatternGetBool(pat, FC_OUTLINE, 0, &ol) != FcResultMatch
|| ol != FcTrue)
continue;
if (FcPatternGetInteger(pat, FC_SLANT, 0, &at) != FcResultMatch
|| at < italic)
continue;
if (FcPatternGetInteger(pat, FC_WEIGHT, 0, &at) != FcResultMatch
|| at < bold)
continue;
if (strcasecmp(fullname, family) == 0) {
FcFontSetAdd(result, FcPatternDuplicate(pat));
break;
}
}
}
}
return result;
}
开发者ID:creationst,项目名称:Creation2,代码行数:57,代码来源:ass_fontconfig.c
示例10: claro_ft2_get_family
static const char * claro_ft2_get_family(claro_font_pattern_t * pattern)
{
FcPattern * fc_pattern;
FcResult res;
FcChar8 * family;
g_return_val_if_fail(pattern != NULL, NULL);
fc_pattern = (FcPattern *)pattern->native;
res = FcPatternGetString (fc_pattern, FC_FAMILY, 0, &family);
if(res != FcResultMatch)
return NULL;
else
return (const char *)family;
}
开发者ID:theojulienne,项目名称:Claro,代码行数:17,代码来源:claro-font-ft2.c
示例11: FcPatternBuild
/**
* using fontconfig for just getting the font file name by a wanted font name and style.
*/
char *get_font_filename(const char *family, const char *style) {
//initialize fontconfig
if (!FcInit()) {
throw util::Error{MSG(err) << "Failed to initialize fontconfig."};
}
//FcPattern *font_pattern = FcNameParse((const unsigned char *)"DejaVu Serif:style=Book");
FcPattern *font_pattern = FcPatternBuild(nullptr, FC_FAMILY, FcTypeString, family, nullptr);
FcPatternBuild(font_pattern, FC_STYLE, FcTypeString, style, nullptr);
//debug output: display above pattern as parsable string.
FcChar8 *query_string = FcNameUnparse(font_pattern);
log::log(MSG(info) << "Font queried: " << query_string);
free(query_string);
//tell fontconfig to find the best match
FcResult font_match_result;
FcPattern *font_match = FcFontMatch(nullptr, font_pattern, &font_match_result);
/*
//debug output: display matching font pattern as parsable string
FcChar8 *match_string = FcNameUnparse(font_match);
log::dbg2("resulting font: %s", match_string);
free(match_string);
*/
//get attibute FC_FILE (= filename) of best-matched font
FcChar8 *font_filename_tmp;
if (FcPatternGetString(font_match, FC_FILE, 0, &font_filename_tmp) != FcResultMatch) {
throw util::Error(MSG(err) << "Fontconfig could not provide font " << family << " " << style);
}
//copy the font filename because it will be freed when the pattern is destroyed.
char *font_filename = util::copy((const char *)font_filename_tmp);
log::log(MSG(info) << "Font file: " << font_filename);
//deinitialize fontconfig.
FcPatternDestroy(font_match);
FcPatternDestroy(font_pattern);
FcFini();
return font_filename;
}
开发者ID:Dotile,项目名称:openage,代码行数:47,代码来源:font.cpp
示例12: find_font_file
/** Find a font file from its family name.
* @param font_config fontconfig instance
* @param font_name name of the font
* @return full path to the font file
*/
gchar* find_font_file (FcConfig* font_config, const gchar* font_name) {
const FcChar8* name;
FcPattern* search_pattern;
FcPattern* font;
FcChar8* file;
gchar* path;
FcObjectSet* font_properties;
FcFontSet* fonts;
int i;
if (font_config == NULL) {
g_warning("Font config not loaded.");
return NULL;
}
path = NULL;
name = font_name;
search_pattern = FcPatternCreate ();
FcPatternAddString (search_pattern, FC_FAMILY, name);
FcPatternAddBool (search_pattern, FC_SCALABLE, FcTrue);
FcPatternAddInteger (search_pattern, FC_WEIGHT, FC_WEIGHT_MEDIUM);
FcPatternAddInteger (search_pattern, FC_SLANT, FC_SLANT_ROMAN);
font_properties = FcObjectSetBuild (FC_FILE, NULL);
fonts = FcFontList (font_config, search_pattern, font_properties);
if (fonts->nfont > 0) {
for (i = 0; i < fonts->nfont; i++) {
font = fonts->fonts[i];
if (FcPatternGetString(font, FC_FILE, 0, &file) == FcResultMatch) {
path = g_strdup ((gchar*) file);
break;
}
}
FcPatternDestroy (font);
}
FcPatternDestroy (search_pattern);
return path;
}
开发者ID:jasperla,项目名称:birdfont,代码行数:48,代码来源:fontconfig.c
示例13: FcFontSort
const SimpleFontData* FontCache::getFontDataForCharacters(const Font& font, const UChar* characters, int length)
{
FcResult fresult;
// Avoid copying FontPlatformData.
FontPlatformData* prim = const_cast<FontPlatformData*>(&font.primaryFont()->m_font);
if (!prim->m_fallbacks)
prim->m_fallbacks = FcFontSort(NULL, prim->m_pattern, FcTrue, NULL, &fresult);
FcFontSet* fs = prim->m_fallbacks;
FT_Library library = FontPlatformData::m_library;
FcChar8* fc_filename;
char* filename;
int id;
FT_Face face;
for (int i = 0; i < fs->nfont; i++) {
FcPattern* fin = FcFontRenderPrepare(0, prim->m_pattern, fs->fonts[i]);
if (FcPatternGetString(fin, FC_FILE, 0, &fc_filename) != FcResultMatch)
continue;
filename = (char *) fc_filename; // Use C cast as FcChar is a fontconfig type.
if (FcPatternGetInteger(fin, FC_INDEX, 0, &id) != FcResultMatch)
continue;
if (FT_Error error = FT_New_Face(library, filename, id, &face))
continue;
// FIXME: is it really necessary ?
FT_Set_Pixel_Sizes(face, 0, static_cast<uint> (font.fontDescription().computedSize()));
FontPlatformData alternateFont(face, font.fontDescription().computedPixelSize(), false, false);
// FIXME: FT_Done_Face(face); we should clean the face correctly the FT_Face but we can't do that here...
alternateFont.m_pattern = fin;
SimpleFontData* sfd = getCachedFontData(&alternateFont);
if (sfd->containsCharacters(characters, length))
return sfd;
}
return 0;
}
开发者ID:jackiekaon,项目名称:owb-mirror,代码行数:43,代码来源:BCFontCacheFreetype.cpp
示例14: adoptRef
Vector<String> FontCache::systemFontFamilies()
{
RefPtr<FcPattern> scalablesOnlyPattern = adoptRef(FcPatternCreate());
FcPatternAddBool(scalablesOnlyPattern.get(), FC_SCALABLE, FcTrue);
FcUniquePtr<FcObjectSet> familiesOnly(FcObjectSetBuild(FC_FAMILY, nullptr));
FcUniquePtr<FcFontSet> fontSet(FcFontList(nullptr, scalablesOnlyPattern.get(), familiesOnly.get()));
Vector<String> fontFamilies;
for (int i = 0; i < fontSet->nfont; i++) {
FcPattern* pattern = fontSet->fonts[i];
FcChar8* family = nullptr;
FcPatternGetString(pattern, FC_FAMILY, 0, &family);
if (family)
fontFamilies.appendVector(patternToFamilies(*pattern));
}
return fontFamilies;
}
开发者ID:nickooms,项目名称:webkit,代码行数:19,代码来源:FontCacheFreeType.cpp
示例15: FcInit
FcStrSet *fcinfo_fontformats(const FcPattern *filter)
{
FcFontSet *fontset;
FcStrSet *result;
FcChar8 *format;
int f;
FcInit();
fontset = fcinfo(NULL, filter, FcFalse, 1, FC_FONTFORMAT);
result = FcStrSetCreate();
for (f = 0; f < fontset->nfont; f++)
{
assert(FcPatternGetString(fontset->fonts[f], FC_FONTFORMAT, 0, &format)
== FcResultMatch);
FcStrSetAdd(result, format);
}
return result;
}
开发者ID:pgajdos,项目名称:fontinfo,代码行数:20,代码来源:fcinfo.c
示例16: platform_get_font_path
bool platform_get_font_path(TTFFontDescriptor *font, utf8 *buffer, size_t size)
{
assert(buffer != NULL);
assert(font != NULL);
log_verbose("Looking for font %s with FontConfig.", font->font_name);
FcConfig* config = FcInitLoadConfigAndFonts();
if (!config)
{
log_error("Failed to initialize FontConfig library");
FcFini();
return false;
}
FcPattern* pat = FcNameParse((const FcChar8*) font->font_name);
FcConfigSubstitute(config, pat, FcMatchPattern);
FcDefaultSubstitute(pat);
bool found = false;
FcResult result = FcResultNoMatch;
FcPattern* match = FcFontMatch(config, pat, &result);
if (match)
{
FcChar8* filename = NULL;
if (FcPatternGetString(match, FC_FILE, 0, &filename) == FcResultMatch)
{
found = true;
safe_strcpy(buffer, (utf8*) filename, size);
log_verbose("FontConfig provided font %s", filename);
}
FcPatternDestroy(match);
} else {
log_warning("Failed to find required font.");
}
FcPatternDestroy(pat);
FcConfigDestroy(config);
FcFini();
return found;
}
开发者ID:trigger-death,项目名称:OpenRCT2,代码行数:41,代码来源:linux.c
示例17: find_font
static int find_font(info_rec* info, char* family, char* path)
{
FcPattern* pattern;
FcPattern* matchedPattern;
FcResult result;
FcChar8* s;
pattern = FcPatternBuild(NULL, FC_FAMILY, FcTypeString, family,
(char*) NULL);
if (pattern == NULL)
return YUV_fontconfig;
if (FcConfigSubstitute(info->config, pattern, FcMatchPattern) != FcTrue)
return YUV_fontconfig;
FcDefaultSubstitute(pattern);
matchedPattern = FcFontMatch(info->config, pattern, &result);
FcPatternDestroy(pattern);
if (FcPatternGetString(matchedPattern, FC_FILE, 0, &s) != FcResultMatch)
return YUV_fontconfig;
strcpy(path, (char*)s);
FcPatternDestroy(matchedPattern);
return YUV_OK;
}
开发者ID:UIKit0,项目名称:bbc-ingex,代码行数:22,代码来源:YUV_text_overlay.c
示例18: fcFindFont
value fcFindFont( value _familyName, value _weight, value _slant, value _size ) {
val_check(_familyName,string);
val_check(_weight,number);
val_check(_slant,number);
val_check(_size,number);
const char *familyName = val_string(_familyName);
int weight = val_number(_weight);
int slant = val_number(_slant);
float size = val_number(_size);
FcPattern *pattern;
pattern = FcNameParse( (FcChar8*)familyName );
FcDefaultSubstitute( pattern );
FcConfigSubstitute( FcConfigGetCurrent(), pattern, FcMatchPattern );
FcResult result;
FcPattern *match = FcFontMatch( 0, pattern, &result );
FcPatternDestroy( pattern );
if( !match ) val_throw(alloc_string("Could not find font"));
FcChar8 *temp;
int id;
pattern = FcPatternDuplicate(match);
if( FcPatternGetString( pattern, FC_FILE, 0, &temp ) != FcResultMatch ||
FcPatternGetInteger( pattern, FC_INDEX, 0, &id ) != FcResultMatch ) {
val_throw(alloc_string("Could not load font"));
}
value ret = alloc_string((const char *)temp);
FcPatternDestroy( pattern );
FcPatternDestroy( match );
return ret;
}
开发者ID:dturing,项目名称:xinf,代码行数:39,代码来源:neko-fontconfig.c
示例19: strchr
TTF_Font *load_font(const char *font_spec)
{
int font_size;
char *font_name;
/* figure out font size from name, or default to 24 */
char *sep = strchr(font_spec, ':');
if(sep) {
font_name = strndup(font_spec, sep - font_spec);
font_size = strtol(sep+1, NULL, 10);
} else {
font_name = strdup(font_spec);
font_size = 24;
}
FcConfig *cfg = FcInitLoadConfigAndFonts();
FcPattern *pattern = FcNameParse((const FcChar8*)font_name);
FcConfigSubstitute(cfg, pattern, FcMatchPattern);
FcDefaultSubstitute(pattern);
TTF_Font *ret = NULL;
FcResult result = FcResultNoMatch;
FcPattern* font = FcFontMatch(cfg, pattern, &result);
if (font) {
FcChar8 *path = NULL;
if (FcPatternGetString(font, FC_FILE, 0, &path) == FcResultMatch) {
ret = TTF_OpenFont((char*)path, font_size);
}
FcPatternDestroy(font);
}
FcPatternDestroy(pattern);
FcConfigDestroy(cfg);
free(font_name);
return ret;
}
开发者ID:eXeC64,项目名称:imv,代码行数:38,代码来源:util.c
示例20: FcListFamilies
GeeArrayList *
FcListFamilies(void)
{
int i;
FcPattern * pattern;
FcFontSet * fontset;
FcObjectSet * objectset = 0;
GeeArrayList * famlist = gee_array_list_new(G_TYPE_STRING,
(GBoxedCopyFunc) g_strdup,
(GDestroyNotify) g_free0,
NULL,
NULL,
NULL);
g_assert(FcInit());
pattern = FcNameParse((FcChar8 *) ":");
objectset = FcObjectSetBuild (FC_FAMILY, NULL);
fontset = FcFontList(NULL, pattern, objectset);
for (i = 0; i < fontset->nfont; i++) {
FcChar8 * family;
if (FcPatternGetString(fontset->fonts[i], FC_FAMILY, 0, &family) == FcResultMatch) {
if (gee_abstract_collection_contains((GeeAbstractCollection *) famlist, family))
continue;
else
gee_abstract_collection_add((GeeAbstractCollection *) famlist, family);
}
}
if (objectset)
FcObjectSetDestroy(objectset);
if (pattern)
FcPatternDestroy(pattern);
if (fontset)
FcFontSetDestroy(fontset);
return famlist;
}
开发者ID:Heether,项目名称:font-manager,代码行数:37,代码来源:_Glue_.c
注:本文中的FcPatternGetString函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论