Remove support for using X fonts

This was used by wxGTK 1, which is not supported any longer, and wxX11,
which now always uses Pango instead, so all this code became completely
unused and can be removed to simplify things.

Closes #23442.
This commit is contained in:
Vadim Zeitlin 2023-04-12 14:50:11 +02:00
parent 102600eb37
commit 0fc251bfca
8 changed files with 0 additions and 1346 deletions

View file

@ -2583,11 +2583,6 @@ typedef int (* LINKAGEMODE wxListIterateFunction)(void *current);
/* miscellaneous */
/* ---------------------------------------------------------------------------- */
/* define this macro if font handling is done using the X font names */
#if defined(__X__)
#define _WX_X_FONTLIKE
#endif
/* macro to specify "All Files" on different platforms */
#if defined(__WXMSW__)
# define wxALL_FILES_PATTERN wxT("*.*")

View file

@ -47,9 +47,6 @@ struct WXDLLIMPEXP_CORE wxNativeEncodingInfo
{ }
int charset;
#elif defined(_WX_X_FONTLIKE)
wxString xregistry,
xencoding;
#elif defined(wxHAS_UTF8_FONTS)
// ports using UTF-8 for text don't need encoding information for fonts
#else

View file

@ -37,33 +37,6 @@ class WXDLLIMPEXP_FWD_BASE wxArrayString;
class WXDLLIMPEXP_FWD_CORE wxWindow;
struct WXDLLIMPEXP_FWD_CORE wxNativeEncodingInfo;
#if defined(_WX_X_FONTLIKE)
// the symbolic names for the XLFD fields (with examples for their value)
//
// NB: we suppose that the font always starts with the empty token (font name
// registry field) as we never use nor generate it anyhow
enum wxXLFDField
{
wxXLFD_FOUNDRY, // adobe
wxXLFD_FAMILY, // courier, times, ...
wxXLFD_WEIGHT, // black, bold, demibold, medium, regular, light
wxXLFD_SLANT, // r/i/o (roman/italique/oblique)
wxXLFD_SETWIDTH, // condensed, expanded, ...
wxXLFD_ADDSTYLE, // whatever - usually nothing
wxXLFD_PIXELSIZE, // size in pixels
wxXLFD_POINTSIZE, // size in points
wxXLFD_RESX, // 72, 75, 100, ...
wxXLFD_RESY,
wxXLFD_SPACING, // m/p/c (monospaced/proportional/character cell)
wxXLFD_AVGWIDTH, // average width in 1/10 pixels
wxXLFD_REGISTRY, // iso8859, rawin, koi8, ...
wxXLFD_ENCODING, // 1, r, r, ...
wxXLFD_MAX
};
#endif // _WX_X_FONTLIKE
// ----------------------------------------------------------------------------
// types
// ----------------------------------------------------------------------------
@ -84,40 +57,6 @@ public:
// separately and handle them ourselves in {To,From}String() methods.
bool m_underlined;
bool m_strikethrough;
#elif defined(_WX_X_FONTLIKE)
// the members can't be accessed directly as we only parse the
// xFontName on demand
private:
// the components of the XLFD
wxString fontElements[wxXLFD_MAX];
// the full XLFD
wxString xFontName;
// true until SetXFontName() is called
bool m_isDefault;
// return true if we have already initialized fontElements
inline bool HasElements() const;
public:
// init the elements from an XLFD, return true if ok
bool FromXFontName(const wxString& xFontName);
// return false if we were never initialized with a valid XLFD
bool IsDefault() const { return m_isDefault; }
// return the XLFD (using the fontElements if necessary)
wxString GetXFontName() const;
// get the given XFLD component
wxString GetXFontComponent(wxXLFDField field) const;
// change the font component
void SetXFontComponent(wxXLFDField field, const wxString& value);
// set the XFLD
void SetXFontName(const wxString& xFontName);
#elif defined(__WXMSW__)
// Preserve compatibility in the semi-public (i.e. private, but still
// unfortunately used by some existing code outside of the library) API
@ -349,12 +288,4 @@ WXDLLIMPEXP_CORE bool wxGetNativeFontEncoding(wxFontEncoding encoding,
// return true if such font(s) exist, false otherwise
WXDLLIMPEXP_CORE bool wxTestFontEncoding(const wxNativeEncodingInfo& info);
// ----------------------------------------------------------------------------
// font-related functions (X and GTK)
// ----------------------------------------------------------------------------
#ifdef _WX_X_FONTLIKE
#include "wx/unix/fontutil.h"
#endif // X || GDK
#endif // _WX_FONTUTIL_H_

View file

@ -117,33 +117,12 @@ public:
// Implementation
#if wxUSE_PANGO
// Set Pango attributes in the specified layout. Currently only
// underlined and strike-through attributes are handled by this function.
//
// If neither of them is specified, returns false, otherwise sets up the
// attributes and returns true.
bool SetPangoAttrs(PangoLayout* layout) const;
#else
// Find an existing, or create a new, XFontStruct
// based on this wxFont and the given scale. Append the
// font to list in the private data for future reference.
// TODO This is a fairly basic implementation, that doesn't
// allow for different facenames, and also doesn't do a mapping
// between 'standard' facenames (e.g. Arial, Helvetica, Times Roman etc.)
// and the fonts that are available on a particular system.
// Maybe we need to scan the user's machine to build up a profile
// of the fonts and a mapping file.
// Return font struct, and optionally the font list
wxXFont *GetInternalFont(double scale = 1.0,
WXDisplay* display = nullptr) const;
// Helper function for convenient access of the above.
WXFontStructPtr GetFontStruct(double scale = 1.0,
WXDisplay* display = nullptr) const;
#endif
protected:
virtual wxGDIRefData *CreateGDIRefData() const;

View file

@ -27,9 +27,7 @@
// Include common declarations
#include "wx/x11/privx.h"
#if wxUSE_PANGO
#include <pango/pango.h>
#endif
class WXDLLIMPEXP_FWD_CORE wxMouseEvent;
class WXDLLIMPEXP_FWD_CORE wxKeyEvent;

View file

@ -39,8 +39,6 @@
// Pango
// ----------------------------------------------------------------------------
#if wxUSE_PANGO
#include <pango/pango.h>
PangoContext* wxGetPangoContext();
@ -105,249 +103,4 @@ bool wxFontEnumerator::EnumerateEncodings(const wxString& facename)
}
#else // !wxUSE_PANGO
#ifdef __VMS__ // Xlib.h for VMS is not (yet) compatible with C++
// The resulting warnings are switched off here
#pragma message disable nosimpint
#endif
#include <X11/Xlib.h>
#ifdef __VMS__
#pragma message enable nosimpint
#endif
// ----------------------------------------------------------------------------
// private functions
// ----------------------------------------------------------------------------
// create the list of all fonts with the given spacing and encoding
static char **CreateFontList(wxChar spacing, wxFontEncoding encoding,
int *nFonts);
// extract all font families from the given font list and call our
// OnFacename() for each of them
static bool ProcessFamiliesFromFontList(wxFontEnumerator *This,
char **fonts,
int nFonts);
// ----------------------------------------------------------------------------
// private types
// ----------------------------------------------------------------------------
// ============================================================================
// implementation
// ============================================================================
// ----------------------------------------------------------------------------
// helpers
// ----------------------------------------------------------------------------
#if !wxUSE_NANOX
static char **CreateFontList(wxChar spacing,
wxFontEncoding encoding,
int *nFonts)
{
wxNativeEncodingInfo info;
wxGetNativeFontEncoding(encoding, &info);
#if wxUSE_FONTMAP
if ( !wxTestFontEncoding(info) )
{
// ask font mapper for a replacement
(void)wxFontMapper::Get()->GetAltForEncoding(encoding, &info);
}
#endif // wxUSE_FONTMAP
wxString pattern;
pattern.Printf(wxT("-*-*-*-*-*-*-*-*-*-*-%c-*-%s-%s"),
spacing,
info.xregistry.c_str(),
info.xencoding.c_str());
// get the list of all fonts
return XListFonts((Display *)wxGetDisplay(), pattern.mb_str(), 32767, nFonts);
}
static bool ProcessFamiliesFromFontList(wxFontEnumerator *This,
char **fonts,
int nFonts)
{
#if wxUSE_REGEX
wxRegEx re(wxT("^(-[^-]*){14}$"), wxRE_NOSUB);
#endif // wxUSE_REGEX
// extract the list of (unique) font families
wxSortedArrayString families;
for ( int n = 0; n < nFonts; n++ )
{
char *font = fonts[n];
#if wxUSE_REGEX
if ( !re.Matches(font) )
#else // !wxUSE_REGEX
if ( !wxString(font).Matches(wxT("-*-*-*-*-*-*-*-*-*-*-*-*-*-*")) )
#endif // wxUSE_REGEX/!wxUSE_REGEX
{
// it's not a full font name (probably an alias)
continue;
}
// coverity[returned_null]
char *dash = strchr(font + 1, '-');
char *family = dash + 1;
dash = strchr(family, '-');
*dash = '\0'; // not-null because Matches() above succeeded
wxString fam(family);
if ( families.Index(fam) == wxNOT_FOUND )
{
if ( !This->OnFacename(fam) )
{
// stop enumerating
return false;
}
families.Add(fam);
}
//else: already seen
}
return true;
}
#endif
// wxUSE_NANOX
// ----------------------------------------------------------------------------
// wxFontEnumerator
// ----------------------------------------------------------------------------
bool wxFontEnumerator::EnumerateFacenames(wxFontEncoding encoding,
bool fixedWidthOnly)
{
#if wxUSE_NANOX
return false;
#else
int nFonts;
char **fonts;
if ( fixedWidthOnly )
{
bool cont = true;
fonts = CreateFontList(wxT('m'), encoding, &nFonts);
if ( fonts )
{
cont = ProcessFamiliesFromFontList(this, fonts, nFonts);
XFreeFontNames(fonts);
}
if ( !cont )
{
return true;
}
fonts = CreateFontList(wxT('c'), encoding, &nFonts);
if ( !fonts )
{
return true;
}
}
else
{
fonts = CreateFontList(wxT('*'), encoding, &nFonts);
if ( !fonts )
{
// it's ok if there are no fonts in given encoding - but it's not
// ok if there are no fonts at all
wxASSERT_MSG(encoding != wxFONTENCODING_SYSTEM,
wxT("No fonts at all on this system?"));
return false;
}
}
(void)ProcessFamiliesFromFontList(this, fonts, nFonts);
XFreeFontNames(fonts);
return true;
#endif
// wxUSE_NANOX
}
bool wxFontEnumerator::EnumerateEncodings(const wxString& family)
{
#if wxUSE_NANOX
return false;
#else
wxString pattern;
pattern.Printf(wxT("-*-%s-*-*-*-*-*-*-*-*-*-*-*-*"),
family.empty() ? wxString("*") : family);
// get the list of all fonts
int nFonts;
char **fonts = XListFonts((Display *)wxGetDisplay(), pattern.mb_str(),
32767, &nFonts);
if ( !fonts )
{
// unknown family?
return false;
}
// extract the list of (unique) encodings
wxSortedArrayString encodings;
for ( int n = 0; n < nFonts; n++ )
{
char *font = fonts[n];
if ( !wxString(font).Matches(wxT("-*-*-*-*-*-*-*-*-*-*-*-*-*-*")) )
{
// it's not a full font name (probably an alias)
continue;
}
// extract the family
char *dash = strchr(font + 1, '-');
char *familyFont = dash + 1;
dash = strchr(familyFont, '-');
*dash = '\0'; // not-null because Matches() above succeeded
if ( !family.empty() && (family != familyFont) )
{
// family doesn't match
continue;
}
// now extract the registry/encoding
char *p = dash + 1; // just after the dash after family
dash = strrchr(p, '-');
wxString registry(dash + 1);
*dash = '\0';
dash = strrchr(p, '-');
wxString encoding(dash + 1);
encoding << wxT('-') << registry;
if ( encodings.Index(encoding) == wxNOT_FOUND )
{
if ( !OnFontEncoding(familyFont, encoding) )
{
break;
}
encodings.Add(encoding);
}
//else: already had this one
}
XFreeFontNames(fonts);
return true;
#endif
// wxUSE_NANOX
}
#endif // !wxUSE_PANGO
#endif // wxUSE_FONTENUM

File diff suppressed because it is too large Load diff

View file

@ -524,13 +524,6 @@ bool wxFont::GetStrikethrough() const
return M_FONTDATA->m_nativeFontInfo.GetStrikethrough();
}
#if defined( __WXX11__ ) && ( wxUSE_PANGO == 0 )
bool wxNativeFontInfo::GetStrikethrough() const
{
return false;
}
#endif
wxFontEncoding wxFont::GetEncoding() const
{
wxCHECK_MSG( IsOk(), wxFONTENCODING_DEFAULT, wxT("invalid font") );
@ -622,7 +615,6 @@ void wxFont::DoSetNativeFontInfo( const wxNativeFontInfo& info )
M_FONTDATA->SetNativeFontInfo( info );
}
#if wxUSE_PANGO
// Although we don't use this function yet, but we must create it here.
// first, for the prepare the unicode drawing support in wxUniv/x11 port.
// If we use pango to draw the text, then we must set some attributes
@ -651,4 +643,3 @@ bool wxFont::SetPangoAttrs(PangoLayout* layout) const
return true;
}
#endif