Jump to content
Compatible Support Forums
Sign in to follow this  
Yuking

Why XFT eats so many mem?

Recommended Posts

I wrote a small test program using XFT rendering fonts.

'ps -aux' shows it used ~18M mem, why so terrible?

thanks very much!

Share this post


Link to post

As to what your program actually does...

 

I am guessing you are displaying all your fonts you have installed....

 

Okay, guess what XFT only uses what it needs to cache the rendering info it needs to render the fonts in your program... each font requires a certain amount... so if you were showing *ALL* the fonts... then *ALL* the currently in use fonts are cached...

 

And, BTW, I have ~2000 fonts installed on my mahcine... for publishing and such. A wide array, PS Type1 and TT Fonts combined... if I were to Display all the fonts at the same time... well, XFT would take ~260MB...

 

Hope this helps...

Share this post


Link to post

Here is my codes:

-----------------------------------------------

......

XftPatternAddString (pattern, "family", myFont);

XftPatternAddInteger (pattern, "pixelsize", 14);

XftPatternAddBool (pattern, "antialias", 1);

XftColorAllocName (dpy, DefaultVisual (dpy, DefaultScreen (dpy)), DefaultColormap (dpy, DefaultScreen (dpy)), "black", &color);

xftFont = XftFontOpenPattern (dpy, XftFontMatch (dpy, iScreen, pattern, &result));

xftDraw = XftDrawCreate (dpy, myWindow, DefaultVisual (dpy, DefaultScreen (dpy)), DefaultColormap (dpy, DefaultScreen (dpy)));

......

-----------------------------------------------

myFont is string referring to a Chinese font (simsun). If I chang myFont to another font, such as "courier", all are OK!

Does XFT load the whole font file into mem? The size of "simsun" is about 10M.

Share this post


Link to post

If it is being referenced... on screen or in the rendering engine for "X" then yes is has to load the whole thing... There is no partial caching of the info for a particiular font.

 

Look at it this way, Let's say you want to run the dreaded Microsoft word... which is a huge pig for memory. But you only want to use it for text editing... and saving to ASCII. You get the WHOLE thing... not just the TEXT editing part.

 

So, needless to say, it does read the whole file... it has to be ready to encode to the Rendering engine all the info *ANY* character in the font... even if you NEVER display but one character.

 

Hope this helps!

 

If not, questions posted publically will be answered... private messages will be ignored.

Share this post


Link to post

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×