[Fontconfig] fontconfig issue
Archana Mathari
archnavnr24 at gmail.com
Thu May 17 02:52:30 PDT 2012
Hi,
const char* FontConfig::Find(const char* family, bool isBold, bool isItalic)
{
const char* filename = NULL;
int weight = FC_WEIGHT_MEDIUM;
if(isBold) {
weight = FC_WEIGHT_BOLD;
}
int slant = FC_SLANT_ROMAN;
if(isItalic) {
slant = FC_SLANT_ITALIC;
}
FcPattern* pattern = FcPatternBuild(NULL,
FC_SCALABLE,
FcTypeBool, true,
FC_FAMILY,
FcTypeString, family,
FC_WEIGHT,
FcTypeInteger, weight,
FC_SLANT,
FcTypeInteger, slant,
NULL);
if(pattern) {
FcConfigSubstitute(0, pattern, FcMatchPattern);
FcDefaultSubstitute(pattern);
FcResult result;
FcPattern* match = FcFontMatch(0, pattern, &result);
if(match) {
FcChar8* str = 0;
if(FcPatternGetString(match, FC_FILE, 0, &str) ==
FcResultMatch) {
filename = (const char*)str;
}
FcPatternDestroy(match);---------------------------------------*added newly*
}
FcPatternDestroy(pattern);
}
printf("return from FontConfig::Find\n");
return filename;
}
since const char* filename = NULL; i have to set the filename pointer with
str.I cannot copy rite..
*With this change now that error has gone ,but still two more FcFontMatch
errors are dere
i.e*
284 bytes in 7 blocks are possibly lost in loss record 97 of 140
==17210== at 0x4024F20: malloc (vg_replace_malloc.c:236)
==17210== by 0x4C667A6: FcStrStaticName (fcpat.c:1065)
==17210== by 0x4C678AF: FcValueSave (fcpat.c:101)
==17210== by 0x4C679B2: FcPatternObjectAddWithBinding (fcpat.c:485)
==17210== by 0x4C681CB: FcPatternObjectAdd (fcpat.c:537)
==17210== by 0x4C64287: FcFontRenderPrepare (fcmatch.c:420)
==17210== by 0x4C644C7: FcFontMatch (fcmatch.c:564)
==17210== by 0x4B344C4: FontConfig::Find(char const*, bool, bool)
(unixfontconfig.cpp:77)
==17210== by 0x4B3439C: FontConfig::FindFont(char const*, bool, bool)
(unixfontconfig.cpp:50)
==17210== by 0x4B3523A: SIInterface::SI_CreateFont(MM_Object*,
FI_FontInfo const*, void**) (SITextDrawImpl.cpp:324)
==17210== by 0x625BDE7: HostCallback2<unsigned short, FI_FontInfo
const*, void**>::Invoke(void*) (si_wrappers.cpp:130)
==17210== by 0x63A1331:
CorePlayer::InvokeHostCallback(VirtualHostCallback&) (splayer.cpp:12240)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
16 bytes in 1 blocks are possibly lost in loss record 33 of 140
==17210== at 0x4024F20: malloc (vg_replace_malloc.c:236)
==17210== by 0x4C667A6: FcStrStaticName (fcpat.c:1065)
==17210== by 0x4C68283: FcPatternObjectAddString (fcpat.c:655)
==17210== by 0x4C5A570: FcDefaultSubstitute (fcdefault.c:167)
==17210== by 0x4B344AA: FontConfig::Find(char const*, bool, bool)
(unixfontconfig.cpp:75)
==17210== by 0x4B3439C: FontConfig::FindFont(char const*, bool, bool)
(unixfontconfig.cpp:50)
==17210== by 0x4B3523A: SIInterface::SI_CreateFont(MM_Object*,
FI_FontInfo const*, void**) (SITextDrawImpl.cpp:324)
==17210== by 0x625BDE7: HostCallback2<unsigned short, FI_FontInfo
const*, void**>::Invoke(void*) (si_wrappers.cpp:130)
==17210== by 0x63A1331:
CorePlayer::InvokeHostCallback(VirtualHostCallback&) (splayer.cpp:12240)
==17210== by 0x62550B9: MM_SI_CreateFont(PlatformPlayer*, FI_FontInfo
const*, void**) (si_wrappers.cpp:1067)
==17210== by 0x6242DA8:
PlatformEDevice::CreatePlatformFont(PlatformECharFormat*, int, unsigned
char) (FL_fonts.cpp:1157)
==17210== by 0x62422EA:
PlatformEDevice::SetCharFormat(PlatformECharFormat*, int) (FL_fonts.cpp:640)
==17210==
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Archana.
On Thu, May 17, 2012 at 12:13 PM, Akira TAGOH <akira at tagoh.org> wrote:
> On Thu, May 17, 2012 at 2:51 PM, Archana Mathari <archnavnr24 at gmail.com>
> wrote:
> > Hi,
> >
> > Yes, i am able to see many errors related to FcFontMatch in
> > valgrind..FcPatternDestroy() function is called after FcFontMatch() in my
> > code below is the function......
> >
> > FcPattern* match = FcFontMatch(0, pattern, &result);
> > if(match) {
> > FcChar8* str = 0;
> > if(FcPatternGetString(match, FC_FILE, 0, &str) ==
> > FcResultMatch) {
> > filename = (const char*)str;
> > }
> > }
> > FcPatternDestroy(pattern);
> > }
> > printf("return from FontConfig::Find\n");
> > return filename;
> > }
>
> You have to call FcPatternDestroy() for "match" too. due to that, you
> need to copy "str" to "filename" instead of set a pointer.
>
> --
> Akira TAGOH
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/fontconfig/attachments/20120517/7c27a7b1/attachment.html>
More information about the Fontconfig
mailing list