home *** CD-ROM | disk | FTP | other *** search
/ Clickx 115 / Clickx 115.iso / software / tools / windows / tails-i386-0.16.iso / live / filesystem.squashfs / usr / include / scribus-ng / scfonts.h < prev    next >
Encoding:
C/C++ Source or Header  |  2007-09-02  |  3.0 KB  |  99 lines

  1. /*
  2. For general Scribus (>=1.3.2) copyright and licensing information please refer
  3. to the COPYING file provided with the program. Following this notice may exist
  4. a copyright and/or license notice that predates the release of Scribus 1.3.2
  5. for which a new license (GPL+exception) is in place.
  6. */
  7. #ifndef SCFONTS_H
  8. #define SCFONTS_H
  9.  
  10. #include <QByteArray>
  11. #include <QDateTime>
  12. #include <QFont>
  13. #include <QList>
  14. #include <QMap>
  15. #include <QString>
  16. #include <QStringList>
  17.  
  18. #include <ft2build.h>
  19. #include FT_FREETYPE_H
  20. #include FT_OUTLINE_H
  21. #include FT_GLYPH_H
  22.  
  23. FT_Error ftIOFunc( FT_Stream fts, unsigned long offset, unsigned char* buffer, unsigned long count);
  24.  
  25. #include "fonts/scface.h"
  26. #include "fpointarray.h"
  27. #include "scconfig.h"
  28. #include "scribusapi.h"
  29.  
  30.  
  31. class ScribusDoc;
  32.  
  33. /*! \brief Main class SCFonts.
  34. Subclass of QDict<ScFace>.
  35. This class replaces the previous SCFonts typedef, and is nearly as convenient.
  36. The chief difference from the application point of view is that while data can
  37. still be retrieved with SCFonts[fontname], this cannot be used to add members.
  38. Since the only piece of code that will generally add members is scfonts.h, this
  39. is not a major problem.
  40. */
  41. class SCRIBUS_API SCFonts : public QMap<QString,ScFace>
  42. {
  43.     public:
  44.         SCFonts();
  45.         ~SCFonts();
  46.         void updateFontMap();
  47.         void GetFonts(QString pf, bool showFontInfo=false);
  48.         void AddScalableFonts(const QString& path, QString DocName = "");
  49.         /// Returns a font with that name; creates a replacement font if not found
  50.         const ScFace& findFont(const QString& fontName, ScribusDoc* doc = NULL);
  51.         /// Returns a map of pairs (scName, replacementName). Using this map for replaceFonts() will make substitutions permanent
  52.         QMap<QString,QString> getSubstitutions(const QList<QString> skip = QList<QString>()) const;
  53.         /// Changes replacement fonts to point to new real fonts. For all keys 'nam' in 'substitutes', findFont(name).isReplacement() must be true
  54.         void setSubstitutions(const QMap<QString,QString>& substitutes, ScribusDoc* doc = NULL);
  55.         void removeFont(QString name);
  56.         /// maps family name to face variants
  57.         QMap<QString, QStringList> fontMap;
  58.     private:
  59.         void ReadCacheList(QString pf);
  60.         void WriteCacheList(QString pf);
  61.         void AddPath(QString p);
  62.         bool AddScalableFont(QString filename, FT_Library &library, QString DocName);
  63.         void AddUserPath(QString pf);
  64. #ifdef HAVE_FONTCONFIG
  65.         void AddFontconfigFonts();
  66. #else
  67. #ifndef Q_OS_MAC
  68.         void AddXFontServerPath();
  69.         void AddXFontPath();
  70. #endif
  71. #endif
  72.         QStringList FontPath;
  73.         QString ExtraPath;
  74.         struct testCache
  75.         {
  76.             bool isOK;
  77.             bool isChecked;
  78.             QDateTime lastMod;
  79.         };
  80.         QMap<QString, testCache> checkedFonts;
  81.     protected:
  82.         bool showFontInformation;
  83. };
  84.  
  85. struct SCFontsIterator
  86. {
  87.     SCFontsIterator(SCFonts& fonts): it(fonts.begin()), end_it(fonts.end()) 
  88.     {}
  89.     ScFace& current()          { return *it; }
  90.     QString currentKey() const { return it.key(); }
  91.     bool hasNext()       const { return it != end_it; }
  92.     ScFace& next()             { ++it; return current(); }
  93.  
  94. private:
  95.     QMap<QString,ScFace>::Iterator it, end_it;
  96. };
  97.  
  98. #endif
  99.