00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 #ifndef FONTFACE_INCLUDED
00012 #define FONTFACE_INCLUDED
00013
00014 #include <string>
00015 #include <set>
00016 #include <vector>
00017
00018 #include <ft2build.h>
00019 #include FT_FREETYPE_H
00020 #include FT_SFNT_NAMES_H
00021
00022 #include "Utf8String.h"
00023 #include "FontLibrary.h"
00024 #include "OrthographyResults.h"
00025 #include "LicenseData.h"
00026
00027
00028
00029
00030 #include "MLR.h"
00031
00032
00033
00034
00035
00036 class FontFace{
00037
00038 public:
00039
00040
00041
00042
00043
00044 struct compare{
00045 bool operator()(const FontFace *f1,const FontFace *f2) const{
00046 std::string t1, t2;
00047 t1 = f1->_commonName;
00048 t1 += f1->_subFamily ;
00049 t2 = f2->_commonName;
00050 t2 += f2->_subFamily ;
00051 return t1 < t2;
00052 }
00053 };
00054
00055
00056
00057
00058 enum FAMILY { SERIF, SANS, CURSIVE, FANTASY, MONOSPACE };
00059 enum STYLE { NORMAL, ITALIC, OBLIQUE };
00060 enum VARIANT { NORMAL_VARIANT, SMALL_CAPS };
00061
00062 enum WEIGHT { NORMAL_WEIGHT, BOLD, W100, W200, W300, W400, W500, W600, W700, W800, W900 };
00063
00064
00065
00066
00067
00068 enum STROKE { UNMODULATED, SEMIMODULATED, MODULATED };
00069
00070 enum NAMEID {
00071 NID_COPYRIGHT =0,
00072 NID_FONT_FAMILY =1,
00073 NID_FONT_SUBFAM =2,
00074 NID_UNIQUE_ID =3,
00075 NID_FULL_NAME =4,
00076 NID_VERSION =5,
00077 NID_POSTSCRIPT =6,
00078 NID_TRADEMARK =7,
00079 NID_VENDOR =8,
00080 NID_DESIGNER =9,
00081 NID_DESCRIPTION =10,
00082 NID_URL_VENDOR =11,
00083 NID_URL_DESIGNER=12,
00084 NID_LICENSE =13,
00085 NID_URL_LICENSE =14,
00086 NID_RESERVED =15,
00087 NID_PREF_NAME =16,
00088 NID_PREF_SUBFAM =17,
00089 NID_MAC_FULLNAME=18,
00090 NID_SAMPLETEXT =19,
00091 NID_FINDFONT_NM =20,
00092 };
00093
00094 private:
00095
00096 FT_Face _face;
00097
00098 std::string _fileName;
00099 std::string _commonName;
00100 std::string _nativeName;
00101 std::string _subFamily;
00102
00103 std::string _copyright;
00104
00105 std::string _licenseURL;
00106
00107 unsigned _glyphCount;
00108
00109 FAMILY _genericFamily;
00110 STYLE _style;
00111 VARIANT _variant;
00112 WEIGHT _weight;
00113 STROKE _stroke;
00114
00115
00116
00117
00118 std::vector< const OrthographyResults * > _supportedOrthographies;
00119
00120
00121
00122
00123 const LicenseData *_licenseData;
00124
00125 bool _hasVerticalMetrics;
00126 bool _isFixedWidth;
00127 bool _hasFixedSizes;
00128
00129 std::set<UTF32> _unicodeValues;
00130
00131 UTF8String _getPlatform3Encoding1String( unsigned length, const FT_Byte *string) const;
00132 UTF8String _getPlatform1Encoding0String( unsigned length, const FT_Byte *string) const;
00133 UTF8String _getStringFromTrueTypeFont(FT_SfntName &fontName) const;
00134
00135 unsigned int _getUnicodeValues(void);
00136
00137
00138
00139
00140 bool _reportMissing;
00141 bool _reportFragmentary;
00142 bool _reportPartial;
00143 bool _reportFull;
00144
00145 public:
00146
00147
00148
00149
00150 FontFace( FontLibrary &library, const std::string &fileName );
00151
00152
00153
00154
00155 ~FontFace();
00156
00157
00158
00159
00160 bool hasUnicodeValue(UTF32) const;
00161
00162
00163
00164
00165 std::string getBasicReport(void) const;
00166 std::string getOrthographyReport(void) const;
00167
00168
00169
00170
00171 void setReportOnMissing(bool x);
00172 void setReportOnFragmentary(bool x);
00173 void setReportOnPartial(bool x);
00174 void setReportOnFull(bool x);
00175
00176 private:
00177
00178 bool _checkOrthography( const OrthographyData *pData );
00179 void _checkOrthographies(void);
00180
00181 bool _checkLicense( const std::string &test, const LicenseData *pData);
00182 bool _checkAllKnownLicenses( const std::string &licenseString);
00183 void _storeCopyrightSummary(const std::string ©rightString);
00184 void _checkLicenses(void);
00185
00186 public:
00187
00188
00189
00190
00191 const std::string & getFileName(void) const;
00192 const std::string & getCommonName(void) const;
00193 const std::string & getNativeName(void) const;
00194 const std::string & getSubFamily(void) const;
00195
00196 std::string getLicenseReport(void) const;
00197 const std::string & getCopyright(void) const;
00198
00199 unsigned getGlyphCount(void) const;
00200 unsigned getCharacterCount(void) const;
00201 FAMILY getFamily(void) const;
00202 STYLE getStyle(void) const;
00203 VARIANT getVariant(void) const;
00204 WEIGHT getWeight(void) const;
00205 STROKE getStroke(void) const;
00206 bool hasVerticalMetrics(void) const;
00207 bool isFixedWidth(void) const;
00208 bool hasFixedSizes(void) const;
00209
00210
00211
00212
00213
00214 void fillReport(MLR *mlr);
00215
00216 };
00217
00218 #endif