ATSU Support in font extended
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@31607 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
3d1a4878f3
commit
3e5270737b
@ -9,11 +9,12 @@
|
||||
// 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"
|
||||
@ -45,7 +46,8 @@ public:
|
||||
, m_macFontNum(0)
|
||||
, m_macFontSize(0)
|
||||
, m_macFontStyle(0)
|
||||
, m_macATSUFontID()
|
||||
, m_macATSUFontID(0)
|
||||
, m_macATSUStyle(0)
|
||||
{
|
||||
Init(10, wxDEFAULT, wxNORMAL, wxNORMAL, FALSE,
|
||||
wxT("Geneva"), wxFONTENCODING_DEFAULT);
|
||||
@ -65,6 +67,7 @@ public:
|
||||
, m_macFontSize(data.m_macFontSize)
|
||||
, m_macFontStyle(data.m_macFontStyle)
|
||||
, m_macATSUFontID(data.m_macATSUFontID)
|
||||
, m_macATSUStyle(0)
|
||||
{
|
||||
Init(data.m_pointSize, data.m_family, data.m_style, data.m_weight,
|
||||
data.m_underlined, data.m_faceName, data.m_encoding);
|
||||
@ -89,6 +92,7 @@ public:
|
||||
, m_macFontSize(0)
|
||||
, m_macFontStyle(0)
|
||||
, m_macATSUFontID(0)
|
||||
, m_macATSUStyle(0)
|
||||
{
|
||||
Init(size, family, style, weight, underlined, faceName, encoding);
|
||||
}
|
||||
@ -129,6 +133,7 @@ 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 ;
|
||||
|
||||
@ -171,6 +176,7 @@ void wxFontRefData::Init(int pointSize,
|
||||
m_macFontStyle = 0;
|
||||
m_macATSUFontID = 0;
|
||||
m_macATSUAdditionalQDStyles = 0 ;
|
||||
m_macATSUStyle = NULL ;
|
||||
|
||||
m_macThemeFontID = kThemeCurrentPortFont ;
|
||||
m_noAA = FALSE;
|
||||
@ -178,6 +184,11 @@ void wxFontRefData::Init(int pointSize,
|
||||
|
||||
wxFontRefData::~wxFontRefData()
|
||||
{
|
||||
if ( m_macATSUStyle )
|
||||
{
|
||||
::ATSUDisposeStyle((ATSUStyle)m_macATSUStyle);
|
||||
m_macATSUStyle = NULL ;
|
||||
}
|
||||
}
|
||||
|
||||
void wxFontRefData::MacFindFont()
|
||||
@ -211,7 +222,7 @@ void wxFontRefData::MacFindFont()
|
||||
case wxROMAN :
|
||||
case wxDECORATIVE :
|
||||
#ifdef __WXMAC_OSX__
|
||||
::GetFNum( "\pTimes New Roman" , &m_macFontNum) ;
|
||||
::GetFNum( "\pTimes" , &m_macFontNum) ;
|
||||
#else
|
||||
::GetFNum( "\pTimes" , &m_macFontNum) ;
|
||||
#endif
|
||||
@ -260,6 +271,9 @@ void wxFontRefData::MacFindFont()
|
||||
}
|
||||
|
||||
// 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 )
|
||||
@ -289,7 +303,57 @@ void wxFontRefData::MacFindFont()
|
||||
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") ) ;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
@ -333,7 +397,7 @@ bool wxFont::Create(int pointSize,
|
||||
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();
|
||||
|
||||
@ -515,6 +579,12 @@ wxUint32 wxFont::MacGetATSUFontID() const
|
||||
return M_FONTDATA->m_macATSUFontID;
|
||||
}
|
||||
|
||||
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 , NULL, wxT("invalid font") );
|
||||
|
Loading…
Reference in New Issue
Block a user