src/gui/text/qfontengine_x11_p.h
changeset 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the QtGui module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #ifndef QFONTENGINE_X11_P_H
       
    43 #define QFONTENGINE_X11_P_H
       
    44 
       
    45 //
       
    46 //  W A R N I N G
       
    47 //  -------------
       
    48 //
       
    49 // This file is not part of the Qt API.  It exists purely as an
       
    50 // implementation detail.  This header file may change from version to
       
    51 // version without notice, or even be removed.
       
    52 //
       
    53 // We mean it.
       
    54 //
       
    55 #include <private/qt_x11_p.h>
       
    56 
       
    57 #include <private/qfontengine_ft_p.h>
       
    58 
       
    59 QT_BEGIN_NAMESPACE
       
    60 
       
    61 class QFreetypeFace;
       
    62 
       
    63 // --------------------------------------------------------------------------
       
    64 
       
    65 class QFontEngineMultiXLFD : public QFontEngineMulti
       
    66 {
       
    67 public:
       
    68     QFontEngineMultiXLFD(const QFontDef &r, const QList<int> &l, int s);
       
    69     ~QFontEngineMultiXLFD();
       
    70 
       
    71     void loadEngine(int at);
       
    72 
       
    73 private:
       
    74     QList<int> encodings;
       
    75     int screen;
       
    76     QFontDef request;
       
    77 };
       
    78 
       
    79 /**
       
    80  * \internal The font engine for X Logical Font Description (XLFD) fonts, which is for X11 systems without freetype.
       
    81  */
       
    82 class QFontEngineXLFD : public QFontEngine
       
    83 {
       
    84 public:
       
    85     QFontEngineXLFD(XFontStruct *f, const QByteArray &name, int mib);
       
    86     ~QFontEngineXLFD();
       
    87 
       
    88     virtual QFontEngine::FaceId faceId() const;
       
    89     QFontEngine::Properties properties() const;
       
    90     virtual void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics);
       
    91     virtual bool getSfntTableData(uint tag, uchar *buffer, uint *length) const;
       
    92     virtual int synthesized() const;
       
    93 
       
    94     virtual bool stringToCMap(const QChar *str, int len, QGlyphLayout *glyphs, int *nglyphs,
       
    95                       QTextEngine::ShaperFlags flags) const;
       
    96     virtual void recalcAdvances(QGlyphLayout *, QTextEngine::ShaperFlags) const;
       
    97 
       
    98     virtual glyph_metrics_t boundingBox(const QGlyphLayout &glyphs);
       
    99     virtual glyph_metrics_t boundingBox(glyph_t glyph);
       
   100 
       
   101     virtual void addOutlineToPath(qreal x, qreal y, const QGlyphLayout &glyphs, QPainterPath *path, QTextItem::RenderFlags);
       
   102     virtual QFixed ascent() const;
       
   103     virtual QFixed descent() const;
       
   104     virtual QFixed leading() const;
       
   105     virtual qreal maxCharWidth() const;
       
   106     virtual qreal minLeftBearing() const;
       
   107     virtual qreal minRightBearing() const;
       
   108     virtual QImage alphaMapForGlyph(glyph_t);
       
   109 
       
   110     virtual inline Type type() const
       
   111     { return QFontEngine::XLFD; }
       
   112 
       
   113     virtual bool canRender(const QChar *string, int len);
       
   114     virtual const char *name() const;
       
   115 
       
   116     inline XFontStruct *fontStruct() const
       
   117     { return _fs; }
       
   118 
       
   119 #ifndef QT_NO_FREETYPE
       
   120     FT_Face non_locked_face() const;
       
   121     glyph_t glyphIndexToFreetypeGlyphIndex(glyph_t g) const;
       
   122 #endif
       
   123     uint toUnicode(glyph_t g) const;
       
   124 
       
   125 private:
       
   126     QBitmap bitmapForGlyphs(const QGlyphLayout &glyphs, const glyph_metrics_t &metrics, QTextItem::RenderFlags flags = 0);
       
   127 
       
   128     XFontStruct *_fs;
       
   129     QByteArray _name;
       
   130     QTextCodec *_codec;
       
   131     int _cmap;
       
   132     int lbearing, rbearing;
       
   133     mutable QFontEngine::FaceId face_id;
       
   134     mutable QFreetypeFace *freetype;
       
   135     mutable int synth;
       
   136 };
       
   137 
       
   138 #ifndef QT_NO_FONTCONFIG
       
   139 
       
   140 class Q_GUI_EXPORT QFontEngineMultiFT : public QFontEngineMulti
       
   141 {
       
   142 public:
       
   143     QFontEngineMultiFT(QFontEngine *fe, FcPattern *firstEnginePattern, FcPattern *p, int s, const QFontDef &request);
       
   144     ~QFontEngineMultiFT();
       
   145 
       
   146     void loadEngine(int at);
       
   147 
       
   148 private:
       
   149     QFontDef request;
       
   150     FcPattern *pattern;
       
   151     FcPattern *firstEnginePattern;
       
   152     FcFontSet *fontSet;
       
   153     int screen;
       
   154     int firstFontIndex; // first font in fontset
       
   155 };
       
   156 
       
   157 class Q_GUI_EXPORT QFontEngineX11FT : public QFontEngineFT
       
   158 {
       
   159 public:
       
   160     explicit QFontEngineX11FT(FcPattern *pattern, const QFontDef &fd, int screen);
       
   161     ~QFontEngineX11FT();
       
   162 
       
   163 #ifndef QT_NO_XRENDER
       
   164     int xglyph_format;
       
   165 #endif
       
   166 
       
   167 protected:
       
   168     virtual bool uploadGlyphToServer(QGlyphSet *set, uint glyphid, Glyph *g, GlyphInfo *info, int glyphDataSize) const;
       
   169     virtual unsigned long allocateServerGlyphSet();
       
   170     virtual void freeServerGlyphSet(unsigned long id);
       
   171 };
       
   172 
       
   173 #endif // QT_NO_FONTCONFIG
       
   174 
       
   175 QT_END_NAMESPACE
       
   176 
       
   177 #endif // QFONTENGINE_X11_P_H