Remove useless wxFont::ActivatePrivateFonts()
Just "activate" the font immediately when adding it using AddPrivateFont(), nothing seems to be gained from having two functions and it just makes things more complicated both when implementing and when using the API.
This commit is contained in:
@@ -82,12 +82,9 @@ system. On Macintosh/OSX this can be arranged by placing the desired fonts
|
|||||||
within the Application Bundle in Contents/Resources/Fonts and using
|
within the Application Bundle in Contents/Resources/Fonts and using
|
||||||
the ATSApplicationFontsPath key to point there. The full details of the
|
the ATSApplicationFontsPath key to point there. The full details of the
|
||||||
procedure there can be found as OSX developer resources. For the GTK+ and
|
procedure there can be found as OSX developer resources. For the GTK+ and
|
||||||
Windows ports it is possible to add TrueType fonts at run-time using
|
Windows ports it is possible to add TrueType fonts from arbitrary locations at
|
||||||
a sequence of calls to wxFont::AddPrivateFont() to give the names of files
|
run-time using wxFont::AddPrivateFont(). Notice that under MSW this function
|
||||||
containing font data, followed by a call to wxFont::ActivatePrivateFonts()
|
should be called before creating the first wxGraphicsContext object if you want
|
||||||
to complete the process of making the fonts available. These functions
|
the private font to be usable from it.
|
||||||
return false if they fail. They should be called just once before any
|
|
||||||
graphics contexts have been created or other activity liable to use fonts
|
|
||||||
has happened.
|
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
@@ -328,11 +328,12 @@ public:
|
|||||||
// from the string representation of wxNativeFontInfo
|
// from the string representation of wxNativeFontInfo
|
||||||
static wxFont *New(const wxString& strNativeFontDesc);
|
static wxFont *New(const wxString& strNativeFontDesc);
|
||||||
|
|
||||||
// These functions can be used to load private fonts if supported by this
|
// Load the font from the given file and return true on success or false on
|
||||||
// platform (wxHAS_PRIVATE_FONTS is defined): first add one or more files
|
// error (an error message will be logged in this case, unless there is no
|
||||||
// and then activate all of them at once.
|
// support for private fonts at all in the current port, in which case
|
||||||
|
// wxHAS_PRIVATE_FONTS will not be defined allowing to check for this at
|
||||||
|
// compile-time).
|
||||||
static bool AddPrivateFont(const wxString& filename);
|
static bool AddPrivateFont(const wxString& filename);
|
||||||
static bool ActivatePrivateFonts();
|
|
||||||
|
|
||||||
// comparison
|
// comparison
|
||||||
bool operator==(const wxFont& font) const;
|
bool operator==(const wxFont& font) const;
|
||||||
|
@@ -678,30 +678,25 @@ public:
|
|||||||
@c ATSApplicationFontsPath to @c Fonts value in your @c Info.plist
|
@c ATSApplicationFontsPath to @c Fonts value in your @c Info.plist
|
||||||
file. See also wxStandardPaths::GetResourcesDir().
|
file. See also wxStandardPaths::GetResourcesDir().
|
||||||
|
|
||||||
Notice that this method must be called before any graphics contexts
|
Under MSW this method must be called before any wxGraphicsContext
|
||||||
have been created.
|
objects have been created, otherwise the private font won't be usable
|
||||||
|
from them.
|
||||||
|
|
||||||
|
Under Unix this method requires Pango 1.38 or later and will return @a
|
||||||
|
false and log an error message explaining the problem if this
|
||||||
|
requirement is not satisfied either at compile- or run-time.
|
||||||
|
|
||||||
Currently this method is implemented for all major platforms but you
|
Currently this method is implemented for all major platforms but you
|
||||||
may also test for @c wxHAS_PRIVATE_FONTS preprocessor symbol: if it is
|
may also test for @c wxHAS_PRIVATE_FONTS preprocessor symbol: if it is
|
||||||
not defined, this function and ActivatePrivatefonts() are not
|
not defined, this function is not implemented at all and simply always
|
||||||
implemented at all and always simply return false.
|
returns false.
|
||||||
|
|
||||||
@return @true if the font was added and ActivatePrivatefonts() should
|
@return @true if the font was added and can now be used.
|
||||||
be called next or @false if adding it failed.
|
|
||||||
|
|
||||||
@since 3.1.1
|
@since 3.1.1
|
||||||
*/
|
*/
|
||||||
static bool AddPrivateFont(const wxString& filename);
|
static bool AddPrivateFont(const wxString& filename);
|
||||||
|
|
||||||
/**
|
|
||||||
Make all fonts registered by AddPrivateFont() actually available.
|
|
||||||
|
|
||||||
@return @true if the private fonts can now be used or @false on error.
|
|
||||||
|
|
||||||
@since 3.1.1
|
|
||||||
*/
|
|
||||||
static bool ActivatePrivatefonts();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Gets the point size.
|
Gets the point size.
|
||||||
|
|
||||||
|
@@ -426,10 +426,6 @@ MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
|
|||||||
{
|
{
|
||||||
wxLogWarning("Failed to add private font from \"%s\"", privfont);
|
wxLogWarning("Failed to add private font from \"%s\"", privfont);
|
||||||
}
|
}
|
||||||
else if ( !wxFont::ActivatePrivateFonts() )
|
|
||||||
{
|
|
||||||
wxLogWarning("Failed to activate the private fonts");
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
menuSelect->AppendSeparator();
|
menuSelect->AppendSeparator();
|
||||||
|
@@ -1148,9 +1148,4 @@ bool wxFontBase::AddPrivateFont(const wxString& WXUNUSED(filename))
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxFontBase::ActivatePrivateFonts()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // !wxHAS_PRIVATE_FONTS
|
#endif // !wxHAS_PRIVATE_FONTS
|
||||||
|
@@ -601,6 +601,14 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxFcConfigDestroyModule, wxModule);
|
|||||||
|
|
||||||
bool wxFontBase::AddPrivateFont(const wxString& filename)
|
bool wxFontBase::AddPrivateFont(const wxString& filename)
|
||||||
{
|
{
|
||||||
|
wxString why;
|
||||||
|
|
||||||
|
// All this code only works if we have pango_context_get_font_map() which
|
||||||
|
// is new in 1.38, so don't bother compiling -- or running -- it if this is
|
||||||
|
// not the case.
|
||||||
|
#if PANGO_VERSION_CHECK(1,38,0)
|
||||||
|
if ( wx_pango_version_check(1,38,0) == NULL )
|
||||||
|
{
|
||||||
if ( !gs_fcConfig )
|
if ( !gs_fcConfig )
|
||||||
{
|
{
|
||||||
gs_fcConfig = FcInitLoadConfigAndFonts();
|
gs_fcConfig = FcInitLoadConfigAndFonts();
|
||||||
@@ -620,11 +628,6 @@ bool wxFontBase::AddPrivateFont(const wxString& filename)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxFontBase::ActivatePrivateFonts()
|
|
||||||
{
|
|
||||||
wxGtkObject<PangoContext> context(wxGetPangoContext());
|
wxGtkObject<PangoContext> context(wxGetPangoContext());
|
||||||
PangoFontMap* const fmap = pango_context_get_font_map(context);
|
PangoFontMap* const fmap = pango_context_get_font_map(context);
|
||||||
if ( !fmap || !PANGO_IS_FC_FONT_MAP(fmap) )
|
if ( !fmap || !PANGO_IS_FC_FONT_MAP(fmap) )
|
||||||
@@ -633,10 +636,6 @@ bool wxFontBase::ActivatePrivateFonts()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString why;
|
|
||||||
#if PANGO_VERSION_CHECK(1,38,0)
|
|
||||||
if ( wx_pango_version_check(1,38,0) == NULL )
|
|
||||||
{
|
|
||||||
PangoFcFontMap* const fcfmap = PANGO_FC_FONT_MAP(fmap);
|
PangoFcFontMap* const fcfmap = PANGO_FC_FONT_MAP(fmap);
|
||||||
pango_fc_font_map_set_config(fcfmap, gs_fcConfig);
|
pango_fc_font_map_set_config(fcfmap, gs_fcConfig);
|
||||||
|
|
||||||
|
@@ -35,7 +35,6 @@
|
|||||||
#endif // WX_PRECOMP
|
#endif // WX_PRECOMP
|
||||||
|
|
||||||
#include "wx/encinfo.h"
|
#include "wx/encinfo.h"
|
||||||
#include "wx/filename.h"
|
|
||||||
#include "wx/fontutil.h"
|
#include "wx/fontutil.h"
|
||||||
#include "wx/fontmap.h"
|
#include "wx/fontmap.h"
|
||||||
|
|
||||||
@@ -1122,28 +1121,13 @@ wxIMPLEMENT_DYNAMIC_CLASS(wxPrivateFontsListModule, wxModule);
|
|||||||
|
|
||||||
bool wxFontBase::AddPrivateFont(const wxString& filename)
|
bool wxFontBase::AddPrivateFont(const wxString& filename)
|
||||||
{
|
{
|
||||||
if ( !wxFileName::FileExists(filename) )
|
if ( !AddFontResourceEx(filename.t_str(), FR_PRIVATE, 0) )
|
||||||
{
|
{
|
||||||
wxLogError(_("Font file \"%s\" doesn't exist."), filename);
|
wxLogSysError(_("Font file \"%s\" couldn't be loaded"), filename);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Remember it for use in wxGDIPlusRenderer::Load().
|
||||||
gs_privateFontFileNames.Add(filename);
|
gs_privateFontFileNames.Add(filename);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxFontBase::ActivatePrivateFonts()
|
|
||||||
{
|
|
||||||
const int n = gs_privateFontFileNames.size();
|
|
||||||
for ( int i = 0 ; i < n; i++ )
|
|
||||||
{
|
|
||||||
const wxString& fname = gs_privateFontFileNames[i];
|
|
||||||
if ( !AddFontResourceEx(fname.t_str(), FR_PRIVATE, 0) )
|
|
||||||
{
|
|
||||||
wxLogSysError(_("Font file \"%s\" couldn't be loaded"),
|
|
||||||
fname);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
@@ -95,12 +95,6 @@ bool wxFontBase::AddPrivateFont(const wxString& filename)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxFontBase::ActivatePrivateFonts()
|
|
||||||
{
|
|
||||||
// Nothing to do here.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// helper functions
|
// helper functions
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
Reference in New Issue
Block a user