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 #include "RPainterPath.h"
33 
41 public:
42  RFont();
43  RFont(const QString& fileName);
44  ~RFont();
45 
46  bool isValid() const {
47  return !fileName.isEmpty();
48  }
49 
51  QString getFileName() const {
52  return fileName;
53  }
54 
56  QString getEncoding() const {
57  return encoding;
58  }
59 
61  const QStringList getNames() const {
62  return names;
63  }
64 
66  const QStringList getAuthors() const {
67  return authors;
68  }
69 
71  double getLetterSpacing() const {
72  return letterSpacing;
73  }
74 
76  double getWordSpacing() const {
77  return wordSpacing;
78  }
79 
81  double getLineSpacingFactor() const {
82  return lineSpacingFactor;
83  }
84 
85  bool load();
86 
90  bool isLoaded() const {
91  return loaded;
92  }
93 
97  QMap<QChar, RPainterPath> getGlyphMap() const {
98  return glyphMap;
99  }
100 
104  RPainterPath getGlyph(const QChar& ch, bool draft = false) const;
105 
109  QPainterPath getShape(const QString& name) const;
110 
114  QString getShapeName(const QChar& ch) const;
115 
116  //int countGlyphs() {
117  // return glyphMap.count();
118  //}
119 
120  //QPainterPath glyphAt(int i) {
121  // return glyphMap.values()
122  //}
123 
124 private:
126  QMap<QChar, RPainterPath> glyphMap;
128  QMap<QString, QPainterPath> shapeMap;
129  QMap<QChar, QString> numNameMap;
130  QMap<QChar, QPainterPath> glyphDraftMap;
131 
133  QString fileName;
134 
136  QString encoding;
137 
139  QStringList names;
140 
142  QStringList authors;
143 
145  bool loaded;
146 
149 
151  double wordSpacing;
152 
155 };
156 
159 
160 #endif
double letterSpacing
Default letter spacing for this font.
Definition: RFont.h:148
Copyright (c) 2011-2017 by Andrew Mustun.
Definition: RFont.h:40
bool loaded
Is this font currently loaded into memory?
Definition: RFont.h:145
#define QCADCORE_EXPORT
Definition: core_global.h:10
QMap< QChar, QPainterPath > glyphDraftMap
Definition: RFont.h:130
const QStringList getNames() const
Definition: RFont.h:61
QMap< QChar, RPainterPath > getGlyphMap() const
Definition: RFont.h:97
QMap< QChar, RPainterPath > glyphMap
list of glyphs as painter paths (letters)
Definition: RFont.h:126
double wordSpacing
Default word spacing for this font.
Definition: RFont.h:151
QString getEncoding() const
Definition: RFont.h:56
double getWordSpacing() const
Definition: RFont.h:76
const QStringList getAuthors() const
Definition: RFont.h:66
Q_DECLARE_METATYPE(RMath *)
double lineSpacingFactor
Default line spacing factor for this font.
Definition: RFont.h:154
QMap< QString, QPainterPath > shapeMap
list of shapes (used for complex line types)
Definition: RFont.h:128
double getLetterSpacing() const
Definition: RFont.h:71
QString fileName
Font file name.
Definition: RFont.h:133
Extended painter path with a z-level and a pen.
Definition: RPainterPath.h:46
bool isValid() const
Definition: RFont.h:46
QStringList names
Font names.
Definition: RFont.h:139
double getLineSpacingFactor() const
Definition: RFont.h:81
QStringList authors
Authors.
Definition: RFont.h:142
QString encoding
Font encoding (see docu for QTextCodec)
Definition: RFont.h:136
QMap< QChar, QString > numNameMap
Definition: RFont.h:129
QString getFileName() const
Definition: RFont.h:51
bool isLoaded() const
Definition: RFont.h:90