Qt 4.8
Macros | Typedefs | Functions | Variables
qfont_x11.cpp File Reference
#include "qplatformdefs.h"
#include "qfont.h"
#include "qapplication.h"
#include "qfontinfo.h"
#include "qfontdatabase.h"
#include "qfontmetrics.h"
#include "qpaintdevice.h"
#include "qtextcodec.h"
#include "qiodevice.h"
#include "qhash.h"
#include <private/qunicodetables_p.h>
#include "qfont_p.h"
#include "qfontengine_p.h"
#include "qfontengine_x11_p.h"
#include "qtextengine_p.h"
#include <private/qt_x11_p.h>
#include "qx11info_x11.h"
#include <time.h>
#include <stdlib.h>
#include <ctype.h>

Go to the source code of this file.

Macros

#define QFONTLOADER_DEBUG
 
#define QFONTLOADER_DEBUG_VERBOSE
 
#define QT_FATAL_ASSERT
 

Typedefs

typedef QHash< int, QStringFallBackHash
 

Functions

static bool fontExists (const QString &fontName)
 
QString qt_fallback_font_family (int script)
 
static QByteArray qt_fixXLFD (const QByteArray &xlfd)
 
double qt_pixelSize (double pointSize, int dpi)
 
double qt_pointSize (double pixelSize, int dpi)
 
Q_GUI_EXPORT void qt_x11_set_fallback_font_family (int script, const QString &family)
 

Variables

static const char *const tryFonts []
 

Macro Definition Documentation

◆ QFONTLOADER_DEBUG

#define QFONTLOADER_DEBUG

Definition at line 69 of file qfont_x11.cpp.

◆ QFONTLOADER_DEBUG_VERBOSE

#define QFONTLOADER_DEBUG_VERBOSE

Definition at line 70 of file qfont_x11.cpp.

◆ QT_FATAL_ASSERT

#define QT_FATAL_ASSERT

Definition at line 42 of file qfont_x11.cpp.

Typedef Documentation

◆ FallBackHash

typedef QHash<int, QString> FallBackHash

Definition at line 110 of file qfont_x11.cpp.

Function Documentation

◆ fontExists()

static bool fontExists ( const QString fontName)
static

Definition at line 339 of file qfont_x11.cpp.

340 {
341  int count;
342  char **fontNames = XListFonts(QX11Info::display(), (char*)fontName.toLatin1().constData(), 32768, &count);
343  if (fontNames) XFreeFontNames(fontNames);
344 
345  return count != 0;
346 }
QByteArray toLatin1() const Q_REQUIRED_RESULT
Returns a Latin-1 representation of the string as a QByteArray.
Definition: qstring.cpp:3993
const char * constData() const
Returns a pointer to the data stored in the byte array.
Definition: qbytearray.h:433
static Display * display()
Returns the default display for the application.

◆ qt_fallback_font_family()

QString qt_fallback_font_family ( int  script)

Definition at line 114 of file qfont_x11.cpp.

Referenced by getFcPattern().

115 {
116  FallBackHash *hash = fallBackHash();
117  return hash->value(script);
118 }
static uint hash(const uchar *p, int n)
Definition: qhash.cpp:68
const T value(const Key &key) const
Returns the value associated with the key.
Definition: qhash.h:606
Q_CORE_EXPORT int QT_FASTCALL script(uint ucs4)

◆ qt_fixXLFD()

static QByteArray qt_fixXLFD ( const QByteArray xlfd)
static

Definition at line 98 of file qfont_x11.cpp.

Referenced by qt_x11_set_fallback_font_family().

99 {
100  QByteArray ret = xlfd;
101  int count = 0;
102  char **fontNames =
103  XListFonts(QX11Info::display(), xlfd, 32768, &count);
104  if (count > 0)
105  ret = fontNames[0];
106  XFreeFontNames(fontNames);
107  return ret ;
108 }
The QByteArray class provides an array of bytes.
Definition: qbytearray.h:135
static Display * display()
Returns the default display for the application.

◆ qt_pixelSize()

double qt_pixelSize ( double  pointSize,
int  dpi 
)

Definition at line 74 of file qfont_x11.cpp.

Referenced by QFontDatabase::loadXlfd(), and qt_fillFontDef().

75 {
76  if (pointSize < 0)
77  return -1.;
78  if (dpi == 75) // the stupid 75 dpi setting on X11
79  dpi = 72;
80  return (pointSize * dpi) /72.;
81 }
static float pointSize(const QFontDef &fd, int dpi)
Definition: qfont_win.cpp:90

◆ qt_pointSize()

double qt_pointSize ( double  pixelSize,
int  dpi 
)

Definition at line 83 of file qfont_x11.cpp.

Referenced by QFontDatabase::loadXlfd(), qt_FcPatternToQFontDef(), and qt_fillFontDef().

84 {
85  if (pixelSize < 0)
86  return -1.;
87  if (dpi == 75) // the stupid 75 dpi setting on X11
88  dpi = 72;
89  return pixelSize * 72. / ((double) dpi);
90 }
static float pixelSize(const QFontDef &request, int dpi)
Definition: qfont_win.cpp:80

◆ qt_x11_set_fallback_font_family()

Q_GUI_EXPORT void qt_x11_set_fallback_font_family ( int  script,
const QString family 
)

Definition at line 121 of file qfont_x11.cpp.

122 {
123  FallBackHash *hash = fallBackHash();
124  if (!family.isEmpty())
125  hash->insert(script, family);
126  else
127  hash->remove(script);
128 }
static uint hash(const uchar *p, int n)
Definition: qhash.cpp:68
int remove(const Key &key)
Removes all the items that have the key from the hash.
Definition: qhash.h:784
iterator insert(const Key &key, const T &value)
Inserts a new item with the key and a value of value.
Definition: qhash.h:753
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
Definition: qstring.h:704
Q_CORE_EXPORT int QT_FASTCALL script(uint ucs4)

Variable Documentation

◆ tryFonts

const char* const tryFonts[]
static
Initial value:
= {
"-*-helvetica-medium-r-*-*-*-120-*-*-*-*-*-*",
"-*-courier-medium-r-*-*-*-120-*-*-*-*-*-*",
"-*-times-medium-r-*-*-*-120-*-*-*-*-*-*",
"-*-lucida-medium-r-*-*-*-120-*-*-*-*-*-*",
"-*-helvetica-*-*-*-*-*-120-*-*-*-*-*-*",
"-*-courier-*-*-*-*-*-120-*-*-*-*-*-*",
"-*-times-*-*-*-*-*-120-*-*-*-*-*-*",
"-*-lucida-*-*-*-*-*-120-*-*-*-*-*-*",
"-*-helvetica-*-*-*-*-*-*-*-*-*-*-*-*",
"-*-courier-*-*-*-*-*-*-*-*-*-*-*-*",
"-*-times-*-*-*-*-*-*-*-*-*-*-*-*",
"-*-lucida-*-*-*-*-*-*-*-*-*-*-*-*",
"-*-fixed-*-*-*-*-*-*-*-*-*-*-*-*",
"6x13",
"7x13",
"8x13",
"9x15",
"fixed",
0
}

Definition at line 316 of file qfont_x11.cpp.

Referenced by fontExists().