adding CoreText implementation
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50331 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -40,45 +40,12 @@ class WXDLLEXPORT wxFontRefData: public wxGDIRefData
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
wxFontRefData()
|
wxFontRefData()
|
||||||
: m_fontId(0)
|
|
||||||
, m_pointSize(10)
|
|
||||||
, m_family(wxDEFAULT)
|
|
||||||
, m_style(wxNORMAL)
|
|
||||||
, m_weight(wxNORMAL)
|
|
||||||
, m_underlined(false)
|
|
||||||
, m_faceName(wxT("applicationfont"))
|
|
||||||
, m_encoding(wxFONTENCODING_DEFAULT)
|
|
||||||
#ifdef __LP64__
|
|
||||||
#else
|
|
||||||
, m_macFontFamily(0)
|
|
||||||
, m_macFontSize(0)
|
|
||||||
, m_macFontStyle(0)
|
|
||||||
, m_macATSUFontID(0)
|
|
||||||
#endif
|
|
||||||
, m_macATSUStyle(0)
|
|
||||||
{
|
{
|
||||||
Init(m_pointSize, m_family, m_style, m_weight,
|
Init(10, wxDEFAULT, wxNORMAL, wxNORMAL,
|
||||||
m_underlined, m_faceName, m_encoding);
|
false, wxT("applicationfont"), wxFONTENCODING_DEFAULT);
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFontRefData(const wxFontRefData& data)
|
wxFontRefData(const wxFontRefData& data)
|
||||||
: wxGDIRefData()
|
|
||||||
, m_fontId(data.m_fontId)
|
|
||||||
, m_pointSize(data.m_pointSize)
|
|
||||||
, m_family(data.m_family)
|
|
||||||
, m_style(data.m_style)
|
|
||||||
, m_weight(data.m_weight)
|
|
||||||
, m_underlined(data.m_underlined)
|
|
||||||
, m_faceName(data.m_faceName)
|
|
||||||
, m_encoding(data.m_encoding)
|
|
||||||
#ifdef __LP64__
|
|
||||||
#else
|
|
||||||
, m_macFontFamily(data.m_macFontFamily)
|
|
||||||
, m_macFontSize(data.m_macFontSize)
|
|
||||||
, m_macFontStyle(data.m_macFontStyle)
|
|
||||||
, m_macATSUFontID(data.m_macATSUFontID)
|
|
||||||
#endif
|
|
||||||
, m_macATSUStyle(0)
|
|
||||||
{
|
{
|
||||||
Init(data.m_pointSize, data.m_family, data.m_style, data.m_weight,
|
Init(data.m_pointSize, data.m_family, data.m_style, data.m_weight,
|
||||||
data.m_underlined, data.m_faceName, data.m_encoding);
|
data.m_underlined, data.m_faceName, data.m_encoding);
|
||||||
@@ -91,22 +58,6 @@ public:
|
|||||||
bool underlined,
|
bool underlined,
|
||||||
const wxString& faceName,
|
const wxString& faceName,
|
||||||
wxFontEncoding encoding)
|
wxFontEncoding encoding)
|
||||||
: m_fontId(0)
|
|
||||||
, m_pointSize(size)
|
|
||||||
, m_family(family)
|
|
||||||
, m_style(style)
|
|
||||||
, m_weight(weight)
|
|
||||||
, m_underlined(underlined)
|
|
||||||
, m_faceName(faceName)
|
|
||||||
, m_encoding(encoding)
|
|
||||||
#ifdef __LP64__
|
|
||||||
#else
|
|
||||||
, m_macFontFamily(0)
|
|
||||||
, m_macFontSize(0)
|
|
||||||
, m_macFontStyle(0)
|
|
||||||
, m_macATSUFontID(0)
|
|
||||||
#endif
|
|
||||||
, m_macATSUStyle(0)
|
|
||||||
{
|
{
|
||||||
Init(size, family, style, weight, underlined, faceName, encoding);
|
Init(size, family, style, weight, underlined, faceName, encoding);
|
||||||
}
|
}
|
||||||
@@ -132,7 +83,6 @@ protected:
|
|||||||
wxFontEncoding encoding);
|
wxFontEncoding encoding);
|
||||||
|
|
||||||
// font characterstics
|
// font characterstics
|
||||||
int m_fontId;
|
|
||||||
int m_pointSize;
|
int m_pointSize;
|
||||||
int m_family;
|
int m_family;
|
||||||
int m_style;
|
int m_style;
|
||||||
@@ -143,7 +93,7 @@ protected:
|
|||||||
bool m_noAA; // No anti-aliasing
|
bool m_noAA; // No anti-aliasing
|
||||||
|
|
||||||
public:
|
public:
|
||||||
#ifndef __LP64__
|
#if wxMAC_USE_ATSU_TEXT
|
||||||
FMFontFamily m_macFontFamily;
|
FMFontFamily m_macFontFamily;
|
||||||
FMFontSize m_macFontSize;
|
FMFontSize m_macFontSize;
|
||||||
FMFontStyle m_macFontStyle;
|
FMFontStyle m_macFontStyle;
|
||||||
@@ -160,11 +110,12 @@ public:
|
|||||||
// for true themeing support we must store the correct font
|
// for true themeing support we must store the correct font
|
||||||
// information here, as this speeds up and optimizes rendering
|
// information here, as this speeds up and optimizes rendering
|
||||||
ThemeFontID m_macThemeFontID ;
|
ThemeFontID m_macThemeFontID ;
|
||||||
#else
|
ATSUStyle m_macATSUStyle ;
|
||||||
CTFontRef m_macFontRef;
|
#endif
|
||||||
|
#if wxMAC_USE_CORE_TEXT
|
||||||
|
wxCFRef<CTFontRef> m_ctFont;
|
||||||
CTFontUIFontType m_macUIFontType;
|
CTFontUIFontType m_macUIFontType;
|
||||||
#endif
|
#endif
|
||||||
ATSUStyle m_macATSUStyle ;
|
|
||||||
wxNativeFontInfo m_info;
|
wxNativeFontInfo m_info;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -195,20 +146,19 @@ void wxFontRefData::Init(int pointSize,
|
|||||||
m_underlined = underlined;
|
m_underlined = underlined;
|
||||||
m_faceName = faceName;
|
m_faceName = faceName;
|
||||||
m_encoding = encoding;
|
m_encoding = encoding;
|
||||||
#ifdef __LP64__
|
m_noAA = false;
|
||||||
|
#ifdef wxMAC_USE_CORE_TEXT
|
||||||
m_macUIFontType = kCTFontNoFontType;
|
m_macUIFontType = kCTFontNoFontType;
|
||||||
m_macFontRef = 0;
|
#endif
|
||||||
#else
|
#if wxMAC_USE_ATSU_TEXT
|
||||||
m_macFontFamily = 0 ;
|
m_macFontFamily = 0 ;
|
||||||
m_macFontSize = 0;
|
m_macFontSize = 0;
|
||||||
m_macFontStyle = 0;
|
m_macFontStyle = 0;
|
||||||
m_macATSUFontID = 0;
|
m_macATSUFontID = 0;
|
||||||
m_macATSUAdditionalQDStyles = 0 ;
|
m_macATSUAdditionalQDStyles = 0 ;
|
||||||
|
|
||||||
m_macThemeFontID = kThemeCurrentPortFont ;
|
m_macThemeFontID = kThemeCurrentPortFont ;
|
||||||
#endif
|
|
||||||
m_macATSUStyle = NULL ;
|
m_macATSUStyle = NULL ;
|
||||||
m_noAA = false;
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
wxFontRefData::~wxFontRefData()
|
wxFontRefData::~wxFontRefData()
|
||||||
@@ -220,147 +170,96 @@ wxFontRefData::~wxFontRefData()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if wxMAC_USE_CORE_TEXT
|
||||||
|
|
||||||
|
/* code mixed together from 2 different routines from Core Text Manual Common Operations */
|
||||||
|
|
||||||
|
static CTFontRef wxMacCreateCTFont(CFStringRef iFamilyName, CTFontSymbolicTraits iTraits, CGFloat iSize )
|
||||||
|
{
|
||||||
|
CTFontDescriptorRef descriptor = NULL;
|
||||||
|
CFMutableDictionaryRef attributes;
|
||||||
|
|
||||||
|
assert(iFamilyName != NULL);
|
||||||
|
// Create a mutable dictionary to hold our attributes.
|
||||||
|
attributes = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
|
||||||
|
&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
|
||||||
|
check(attributes != NULL);
|
||||||
|
|
||||||
|
if (attributes != NULL) {
|
||||||
|
// Add a family name to our attributes.
|
||||||
|
CFDictionaryAddValue(attributes, kCTFontFamilyNameAttribute, iFamilyName);
|
||||||
|
|
||||||
|
|
||||||
|
if ( iTraits ) {
|
||||||
|
CFMutableDictionaryRef traits;
|
||||||
|
CFNumberRef symTraits;
|
||||||
|
|
||||||
|
// Create the traits dictionary.
|
||||||
|
symTraits = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type,
|
||||||
|
&iTraits);
|
||||||
|
check(symTraits != NULL);
|
||||||
|
|
||||||
|
if (symTraits != NULL) {
|
||||||
|
// Create a dictionary to hold our traits values.
|
||||||
|
traits = CFDictionaryCreateMutable(kCFAllocatorDefault, 0,
|
||||||
|
&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
|
||||||
|
check(traits != NULL);
|
||||||
|
|
||||||
|
if (traits != NULL) {
|
||||||
|
// Add the symbolic traits value to the traits dictionary.
|
||||||
|
CFDictionaryAddValue(traits, kCTFontSymbolicTrait, symTraits);
|
||||||
|
|
||||||
|
// Add the traits attribute to our attributes.
|
||||||
|
CFDictionaryAddValue(attributes, kCTFontTraitsAttribute, traits);
|
||||||
|
CFRelease(traits);
|
||||||
|
}
|
||||||
|
CFRelease(symTraits);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Create the font descriptor with our attributes and input size.
|
||||||
|
descriptor = CTFontDescriptorCreateWithAttributes(attributes);
|
||||||
|
check(descriptor != NULL);
|
||||||
|
|
||||||
|
CFRelease(attributes);
|
||||||
|
}
|
||||||
|
// Return our font descriptor.
|
||||||
|
CTFontRef font = CTFontCreateWithFontDescriptor( descriptor, iSize, NULL);
|
||||||
|
CFRelease( descriptor );
|
||||||
|
return font ;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
void wxFontRefData::MacFindFont()
|
void wxFontRefData::MacFindFont()
|
||||||
{
|
{
|
||||||
OSStatus status = noErr;
|
OSStatus status = noErr;
|
||||||
Str255 qdFontName ;
|
|
||||||
|
|
||||||
#ifdef __LP64__
|
#if wxMAC_USE_CORE_TEXT
|
||||||
if ( m_faceName.empty() && m_family == wxDEFAULT )
|
if ( CTFontCreateWithName != NULL )
|
||||||
{
|
{
|
||||||
m_macUIFontType = kCTFontSystemFontType;
|
if ( m_faceName.empty() && m_family == wxDEFAULT && m_macUIFontType == kCTFontNoFontType )
|
||||||
}
|
|
||||||
|
|
||||||
if ( m_macUIFontType != kCTFontNoFontType )
|
|
||||||
{
|
|
||||||
m_macFontRef = CTFontCreateUIFontForLanguage( m_macUIFontType, 0.0, NULL );
|
|
||||||
wxMacCFStringHolder name( CTFontCopyFamilyName( m_macFontRef ) );
|
|
||||||
m_faceName = name.AsString();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( m_faceName.empty() )
|
|
||||||
{
|
{
|
||||||
switch ( m_family )
|
m_macUIFontType = kCTFontSystemFontType;
|
||||||
{
|
|
||||||
case wxSCRIPT :
|
|
||||||
case wxROMAN :
|
|
||||||
case wxDECORATIVE :
|
|
||||||
m_faceName = wxT("Times");
|
|
||||||
break ;
|
|
||||||
|
|
||||||
case wxSWISS :
|
|
||||||
m_faceName = wxT("Lucida Grande");
|
|
||||||
break ;
|
|
||||||
|
|
||||||
case wxMODERN :
|
|
||||||
case wxTELETYPE:
|
|
||||||
m_faceName = wxT("Monaco");
|
|
||||||
break ;
|
|
||||||
|
|
||||||
default:
|
|
||||||
m_faceName = wxT("Times");
|
|
||||||
break ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMacCFStringHolder cf( m_faceName, wxLocale::GetSystemEncoding() );
|
if ( m_macUIFontType != kCTFontNoFontType )
|
||||||
m_macFontRef = CTFontCreateWithName( cf, m_pointSize, NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( m_macATSUStyle )
|
|
||||||
{
|
|
||||||
::ATSUDisposeStyle((ATSUStyle)m_macATSUStyle);
|
|
||||||
m_macATSUStyle = NULL ;
|
|
||||||
}
|
|
||||||
|
|
||||||
status = ::ATSUCreateStyle((ATSUStyle *)&m_macATSUStyle);
|
|
||||||
wxASSERT_MSG( status == noErr , wxT("couldn't create ATSU style") );
|
|
||||||
|
|
||||||
ATSUAttributeTag atsuTags[] =
|
|
||||||
{
|
|
||||||
kATSUSizeTag ,
|
|
||||||
kATSUVerticalCharacterTag,
|
|
||||||
kATSUQDBoldfaceTag ,
|
|
||||||
kATSUQDItalicTag ,
|
|
||||||
kATSUQDUnderlineTag ,
|
|
||||||
kATSUQDCondensedTag ,
|
|
||||||
kATSUQDExtendedTag ,
|
|
||||||
kATSUFontTag ,
|
|
||||||
};
|
|
||||||
ByteCount atsuSizes[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
|
|
||||||
{
|
|
||||||
sizeof( Fixed ) ,
|
|
||||||
sizeof( ATSUVerticalCharacterType),
|
|
||||||
sizeof( Boolean ) ,
|
|
||||||
sizeof( Boolean ) ,
|
|
||||||
sizeof( Boolean ) ,
|
|
||||||
sizeof( Boolean ) ,
|
|
||||||
sizeof( Boolean ) ,
|
|
||||||
sizeof( ATSUFontID ) ,
|
|
||||||
};
|
|
||||||
|
|
||||||
Boolean kTrue = true ;
|
|
||||||
Boolean kFalse = false ;
|
|
||||||
|
|
||||||
Fixed atsuSize = IntToFixed( m_pointSize );
|
|
||||||
short m_macATSUAdditionalQDStyles = 0;
|
|
||||||
ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal;
|
|
||||||
ATSUFontID atsuFontID = 0;
|
|
||||||
int attributeCount = sizeof(atsuTags) / sizeof(ATSUAttributeTag) ;
|
|
||||||
|
|
||||||
// attempt to add atsu font
|
|
||||||
#if 0
|
|
||||||
status = ATSUFindFontFromName(m_faceName.c_str(), strlen(m_faceName.c_str()), kFontFamilyName, kFontNoPlatform, kFontNoScript, kFontNoLanguage, &atsuFontID);
|
|
||||||
if ( status != noErr )
|
|
||||||
{
|
|
||||||
attributeCount--;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
ATSUAttributeValuePtr atsuValues[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
|
|
||||||
{
|
|
||||||
&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 ,
|
|
||||||
&atsuFontID ,
|
|
||||||
};
|
|
||||||
|
|
||||||
status = ::ATSUSetAttributes( (ATSUStyle)m_macATSUStyle, attributeCount, atsuTags, atsuSizes, atsuValues);
|
|
||||||
|
|
||||||
wxASSERT_MSG( status == noErr , wxT("couldn't modify ATSU style") );
|
|
||||||
#else
|
|
||||||
if ( m_macThemeFontID != kThemeCurrentPortFont )
|
|
||||||
{
|
|
||||||
Style style ;
|
|
||||||
GetThemeFont( m_macThemeFontID, GetApplicationScript(), qdFontName, &m_macFontSize, &style );
|
|
||||||
m_macFontStyle = style ;
|
|
||||||
m_faceName = wxMacMakeStringFromPascal( qdFontName );
|
|
||||||
if ( m_macFontStyle & bold )
|
|
||||||
m_weight = wxBOLD ;
|
|
||||||
else
|
|
||||||
m_weight = wxNORMAL ;
|
|
||||||
if ( m_macFontStyle & italic )
|
|
||||||
m_style = wxITALIC ;
|
|
||||||
if ( m_macFontStyle & underline )
|
|
||||||
m_underlined = true ;
|
|
||||||
m_pointSize = m_macFontSize ;
|
|
||||||
m_macFontFamily = FMGetFontFamilyFromName( qdFontName );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if ( m_faceName.empty() )
|
|
||||||
{
|
{
|
||||||
if ( m_family == wxDEFAULT )
|
m_ctFont.reset(CTFontCreateUIFontForLanguage( m_macUIFontType, 0.0, NULL ));
|
||||||
|
|
||||||
|
wxMacCFStringHolder name( CTFontCopyFamilyName( m_ctFont ) );
|
||||||
|
m_faceName = name.AsString();
|
||||||
|
if ( CTFontGetSize(m_ctFont) == 0 )
|
||||||
{
|
{
|
||||||
m_macFontFamily = GetAppFont();
|
m_ctFont.reset(CTFontCreateUIFontForLanguage( m_macUIFontType, 12, NULL ));
|
||||||
FMGetFontFamilyName(m_macFontFamily,qdFontName);
|
|
||||||
m_faceName = wxMacMakeStringFromPascal( qdFontName );
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
m_pointSize = CTFontGetSize(m_ctFont) ;
|
||||||
|
// reset this so that future manipulation don't fall back
|
||||||
|
m_macUIFontType = kCTFontNoFontType;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( m_faceName.empty() )
|
||||||
{
|
{
|
||||||
switch ( m_family )
|
switch ( m_family )
|
||||||
{
|
{
|
||||||
@@ -383,93 +282,162 @@ void wxFontRefData::MacFindFont()
|
|||||||
m_faceName = wxT("Times");
|
m_faceName = wxT("Times");
|
||||||
break ;
|
break ;
|
||||||
}
|
}
|
||||||
wxMacStringToPascal( m_faceName , qdFontName );
|
|
||||||
m_macFontFamily = FMGetFontFamilyFromName( qdFontName );
|
|
||||||
if ( m_macFontFamily == kInvalidFontFamily )
|
|
||||||
{
|
|
||||||
wxLogDebug( wxT("ATSFontFamilyFindFromName failed for %s"), m_faceName.c_str() );
|
|
||||||
m_macFontFamily = GetAppFont();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxMacCFStringHolder cf( m_faceName, wxLocale::GetSystemEncoding() );
|
||||||
|
CTFontSymbolicTraits traits = 0;
|
||||||
|
|
||||||
|
if (m_weight == wxBOLD)
|
||||||
|
traits |= kCTFontBoldTrait;
|
||||||
|
if (m_style == wxITALIC || m_style == wxSLANT)
|
||||||
|
traits |= kCTFontItalicTrait;
|
||||||
|
|
||||||
|
m_ctFont.reset( wxMacCreateCTFont( cf, traits, m_pointSize ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if wxMAC_USE_ATSU_TEXT
|
||||||
|
{
|
||||||
|
Str255 qdFontName ;
|
||||||
|
if ( m_macThemeFontID != kThemeCurrentPortFont )
|
||||||
|
{
|
||||||
|
Style style ;
|
||||||
|
GetThemeFont( m_macThemeFontID, GetApplicationScript(), qdFontName, &m_macFontSize, &style );
|
||||||
|
if ( m_macFontSize == 0 )
|
||||||
|
m_macFontSize = 12;
|
||||||
|
m_macFontStyle = style ;
|
||||||
|
m_faceName = wxMacMakeStringFromPascal( qdFontName );
|
||||||
|
if ( m_macFontStyle & bold )
|
||||||
|
m_weight = wxBOLD ;
|
||||||
|
else
|
||||||
|
m_weight = wxNORMAL ;
|
||||||
|
if ( m_macFontStyle & italic )
|
||||||
|
m_style = wxITALIC ;
|
||||||
|
if ( m_macFontStyle & underline )
|
||||||
|
m_underlined = true ;
|
||||||
|
m_pointSize = m_macFontSize ;
|
||||||
|
m_macFontFamily = FMGetFontFamilyFromName( qdFontName );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ( m_faceName == wxT("systemfont") )
|
if ( m_faceName.empty() )
|
||||||
m_macFontFamily = GetSysFont();
|
|
||||||
else if ( m_faceName == wxT("applicationfont") )
|
|
||||||
m_macFontFamily = GetAppFont();
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
wxMacCFStringHolder cf( m_faceName, wxLocale::GetSystemEncoding() );
|
if ( m_family == wxDEFAULT )
|
||||||
ATSFontFamilyRef atsfamily = ATSFontFamilyFindFromName( cf , kATSOptionFlagsDefault );
|
|
||||||
if ( atsfamily == (ATSFontFamilyRef) -1 )
|
|
||||||
{
|
{
|
||||||
wxLogDebug( wxT("ATSFontFamilyFindFromName failed for ") + m_faceName );
|
|
||||||
m_macFontFamily = GetAppFont();
|
m_macFontFamily = GetAppFont();
|
||||||
|
FMGetFontFamilyName(m_macFontFamily,qdFontName);
|
||||||
|
m_faceName = wxMacMakeStringFromPascal( qdFontName );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_macFontFamily = FMGetFontFamilyFromATSFontFamilyRef( atsfamily );
|
{
|
||||||
|
switch ( m_family )
|
||||||
|
{
|
||||||
|
case wxSCRIPT :
|
||||||
|
case wxROMAN :
|
||||||
|
case wxDECORATIVE :
|
||||||
|
m_faceName = wxT("Times");
|
||||||
|
break ;
|
||||||
|
|
||||||
|
case wxSWISS :
|
||||||
|
m_faceName = wxT("Lucida Grande");
|
||||||
|
break ;
|
||||||
|
|
||||||
|
case wxMODERN :
|
||||||
|
case wxTELETYPE:
|
||||||
|
m_faceName = wxT("Monaco");
|
||||||
|
break ;
|
||||||
|
|
||||||
|
default:
|
||||||
|
m_faceName = wxT("Times");
|
||||||
|
break ;
|
||||||
|
}
|
||||||
|
wxMacStringToPascal( m_faceName , qdFontName );
|
||||||
|
m_macFontFamily = FMGetFontFamilyFromName( qdFontName );
|
||||||
|
if ( m_macFontFamily == kInvalidFontFamily )
|
||||||
|
{
|
||||||
|
wxLogDebug( wxT("ATSFontFamilyFindFromName failed for %s"), m_faceName.c_str() );
|
||||||
|
m_macFontFamily = GetAppFont();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ( m_faceName == wxT("systemfont") )
|
||||||
|
m_macFontFamily = GetSysFont();
|
||||||
|
else if ( m_faceName == wxT("applicationfont") )
|
||||||
|
m_macFontFamily = GetAppFont();
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxMacCFStringHolder cf( m_faceName, wxLocale::GetSystemEncoding() );
|
||||||
|
ATSFontFamilyRef atsfamily = ATSFontFamilyFindFromName( cf , kATSOptionFlagsDefault );
|
||||||
|
if ( atsfamily == (ATSFontFamilyRef) -1 )
|
||||||
|
{
|
||||||
|
wxLogDebug( wxT("ATSFontFamilyFindFromName failed for ") + m_faceName );
|
||||||
|
m_macFontFamily = GetAppFont();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
m_macFontFamily = FMGetFontFamilyFromATSFontFamilyRef( atsfamily );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
m_macFontStyle = 0;
|
||||||
|
if (m_weight == wxBOLD)
|
||||||
|
m_macFontStyle |= bold;
|
||||||
|
if (m_style == wxITALIC || m_style == wxSLANT)
|
||||||
|
m_macFontStyle |= italic;
|
||||||
|
if (m_underlined)
|
||||||
|
m_macFontStyle |= underline;
|
||||||
|
m_macFontSize = m_pointSize ;
|
||||||
}
|
}
|
||||||
|
|
||||||
m_macFontStyle = 0;
|
// we try to get as much styles as possible into ATSU
|
||||||
if (m_weight == wxBOLD)
|
|
||||||
m_macFontStyle |= bold;
|
|
||||||
if (m_style == wxITALIC || m_style == wxSLANT)
|
|
||||||
m_macFontStyle |= italic;
|
|
||||||
if (m_underlined)
|
|
||||||
m_macFontStyle |= underline;
|
|
||||||
m_macFontSize = m_pointSize ;
|
|
||||||
}
|
|
||||||
|
|
||||||
// we try to get as much styles as possible into ATSU
|
|
||||||
|
|
||||||
|
|
||||||
// ATSUFontID and FMFont are equivalent
|
// ATSUFontID and FMFont are equivalent
|
||||||
FMFontStyle intrinsicStyle = 0 ;
|
FMFontStyle intrinsicStyle = 0 ;
|
||||||
status = FMGetFontFromFontFamilyInstance( m_macFontFamily , m_macFontStyle , &m_macATSUFontID , &intrinsicStyle);
|
status = FMGetFontFromFontFamilyInstance( m_macFontFamily , m_macFontStyle , &m_macATSUFontID , &intrinsicStyle);
|
||||||
wxASSERT_MSG( status == noErr , wxT("couldn't get an ATSUFont from font family") );
|
wxASSERT_MSG( status == noErr , wxT("couldn't get an ATSUFont from font family") );
|
||||||
m_macATSUAdditionalQDStyles = m_macFontStyle & (~intrinsicStyle );
|
m_macATSUAdditionalQDStyles = m_macFontStyle & (~intrinsicStyle );
|
||||||
|
|
||||||
if ( m_macATSUStyle )
|
if ( m_macATSUStyle )
|
||||||
{
|
{
|
||||||
::ATSUDisposeStyle((ATSUStyle)m_macATSUStyle);
|
::ATSUDisposeStyle((ATSUStyle)m_macATSUStyle);
|
||||||
m_macATSUStyle = NULL ;
|
m_macATSUStyle = NULL ;
|
||||||
}
|
}
|
||||||
|
|
||||||
status = ::ATSUCreateStyle((ATSUStyle *)&m_macATSUStyle);
|
status = ::ATSUCreateStyle((ATSUStyle *)&m_macATSUStyle);
|
||||||
wxASSERT_MSG( status == noErr , wxT("couldn't create ATSU style") );
|
wxASSERT_MSG( status == noErr , wxT("couldn't create ATSU style") );
|
||||||
|
|
||||||
ATSUAttributeTag atsuTags[] =
|
ATSUAttributeTag atsuTags[] =
|
||||||
{
|
{
|
||||||
kATSUFontTag ,
|
kATSUFontTag ,
|
||||||
kATSUSizeTag ,
|
kATSUSizeTag ,
|
||||||
kATSUVerticalCharacterTag,
|
kATSUVerticalCharacterTag,
|
||||||
kATSUQDBoldfaceTag ,
|
kATSUQDBoldfaceTag ,
|
||||||
kATSUQDItalicTag ,
|
kATSUQDItalicTag ,
|
||||||
kATSUQDUnderlineTag ,
|
kATSUQDUnderlineTag ,
|
||||||
kATSUQDCondensedTag ,
|
kATSUQDCondensedTag ,
|
||||||
kATSUQDExtendedTag ,
|
kATSUQDExtendedTag ,
|
||||||
};
|
};
|
||||||
ByteCount atsuSizes[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
|
ByteCount atsuSizes[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
|
||||||
{
|
{
|
||||||
sizeof( ATSUFontID ) ,
|
sizeof( ATSUFontID ) ,
|
||||||
sizeof( Fixed ) ,
|
sizeof( Fixed ) ,
|
||||||
sizeof( ATSUVerticalCharacterType),
|
sizeof( ATSUVerticalCharacterType),
|
||||||
sizeof( Boolean ) ,
|
sizeof( Boolean ) ,
|
||||||
sizeof( Boolean ) ,
|
sizeof( Boolean ) ,
|
||||||
sizeof( Boolean ) ,
|
sizeof( Boolean ) ,
|
||||||
sizeof( Boolean ) ,
|
sizeof( Boolean ) ,
|
||||||
sizeof( Boolean ) ,
|
sizeof( Boolean ) ,
|
||||||
};
|
};
|
||||||
|
|
||||||
Boolean kTrue = true ;
|
Boolean kTrue = true ;
|
||||||
Boolean kFalse = false ;
|
Boolean kFalse = false ;
|
||||||
|
|
||||||
Fixed atsuSize = IntToFixed( m_macFontSize );
|
Fixed atsuSize = IntToFixed( m_macFontSize );
|
||||||
ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal;
|
ATSUVerticalCharacterType kHorizontal = kATSUStronglyHorizontal;
|
||||||
ATSUAttributeValuePtr atsuValues[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
|
ATSUAttributeValuePtr atsuValues[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
|
||||||
{
|
{
|
||||||
&m_macATSUFontID ,
|
&m_macATSUFontID ,
|
||||||
&atsuSize ,
|
&atsuSize ,
|
||||||
&kHorizontal,
|
&kHorizontal,
|
||||||
@@ -478,14 +446,16 @@ void wxFontRefData::MacFindFont()
|
|||||||
(m_macATSUAdditionalQDStyles & underline) ? &kTrue : &kFalse ,
|
(m_macATSUAdditionalQDStyles & underline) ? &kTrue : &kFalse ,
|
||||||
(m_macATSUAdditionalQDStyles & condense) ? &kTrue : &kFalse ,
|
(m_macATSUAdditionalQDStyles & condense) ? &kTrue : &kFalse ,
|
||||||
(m_macATSUAdditionalQDStyles & extend) ? &kTrue : &kFalse ,
|
(m_macATSUAdditionalQDStyles & extend) ? &kTrue : &kFalse ,
|
||||||
};
|
};
|
||||||
|
|
||||||
status = ::ATSUSetAttributes(
|
status = ::ATSUSetAttributes(
|
||||||
(ATSUStyle)m_macATSUStyle,
|
(ATSUStyle)m_macATSUStyle,
|
||||||
sizeof(atsuTags) / sizeof(ATSUAttributeTag) ,
|
sizeof(atsuTags) / sizeof(ATSUAttributeTag) ,
|
||||||
atsuTags, atsuSizes, atsuValues);
|
atsuTags, atsuSizes, atsuValues);
|
||||||
|
|
||||||
wxASSERT_MSG( status == noErr , wxT("couldn't modify ATSU style") );
|
wxASSERT_MSG( status == noErr , wxT("couldn't modify ATSU style") );
|
||||||
|
return;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -526,7 +496,7 @@ bool wxFont::Create(int pointSize,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __LP64__
|
#if wxMAC_USE_CORE_TEXT
|
||||||
|
|
||||||
bool wxFont::MacCreateUIFont(wxUint32 ctFontType )
|
bool wxFont::MacCreateUIFont(wxUint32 ctFontType )
|
||||||
{
|
{
|
||||||
@@ -546,18 +516,23 @@ bool wxFont::MacCreateUIFont(wxUint32 ctFontType )
|
|||||||
|
|
||||||
bool wxFont::MacCreateThemeFont(wxUint16 themeFontID)
|
bool wxFont::MacCreateThemeFont(wxUint16 themeFontID)
|
||||||
{
|
{
|
||||||
#ifdef __LP64__
|
#if wxMAC_USE_CORE_TEXT
|
||||||
return MacCreateUIFont(HIThemeGetUIFontType(themeFontID));
|
if ( HIThemeGetUIFontType != NULL )
|
||||||
#else
|
{
|
||||||
UnRef();
|
return MacCreateUIFont(HIThemeGetUIFontType(themeFontID));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if wxMAC_USE_CORE_TEXT
|
||||||
|
{
|
||||||
|
UnRef();
|
||||||
|
|
||||||
m_refData = new wxFontRefData(
|
m_refData = new wxFontRefData(
|
||||||
12, wxDEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL,
|
12, wxDEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL,
|
||||||
false, wxEmptyString, wxFONTENCODING_DEFAULT );
|
false, wxEmptyString, wxFONTENCODING_DEFAULT );
|
||||||
|
|
||||||
M_FONTDATA->m_macThemeFontID = themeFontID ;
|
|
||||||
RealizeResource();
|
|
||||||
|
|
||||||
|
M_FONTDATA->m_macThemeFontID = themeFontID ;
|
||||||
|
RealizeResource();
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -599,6 +574,9 @@ void wxFont::Unshare()
|
|||||||
|
|
||||||
void wxFont::SetPointSize(int pointSize)
|
void wxFont::SetPointSize(int pointSize)
|
||||||
{
|
{
|
||||||
|
if ( M_FONTDATA->m_pointSize == pointSize )
|
||||||
|
return;
|
||||||
|
|
||||||
Unshare();
|
Unshare();
|
||||||
|
|
||||||
M_FONTDATA->m_pointSize = pointSize;
|
M_FONTDATA->m_pointSize = pointSize;
|
||||||
@@ -739,7 +717,7 @@ bool wxFont::GetNoAntiAliasing() const
|
|||||||
return M_FONTDATA->m_noAA;
|
return M_FONTDATA->m_noAA;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef __LP64__
|
#if wxMAC_USE_ATSU_TEXT
|
||||||
|
|
||||||
short wxFont::MacGetFontNum() const
|
short wxFont::MacGetFontNum() const
|
||||||
{
|
{
|
||||||
@@ -789,20 +767,15 @@ wxUint16 wxFont::MacGetThemeFontID() const
|
|||||||
|
|
||||||
return M_FONTDATA->m_macThemeFontID;
|
return M_FONTDATA->m_macThemeFontID;
|
||||||
}
|
}
|
||||||
#else
|
#endif
|
||||||
|
|
||||||
|
#if wxMAC_USE_CORE_TEXT
|
||||||
|
|
||||||
const void * wxFont::MacGetCTFont() const
|
const void * wxFont::MacGetCTFont() const
|
||||||
{
|
{
|
||||||
wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
|
wxCHECK_MSG( M_FONTDATA != NULL , 0, wxT("invalid font") );
|
||||||
|
|
||||||
return M_FONTDATA->m_macFontRef;
|
return (CTFontRef)(M_FONTDATA->m_ctFont);
|
||||||
}
|
|
||||||
|
|
||||||
// to be removed
|
|
||||||
void * wxFont::MacGetATSUStyle() const
|
|
||||||
{
|
|
||||||
wxCHECK_MSG( M_FONTDATA != NULL , NULL, wxT("invalid font") );
|
|
||||||
|
|
||||||
return M_FONTDATA->m_macATSUStyle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@@ -696,18 +696,37 @@ public:
|
|||||||
wxMacCoreGraphicsFontData( wxGraphicsRenderer* renderer, const wxFont &font, const wxColour& col );
|
wxMacCoreGraphicsFontData( wxGraphicsRenderer* renderer, const wxFont &font, const wxColour& col );
|
||||||
~wxMacCoreGraphicsFontData();
|
~wxMacCoreGraphicsFontData();
|
||||||
|
|
||||||
|
#if wxMAC_USE_ATSU_TEXT
|
||||||
virtual ATSUStyle GetATSUStyle() { return m_macATSUIStyle; }
|
virtual ATSUStyle GetATSUStyle() { return m_macATSUIStyle; }
|
||||||
|
#endif
|
||||||
|
#if wxMAC_USE_CORE_TEXT
|
||||||
|
CTFontRef GetCTFont() const { return m_ctFont ; }
|
||||||
|
#endif
|
||||||
|
wxColour GetColour() const { return m_colour ; }
|
||||||
|
|
||||||
|
bool GetUnderlined() const { return m_underlined ; }
|
||||||
private :
|
private :
|
||||||
|
wxColour m_colour;
|
||||||
|
bool m_underlined;
|
||||||
|
#if wxMAC_USE_ATSU_TEXT
|
||||||
ATSUStyle m_macATSUIStyle;
|
ATSUStyle m_macATSUIStyle;
|
||||||
|
#endif
|
||||||
|
#if wxMAC_USE_CORE_TEXT
|
||||||
|
wxCFRef< CTFontRef > m_ctFont;
|
||||||
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
wxMacCoreGraphicsFontData::wxMacCoreGraphicsFontData(wxGraphicsRenderer* renderer, const wxFont &font, const wxColour& col) : wxGraphicsObjectRefData( renderer )
|
wxMacCoreGraphicsFontData::wxMacCoreGraphicsFontData(wxGraphicsRenderer* renderer, const wxFont &font, const wxColour& col) : wxGraphicsObjectRefData( renderer )
|
||||||
{
|
{
|
||||||
m_macATSUIStyle = NULL;
|
m_macATSUIStyle = NULL;
|
||||||
|
OSStatus status = noErr;
|
||||||
|
m_colour = col;
|
||||||
|
m_underlined = font.GetUnderlined();
|
||||||
|
|
||||||
#if wxMAC_USE_CORE_TEXT
|
#if wxMAC_USE_CORE_TEXT
|
||||||
#elif wxMAC_USE_ATSU_TEXT
|
m_ctFont.reset( wxCFRetain((CTFontRef) font.MacGetCTFont()) );
|
||||||
OSStatus status;
|
#endif
|
||||||
|
#if wxMAC_USE_ATSU_TEXT
|
||||||
|
|
||||||
status = ATSUCreateAndCopyStyle( (ATSUStyle) font.MacGetATSUStyle() , &m_macATSUIStyle );
|
status = ATSUCreateAndCopyStyle( (ATSUStyle) font.MacGetATSUStyle() , &m_macATSUIStyle );
|
||||||
|
|
||||||
@@ -739,20 +758,23 @@ wxMacCoreGraphicsFontData::wxMacCoreGraphicsFontData(wxGraphicsRenderer* rendere
|
|||||||
atsuTags, atsuSizes, atsuValues);
|
atsuTags, atsuSizes, atsuValues);
|
||||||
|
|
||||||
wxASSERT_MSG( status == noErr , wxT("couldn't modify ATSU style") );
|
wxASSERT_MSG( status == noErr , wxT("couldn't modify ATSU style") );
|
||||||
#elif WXMAC_USE_CG_TEXT
|
#endif
|
||||||
|
#if WXMAC_USE_CG_TEXT
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMacCoreGraphicsFontData::~wxMacCoreGraphicsFontData()
|
wxMacCoreGraphicsFontData::~wxMacCoreGraphicsFontData()
|
||||||
{
|
{
|
||||||
#if wxMAC_USE_CORE_TEXT
|
#if wxMAC_USE_CORE_TEXT
|
||||||
#elif wxMAC_USE_ATSU_TEXT
|
#endif
|
||||||
|
#if wxMAC_USE_ATSU_TEXT
|
||||||
if ( m_macATSUIStyle )
|
if ( m_macATSUIStyle )
|
||||||
{
|
{
|
||||||
::ATSUDisposeStyle((ATSUStyle)m_macATSUIStyle);
|
::ATSUDisposeStyle((ATSUStyle)m_macATSUIStyle);
|
||||||
m_macATSUIStyle = NULL;
|
m_macATSUIStyle = NULL;
|
||||||
}
|
}
|
||||||
#elif WXMAC_USE_CG_TEXT
|
#endif
|
||||||
|
#if WXMAC_USE_CG_TEXT
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1720,10 +1742,39 @@ void wxMacCoreGraphicsContext::DrawText( const wxString &str, wxDouble x, wxDoub
|
|||||||
|
|
||||||
EnsureIsValid();
|
EnsureIsValid();
|
||||||
#if wxMAC_USE_CORE_TEXT
|
#if wxMAC_USE_CORE_TEXT
|
||||||
// TODO core text implementation here
|
if ( UMAGetSystemVersion() >= 0x1050 )
|
||||||
#elif wxMAC_USE_ATSU_TEXT
|
{
|
||||||
DrawText(str, x, y, 0.0);
|
wxMacCoreGraphicsFontData* fref = (wxMacCoreGraphicsFontData*)m_font.GetRefData();
|
||||||
#elif WXMAC_USE_CG_TEXT
|
wxMacCFStringHolder text(str, wxLocale::GetSystemEncoding() );
|
||||||
|
CTFontRef font = fref->GetCTFont();
|
||||||
|
CGColorRef col = fref->GetColour().GetPixel();
|
||||||
|
CTUnderlineStyle ustyle = fref->GetUnderlined() ? kCTUnderlineStyleSingle : kCTUnderlineStyleNone ;
|
||||||
|
wxCFRef<CFNumberRef> underlined( CFNumberCreate(NULL, kCFNumberSInt32Type, &ustyle) );
|
||||||
|
CFStringRef keys[] = { kCTFontAttributeName , kCTForegroundColorAttributeName, kCTUnderlineStyleAttributeName };
|
||||||
|
CFTypeRef values[] = { font, col, underlined };
|
||||||
|
wxCFRef<CFDictionaryRef> attributes( CFDictionaryCreate(kCFAllocatorDefault, (const void**) &keys, (const void**) &values,
|
||||||
|
WXSIZEOF( keys ), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks) );
|
||||||
|
wxCFRef<CFAttributedStringRef> attrtext( CFAttributedStringCreate(kCFAllocatorDefault, text, attributes) );
|
||||||
|
wxCFRef<CTLineRef> line( CTLineCreateWithAttributedString(attrtext) );
|
||||||
|
|
||||||
|
y += CTFontGetAscent(font);
|
||||||
|
|
||||||
|
CGContextSaveGState(m_cgContext);
|
||||||
|
CGContextTranslateCTM(m_cgContext, x, y);
|
||||||
|
CGContextScaleCTM(m_cgContext, 1, -1);
|
||||||
|
CGContextSetTextPosition(m_cgContext, 0, 0);
|
||||||
|
CTLineDraw( line, m_cgContext );
|
||||||
|
CGContextRestoreGState(m_cgContext);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if wxMAC_USE_ATSU_TEXT
|
||||||
|
{
|
||||||
|
DrawText(str, x, y, 0.0);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if WXMAC_USE_CG_TEXT
|
||||||
// TODO core graphics text implementation here
|
// TODO core graphics text implementation here
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1735,115 +1786,124 @@ void wxMacCoreGraphicsContext::DrawText( const wxString &str, wxDouble x, wxDoub
|
|||||||
|
|
||||||
EnsureIsValid();
|
EnsureIsValid();
|
||||||
#if wxMAC_USE_CORE_TEXT
|
#if wxMAC_USE_CORE_TEXT
|
||||||
// default implementation takes care of rotation and calls non rotated DrawText afterwards
|
if ( UMAGetSystemVersion() >= 0x1050 )
|
||||||
wxGraphicsContext::DrawText( str, x, y, angle );
|
{
|
||||||
#elif wxMAC_USE_ATSU_TEXT
|
// default implementation takes care of rotation and calls non rotated DrawText afterwards
|
||||||
OSStatus status = noErr;
|
wxGraphicsContext::DrawText( str, x, y, angle );
|
||||||
ATSUTextLayout atsuLayout;
|
return;
|
||||||
UniCharCount chars = str.length();
|
}
|
||||||
UniChar* ubuf = NULL;
|
#endif
|
||||||
|
#if wxMAC_USE_ATSU_TEXT
|
||||||
|
{
|
||||||
|
OSStatus status = noErr;
|
||||||
|
ATSUTextLayout atsuLayout;
|
||||||
|
UniCharCount chars = str.length();
|
||||||
|
UniChar* ubuf = NULL;
|
||||||
|
|
||||||
#if SIZEOF_WCHAR_T == 4
|
#if SIZEOF_WCHAR_T == 4
|
||||||
wxMBConvUTF16 converter;
|
wxMBConvUTF16 converter;
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
size_t unicharlen = converter.WC2MB( NULL , str.wc_str() , 0 );
|
size_t unicharlen = converter.WC2MB( NULL , str.wc_str() , 0 );
|
||||||
ubuf = (UniChar*) malloc( unicharlen + 2 );
|
ubuf = (UniChar*) malloc( unicharlen + 2 );
|
||||||
converter.WC2MB( (char*) ubuf , str.wc_str(), unicharlen + 2 );
|
converter.WC2MB( (char*) ubuf , str.wc_str(), unicharlen + 2 );
|
||||||
#else
|
#else
|
||||||
const wxWCharBuffer wchar = str.wc_str( wxConvLocal );
|
const wxWCharBuffer wchar = str.wc_str( wxConvLocal );
|
||||||
size_t unicharlen = converter.WC2MB( NULL , wchar.data() , 0 );
|
size_t unicharlen = converter.WC2MB( NULL , wchar.data() , 0 );
|
||||||
ubuf = (UniChar*) malloc( unicharlen + 2 );
|
ubuf = (UniChar*) malloc( unicharlen + 2 );
|
||||||
converter.WC2MB( (char*) ubuf , wchar.data() , unicharlen + 2 );
|
converter.WC2MB( (char*) ubuf , wchar.data() , unicharlen + 2 );
|
||||||
#endif
|
#endif
|
||||||
chars = unicharlen / 2;
|
chars = unicharlen / 2;
|
||||||
#else
|
#else
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
ubuf = (UniChar*) str.wc_str();
|
ubuf = (UniChar*) str.wc_str();
|
||||||
#else
|
#else
|
||||||
wxWCharBuffer wchar = str.wc_str( wxConvLocal );
|
wxWCharBuffer wchar = str.wc_str( wxConvLocal );
|
||||||
chars = wxWcslen( wchar.data() );
|
chars = wxWcslen( wchar.data() );
|
||||||
ubuf = (UniChar*) wchar.data();
|
ubuf = (UniChar*) wchar.data();
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ATSUStyle style = (((wxMacCoreGraphicsFontData*)m_font.GetRefData())->GetATSUStyle());
|
ATSUStyle style = (((wxMacCoreGraphicsFontData*)m_font.GetRefData())->GetATSUStyle());
|
||||||
status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) ubuf , 0 , chars , chars , 1 ,
|
status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) ubuf , 0 , chars , chars , 1 ,
|
||||||
&chars , &style , &atsuLayout );
|
&chars , &style , &atsuLayout );
|
||||||
|
|
||||||
wxASSERT_MSG( status == noErr , wxT("couldn't create the layout of the rotated text") );
|
wxASSERT_MSG( status == noErr , wxT("couldn't create the layout of the rotated text") );
|
||||||
|
|
||||||
status = ::ATSUSetTransientFontMatching( atsuLayout , true );
|
status = ::ATSUSetTransientFontMatching( atsuLayout , true );
|
||||||
wxASSERT_MSG( status == noErr , wxT("couldn't setup transient font matching") );
|
wxASSERT_MSG( status == noErr , wxT("couldn't setup transient font matching") );
|
||||||
|
|
||||||
int iAngle = int( angle * RAD2DEG );
|
int iAngle = int( angle * RAD2DEG );
|
||||||
if ( abs(iAngle) > 0 )
|
if ( abs(iAngle) > 0 )
|
||||||
{
|
|
||||||
Fixed atsuAngle = IntToFixed( iAngle );
|
|
||||||
ATSUAttributeTag atsuTags[] =
|
|
||||||
{
|
{
|
||||||
kATSULineRotationTag ,
|
Fixed atsuAngle = IntToFixed( iAngle );
|
||||||
};
|
ATSUAttributeTag atsuTags[] =
|
||||||
ByteCount atsuSizes[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
|
{
|
||||||
|
kATSULineRotationTag ,
|
||||||
|
};
|
||||||
|
ByteCount atsuSizes[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
|
||||||
|
{
|
||||||
|
sizeof( Fixed ) ,
|
||||||
|
};
|
||||||
|
ATSUAttributeValuePtr atsuValues[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
|
||||||
|
{
|
||||||
|
&atsuAngle ,
|
||||||
|
};
|
||||||
|
status = ::ATSUSetLayoutControls(atsuLayout , sizeof(atsuTags) / sizeof(ATSUAttributeTag),
|
||||||
|
atsuTags, atsuSizes, atsuValues );
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
sizeof( Fixed ) ,
|
ATSUAttributeTag atsuTags[] =
|
||||||
};
|
{
|
||||||
ATSUAttributeValuePtr atsuValues[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
|
kATSUCGContextTag ,
|
||||||
{
|
};
|
||||||
&atsuAngle ,
|
ByteCount atsuSizes[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
|
||||||
};
|
{
|
||||||
status = ::ATSUSetLayoutControls(atsuLayout , sizeof(atsuTags) / sizeof(ATSUAttributeTag),
|
sizeof( CGContextRef ) ,
|
||||||
atsuTags, atsuSizes, atsuValues );
|
};
|
||||||
}
|
ATSUAttributeValuePtr atsuValues[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
|
||||||
|
{
|
||||||
|
&m_cgContext ,
|
||||||
|
};
|
||||||
|
status = ::ATSUSetLayoutControls(atsuLayout , sizeof(atsuTags) / sizeof(ATSUAttributeTag),
|
||||||
|
atsuTags, atsuSizes, atsuValues );
|
||||||
|
}
|
||||||
|
|
||||||
{
|
ATSUTextMeasurement textBefore, textAfter;
|
||||||
ATSUAttributeTag atsuTags[] =
|
ATSUTextMeasurement ascent, descent;
|
||||||
{
|
|
||||||
kATSUCGContextTag ,
|
|
||||||
};
|
|
||||||
ByteCount atsuSizes[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
|
|
||||||
{
|
|
||||||
sizeof( CGContextRef ) ,
|
|
||||||
};
|
|
||||||
ATSUAttributeValuePtr atsuValues[sizeof(atsuTags) / sizeof(ATSUAttributeTag)] =
|
|
||||||
{
|
|
||||||
&m_cgContext ,
|
|
||||||
};
|
|
||||||
status = ::ATSUSetLayoutControls(atsuLayout , sizeof(atsuTags) / sizeof(ATSUAttributeTag),
|
|
||||||
atsuTags, atsuSizes, atsuValues );
|
|
||||||
}
|
|
||||||
|
|
||||||
ATSUTextMeasurement textBefore, textAfter;
|
status = ::ATSUGetUnjustifiedBounds( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd,
|
||||||
ATSUTextMeasurement ascent, descent;
|
&textBefore , &textAfter, &ascent , &descent );
|
||||||
|
|
||||||
status = ::ATSUGetUnjustifiedBounds( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd,
|
wxASSERT_MSG( status == noErr , wxT("couldn't measure the rotated text") );
|
||||||
&textBefore , &textAfter, &ascent , &descent );
|
|
||||||
|
|
||||||
wxASSERT_MSG( status == noErr , wxT("couldn't measure the rotated text") );
|
Rect rect;
|
||||||
|
x += (int)(sin(angle) * FixedToInt(ascent));
|
||||||
|
y += (int)(cos(angle) * FixedToInt(ascent));
|
||||||
|
|
||||||
Rect rect;
|
status = ::ATSUMeasureTextImage( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd,
|
||||||
x += (int)(sin(angle) * FixedToInt(ascent));
|
IntToFixed(x) , IntToFixed(y) , &rect );
|
||||||
y += (int)(cos(angle) * FixedToInt(ascent));
|
wxASSERT_MSG( status == noErr , wxT("couldn't measure the rotated text") );
|
||||||
|
|
||||||
status = ::ATSUMeasureTextImage( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd,
|
CGContextSaveGState(m_cgContext);
|
||||||
IntToFixed(x) , IntToFixed(y) , &rect );
|
CGContextTranslateCTM(m_cgContext, x, y);
|
||||||
wxASSERT_MSG( status == noErr , wxT("couldn't measure the rotated text") );
|
CGContextScaleCTM(m_cgContext, 1, -1);
|
||||||
|
status = ::ATSUDrawText( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd,
|
||||||
|
IntToFixed(0) , IntToFixed(0) );
|
||||||
|
|
||||||
CGContextSaveGState(m_cgContext);
|
wxASSERT_MSG( status == noErr , wxT("couldn't draw the rotated text") );
|
||||||
CGContextTranslateCTM(m_cgContext, x, y);
|
|
||||||
CGContextScaleCTM(m_cgContext, 1, -1);
|
|
||||||
status = ::ATSUDrawText( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd,
|
|
||||||
IntToFixed(0) , IntToFixed(0) );
|
|
||||||
|
|
||||||
wxASSERT_MSG( status == noErr , wxT("couldn't draw the rotated text") );
|
CGContextRestoreGState(m_cgContext);
|
||||||
|
|
||||||
CGContextRestoreGState(m_cgContext);
|
::ATSUDisposeTextLayout(atsuLayout);
|
||||||
|
|
||||||
::ATSUDisposeTextLayout(atsuLayout);
|
|
||||||
|
|
||||||
#if SIZEOF_WCHAR_T == 4
|
#if SIZEOF_WCHAR_T == 4
|
||||||
free( ubuf );
|
free( ubuf );
|
||||||
#endif
|
#endif
|
||||||
#elif WXMAC_USE_CG_TEXT
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if WXMAC_USE_CG_TEXT
|
||||||
// default implementation takes care of rotation and calls non rotated DrawText afterwards
|
// default implementation takes care of rotation and calls non rotated DrawText afterwards
|
||||||
wxGraphicsContext::DrawText( str, x, y, angle );
|
wxGraphicsContext::DrawText( str, x, y, angle );
|
||||||
#endif
|
#endif
|
||||||
@@ -1867,63 +1927,94 @@ void wxMacCoreGraphicsContext::GetTextExtent( const wxString &str, wxDouble *wid
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
#if wxMAC_USE_CORE_TEXT
|
#if wxMAC_USE_CORE_TEXT
|
||||||
// TODO core text implementation here
|
if ( UMAGetSystemVersion() >= 0x1050 )
|
||||||
#elif wxMAC_USE_ATSU_TEXT
|
{
|
||||||
OSStatus status = noErr;
|
wxMacCoreGraphicsFontData* fref = (wxMacCoreGraphicsFontData*)m_font.GetRefData();
|
||||||
|
CTFontRef font = fref->GetCTFont();
|
||||||
|
|
||||||
ATSUTextLayout atsuLayout;
|
wxMacCFStringHolder text(str, wxLocale::GetSystemEncoding() );
|
||||||
UniCharCount chars = str.length();
|
CFStringRef keys[] = { kCTFontAttributeName };
|
||||||
UniChar* ubuf = NULL;
|
CFTypeRef values[] = { font };
|
||||||
|
wxCFRef<CFDictionaryRef> attributes( CFDictionaryCreate(kCFAllocatorDefault, (const void**) &keys, (const void**) &values,
|
||||||
|
WXSIZEOF( keys ), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks) );
|
||||||
|
wxCFRef<CFAttributedStringRef> attrtext( CFAttributedStringCreate(kCFAllocatorDefault, text, attributes) );
|
||||||
|
wxCFRef<CTLineRef> line( CTLineCreateWithAttributedString(attrtext) );
|
||||||
|
|
||||||
|
CGFloat w, a, d, l;
|
||||||
|
|
||||||
|
w = CTLineGetTypographicBounds(line, &a, &d, &l) ;
|
||||||
|
|
||||||
|
if ( height )
|
||||||
|
*height = a+d+l;
|
||||||
|
if ( descent )
|
||||||
|
*descent = d;
|
||||||
|
if ( externalLeading )
|
||||||
|
*externalLeading = l;
|
||||||
|
if ( width )
|
||||||
|
*width = w;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if wxMAC_USE_ATSU_TEXT
|
||||||
|
{
|
||||||
|
OSStatus status = noErr;
|
||||||
|
|
||||||
|
ATSUTextLayout atsuLayout;
|
||||||
|
UniCharCount chars = str.length();
|
||||||
|
UniChar* ubuf = NULL;
|
||||||
|
|
||||||
#if SIZEOF_WCHAR_T == 4
|
#if SIZEOF_WCHAR_T == 4
|
||||||
wxMBConvUTF16 converter;
|
wxMBConvUTF16 converter;
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
size_t unicharlen = converter.WC2MB( NULL , str.wc_str() , 0 );
|
size_t unicharlen = converter.WC2MB( NULL , str.wc_str() , 0 );
|
||||||
ubuf = (UniChar*) malloc( unicharlen + 2 );
|
ubuf = (UniChar*) malloc( unicharlen + 2 );
|
||||||
converter.WC2MB( (char*) ubuf , str.wc_str(), unicharlen + 2 );
|
converter.WC2MB( (char*) ubuf , str.wc_str(), unicharlen + 2 );
|
||||||
#else
|
#else
|
||||||
const wxWCharBuffer wchar = str.wc_str( wxConvLocal );
|
const wxWCharBuffer wchar = str.wc_str( wxConvLocal );
|
||||||
size_t unicharlen = converter.WC2MB( NULL , wchar.data() , 0 );
|
size_t unicharlen = converter.WC2MB( NULL , wchar.data() , 0 );
|
||||||
ubuf = (UniChar*) malloc( unicharlen + 2 );
|
ubuf = (UniChar*) malloc( unicharlen + 2 );
|
||||||
converter.WC2MB( (char*) ubuf , wchar.data() , unicharlen + 2 );
|
converter.WC2MB( (char*) ubuf , wchar.data() , unicharlen + 2 );
|
||||||
#endif
|
#endif
|
||||||
chars = unicharlen / 2;
|
chars = unicharlen / 2;
|
||||||
#else
|
#else
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
ubuf = (UniChar*) str.wc_str();
|
ubuf = (UniChar*) str.wc_str();
|
||||||
#else
|
#else
|
||||||
wxWCharBuffer wchar = str.wc_str( wxConvLocal );
|
wxWCharBuffer wchar = str.wc_str( wxConvLocal );
|
||||||
chars = wxWcslen( wchar.data() );
|
chars = wxWcslen( wchar.data() );
|
||||||
ubuf = (UniChar*) wchar.data();
|
ubuf = (UniChar*) wchar.data();
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ATSUStyle style = (((wxMacCoreGraphicsFontData*)m_font.GetRefData())->GetATSUStyle());
|
ATSUStyle style = (((wxMacCoreGraphicsFontData*)m_font.GetRefData())->GetATSUStyle());
|
||||||
status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) ubuf , 0 , chars , chars , 1 ,
|
status = ::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) ubuf , 0 , chars , chars , 1 ,
|
||||||
&chars , &style , &atsuLayout );
|
&chars , &style , &atsuLayout );
|
||||||
|
|
||||||
wxASSERT_MSG( status == noErr , wxT("couldn't create the layout of the text") );
|
wxASSERT_MSG( status == noErr , wxT("couldn't create the layout of the text") );
|
||||||
|
|
||||||
ATSUTextMeasurement textBefore, textAfter;
|
ATSUTextMeasurement textBefore, textAfter;
|
||||||
ATSUTextMeasurement textAscent, textDescent;
|
ATSUTextMeasurement textAscent, textDescent;
|
||||||
|
|
||||||
status = ::ATSUGetUnjustifiedBounds( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd,
|
status = ::ATSUGetUnjustifiedBounds( atsuLayout, kATSUFromTextBeginning, kATSUToTextEnd,
|
||||||
&textBefore , &textAfter, &textAscent , &textDescent );
|
&textBefore , &textAfter, &textAscent , &textDescent );
|
||||||
|
|
||||||
if ( height )
|
if ( height )
|
||||||
*height = FixedToInt(textAscent + textDescent);
|
*height = FixedToInt(textAscent + textDescent);
|
||||||
if ( descent )
|
if ( descent )
|
||||||
*descent = FixedToInt(textDescent);
|
*descent = FixedToInt(textDescent);
|
||||||
if ( externalLeading )
|
if ( externalLeading )
|
||||||
*externalLeading = 0;
|
*externalLeading = 0;
|
||||||
if ( width )
|
if ( width )
|
||||||
*width = FixedToInt(textAfter - textBefore);
|
*width = FixedToInt(textAfter - textBefore);
|
||||||
|
|
||||||
::ATSUDisposeTextLayout(atsuLayout);
|
::ATSUDisposeTextLayout(atsuLayout);
|
||||||
#if SIZEOF_WCHAR_T == 4
|
#if SIZEOF_WCHAR_T == 4
|
||||||
free( ubuf ) ;
|
free( ubuf ) ;
|
||||||
#endif
|
#endif
|
||||||
#elif WXMAC_USE_CG_TEXT
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if WXMAC_USE_CG_TEXT
|
||||||
// TODO core graphics text implementation here
|
// TODO core graphics text implementation here
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -1937,60 +2028,83 @@ void wxMacCoreGraphicsContext::GetPartialTextExtents(const wxString& text, wxArr
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
#if wxMAC_USE_CORE_TEXT
|
#if wxMAC_USE_CORE_TEXT
|
||||||
// TODO core text implementation here
|
|
||||||
#elif wxMAC_USE_ATSU_TEXT
|
|
||||||
ATSUTextLayout atsuLayout;
|
|
||||||
UniCharCount chars = text.length();
|
|
||||||
UniChar* ubuf = NULL;
|
|
||||||
|
|
||||||
#if SIZEOF_WCHAR_T == 4
|
|
||||||
wxMBConvUTF16 converter;
|
|
||||||
#if wxUSE_UNICODE
|
|
||||||
size_t unicharlen = converter.WC2MB( NULL , text.wc_str() , 0 );
|
|
||||||
ubuf = (UniChar*) malloc( unicharlen + 2 );
|
|
||||||
converter.WC2MB( (char*) ubuf , text.wc_str(), unicharlen + 2 );
|
|
||||||
#else
|
|
||||||
const wxWCharBuffer wchar = text.wc_str( wxConvLocal );
|
|
||||||
size_t unicharlen = converter.WC2MB( NULL , wchar.data() , 0 );
|
|
||||||
ubuf = (UniChar*) malloc( unicharlen + 2 );
|
|
||||||
converter.WC2MB( (char*) ubuf , wchar.data() , unicharlen + 2 );
|
|
||||||
#endif
|
|
||||||
chars = unicharlen / 2;
|
|
||||||
#else
|
|
||||||
#if wxUSE_UNICODE
|
|
||||||
ubuf = (UniChar*) text.wc_str();
|
|
||||||
#else
|
|
||||||
wxWCharBuffer wchar = text.wc_str( wxConvLocal );
|
|
||||||
chars = wxWcslen( wchar.data() );
|
|
||||||
ubuf = (UniChar*) wchar.data();
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
ATSUStyle style = (((wxMacCoreGraphicsFontData*)m_font.GetRefData())->GetATSUStyle());
|
|
||||||
::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) ubuf , 0 , chars , chars , 1 ,
|
|
||||||
&chars , &style , &atsuLayout );
|
|
||||||
|
|
||||||
for ( int pos = 0; pos < (int)chars; pos ++ )
|
|
||||||
{
|
{
|
||||||
unsigned long actualNumberOfBounds = 0;
|
wxMacCoreGraphicsFontData* fref = (wxMacCoreGraphicsFontData*)m_font.GetRefData();
|
||||||
ATSTrapezoid glyphBounds;
|
CTFontRef font = fref->GetCTFont();
|
||||||
|
|
||||||
// We get a single bound, since the text should only require one. If it requires more, there is an issue
|
wxMacCFStringHolder t(text, wxLocale::GetSystemEncoding() );
|
||||||
OSStatus result;
|
CFStringRef keys[] = { kCTFontAttributeName };
|
||||||
result = ATSUGetGlyphBounds( atsuLayout, 0, 0, kATSUFromTextBeginning, pos + 1,
|
CFTypeRef values[] = { font };
|
||||||
kATSUseDeviceOrigins, 1, &glyphBounds, &actualNumberOfBounds );
|
wxCFRef<CFDictionaryRef> attributes( CFDictionaryCreate(kCFAllocatorDefault, (const void**) &keys, (const void**) &values,
|
||||||
if (result != noErr || actualNumberOfBounds != 1 )
|
WXSIZEOF( keys ), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks) );
|
||||||
return;
|
wxCFRef<CFAttributedStringRef> attrtext( CFAttributedStringCreate(kCFAllocatorDefault, t, attributes) );
|
||||||
|
wxCFRef<CTLineRef> line( CTLineCreateWithAttributedString(attrtext) );
|
||||||
|
|
||||||
widths[pos] = FixedToInt( glyphBounds.upperRight.x - glyphBounds.upperLeft.x );
|
int chars = text.length();
|
||||||
//unsigned char uch = s[i];
|
for ( int pos = 0; pos < (int)chars; pos ++ )
|
||||||
|
{
|
||||||
|
widths[pos] = CTLineGetOffsetForStringIndex( line, pos+1 , NULL )+0.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
::ATSUDisposeTextLayout(atsuLayout);
|
|
||||||
#if SIZEOF_WCHAR_T == 4
|
|
||||||
free( ubuf ) ;
|
|
||||||
#endif
|
#endif
|
||||||
#elif WXMAC_USE_CG_TEXT
|
#if wxMAC_USE_ATSU_TEXT
|
||||||
|
{
|
||||||
|
ATSUTextLayout atsuLayout;
|
||||||
|
UniCharCount chars = text.length();
|
||||||
|
UniChar* ubuf = NULL;
|
||||||
|
|
||||||
|
#if SIZEOF_WCHAR_T == 4
|
||||||
|
wxMBConvUTF16 converter;
|
||||||
|
#if wxUSE_UNICODE
|
||||||
|
size_t unicharlen = converter.WC2MB( NULL , text.wc_str() , 0 );
|
||||||
|
ubuf = (UniChar*) malloc( unicharlen + 2 );
|
||||||
|
converter.WC2MB( (char*) ubuf , text.wc_str(), unicharlen + 2 );
|
||||||
|
#else
|
||||||
|
const wxWCharBuffer wchar = text.wc_str( wxConvLocal );
|
||||||
|
size_t unicharlen = converter.WC2MB( NULL , wchar.data() , 0 );
|
||||||
|
ubuf = (UniChar*) malloc( unicharlen + 2 );
|
||||||
|
converter.WC2MB( (char*) ubuf , wchar.data() , unicharlen + 2 );
|
||||||
|
#endif
|
||||||
|
chars = unicharlen / 2;
|
||||||
|
#else
|
||||||
|
#if wxUSE_UNICODE
|
||||||
|
ubuf = (UniChar*) text.wc_str();
|
||||||
|
#else
|
||||||
|
wxWCharBuffer wchar = text.wc_str( wxConvLocal );
|
||||||
|
chars = wxWcslen( wchar.data() );
|
||||||
|
ubuf = (UniChar*) wchar.data();
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ATSUStyle style = (((wxMacCoreGraphicsFontData*)m_font.GetRefData())->GetATSUStyle());
|
||||||
|
::ATSUCreateTextLayoutWithTextPtr( (UniCharArrayPtr) ubuf , 0 , chars , chars , 1 ,
|
||||||
|
&chars , &style , &atsuLayout );
|
||||||
|
|
||||||
|
for ( int pos = 0; pos < (int)chars; pos ++ )
|
||||||
|
{
|
||||||
|
unsigned long actualNumberOfBounds = 0;
|
||||||
|
ATSTrapezoid glyphBounds;
|
||||||
|
|
||||||
|
// We get a single bound, since the text should only require one. If it requires more, there is an issue
|
||||||
|
OSStatus result;
|
||||||
|
result = ATSUGetGlyphBounds( atsuLayout, 0, 0, kATSUFromTextBeginning, pos + 1,
|
||||||
|
kATSUseDeviceOrigins, 1, &glyphBounds, &actualNumberOfBounds );
|
||||||
|
if (result != noErr || actualNumberOfBounds != 1 )
|
||||||
|
return;
|
||||||
|
|
||||||
|
widths[pos] = FixedToInt( glyphBounds.upperRight.x - glyphBounds.upperLeft.x );
|
||||||
|
//unsigned char uch = s[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
::ATSUDisposeTextLayout(atsuLayout);
|
||||||
|
#if SIZEOF_WCHAR_T == 4
|
||||||
|
free( ubuf ) ;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
#if WXMAC_USE_CG_TEXT
|
||||||
// TODO core graphics text implementation here
|
// TODO core graphics text implementation here
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user