#include "wx/osx/private.h"
#if wxOSX_USE_ATSU_TEXT && !wxOSX_USE_CARBON
-// include themeing support
+// include theming support
#include <Carbon/Carbon.h>
#endif
}
wxFontRefData(const wxFontRefData& data);
-
+
wxFontRefData( const wxNativeFontInfo& info ) : m_info(info)
{
Init();
}
wxFontRefData(wxOSXSystemFont font, int size);
-
+
#if wxOSX_USE_CORE_TEXT
wxFontRefData( wxUint32 coreTextFontType );
wxFontRefData( CTFontRef font );
public:
bool m_fontValid;
#if wxOSX_USE_CARBON && wxOSX_USE_ATSU_TEXT
- // for true themeing support we must store the correct font
+ // for true theming support we must store the correct font
// information here, as this speeds up and optimizes rendering
ThemeFontID m_macThemeFontID ;
#endif
#endif
#if wxOSX_USE_CORE_TEXT
m_ctFont = data.m_ctFont;
-#endif
+#endif
m_cgFont = data.m_cgFont;
#if wxOSX_USE_ATSU_TEXT
if ( data.m_macATSUStyle != NULL )
#if wxOSX_USE_IPHONE
m_uiFont = (UIFont*) wxMacCocoaRetain(data.m_uiFont);
#endif
-
+
}
// ============================================================================
#endif
m_cgFont.reset();
#if wxOSX_USE_ATSU_TEXT
+#if wxOSX_USE_CARBON
+ m_macThemeFontID = kThemeCurrentPortFont ;
+#endif
if ( m_macATSUStyle )
{
::ATSUDisposeStyle((ATSUStyle)m_macATSUStyle);
{
wxASSERT( font != wxOSX_SYSTEM_FONT_NONE );
Init();
-
+
#if wxOSX_USE_CORE_TEXT
if ( UMAGetSystemVersion() >= 0x1050 )
{
m_macThemeFontID = kThemeMiniSystemFont;
break;
case wxOSX_SYSTEM_FONT_MINI_BOLD:
- // bold not available under themeing
+ // bold not available under theming
m_macThemeFontID = kThemeMiniSystemFont;
break;
case wxOSX_SYSTEM_FONT_LABELS:
m_macThemeFontID = kThemeViewsFont;
break;
default:
- break;
+ break;
}
if ( m_info.m_faceName.empty() )
{
Style style ;
FMFontSize fontSize;
Str255 qdFontName ;
-
+
GetThemeFont( m_macThemeFontID, GetApplicationScript(), qdFontName, &fontSize, &style );
if ( size != 0 )
fontSize = size;
wxFontStyle fontstyle = wxFONTSTYLE_NORMAL;
wxFontWeight fontweight = wxFONTWEIGHT_NORMAL;
bool underlined = false;
-
+
if ( style & bold )
fontweight = wxFONTWEIGHT_BOLD ;
else
fontstyle = wxFONTSTYLE_ITALIC ;
if ( style & underline )
underlined = true ;
-
+
m_info.Init(fontSize,wxFONTFAMILY_DEFAULT,fontstyle,fontweight,underlined,
wxMacMakeStringFromPascal( qdFontName ), wxFONTENCODING_DEFAULT);
}
{
if ( m_fontValid )
return;
-
+
m_info.EnsureValid();
-
+
#if wxOSX_USE_CORE_TEXT
if ( UMAGetSystemVersion() >= 0x1050 )
{
kATSUQDCondensedTag ,
kATSUQDExtendedTag ,
};
- ByteCount atsuSizes[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
+ ByteCount atsuSizes[WXSIZEOF(atsuTags)] =
{
sizeof( ATSUFontID ) ,
sizeof( Fixed ) ,
Fixed atsuSize = IntToFixed( m_info.m_pointSize );
ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal;
FMFontStyle addQDStyle = m_info.m_atsuAdditionalQDStyles;
- ATSUAttributeValuePtr atsuValues[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
+ ATSUAttributeValuePtr atsuValues[WXSIZEOF(atsuTags)] =
{
&m_info.m_atsuFontID ,
&atsuSize ,
status = ::ATSUSetAttributes(
(ATSUStyle)m_macATSUStyle,
- sizeof(atsuTags) / sizeof(ATSUAttributeTag) ,
+ WXSIZEOF(atsuTags),
atsuTags, atsuSizes, atsuValues);
wxASSERT_MSG( status == noErr , wxT("couldn't modify ATSU style") );
bool wxFont::Create(const wxNativeFontInfo& info)
{
UnRef();
-
+
m_refData = new wxFontRefData( info );
RealizeResource();
-
+
return true;
}
wxFontEncoding encoding)
{
UnRef();
-
+
wxString faceName = faceNameParam;
if ( faceName.empty() )
case wxFONTFAMILY_DEFAULT :
faceName = wxT("Lucida Grande");
break;
-
+
case wxFONTFAMILY_SCRIPT :
case wxFONTFAMILY_ROMAN :
case wxFONTFAMILY_DECORATIVE :
break ;
}
}
-
+
wxNativeFontInfo info;
-
+
info.Init(pointSize, family, style, weight,
underlined, faceName, encoding);
bool wxFont::CreateSystemFont(wxOSXSystemFont font)
{
UnRef();
-
+
m_refData = new wxFontRefData( font, 0 );
-
+
return true;
}
void wxFont::DoSetNativeFontInfo(const wxNativeFontInfo& info)
{
UnRef();
-
+
m_refData = new wxFontRefData( info);
}
// cast away constness otherwise lazy font resolution is not possible
const_cast<wxFont *>(this)->RealizeResource();
-
+
return M_FONTDATA->m_info.m_qdFontFamily;
}
// cast away constness otherwise lazy font resolution is not possible
const_cast<wxFont *>(this)->RealizeResource();
-
+
return M_FONTDATA->m_info.m_qdFontStyle;
}
// cast away constness otherwise lazy font resolution is not possible
const_cast<wxFont *>(this)->RealizeResource();
-
+
return M_FONTDATA->m_macATSUStyle;
}
#if WXWIN_COMPATIBILITY_2_8
-wxUint32 wxFont::MacGetATSUFontID() const
+wxUint32 wxFont::MacGetATSUFontID() const
{
wxCHECK_MSG( M_FONTDATA != NULL, 0, wxT("invalid font") );
// cast away constness otherwise lazy font resolution is not possible
const_cast<wxFont *>(this)->RealizeResource();
-
+
return M_FONTDATA->m_info.m_atsuFontID;
}
// cast away constness otherwise lazy font resolution is not possible
const_cast<wxFont *>(this)->RealizeResource();
-
+
return M_FONTDATA->m_info.m_atsuAdditionalQDStyles;
}
#endif
// cast away constness otherwise lazy font resolution is not possible
const_cast<wxFont *>(this)->RealizeResource();
-
+
return (CTFontRef)(M_FONTDATA->m_ctFont);
}
// cast away constness otherwise lazy font resolution is not possible
const_cast<wxFont *>(this)->RealizeResource();
-
+
return (M_FONTDATA->m_cgFont);
}
// cast away constness otherwise lazy font resolution is not possible
const_cast<wxFont *>(this)->RealizeResource();
-
+
return (M_FONTDATA->m_nsFont);
}
// cast away constness otherwise lazy font resolution is not possible
const_cast<wxFont *>(this)->RealizeResource();
-
+
// M_FONTDATA->m_info.InitFromFont(*this);
return &(M_FONTDATA->m_info);
CTFontDescriptorRef descriptor = NULL;
CFMutableDictionaryRef attributes;
- assert(iFamilyName != NULL);
+ wxASSERT(iFamilyName != NULL);
// Create a mutable dictionary to hold our attributes.
attributes = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
- check(attributes != NULL);
+ wxASSERT(attributes != NULL);
if (attributes != NULL) {
// Add a family name to our attributes.
// Create the traits dictionary.
symTraits = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type,
&iTraits);
- check(symTraits != NULL);
+ wxASSERT(symTraits != NULL);
if (symTraits != NULL) {
// Create a dictionary to hold our traits values.
traits = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
- check(traits != NULL);
+ wxASSERT(traits != NULL);
if (traits != NULL) {
// Add the symbolic traits value to the traits dictionary.
}
// Create the font descriptor with our attributes
descriptor = CTFontDescriptorCreateWithAttributes(attributes);
- check(descriptor != NULL);
+ wxASSERT(descriptor != NULL);
CFRelease(attributes);
}
{
Init();
m_ctFontDescriptor = wxCFRetain(descr);
-
+
wxCFRef< CFNumberRef > sizevalue( (CFNumberRef) CTFontDescriptorCopyAttribute( m_ctFontDescriptor, kCTFontSizeAttribute ) );
float fsize;
if ( CFNumberGetValue( sizevalue , kCFNumberFloatType , &fsize ) )
}
wxCFStringRef familyName( (CFStringRef) CTFontDescriptorCopyAttribute(m_ctFontDescriptor, kCTFontFamilyNameAttribute));
- m_faceName = familyName.AsString();
+ m_faceName = familyName.AsString();
}
#endif
{
if ( m_descriptorValid )
return;
-
+
#if wxOSX_USE_CORE_TEXT
if ( m_ctFontDescriptor == NULL && UMAGetSystemVersion() >= 0x1050 )
{
// ATSUFontID and FMFont are equivalent
FMFontStyle intrinsicStyle = 0 ;
OSStatus status = FMGetFontFromFontFamilyInstance( m_qdFontFamily , m_qdFontStyle , (FMFont*)&m_atsuFontID , &intrinsicStyle);
- wxASSERT_MSG( status == noErr , wxT("couldn't get an ATSUFont from font family") );
+ if ( status != noErr )
+ {
+ wxFAIL_MSG( wxT("couldn't get an ATSUFont from font family") );
+ }
m_atsuAdditionalQDStyles = m_qdFontStyle & (~intrinsicStyle );
m_atsuFontValid = true;
}
{
long l;
- wxStringTokenizer tokenizer(s, _T(";"));
+ wxStringTokenizer tokenizer(s, wxT(";"));
wxString token = tokenizer.GetNextToken();
//
{
wxString s;
- s.Printf(_T("%d;%d;%d;%d;%d;%d;%s;%d"),
+ s.Printf(wxT("%d;%d;%d;%d;%d;%d;%s;%d"),
0, // version
m_pointSize,
m_family,