// Created: 1998-01-01
// RCS-ID: $Id$
// Copyright: (c) Stefan Csomor
-// Licence: wxWidgets licence
+// Licence: wxWindows licence
/////////////////////////////////////////////////////////////////////////////
-#ifdef __GNUG__
+#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
#pragma implementation "font.h"
#endif
-#include "wx/defs.h"
+#include "wx/wxprec.h"
+
#include "wx/string.h"
#include "wx/font.h"
#include "wx/fontutil.h"
, m_macFontNum(0)
, m_macFontSize(0)
, m_macFontStyle(0)
- , m_macATSUFontID()
+ , m_macATSUStyle(0)
+ , m_macATSUFontID(0)
{
Init(10, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE,
wxT("Geneva"), wxFONTENCODING_DEFAULT);
, m_macFontNum(data.m_macFontNum)
, m_macFontSize(data.m_macFontSize)
, m_macFontStyle(data.m_macFontStyle)
+ , m_macATSUStyle(0)
, m_macATSUFontID(data.m_macATSUFontID)
{
Init(data.m_pointSize, data.m_family, data.m_style, data.m_weight,
, m_macFontNum(0)
, m_macFontSize(0)
, m_macFontStyle(0)
+ , m_macATSUStyle(0)
, m_macATSUFontID(0)
{
Init(size, family, style, weight, underlined, faceName, encoding);
virtual ~wxFontRefData();
void SetNoAntiAliasing( bool no = TRUE ) { m_noAA = no; }
- bool GetNoAntiAliasing() { return m_noAA; }
+ bool GetNoAntiAliasing() const { return m_noAA; }
protected:
// common part of all ctors
wxFontEncoding encoding);
// font characterstics
- int m_fontId;
- int m_pointSize;
- int m_family;
- int m_style;
- int m_weight;
- bool m_underlined;
- wxString m_faceName;
- wxFontEncoding m_encoding;
+ int m_fontId;
+ int m_pointSize;
+ int m_family;
+ int m_style;
+ int m_weight;
+ bool m_underlined;
+ wxString m_faceName;
+ wxFontEncoding m_encoding;
bool m_noAA; // No anti-aliasing
public:
// contain some styles (special bold fonts etc) and
// these are the additional qd styles that are not
// included in the ATSU font id
+ ATSUStyle m_macATSUStyle ;
ATSUFontID m_macATSUFontID;
Style m_macATSUAdditionalQDStyles ;
m_macFontStyle = 0;
m_macATSUFontID = 0;
m_macATSUAdditionalQDStyles = 0 ;
+ m_macATSUStyle = NULL ;
m_macThemeFontID = kThemeCurrentPortFont ;
m_noAA = FALSE;
wxFontRefData::~wxFontRefData()
{
+ if ( m_macATSUStyle )
+ {
+ ::ATSUDisposeStyle((ATSUStyle)m_macATSUStyle);
+ m_macATSUStyle = NULL ;
+ }
}
void wxFontRefData::MacFindFont()
case wxDEFAULT :
m_macFontNum = ::GetAppFont() ;
break ;
- case wxDECORATIVE :
- ::GetFNum( "\pTimes" , &m_macFontNum) ;
- break ;
+ case wxSCRIPT :
case wxROMAN :
+ case wxDECORATIVE :
+#ifdef __WXMAC_OSX__
::GetFNum( "\pTimes" , &m_macFontNum) ;
- break ;
- case wxSCRIPT :
+#else
::GetFNum( "\pTimes" , &m_macFontNum) ;
+#endif
break ;
case wxSWISS :
+#ifdef __WXMAC_OSX__
+ ::GetFNum( "\pLucida Grande" , &m_macFontNum) ;
+#else
::GetFNum( "\pGeneva" , &m_macFontNum) ;
+#endif
break ;
case wxMODERN :
+#ifdef __WXMAC_OSX__
+ ::GetFNum( "\pMonaco" , &m_macFontNum) ;
+#else
::GetFNum( "\pMonaco" , &m_macFontNum) ;
+#endif
break ;
}
Str255 name ;
}
// we try to get as much styles as possible into ATSU
+
+ Fixed atsuSize = IntToFixed( m_macFontSize ) ;
+
Style atsuStyle = normal ;
verify_noerr(::ATSUFONDtoFontID(m_macFontNum, atsuStyle , (UInt32*)&m_macATSUFontID) );
if ( m_macFontStyle & bold )
m_macATSUFontID = test ;
}
}
+
m_macATSUAdditionalQDStyles = m_macFontStyle & (~atsuStyle ) ;
+
+ if ( m_macATSUStyle )
+ {
+ ::ATSUDisposeStyle((ATSUStyle)m_macATSUStyle);
+ m_macATSUStyle = NULL ;
+ }
+ OSStatus status = ::ATSUCreateStyle((ATSUStyle *)&m_macATSUStyle) ;
+ wxASSERT_MSG( status == noErr , wxT("couldn't create ATSU style") ) ;
+ ATSUAttributeTag atsuTags[] =
+ {
+ kATSUFontTag ,
+ kATSUSizeTag ,
+ kATSUVerticalCharacterTag,
+ kATSUQDBoldfaceTag ,
+ kATSUQDItalicTag ,
+ kATSUQDUnderlineTag ,
+ kATSUQDCondensedTag ,
+ kATSUQDExtendedTag ,
+ } ;
+ ByteCount atsuSizes[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] =
+ {
+ sizeof( ATSUFontID ) ,
+ sizeof( Fixed ) ,
+ sizeof( ATSUVerticalCharacterType),
+ sizeof( Boolean ) ,
+ sizeof( Boolean ) ,
+ sizeof( Boolean ) ,
+ sizeof( Boolean ) ,
+ sizeof( Boolean ) ,
+ } ;
+ Boolean kTrue = true ;
+ Boolean kFalse = false ;
+
+ ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal;
+ ATSUAttributeValuePtr atsuValues[sizeof(atsuTags)/sizeof(ATSUAttributeTag)] =
+ {
+ &m_macATSUFontID ,
+ &atsuSize ,
+ &kHorizontal,
+ (m_macATSUAdditionalQDStyles & bold) ? &kTrue : &kFalse ,
+ (m_macATSUAdditionalQDStyles & italic) ? &kTrue : &kFalse ,
+ (m_macATSUAdditionalQDStyles & underline) ? &kTrue : &kFalse ,
+ (m_macATSUAdditionalQDStyles & condense) ? &kTrue : &kFalse ,
+ (m_macATSUAdditionalQDStyles & extend) ? &kTrue : &kFalse ,
+ } ;
+ status = ::ATSUSetAttributes((ATSUStyle)m_macATSUStyle, sizeof(atsuTags)/sizeof(ATSUAttributeTag) ,
+ atsuTags, atsuSizes, atsuValues);
+
+ wxASSERT_MSG( status == noErr , wxT("couldn't Modify ATSU style") ) ;
}
// ----------------------------------------------------------------------------
bool wxFont::MacCreateThemeFont(wxUint16 themeFontID )
{
UnRef();
- m_refData = new wxFontRefData(12, 0, 0, wxNORMAL,false, wxEmptyString, wxFONTENCODING_DEFAULT);
+ m_refData = new wxFontRefData(12, wxDEFAULT , wxFONTSTYLE_NORMAL , wxFONTWEIGHT_NORMAL ,false, wxEmptyString, wxFONTENCODING_DEFAULT);
M_FONTDATA->m_macThemeFontID = themeFontID ;
RealizeResource();
int wxFont::GetPointSize() const
{
- wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
+ wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
return M_FONTDATA->m_pointSize;
}
int wxFont::GetFamily() const
{
- wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
+ wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
return M_FONTDATA->m_family;
}
int wxFont::GetStyle() const
{
- wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
+ wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
return M_FONTDATA->m_style;
}
int wxFont::GetWeight() const
{
- wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
+ wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
return M_FONTDATA->m_weight;
}
bool wxFont::GetUnderlined() const
{
- wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
+ wxCHECK_MSG( M_FONTDATA != NULL , false, wxT("invalid font") );
return M_FONTDATA->m_underlined;
}
return M_FONTDATA->m_encoding;
}
-bool wxFont::GetNoAntiAliasing()
+bool wxFont::GetNoAntiAliasing() const
{
- wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
+ wxCHECK_MSG( M_FONTDATA != NULL , false, wxT("invalid font") );
return M_FONTDATA->m_noAA;
}
short wxFont::MacGetFontNum() const
{
- wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
+ wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
return M_FONTDATA->m_macFontNum;
}
short wxFont::MacGetFontSize() const
{
- wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
+ wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
return M_FONTDATA->m_macFontSize;
}
wxByte wxFont::MacGetFontStyle() const
{
- wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
+ wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
return M_FONTDATA->m_macFontStyle;
}
wxUint32 wxFont::MacGetATSUFontID() const
{
- wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
+ wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
return M_FONTDATA->m_macATSUFontID;
}
-wxUint32 wxFont::MacGetATSUAdditionalQDStyles() const
+void* wxFont::MacGetATSUStyle() const
{
wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
+ return M_FONTDATA->m_macATSUStyle;
+}
+
+wxUint32 wxFont::MacGetATSUAdditionalQDStyles() const
+{
+ wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
return M_FONTDATA->m_macATSUAdditionalQDStyles;
}
wxUint16 wxFont::MacGetThemeFontID() const
{
- wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
+ wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
return M_FONTDATA->m_macThemeFontID;
}