Hi all,
I have a scenario where i have to load the font(ttf files) into the memory and apply it to all the selected textframe in the active document. So for loading the font i am using 'AddFontResourceEx()' api.
The problem is this, when i used this api it will not load the font at the same time, it will take some time to load the font. But the plugin will try to apply that font to the text frame. Sometimes font will apply somtimes not.
I am unable to understand its behaviour. Can someone tell me why its happening? Also is there any api through which we can refresh font list?
Thanks in advance....
Interesting. I have a similar problem I solved using AddFontResourceEx(), but it was sort of the reverse. I have a library using FreeType that wouldn't 'see' fonts Adobe was loading (because they were coming from their own folders and not the Windows Font folder).
You have the reverse problem, sort of. You also need to load additional fonts from (presumably) odd locations, but you want Illustrator to see the result. I'm not sure what to do for your case, though perhaps its a matter of timing? Are you seeing this "sometimes it works, sometimes it doesn't" on the same machine, or different ones? If the latter, it could just be the plugin load order. If it's the same machine, that's more troubling.
Either way, your best bet is to find as early a place as possible to do the font loading. Where are you doing it now?
Hi Patterson,
Thanks for the reply. Let me explain more on my problem.
I have a flex panel which populate the list of fonts. When I clicked on any font from the list, plugin loads that font into memory (this font will appear in the font list of illustrator).
I am using AddFontResourceEx() and SendNotifyMessage() functions.
After this, I dispatch a csxs event to the flex panel on the basis of error code of mentioned functions.
Flex listen the event and apply that font to the selected textframe in the document.
But the problem is, even getting the expected return values from above function, font is not being enumerated instantly in Illustrator font list.
It took time about 7-8 seconds or even more to being enumerated.
Could you please tell how I can overcome from this problem?
All my need is that enumerating font asap.
Here is the code snipped..
////Start
long count = 0;
sAIFont->CountFonts(&count); //Here value of count is 187
int err = 0;
err = AddFontResourceEx( fontPath, // font file name
FR_PRIVATE, // font characteristics
NULL
);
//value of err is 1 as I am loading one font..
if(err==0)
{
return false;
}
// send font change notification
bool isNotified = SendNotifyMessage(HWND_BROADCAST, WM_FONTCHANGE, 0, 0);
//value returned by SendNotifyMessage is true.
sAIFont->CountFonts(&count); //Still the value of count is 187
.
////End
Thanks,
Is there any reason you can't pre-load the fonts before they're clicked on in the panel? Or is that the point of the plugin, to load additional fonts?
I don't know what causes the delay, or if there's a way to 'kick' it to make it update faster. The best bet is to have done it long before its needed so they're already there, but if that's the point of the panel, I guess we'll need to see if we can find something else.
I don't see anything that lets you kick the font listing. You're cleary trying something along those lines with SendNotifyMessage(). I suspect it treats that as a call from a different thread, so sometimes it processes it before you count the fonts and sometimes it doesn't.
Have you tried SendMessageCallback()? That lets you do the same thing (I think, more or less) but SendMessageCallback should invoke a callback function when the message has been processed. You could try that, and see if you get consistent results inside the callback function.
Otherwise, I don't have any idae. This is strange territory for Illustrator, and its starting to sound like its an OS problem more than an application problem (if only because the SDK doesn't provide any help).
North America
Europe, Middle East and Africa
Asia Pacific