Remove wxCreateFontFromLogFont() and wxFillLogFont()
These functions are not really useful as converting between wxFont and LOGFONT can be done trivially by passing via wxNativeFontInfo and, in fact, wxCreateFontFromLogFont() managed to do the conversion wrongly by forgetting to update wxNativeFontInfo::pointSize member when changing wxNativeFontInfo::lf. This fixes one unit test failure after the latest changes, although not yet the other one, see the upcoming commit for this.
This commit is contained in:
@@ -961,8 +961,6 @@ extern const wxCursor *wxGetGlobalCursor(); // from msw/cursor.cpp
|
||||
WXDLLIMPEXP_CORE void wxGetCursorPosMSW(POINT* pt);
|
||||
|
||||
WXDLLIMPEXP_CORE void wxGetCharSize(WXHWND wnd, int *x, int *y, const wxFont& the_font);
|
||||
WXDLLIMPEXP_CORE void wxFillLogFont(LOGFONT *logFont, const wxFont *font);
|
||||
WXDLLIMPEXP_CORE wxFont wxCreateFontFromLogFont(const LOGFONT *logFont);
|
||||
WXDLLIMPEXP_CORE wxFontEncoding wxGetFontEncFromCharSet(int charset);
|
||||
|
||||
inline void wxSetWindowFont(HWND hwnd, const wxFont& font)
|
||||
|
@@ -36,6 +36,8 @@
|
||||
#include "wx/math.h"
|
||||
#endif
|
||||
|
||||
#include "wx/fontutil.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -118,7 +120,7 @@ int wxFontDialog::ShowModal()
|
||||
if ( m_fontData.m_initialFont.IsOk() )
|
||||
{
|
||||
flags |= CF_INITTOLOGFONTSTRUCT;
|
||||
wxFillLogFont(&logFont, &m_fontData.m_initialFont);
|
||||
logFont = m_fontData.m_initialFont.GetNativeFontInfo()->lf;
|
||||
}
|
||||
|
||||
if ( m_fontData.m_fontColour.IsOk() )
|
||||
@@ -150,7 +152,7 @@ int wxFontDialog::ShowModal()
|
||||
if ( ChooseFont(&chooseFontStruct) != 0 )
|
||||
{
|
||||
wxRGBToColour(m_fontData.m_fontColour, chooseFontStruct.rgbColors);
|
||||
m_fontData.m_chosenFont = wxCreateFontFromLogFont(&logFont);
|
||||
m_fontData.m_chosenFont = wxFont(wxNativeFontInfo(logFont));
|
||||
m_fontData.EncodingInfo().facename = logFont.lfFaceName;
|
||||
m_fontData.EncodingInfo().charset = logFont.lfCharSet;
|
||||
|
||||
|
@@ -264,35 +264,3 @@ wxFontEncoding wxGetFontEncFromCharSet(int cs)
|
||||
|
||||
return fontEncoding;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
// wxFont <-> LOGFONT conversion
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
void wxFillLogFont(LOGFONT *logFont, const wxFont *font)
|
||||
{
|
||||
wxNativeFontInfo fi;
|
||||
|
||||
// maybe we already have LOGFONT for this font?
|
||||
const wxNativeFontInfo *pFI = font->GetNativeFontInfo();
|
||||
if ( !pFI )
|
||||
{
|
||||
// use wxNativeFontInfo methods to build a LOGFONT for this font
|
||||
fi.InitFromFont(*font);
|
||||
|
||||
pFI = &fi;
|
||||
}
|
||||
|
||||
// transfer all the data to LOGFONT
|
||||
*logFont = pFI->lf;
|
||||
}
|
||||
|
||||
wxFont wxCreateFontFromLogFont(const LOGFONT *logFont)
|
||||
{
|
||||
wxNativeFontInfo info;
|
||||
|
||||
info.lf = *logFont;
|
||||
|
||||
return wxFont(info);
|
||||
}
|
||||
|
||||
|
@@ -345,7 +345,7 @@ extern wxFont wxGetCCDefaultFont()
|
||||
0
|
||||
) )
|
||||
{
|
||||
return wxFont(wxCreateFontFromLogFont(&lf));
|
||||
return wxFont(lf);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -40,6 +40,7 @@
|
||||
#include "wx/wxcrtvararg.h"
|
||||
#endif
|
||||
|
||||
#include "wx/fontutil.h"
|
||||
#include "wx/scopedptr.h"
|
||||
#include "wx/stack.h"
|
||||
#include "wx/sysopt.h"
|
||||
@@ -2826,14 +2827,13 @@ bool wxTextCtrl::MSWSetCharFormat(const wxTextAttr& style, long start, long end)
|
||||
CFM_ITALIC | CFM_BOLD | CFM_UNDERLINE | CFM_STRIKEOUT;
|
||||
|
||||
// fill in data from LOGFONT but recalculate lfHeight because we need
|
||||
// the real height in twips and not the negative number which
|
||||
// wxFillLogFont() returns (this is correct in general and works with
|
||||
// the real height in twips and not the negative number used inside
|
||||
// LOGFONT returns (this is correct in general and works with
|
||||
// the Windows font mapper, but not here)
|
||||
|
||||
wxFont font(style.GetFont());
|
||||
|
||||
LOGFONT lf;
|
||||
wxFillLogFont(&lf, &font);
|
||||
LOGFONT lf = font.GetNativeFontInfo()->lf;
|
||||
cf.yHeight = 20*font.GetPointSize(); // 1 pt = 20 twips
|
||||
cf.bCharSet = lf.lfCharSet;
|
||||
cf.bPitchAndFamily = lf.lfPitchAndFamily;
|
||||
@@ -3157,7 +3157,7 @@ bool wxTextCtrl::GetStyle(long position, wxTextAttr& style)
|
||||
else
|
||||
lf.lfWeight = FW_NORMAL;
|
||||
|
||||
wxFont font = wxCreateFontFromLogFont(& lf);
|
||||
wxFont font(lf);
|
||||
if (font.IsOk())
|
||||
{
|
||||
style.SetFont(font);
|
||||
|
Reference in New Issue
Block a user