IMPLEMENT_DYNAMIC_CLASS(wxFontDialog, wxDialog)
-#include "wx/mac/private.h"
+#include "wx/mac/uma.h"
// ---------------------------------------------------------------------------
// wxFontDialog
{
case kEventFontSelection :
{
+ bool setup = false ;
+#if wxMAC_USE_CORE_TEXT
+ if ( UMAGetSystemVersion() >= 0x1050 )
+ {
+ CTFontDescriptorRef descr;
+ if ( cEvent.GetParameter<CTFontDescriptorRef>( kEventParamCTFontDescriptor, typeCTFontDescriptorRef, &descr ) == noErr )
+ {
+ wxFont font;
+ font.MacCreateFromCTFontDescriptor(descr);
+ fontdata.SetChosenFont( font ) ;
+ setup = true;
+ }
+ }
+#endif
+#if wxMAC_USE_ATSU_TEXT
ATSUFontID fontId = 0 ;
- if ( cEvent.GetParameter<ATSUFontID>(kEventParamATSUFontID, &fontId) == noErr )
+ if ( !setup && (cEvent.GetParameter<ATSUFontID>(kEventParamATSUFontID, &fontId) == noErr) )
{
FMFontStyle fontStyle = cEvent.GetParameter<FMFontStyle>(kEventParamFMFontStyle);
FMFontSize fontSize = cEvent.GetParameter<FMFontSize>(kEventParamFMFontSize);
FMFontFamily fontFamily = cEvent.GetParameter<FMFontFamily>(kEventParamFMFontFamily);
ATSFontFamilyRef atsfontfamilyref = FMGetATSFontFamilyRefFromFontFamily( fontFamily ) ;
OSStatus err = ATSFontFamilyGetName( atsfontfamilyref , kATSOptionFlagsDefault , &cfName ) ;
- wxASSERT_MSG( err == noErr , wxT("ATSFontFamilyGetName failed") );
+ if ( err == noErr )
+ {
+ wxFAIL_MSG("ATSFontFamilyGetName failed");
+ }
#else
// we don't use the ATSU naming anymore
ByteCount actualLength = 0;
char *c = NULL;
OSStatus err = ATSUFindFontName(fontId , kFontFamilyName, kFontUnicodePlatform, kFontNoScriptCode,
- kFontNoLanguageCode , 0 , NULL , &actualLength , NULL );
+ kFontNoLanguageCode , 0 , NULL , &actualLength , NULL );
if ( err == noErr)
{
actualLength += 1 ;
char *c = (char*)malloc( actualLength );
err = ATSUFindFontName(fontId, kFontFamilyName, kFontUnicodePlatform, kFontNoScriptCode,
- kFontNoLanguageCode, actualLength, c , NULL, NULL);
+ kFontNoLanguageCode, actualLength, c , NULL, NULL);
cfName = CFStringCreateWithCharacters(NULL, (UniChar*) c, (actualLength-1) >> 1);
}
else
{
err = ATSUFindFontName(fontId , kFontFamilyName, kFontNoPlatformCode, kFontNoScriptCode,
- kFontNoLanguageCode , 0 , NULL , &actualLength , NULL );
+ kFontNoLanguageCode , 0 , NULL , &actualLength , NULL );
if ( err == noErr )
{
actualLength += 1 ;
c = (char*)malloc(actualLength);
err = ATSUFindFontName(fontId, kFontFamilyName, kFontNoPlatformCode, kFontNoScriptCode,
- kFontNoLanguageCode, actualLength, c , NULL, NULL);
+ kFontNoLanguageCode, actualLength, c , NULL, NULL);
c[actualLength-1] = 0;
cfName = CFStringCreateWithCString(NULL, c, kCFStringEncodingMacRoman );
}
if ( c!=NULL )
free(c);
#endif
-
if ( cfName!=NULL )
{
- fontdata.m_chosenFont.SetFaceName(wxMacCFStringHolder(cfName).AsString(wxLocale::GetSystemEncoding()));
+ fontdata.m_chosenFont.SetFaceName(wxCFStringRef(cfName).AsString(wxLocale::GetSystemEncoding()));
fontdata.m_chosenFont.SetPointSize(fontSize);
fontdata.m_chosenFont.SetStyle(fontStyle & italic ? wxFONTSTYLE_ITALIC : wxFONTSTYLE_NORMAL);
fontdata.m_chosenFont.SetUnderlined((fontStyle & underline)!=0);
fontdata.m_chosenFont.SetWeight(fontStyle & bold ? wxFONTWEIGHT_BOLD : wxFONTWEIGHT_NORMAL);
}
}
+#endif // wxMAC_USE_ATSU_TEXT
+ // retrieving the color
RGBColor fontColor ;
if ( cEvent.GetParameter<RGBColor>(kEventParamFontColor, &fontColor) == noErr )
{
CFDataRef sizesData;
CFDataRef valuesData;
if ( CFDictionaryGetValueIfPresent(attributesDict, kFontPanelAttributeTagsKey, (const void **)&tagsData) &&
- CFDictionaryGetValueIfPresent(attributesDict, kFontPanelAttributeSizesKey, (const void **)&sizesData) &&
- CFDictionaryGetValueIfPresent(attributesDict, kFontPanelAttributeValuesKey, (const void **)&valuesData) )
+ CFDictionaryGetValueIfPresent(attributesDict, kFontPanelAttributeSizesKey, (const void **)&sizesData) &&
+ CFDictionaryGetValueIfPresent(attributesDict, kFontPanelAttributeValuesKey, (const void **)&valuesData) )
{
ItemCount count = CFDataGetLength(tagsData)/sizeof(ATSUAttributeTag);
ATSUAttributeTag *tagPtr = (ATSUAttributeTag *)CFDataGetBytePtr(tagsData);
}
}
}
- break ;
- } ;
+ break ;
+ }
return result ;
}
font = m_fontData.m_initialFont ;
}
- ATSUStyle style = (ATSUStyle)font.MacGetATSUStyle();
- err = SetFontInfoForSelection (kFontSelectionATSUIType,1, &style , NULL);
+ bool setup = false;
+#if wxMAC_USE_CORE_TEXT
+ if ( UMAGetSystemVersion() >= 0x1050 )
+ {
+ CTFontDescriptorRef descr = (CTFontDescriptorRef)font.MacGetCTFontDescriptor();
+ err = SetFontInfoForSelection (kFontSelectionCoreTextType,1, &descr , NULL);
+ setup = true;
+ }
+#endif
+#if wxMAC_USE_ATSU_TEXT
+ if ( !setup )
+ {
+ ATSUStyle style = (ATSUStyle)font.MacGetATSUStyle();
+ err = SetFontInfoForSelection (kFontSelectionATSUIType,1, &style , NULL);
+ setup = true;
+ }
+#endif
// just clicking on ENTER will not send us any font setting event, therefore we have to make sure
// that field is already correct
m_fontData.m_chosenFont = font ;