facename = GetMSWFaceName();
if ( !facename.empty() )
{
- // the face name returned by GetOutlineTextMetrics() may have
- // these suffixes which we don't count as part of face name
- // because we have separate fields for them so remove them
- wxString basename;
- if ( facename.EndsWith(wxS(" Italic"), &basename) ||
- facename.EndsWith(wxS(" Bold"), &basename) )
- facename = basename;
-
// cache the face name, it shouldn't change unless the family
// does and wxNativeFontInfo::SetFamily() resets the face name
const_cast<wxFontRefData *>(this)->SetFaceName(facename);
WXHFONT GetHFONT() const
{
- if ( !m_hFont )
- const_cast<wxFontRefData *>(this)->Alloc();
+ AllocIfNeeded();
return (WXHFONT)m_hFont;
}
}
const wxNativeFontInfo& GetNativeFontInfo() const
- { return m_nativeFontInfo; }
+ {
+ // we need to create the font now to get the corresponding LOGFONT if
+ // it hadn't been done yet
+ AllocIfNeeded();
+
+ // ensure that we have a valid face name in our font information:
+ // GetFaceName() will try to retrieve it from our HFONT and save it if
+ // it was successful
+ (void)GetFaceName();
+
+ return m_nativeFontInfo;
+ }
void SetNativeFontInfo(const wxNativeFontInfo& nativeFontInfo)
{
void Init(const wxNativeFontInfo& info, WXHFONT hFont = 0);
+ void AllocIfNeeded() const
+ {
+ if ( !m_hFont )
+ const_cast<wxFontRefData *>(this)->Alloc();
+ }
+
// retrieve the face name really being used by the font: this is used to
// get the face name selected by the system when we don't specify it (but
// use just the family for example)
return wxString();
}
- // in spite of its type, the otmpFaceName field of OUTLINETEXTMETRIC
- // gives an offset in _bytes_ of the face name from the struct start
- // while the name itself is an array of TCHARs
+ // in spite of its type, the otmpFamilyName field of OUTLINETEXTMETRIC
+ // gives an offset in _bytes_ of the face (not family!) name from the
+ // struct start while the name itself is an array of TCHARs
+ //
+ // FWIW otmpFaceName contains the same thing as otmpFamilyName followed
+ // by a possible " Italic" or " Bold" or something else suffix
return reinterpret_cast<wxChar *>(otm) +
- wxPtrToUInt(otm->otmpFaceName)/sizeof(wxChar);
+ wxPtrToUInt(otm->otmpFamilyName)/sizeof(wxChar);
}
// are we using m_nativeFontInfo.lf.lfHeight for point size or pixel size?
return false;
// the face name may be empty
- wxStrcpy(lf.lfFaceName, tokenizer.GetNextToken());
+ SetFaceName(tokenizer.GetNextToken());
return true;
}
return IsOk() ? &(M_FONTDATA->GetNativeFontInfo()) : NULL;
}
-wxString wxFont::GetNativeFontInfoDesc() const
-{
- wxCHECK_MSG( IsOk(), wxEmptyString, wxT("invalid font") );
-
- // be sure we have an HFONT associated...
- const_cast<wxFont*>(this)->RealizeResource();
- return wxFontBase::GetNativeFontInfoDesc();
-}
-
-wxString wxFont::GetNativeFontInfoUserDesc() const
-{
- wxCHECK_MSG( IsOk(), wxEmptyString, wxT("invalid font") );
-
- // be sure we have an HFONT associated...
- const_cast<wxFont*>(this)->RealizeResource();
- return wxFontBase::GetNativeFontInfoUserDesc();
-}
-
bool wxFont::IsFixedWidth() const
{
wxCHECK_MSG( IsOk(), false, wxT("invalid font") );