X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1e6feb95a79834836e88143b15d9f424ebe79621..e7ca6139d062c37cc7c056b6647097e999b714cd:/src/msw/font.cpp?ds=sidebyside diff --git a/src/msw/font.cpp b/src/msw/font.cpp index a2a73706ed..2ab0fbb804 100644 --- a/src/msw/font.cpp +++ b/src/msw/font.cpp @@ -86,9 +86,9 @@ public: Init(size, family, style, weight, underlined, faceName, encoding); } - wxFontRefData(const wxNativeFontInfo& info) + wxFontRefData(const wxNativeFontInfo& info, WXHFONT hFont = 0) { - Init(info); + Init(info, hFont); } virtual ~wxFontRefData(); @@ -103,7 +103,7 @@ protected: const wxString& faceName, wxFontEncoding encoding); - void Init(const wxNativeFontInfo& info); + void Init(const wxNativeFontInfo& info, WXHFONT hFont = 0); // If TRUE, the pointer to the actual font is temporary and SHOULD NOT BE // DELETED by destructor @@ -161,7 +161,7 @@ void wxFontRefData::Init(int pointSize, m_nativeFontInfoOk = FALSE; } -void wxFontRefData::Init(const wxNativeFontInfo& info) +void wxFontRefData::Init(const wxNativeFontInfo& info, WXHFONT hFont) { // extract family from pitch-and-family int lfFamily = info.lf.lfPitchAndFamily; @@ -230,7 +230,11 @@ void wxFontRefData::Init(const wxNativeFontInfo& info) m_fontId = 0; m_temporary = FALSE; - m_hFont = 0; + // hFont may be zero, or it be passed in case we really want to + // use the exact font created in the underlying system + // (for example where we can't guarantee conversion from HFONT + // to LOGFONT back to HFONT) + m_hFont = hFont; m_nativeFontInfoOk = TRUE; m_nativeFontInfo = info; @@ -366,15 +370,13 @@ wxString wxNativeFontInfo::ToString() const void wxFont::Init() { - if ( wxTheFontList ) - wxTheFontList->Append(this); } -bool wxFont::Create(const wxNativeFontInfo& info) +bool wxFont::Create(const wxNativeFontInfo& info, WXHFONT hFont) { UnRef(); - m_refData = new wxFontRefData(info); + m_refData = new wxFontRefData(info, hFont); RealizeResource(); @@ -416,8 +418,6 @@ bool wxFont::Create(int pointSize, wxFont::~wxFont() { - if ( wxTheFontList ) - wxTheFontList->DeleteObject(this); } // ---------------------------------------------------------------------------- @@ -645,115 +645,11 @@ wxFontEncoding wxFont::GetEncoding() const return M_FONTDATA->m_encoding; } -// ---------------------------------------------------------------------------- -// wxNativeFontInfo -// ---------------------------------------------------------------------------- - -bool wxNativeFontInfo::FromString(const wxString& s) +wxNativeFontInfo *wxFont::GetNativeFontInfo() const { - long l; - - wxStringTokenizer tokenizer(s, _T(";")); - - wxString token = tokenizer.GetNextToken(); - // - // Ignore the version for now - // + if( M_FONTDATA->m_nativeFontInfoOk ) + return new wxNativeFontInfo(M_FONTDATA->m_nativeFontInfo); - token = tokenizer.GetNextToken(); - if ( !token.ToLong(&l) ) - return FALSE; - lf.lfHeight = l; - - token = tokenizer.GetNextToken(); - if ( !token.ToLong(&l) ) - return FALSE; - lf.lfWidth = l; - - token = tokenizer.GetNextToken(); - if ( !token.ToLong(&l) ) - return FALSE; - lf.lfEscapement = l; - - token = tokenizer.GetNextToken(); - if ( !token.ToLong(&l) ) - return FALSE; - lf.lfOrientation = l; - - token = tokenizer.GetNextToken(); - if ( !token.ToLong(&l) ) - return FALSE; - lf.lfWeight = l; - - token = tokenizer.GetNextToken(); - if ( !token.ToLong(&l) ) - return FALSE; - lf.lfItalic = (BYTE)l; - - token = tokenizer.GetNextToken(); - if ( !token.ToLong(&l) ) - return FALSE; - lf.lfUnderline = (BYTE)l; - - token = tokenizer.GetNextToken(); - if ( !token.ToLong(&l) ) - return FALSE; - lf.lfStrikeOut = (BYTE)l; - - token = tokenizer.GetNextToken(); - if ( !token.ToLong(&l) ) - return FALSE; - lf.lfCharSet = (BYTE)l; - - token = tokenizer.GetNextToken(); - if ( !token.ToLong(&l) ) - return FALSE; - lf.lfOutPrecision = (BYTE)l; - - token = tokenizer.GetNextToken(); - if ( !token.ToLong(&l) ) - return FALSE; - lf.lfClipPrecision = (BYTE)l; - - token = tokenizer.GetNextToken(); - if ( !token.ToLong(&l) ) - return FALSE; - lf.lfQuality = (BYTE)l; - - token = tokenizer.GetNextToken(); - if ( !token.ToLong(&l) ) - return FALSE; - lf.lfPitchAndFamily = (BYTE)l; - - token = tokenizer.GetNextToken(); - if(!token) - return FALSE; - wxStrcpy(lf.lfFaceName, token.c_str()); - - return TRUE; -} - -wxString wxNativeFontInfo::ToString() const -{ - wxString s; - - s.Printf(_T("%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%d;%s"), - 0, // version, in case we want to change the format later - lf.lfHeight, - lf.lfWidth, - lf.lfEscapement, - lf.lfOrientation, - lf.lfWeight, - lf.lfItalic, - lf.lfUnderline, - lf.lfStrikeOut, - lf.lfCharSet, - lf.lfOutPrecision, - lf.lfClipPrecision, - lf.lfQuality, - lf.lfPitchAndFamily, - lf.lfFaceName); - - return s; + return 0; }