60 #include <private/qpaintengine_x11_p.h> 66 #include <private/qpainter_p.h> 67 #include <private/qunicodetables_p.h> 69 #include <private/qt_x11_p.h> 70 #include <private/qpixmap_x11_p.h> 77 #if defined(FT_LCD_FILTER_H) 78 #include FT_LCD_FILTER_H 81 #if defined(FC_LCD_FILTER) 83 #ifndef FC_LCD_FILTER_NONE 84 #define FC_LCD_FILTER_NONE FC_LCD_NONE 87 #ifndef FC_LCD_FILTER_DEFAULT 88 #define FC_LCD_FILTER_DEFAULT FC_LCD_DEFAULT 91 #ifndef FC_LCD_FILTER_LIGHT 92 #define FC_LCD_FILTER_LIGHT FC_LCD_LIGHT 95 #ifndef FC_LCD_FILTER_LEGACY 96 #define FC_LCD_FILTER_LEGACY FC_LCD_LEGACY 133 #ifndef QT_NO_FREETYPE 150 font_path = XGetFontPath(
X11->display, &npaths);
151 bool xfsconfig_read =
false;
152 for (
int i=0; i<npaths; i++) {
155 if (((font_path[i])[0] !=
'/') && !xfsconfig_read) {
157 bool finished =
false;
173 fs = fs.left(fs.length()-1);
190 xfsconfig_read =
true;
196 XFreeFontPath(font_path);
216 while (minus < 5 && (pos = xname.
indexOf(
'-', pos + 1)))
219 while (minus < 12 && (pos = xname.
indexOf(
'-', pos + 1)))
242 QFile fontmap(fontmapname);
245 while (!fontmap.
atEnd()) {
258 bool best_match =
false;
260 if (lmapping.
contains(
"-0-0-0-0-")) {
273 ffn = ffn.
mid(colon + 1);
279 face_id.
filename = (*it).toLocal8Bit() +
'/' + ffn;
297 #endif // QT_NO_FREETYPE 305 XCharStruct *xcs = 0;
306 unsigned char r = ch>>8;
307 unsigned char c = ch&0xff;
309 r >= xfs->min_byte1 &&
310 r <= xfs->max_byte1 &&
311 c >= xfs->min_char_or_byte2 &&
312 c <= xfs->max_char_or_byte2) {
313 xcs = xfs->per_char + ((r - xfs->min_byte1) *
314 (xfs->max_char_or_byte2 -
315 xfs->min_char_or_byte2 + 1)) +
316 (c - xfs->min_char_or_byte2);
317 if (xcs->width == 0 && xcs->ascent == 0 && xcs->descent == 0)
324 : _fs(fs), _name(name), _codec(0), _cmap(mib)
328 cache_cost = (((fs->max_byte1 - fs->min_byte1) *
329 (fs->max_char_or_byte2 - fs->min_char_or_byte2 + 1)) +
330 fs->max_char_or_byte2 - fs->min_char_or_byte2);
331 cache_cost = ((fs->max_bounds.ascent + fs->max_bounds.descent) *
344 #ifndef QT_NO_FREETYPE 352 if (*nglyphs < len) {
360 for (
int i = 0; i < len; ++i) {
361 if (s[i].isHighSurrogate() && i < len-1 && s[i+1].isLowSurrogate()) {
375 bool haveNbsp =
false;
376 for (
int i = 0; i < len; i++)
377 if (str[i].unicode() == 0xa0) {
384 if (haveNbsp || mirrored) {
385 for (
int i = 0; i < len; i++)
386 chars[i] = (str[i].unicode() == 0xa0 ? 0x20 :
389 for (
int i = 0; i < len; i++)
390 chars[i] = str[i].unicode();
395 if (ba.
length() == 2*len) {
398 for (
int i = 0; i < len; i++) {
404 for (
int i = 0; i < len; i++)
409 const QChar *
c = str + len;
415 glyphs->
glyphs[--i] = (--
c)->unicode() == 0xa0 ? 0x20 : c->
unicode();
431 if (!
_fs->per_char) {
432 xcs = &
_fs->min_bounds;
435 const unsigned char r = glyphs->
glyphs[i] >> 8;
436 const unsigned char c = glyphs->
glyphs[i] & 0xff;
437 if (r >=
_fs->min_byte1 &&
438 r <= _fs->max_byte1 &&
439 c >=
_fs->min_char_or_byte2 &&
440 c <= _fs->max_char_or_byte2) {
447 else if (!
_fs->max_byte1) {
448 XCharStruct *
base =
_fs->per_char -
_fs->min_char_or_byte2;
450 unsigned int gl = glyphs->
glyphs[--i];
451 xcs = (gl >=
_fs->min_char_or_byte2 && gl <=
_fs->max_char_or_byte2) ?
453 if (!xcs || (!xcs->width && !xcs->ascent && !xcs->descent)) {
487 overall.
x =
qMin(overall.
x, x);
488 overall.
y =
qMin(overall.
y, y);
491 ymax =
qMax(ymax, y + xcs->ascent + xcs->descent);
496 overall.
y =
qMin(overall.
y, overall.
yoff - size);
498 overall.
xoff += size;
503 overall.
width = xmax - overall.
x;
515 gm =
glyph_metrics_t(xcs->lbearing, -xcs->ascent, xcs->rbearing- xcs->lbearing, xcs->ascent + xcs->descent,
531 return (
_fs->descent-1);
543 return _fs->max_bounds.width;
549 return (((f->max_byte1 - f->min_byte1) *
550 (f->max_char_or_byte2 - f->min_char_or_byte2 + 1)) +
551 f->max_char_or_byte2 - f->min_char_or_byte2);
558 XCharStruct *cs =
_fs->per_char;
560 int mx = cs->lbearing;
562 for (
int c = 1;
c < nc;
c++) {
569 int nmx = cs[
c].lbearing;
586 XCharStruct *cs =
_fs->per_char;
588 int mx = cs->rbearing;
590 for (
int c = 1;
c < nc;
c++) {
597 int nmx = cs[
c].rbearing;
619 if (
stringToCMap(
string, len, &glyphs, &nglyphs, 0) ==
false) {
624 bool allExist =
true;
625 for (
int i = 0; i < nglyphs; i++) {
639 if (w <= 0 || h <= 0)
689 #ifndef QT_NO_FREETYPE 711 #ifndef QT_NO_FREETYPE 722 #ifndef QT_NO_FREETYPE 730 #ifndef QT_NO_FREETYPE 734 FT_Set_Char_Size(face, face->units_per_EM << 6, face->units_per_EM << 6, 0, 0);
737 FT_Set_Transform(face, 0, 0);
739 FT_Load_Glyph(face, glyph, FT_LOAD_NO_BITMAP);
741 int left = face->glyph->metrics.horiBearingX;
742 int right = face->glyph->metrics.horiBearingX + face->glyph->metrics.width;
743 int top = face->glyph->metrics.horiBearingY;
744 int bottom = face->glyph->metrics.horiBearingY - face->glyph->metrics.height;
762 #endif // QT_NO_FREETYPE 768 #ifndef QT_NO_FREETYPE 809 for (
int i = 0; i < 256; ++i)
810 colors[i] =
qRgba(0, 0, 0, i);
813 int width = image.
width();
814 int height = image.
height();
815 for (
int y = 0; y < height; ++y) {
817 for (
int x = 0; x < width; ++x)
818 bits[x] = ~(bits[x]-1);
824 #ifndef QT_NO_FREETYPE 858 #ifndef QT_NO_FONTCONFIG 947 FcPatternDestroy(match);
961 FcPatternGetString(pattern, FC_FILE, 0, &fileName);
962 *file_name = (
const char *)fileName;
963 if (!FcPatternGetInteger(pattern, FC_INDEX, 0, index))
966 if (FcPatternGetBool(pattern, FC_ANTIALIAS, 0, &b) == FcResultMatch)
982 face_id.
index = face_index;
988 int subpixel =
X11->display ?
X11->screens[screen].subpixel : FC_RGBA_UNKNOWN;
989 if (subpixel == FC_RGBA_UNKNOWN)
990 (void) FcPatternGetInteger(pattern, FC_RGBA, 0, &subpixel);
991 if (!antialias || subpixel == FC_RGBA_UNKNOWN)
992 subpixel = FC_RGBA_NONE;
1018 #ifdef FC_HINT_STYLE 1023 if (
X11->fc_hint_style > -1 &&
X11->desktopEnvironment ==
DE_GNOME)
1024 hint_style =
X11->fc_hint_style;
1025 else if (FcPatternGetInteger (pattern, FC_HINT_STYLE, 0, &hint_style) == FcResultNoMatch
1026 &&
X11->fc_hint_style > -1)
1027 hint_style =
X11->fc_hint_style;
1029 switch (hint_style) {
1033 case FC_HINT_SLIGHT:
1036 case FC_HINT_MEDIUM:
1046 #if defined(FC_AUTOHINT) && defined(FT_LOAD_FORCE_AUTOHINT) 1048 bool autohint =
false;
1051 if (FcPatternGetBool(pattern, FC_AUTOHINT, 0, &b) == FcResultMatch)
1059 #if defined(FC_LCD_FILTER) && defined(FT_LCD_FILTER_H) 1061 int filter = FC_LCD_FILTER_NONE;
1062 if (FcPatternGetInteger(pattern, FC_LCD_FILTER, 0, &filter) == FcResultMatch) {
1064 case FC_LCD_FILTER_NONE:
1067 case FC_LCD_FILTER_DEFAULT:
1070 case FC_LCD_FILTER_LIGHT:
1073 case FC_LCD_FILTER_LEGACY:
1084 #ifdef FC_EMBEDDED_BITMAP 1087 if (FcPatternGetBool(pattern, FC_EMBEDDED_BITMAP, 0, &b) == FcResultMatch)
1094 #ifndef QT_NO_XRENDER 1095 if (
X11->use_xrender) {
1096 int format = PictStandardA8;
1098 format = PictStandardA1;
1103 format = PictStandardARGB32;
1115 if (!
init(face_id, antialias, defaultFormat))
1120 FcPatternGetCharSet (pattern, FC_CHARSET, 0, &cs);
1132 #ifndef QT_NO_XRENDER 1135 return XRenderCreateGlyphSet(
X11->display, XRenderFindStandardFormat(
X11->display,
xglyph_format));
1143 #ifndef QT_NO_XRENDER 1146 XRenderFreeGlyphSet(
X11->display,
id);
1152 #ifndef QT_NO_XRENDER 1159 if (BitmapBitOrder(
X11->display) != MSBFirst) {
1160 unsigned char *line = g->
data;
1161 int i = glyphDataSize;
1165 c = ((c << 1) & 0xaa) | ((c >> 1) & 0x55);
1166 c = ((c << 2) & 0xcc) | ((c >> 2) & 0x33);
1167 c = ((c << 4) & 0xf0) | ((c >> 4) & 0x0f);
1174 XRenderAddGlyphs (
X11->display,
set->id, &xglyph, info, 1, (
const char *)g->
data, glyphDataSize);
1194 #ifndef QT_NO_XRENDER 1201 #endif // QT_NO_FONTCONFIG
static QFreetypeFace * getFace(const QFontEngine::FaceId &face_id, const QByteArray &fontData=QByteArray())
The QPainter class performs low-level painting on widgets and other paint devices.
SubpixelAntialiasingType subpixelType
QImage toImage() const
Converts the pixmap to a QImage.
unsigned int uploadedToServer
QGlyphJustification * justifications
static QFixed fromFixed(int fixed)
static QString fromLocal8Bit(const char *, int size=-1)
Returns a QString initialized with the first size characters of the 8-bit string str.
QVariant value(const QString &key, const QVariant &defaultValue=QVariant()) const
Returns the value for setting key.
int qt_mib_for_xlfd_encoding(const char *encoding)
static mach_timebase_info_data_t info
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
virtual void addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, QPainterPath *path, QTextItem::RenderFlags)
#define QT_END_NAMESPACE
This macro expands to.
The QMutex class provides access serialization between threads.
const QChar at(int i) const
Returns the character at the given index position in the string.
FcFontSet * qt_fontSetForPattern(FcPattern *pattern, const QFontDef &request)
ushort unicode() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
void setColorTable(const QVector< QRgb > colors)
Sets the color table used to translate color indexes to QRgb values, to the specified colors...
int qt_xlfd_encoding_id(const char *encoding)
#define it(className, varName)
The QPainterPath class provides a container for painting operations, enabling graphical shapes to be ...
bool open(OpenMode flags)
Opens the file using OpenMode mode, returning true if successful; otherwise false.
The QSettings class provides persistent platform-independent application settings.
virtual QFixed leading() const
QFontDef qt_FcPatternToQFontDef(FcPattern *pattern, const QFontDef &request)
bool isNull() const
Returns true if it is a null image, otherwise returns false.
#define at(className, varName)
The QByteArray class provides an array of bytes.
int length() const
Returns the number of characters in this string.
static QStringList fontPath()
The QPointF class defines a point in the plane using floating point precision.
virtual void resize(int width, int height)=0
void beginGroup(const QString &prefix)
Appends prefix to the current group.
virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs)
void insertEngine(const Key &key, QFontEngine *engine)
static bool match(const uchar *found, const char *target, uint len)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the list.
FcPattern * firstEnginePattern
QByteArray toLower() const
Returns a lowercase copy of the byte array.
QLatin1String(DBUS_INTERFACE_DBUS))) Q_GLOBAL_STATIC_WITH_ARGS(QString
virtual qreal minRightBearing() const
int bytesPerLine() const
Returns the number of bytes per image scanline.
const unsigned short * logClusters
Q_GUI_EXPORT void qt_addBitmapToPath(qreal x0, qreal y0, const uchar *image_data, int bpl, int w, int h, QPainterPath *path)
GlyphFormat defaultFormat
bool ref()
Atomically increments the value of this QAtomicInt.
bool getSfntTable(uint tag, uchar *buffer, uint *length) const
The QString class provides a Unicode character string.
virtual qreal maxCharWidth() const
static QFixed fromReal(qreal r)
The QChar class provides a 16-bit Unicode character.
Q_CORE_EXPORT QTextStream & right(QTextStream &s)
glyph_t glyphIndexToFreetypeGlyphIndex(glyph_t g) const
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
void resize(int size)
Sets the size of the vector to size.
virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const
static QFontCache * instance()
Q_GUI_EXPORT void qt_x11ft_convert_pattern(FcPattern *pattern, QByteArray *file_name, int *index, bool *antialias)
bool init(FaceId faceId, bool antiaalias, GlyphFormat defaultFormat=Format_None, const QByteArray &fontData=QByteArray())
bool exists() const
Returns true if the file specified by fileName() exists; otherwise returns false. ...
HintStyle default_hint_style
The QBitmap class provides monochrome (1-bit depth) pixmaps.
static void addGlyphToPath(FT_Face face, FT_GlyphSlot g, const QFixedPoint &point, QPainterPath *path, FT_Fixed x_scale, FT_Fixed y_scale)
static QThread * currentThread()
Returns a pointer to a QThread which manages the currently executing thread.
QStringList toStringList() const
Returns the variant as a QStringList if the variant has type() StringList, String ...
virtual void freeServerGlyphSet(unsigned long id)
static XCharStruct * charStruct(XFontStruct *xfs, uint ch)
#define QT_BEGIN_NAMESPACE
This macro expands to.
virtual bool canRender(const QChar *string, int len)
Q_GUI_EXPORT_INLINE QRgb qRgba(int r, int g, int b, int a)
QByteArray fromUnicode(const QString &uc) const
Converts str from Unicode to the encoding of this codec, and returns the result in a QByteArray...
virtual int synthesized() const
int lastIndexOf(char c, int from=-1) const
Returns the index position of the last occurrence of character ch in the byte array, searching backward from index position from.
struct FT_FaceRec_ * FT_Face
static float pixelSize(const QFontDef &request, int dpi)
QString left(int n) const Q_REQUIRED_RESULT
Returns a substring that contains the n leftmost characters of the string.
static QFontEngine::FaceId fontFile(const QByteArray &_xname, QFreetypeFace **freetype, int *synth)
QString trimmed() const Q_REQUIRED_RESULT
Returns a string that has whitespace removed from the start and the end.
virtual bool uploadGlyphToServer(QGlyphSet *set, uint glyphid, Glyph *g, GlyphInfo *info, int glyphDataSize) const
const T & at(int i) const
Returns the item at index position i in the list.
QChar mirroredChar() const
Returns the mirrored character if this character is a mirrored character; otherwise returns the chara...
The QStringList class provides a list of strings.
static void addBitmapToPath(FT_GlyphSlot slot, const QFixedPoint &point, QPainterPath *path, bool=false)
static int maxIndex(XFontStruct *f)
The QImage class provides a hardware-independent image representation that allows direct access to th...
virtual qreal minLeftBearing() const
virtual int mibEnum() const =0
Subclasses of QTextCodec must reimplement this function.
static const char * data(const QByteArray &arr)
int indexOf(QChar c, int from=0, Qt::CaseSensitivity cs=Qt::CaseSensitive) const
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal...
virtual void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics)
static QTextCodec * codecForMib(int mib)
Returns the QTextCodec which matches the MIBenum mib.
virtual const char * name() const
QByteArray left(int len) const
Returns a byte array that contains the leftmost len bytes of this byte array.
QByteArray mid(int index, int len=-1) const
Returns a byte array containing len bytes from this byte array, starting at position pos...
int indexOf(char c, int from=0) const
Returns the index position of the first occurrence of the character ch in the byte array...
virtual void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics)
static QStringList * qt_fontpath
const T & at(int i) const
Returns the item at index position i in the vector.
static QFontEngine * loadXlfd(int screen, int script, const QFontDef &request, int force_encoding_id=-1)
QFontEngine::FaceId face_id
QVector< QFontEngine * > engines
QByteArray postscriptName
int length() const
Same as size().
void resize(int totalGlyphs)
const char * constData() const
Returns a pointer to the data stored in the byte array.
QString toUnicode(const QByteArray &) const
Converts a from the encoding of this codec to Unicode, and returns the result in a QString...
virtual const char * name() const
QString mid(int position, int n=-1) const Q_REQUIRED_RESULT
Returns a string that contains n characters of this string, starting at the specified position index...
uchar * bits()
Returns a pointer to the first pixel data.
bool initFromFontEngine(const QFontEngineFT *fontEngine)
QFontEngine::Properties properties() const
QFontEngineX11FT(const QFontDef &fontDef)
int width() const
Returns the width of the image.
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
QImage convertToFormat(Format f, Qt::ImageConversionFlags flags=Qt::AutoColor) const Q_REQUIRED_RESULT
Returns a copy of the image in the given format.
static void set(QJustificationPoint *point, int type, const QGlyphLayout &glyph, QFontEngine *fe)
The QFile class provides an interface for reading from and writing to files.
virtual Properties properties() const
QString trimmed(QString source)
qint64 readLine(char *data, qint64 maxlen)
This function reads a line of ASCII characters from the device, up to a maximum of maxSize - 1 bytes...
void release(const QFontEngine::FaceId &face_id)
FT_Face non_locked_face() const
virtual QFixed descent() const
static QMap< QByteArray, int > mapping
const_iterator ConstIterator
Qt-style synonym for QList::const_iterator.
void drawTextItem(const QPointF &p, const QTextItem &ti)
Draws the text item ti at position p.
QFontEngine::Properties properties() const
void setPen(const QColor &color)
Sets the painter's pen to have style Qt::SolidLine, width 0 and the specified color.
bool canUploadGlyphsToServer
QFontEngine * cloneWithSize(qreal pixelSize) const
QFontEngine::FaceId face_id
QFuture< void > filter(Sequence &sequence, FilterFunction filterFunction)
int height() const
Returns the height of the image.
virtual unsigned long allocateServerGlyphSet()
QMutex * qt_fontdatabase_mutex()
QFontEngineXLFD(XFontStruct *f, const QByteArray &name, int mib)
The QPixmap class is an off-screen image representation that can be used as a paint device...
virtual bool getSfntTableData(uint tag, uchar *buffer, uint *length) const
virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs, QTextEngine::ShaperFlags flags) const
QFontEngineMultiXLFD(const QFontDef &r, const QList< int > &l, int s)
bool isEmpty() const
Returns true if the byte array has size 0; otherwise returns false.
QBitmap bitmapForGlyphs(const QGlyphLayout &glyphs, const glyph_metrics_t &metrics, QTextItem::RenderFlags flags=0)
QFontEngine * findEngine(const Key &key)
FileError error() const
Returns the file error status.
static bool testAttribute(Qt::ApplicationAttribute attribute)
Returns true if attribute attribute is set; otherwise returns false.
bool atEnd() const
Returns true if the end of the file has been reached; otherwise returns false.
static const KeyPair *const end
QFontEngineMultiFT(QFontEngine *fe, FcPattern *firstEnginePattern, FcPattern *p, int s, const QFontDef &request)
virtual void close()
Calls QFile::flush() and closes the file.
Q_CORE_EXPORT QTextStream & left(QTextStream &s)
#define Q_UNUSED(x)
Indicates to the compiler that the parameter with the specified name is not used in the body of a fun...
static QString fileName(const QString &fileUrl)
virtual QImage alphaMapForGlyph(glyph_t)
int size() const
Returns the number of items in the vector.
uint toUnicode(glyph_t g) const
The QLatin1Char class provides an 8-bit ASCII/Latin-1 character.
virtual QFontEngine::FaceId faceId() const
virtual QFixed ascent() const
static Display * display()
Returns the default display for the application.
uchar * scanLine(int)
Returns a pointer to the pixel data at the scanline with index i.
void setFileName(const QString &name)
Sets the name of the file.
void fillRect(const QRectF &, const QBrush &)
Fills the given rectangle with the brush specified.
static QFontEngine * engineForPattern(FcPattern *match, const QFontDef &request, int screen)
QBool contains(char c) const
Returns true if the byte array contains the character ch; otherwise returns false.
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the list...