font from file

Chad Wagner chad at chadawagner.com
Thu May 3 21:49:40 PDT 2007


To answer my own question, it ended up being pretty easy on Mac just  
by activating the font from the file in my own code, then the wxFont  
can be created by face name as usual.

	// Path to resource files in Mac bundle
	wxString					m_resourceDir;
	// container of locally activated font
	ATSFontContainerRef			m_fontContainer;
	FSSpec spec;

	wxMacFilename2FSSpec(m_resourceDir + _T("Bank Gothic Light.ttf"),  
&spec);
	OSStatus status = ATSFontActivateFromFileSpecification(&spec,  
kATSFontContextLocal, kATSFontFormatUnspecified, NULL,  
kATSOptionFlagsDefault, &m_fontContainer);
	wxASSERT_MSG(status == noErr, _T("font activation failed"));

and then anywhere in the app this works fine:
	wxFont(9, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL |  
wxFONTFLAG_ANTIALIASED, wxFONTWEIGHT_NORMAL, false, _T("Bank Gothic  
Light"));

I deactivate when I'm done (in main frame destructor) using  
ATSFontDeactivate(m_fontContainer, NULL, kATSOptionFlagsDefault)

however I couldn't seem to get it to work for the actual Mac fonts,  
only for the Windows TrueType font... strange, but I'm okay with that.
hopefully there is a similarly succinct way on Win.


On Apr 26, 2007, at 11:19 AM, Vadim Zeitlin wrote:

> On Thu, 26 Apr 2007 11:07:47 -0400 Chad Wagner  
> <chad at chadawagner.com> wrote:
>
> CW> Before I reinvent the wheel, does anyone know how it is  
> possible to
> CW> use a font within wxWidgets that is loaded from a file
>
>  No, there is no support for this currently. But it was discussed  
> in the
> past and I believe someone posted code to do it at least under  
> Windows.
>
>  Regards,
> VZ
>
> -- 
> TT-Solutions: wxWidgets consultancy and technical support
>                http://www.tt-solutions.com/
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: wx-users-unsubscribe at lists.wxwidgets.org
> For additional commands, e-mail: wx-users-help at lists.wxwidgets.org
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wx-users/attachments/20070504/7638bcd2/attachment.htm


More information about the wx-users mailing list