QCAD
Open Source 2D CAD
RFont.h
Go to the documentation of this file.
1 
20 #ifndef RFONT_H
21 #define RFONT_H
22 
23 #include "core_global.h"
24 
25 #include <QMetaType>
26 #include <QChar>
27 #include <QMap>
28 #include <QPainterPath>
29 #include <QString>
30 #include <QStringList>
31 
32 
40 public:
41  RFont();
42  RFont(const QString& fileName);
43  ~RFont();
44 
45  bool isValid() const {
46  return !fileName.isEmpty();
47  }
48 
50  QString getFileName() const {
51  return fileName;
52  }
53 
55  QString getEncoding() const {
56  return encoding;
57  }
58 
60  const QStringList getNames() const {
61  return names;
62  }
63 
65  const QStringList getAuthors() const {
66  return authors;
67  }
68 
70  double getLetterSpacing() const {
71  return letterSpacing;
72  }
73 
75  double getWordSpacing() const {
76  return wordSpacing;
77  }
78 
80  double getLineSpacingFactor() const {
81  return lineSpacingFactor;
82  }
83 
84  bool load();
85 
89  bool isLoaded() const {
90  return loaded;
91  }
92 
96  QMap<QChar, QPainterPath> getGlyphMap() const {
97  return glyphMap;
98  }
99 
103  QPainterPath getGlyph(const QChar& ch, bool draft = false) const;
104 
108  QPainterPath getShape(const QString& name) const;
109 
113  QString getShapeName(const QChar& ch) const;
114 
115  //int countGlyphs() {
116  // return glyphMap.count();
117  //}
118 
119  //QPainterPath glyphAt(int i) {
120  // return glyphMap.values()
121  //}
122 
123 private:
125  QMap<QChar, QPainterPath> glyphMap;
126  QMap<QString, QPainterPath> shapeMap;
127  QMap<QChar, QString> numNameMap;
128  QMap<QChar, QPainterPath> glyphDraftMap;
129 
131  QString fileName;
132 
134  QString encoding;
135 
137  QStringList names;
138 
140  QStringList authors;
141 
143  bool loaded;
144 
147 
149  double wordSpacing;
150 
153 };
154 
157 
158 #endif
double letterSpacing
Default letter spacing for this font.
Definition: RFont.h:146
Copyright (c) 2011-2015 by Andrew Mustun.
Definition: RFont.h:39
bool loaded
Is this font currently loaded into memory?
Definition: RFont.h:143
#define QCADCORE_EXPORT
Definition: core_global.h:10
QMap< QChar, QPainterPath > glyphDraftMap
Definition: RFont.h:128
const QStringList getNames() const
Definition: RFont.h:60
double wordSpacing
Default word spacing for this font.
Definition: RFont.h:149
QString getEncoding() const
Definition: RFont.h:55
QMap< QChar, QPainterPath > getGlyphMap() const
Definition: RFont.h:96
double getWordSpacing() const
Definition: RFont.h:75
const QStringList getAuthors() const
Definition: RFont.h:65
Q_DECLARE_METATYPE(RMath *)
double lineSpacingFactor
Default line spacing factor for this font.
Definition: RFont.h:152
QMap< QString, QPainterPath > shapeMap
Definition: RFont.h:126
double getLetterSpacing() const
Definition: RFont.h:70
QString fileName
Font file name.
Definition: RFont.h:131
bool isValid() const
Definition: RFont.h:45
QStringList names
Font names.
Definition: RFont.h:137
double getLineSpacingFactor() const
Definition: RFont.h:80
QStringList authors
Authors.
Definition: RFont.h:140
QString encoding
Font encoding (see docu for QTextCodec)
Definition: RFont.h:134
QMap< QChar, QString > numNameMap
Definition: RFont.h:127
QMap< QChar, QPainterPath > glyphMap
list of glyphs as painter paths (letters)
Definition: RFont.h:125
QString getFileName() const
Definition: RFont.h:50
bool isLoaded() const
Definition: RFont.h:89