Hi,<br>const char* FontConfig::Find(const char* family, bool isBold, bool isItalic)<br>{<br> const char* filename = NULL;<br> int weight = FC_WEIGHT_MEDIUM;<br> if(isBold) {<br> weight = FC_WEIGHT_BOLD;<br>
}<br> int slant = FC_SLANT_ROMAN;<br> if(isItalic) {<br> slant = FC_SLANT_ITALIC;<br> }<br> FcPattern* pattern = FcPatternBuild(NULL,<br> FC_SCALABLE, FcTypeBool, true,<br>
FC_FAMILY, FcTypeString, family,<br> FC_WEIGHT, FcTypeInteger, weight,<br> FC_SLANT, FcTypeInteger, slant,<br>
NULL);<br> if(pattern) {<br> FcConfigSubstitute(0, pattern, FcMatchPattern);<br> FcDefaultSubstitute(pattern);<br> FcResult result;<br>
FcPattern* match = FcFontMatch(0, pattern, &result);<br> if(match) {<br> FcChar8* str = 0;<br> if(FcPatternGetString(match, FC_FILE, 0, &str) == FcResultMatch) {<br>
filename = (const char*)str;<br> }<br> FcPatternDestroy(match);---------------------------------------<b>added newly</b><br> }<br> FcPatternDestroy(pattern);<br>
}<br> printf("return from FontConfig::Find\n");<br> return filename;<br>}<br><br><br>since const char* filename = NULL; i have to set the filename pointer with str.I cannot copy rite..<br><br>
<b>With this change now that error has gone ,but still two more FcFontMatch errors are dere <br>i.e</b><br>284 bytes in 7 blocks are possibly lost in loss record 97 of 140<br>==17210== at 0x4024F20: malloc (vg_replace_malloc.c:236)<br>
==17210== by 0x4C667A6: FcStrStaticName (fcpat.c:1065)<br>==17210== by 0x4C678AF: FcValueSave (fcpat.c:101)<br>==17210== by 0x4C679B2: FcPatternObjectAddWithBinding (fcpat.c:485)<br>==17210== by 0x4C681CB: FcPatternObjectAdd (fcpat.c:537)<br>
==17210== by 0x4C64287: FcFontRenderPrepare (fcmatch.c:420)<br>==17210== by 0x4C644C7: FcFontMatch (fcmatch.c:564)<br>==17210== by 0x4B344C4: FontConfig::Find(char const*, bool, bool) (unixfontconfig.cpp:77)<br>==17210== by 0x4B3439C: FontConfig::FindFont(char const*, bool, bool) (unixfontconfig.cpp:50)<br>
==17210== by 0x4B3523A: SIInterface::SI_CreateFont(MM_Object*, FI_FontInfo const*, void**) (SITextDrawImpl.cpp:324)<br>==17210== by 0x625BDE7: HostCallback2<unsigned short, FI_FontInfo const*, void**>::Invoke(void*) (si_wrappers.cpp:130)<br>
==17210== by 0x63A1331: CorePlayer::InvokeHostCallback(VirtualHostCallback&) (splayer.cpp:12240)<br><br>------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<br>
<br> 16 bytes in 1 blocks are possibly lost in loss record 33 of 140<br>==17210== at 0x4024F20: malloc (vg_replace_malloc.c:236)<br>==17210== by 0x4C667A6: FcStrStaticName (fcpat.c:1065)<br>==17210== by 0x4C68283: FcPatternObjectAddString (fcpat.c:655)<br>
==17210== by 0x4C5A570: FcDefaultSubstitute (fcdefault.c:167)<br>==17210== by 0x4B344AA: FontConfig::Find(char const*, bool, bool) (unixfontconfig.cpp:75)<br>==17210== by 0x4B3439C: FontConfig::FindFont(char const*, bool, bool) (unixfontconfig.cpp:50)<br>
==17210== by 0x4B3523A: SIInterface::SI_CreateFont(MM_Object*, FI_FontInfo const*, void**) (SITextDrawImpl.cpp:324)<br>==17210== by 0x625BDE7: HostCallback2<unsigned short, FI_FontInfo const*, void**>::Invoke(void*) (si_wrappers.cpp:130)<br>
==17210== by 0x63A1331: CorePlayer::InvokeHostCallback(VirtualHostCallback&) (splayer.cpp:12240)<br>==17210== by 0x62550B9: MM_SI_CreateFont(PlatformPlayer*, FI_FontInfo const*, void**) (si_wrappers.cpp:1067)<br>
==17210== by 0x6242DA8: PlatformEDevice::CreatePlatformFont(PlatformECharFormat*, int, unsigned char) (FL_fonts.cpp:1157)<br>==17210== by 0x62422EA: PlatformEDevice::SetCharFormat(PlatformECharFormat*, int) (FL_fonts.cpp:640)<br>
==17210==<br>--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<br><br>Archana.<br>
<br><div class="gmail_quote">On Thu, May 17, 2012 at 12:13 PM, Akira TAGOH <span dir="ltr"><<a href="mailto:akira@tagoh.org" target="_blank">akira@tagoh.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div class="im">On Thu, May 17, 2012 at 2:51 PM, Archana Mathari <<a href="mailto:archnavnr24@gmail.com">archnavnr24@gmail.com</a>> wrote:<br>
> Hi,<br>
><br>
> Yes, i am able to see many errors related to FcFontMatch in<br>
> valgrind..FcPatternDestroy() function is called after FcFontMatch() in my<br>
> code below is the function......<br>
><br>
> FcPattern* match = FcFontMatch(0, pattern, &result);<br>
> if(match) {<br>
> FcChar8* str = 0;<br>
> if(FcPatternGetString(match, FC_FILE, 0, &str) ==<br>
> FcResultMatch) {<br>
> filename = (const char*)str;<br>
> }<br>
> }<br>
> FcPatternDestroy(pattern);<br>
> }<br>
> printf("return from FontConfig::Find\n");<br>
> return filename;<br>
> }<br>
<br>
</div>You have to call FcPatternDestroy() for "match" too. due to that, you<br>
need to copy "str" to "filename" instead of set a pointer.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Akira TAGOH<br>
</font></span></blockquote></div><br>