34 #undef HBTYPEFACEINFO_DEBUG_ENABLE |
34 #undef HBTYPEFACEINFO_DEBUG_ENABLE |
35 //#define HBTYPEFACEINFO_DEBUG_ENABLE |
35 //#define HBTYPEFACEINFO_DEBUG_ENABLE |
36 |
36 |
37 |
37 |
38 #ifdef Q_OS_SYMBIAN |
38 #ifdef Q_OS_SYMBIAN |
39 #define HB_FONTS_WRITABLE_PATH QString("c:\\hb\\fonts") |
39 #define HB_FONTS_WRITABLE_PATH QString("c:\\hb\\fonts") |
40 #else |
40 #else |
41 #ifndef Q_OS_UNIX |
41 #ifndef Q_OS_UNIX |
42 #define HB_FONTS_WRITABLE_PATH QString("c:\\Hb\\lib") |
42 #define HB_FONTS_WRITABLE_PATH QString("c:\\Hb\\lib") |
43 #endif |
43 #endif |
44 #endif |
44 #endif |
45 |
45 |
46 // Recognized texts for values of role strings |
46 // Recognized texts for values of role strings |
47 #define PRIMARY_STRING "primary" |
47 #define PRIMARY_STRING "primary" |
48 #define SECONDARY_STRING "secondary" |
48 #define SECONDARY_STRING "secondary" |
92 return encoded; |
92 return encoded; |
93 } |
93 } |
94 |
94 |
95 static bool isAliasRole(const QString &roleName) |
95 static bool isAliasRole(const QString &roleName) |
96 { |
96 { |
97 bool alias(false); // return value |
97 bool alias(false); // return value |
98 QString name = roleName.toLower(); |
98 QString name = roleName.toLower(); |
99 if (name == ALIAS_STRING) { |
99 if (name == ALIAS_STRING) { |
100 alias = true; |
100 alias = true; |
101 } |
101 } |
102 return alias; |
102 return alias; |
103 } |
103 } |
104 /*! |
104 /*! |
105 Returns path to a writable location that should be used as a base storage folder for |
105 Returns path to a writable location that should be used as a base storage folder for |
106 dynamic metric creation. |
106 dynamic metric creation. |
107 */ |
107 */ |
111 return HB_FONTS_WRITABLE_PATH; |
111 return HB_FONTS_WRITABLE_PATH; |
112 #else |
112 #else |
113 if (QString(HB_BUILD_DIR) == QString(HB_INSTALL_DIR)) { |
113 if (QString(HB_BUILD_DIR) == QString(HB_INSTALL_DIR)) { |
114 // This is local build so also use local writable path. |
114 // This is local build so also use local writable path. |
115 return QString(HB_INSTALL_DIR) + QDir::separator() + QString(".hb") |
115 return QString(HB_INSTALL_DIR) + QDir::separator() + QString(".hb") |
116 + QDir::separator() + QString("fonts"); |
116 + QDir::separator() + QString("fonts"); |
117 } else { |
117 } else { |
118 #ifdef Q_OS_UNIX |
118 #ifdef Q_OS_UNIX |
119 return QDir::homePath() + QDir::separator() + QString(".hb") |
119 return QDir::homePath() + QDir::separator() + QString(".hb") |
120 + QDir::separator() + QString("fonts"); |
120 + QDir::separator() + QString("fonts"); |
121 #else |
121 #else |
122 return HB_FONTS_WRITABLE_PATH ; |
122 return HB_FONTS_WRITABLE_PATH ; |
123 #endif |
123 #endif |
124 } |
124 } |
125 #endif |
125 #endif |
182 HbFontSpec::Role roleEnum; |
182 HbFontSpec::Role roleEnum; |
183 if (encodeRole(role, roleEnum)){ |
183 if (encodeRole(role, roleEnum)){ |
184 item.mRoleEnum = roleEnum; |
184 item.mRoleEnum = roleEnum; |
185 item.mFamily = family; |
185 item.mFamily = family; |
186 item.mIsBold = isBold; |
186 item.mIsBold = isBold; |
187 item.mIsAlias = false; |
187 item.mIsAlias = false; |
188 mTypefaceInfoVector->append( item ); |
188 mTypefaceInfoVector->append( item ); |
189 } |
189 } |
190 else if (isAliasRole(role)) { |
190 else if (isAliasRole(role)) { |
191 item.mRoleEnum = HbFontSpec::Undefined; |
191 item.mRoleEnum = HbFontSpec::Undefined; |
192 item.mFamily = aliasFamily; |
192 item.mFamily = aliasFamily; |
193 item.mAliasedFamily = family; |
193 item.mAliasedFamily = family; |
194 item.mIsBold = isBold; |
194 item.mIsBold = isBold; |
195 item.mIsAlias = true; |
195 item.mIsAlias = true; |
196 mTypefaceInfoVector->append( item ); |
196 mTypefaceInfoVector->append( item ); |
197 } |
197 } |
198 } |
198 } |
199 |
199 |
200 HbTypefaceInfoItem *undefinedFontspec = 0; |
200 HbTypefaceInfoItem *undefinedFontspec = 0; |
201 HbTypefaceInfoItem *secondaryFontspec = 0; |
201 HbTypefaceInfoItem *secondaryFontspec = 0; |
241 |
241 |
242 |
242 |
243 |
243 |
244 |
244 |
245 bool HbTypefaceInfoDatabase::readTypefaceMetricsFile( HbTypefaceXmlParser *parser, |
245 bool HbTypefaceInfoDatabase::readTypefaceMetricsFile( HbTypefaceXmlParser *parser, |
246 HbTypefaceInfoItem *typeFaceInfoItem ) |
246 HbTypefaceInfoItem *typeFaceInfoItem ) |
247 { |
247 { |
|
248 Q_ASSERT (parser && typeFaceInfoItem); |
|
249 |
248 int numPoints(0); |
250 int numPoints(0); |
249 |
251 QString typefaceMetricsFileName; |
250 parser->init(); |
252 |
251 |
253 typefaceMetricsFileName.append(TYPEFACE_RESOURCE_FOLDER); |
252 QString typefaceMetricsFileName; |
254 typefaceMetricsFileName.append(QDir::separator()); |
253 |
255 typefaceMetricsFileName.append(TYPEFACE_METRICS_FILE_STEM); |
254 typefaceMetricsFileName.append(TYPEFACE_RESOURCE_FOLDER); |
256 |
255 typefaceMetricsFileName.append(QDir::separator()); |
|
256 typefaceMetricsFileName.append(TYPEFACE_METRICS_FILE_STEM); |
|
257 // replace whitespace with underscores and append |
257 // replace whitespace with underscores and append |
258 QString temp = typeFaceInfoItem->mFamily; |
258 QString temp = typeFaceInfoItem->mFamily; |
259 temp = temp.toLower().replace(QRegExp("\\s+"), QString("_")); |
259 temp = temp.toLower().replace(QRegExp("\\s+"), QString("_")); |
260 typefaceMetricsFileName.append( temp ); |
260 typefaceMetricsFileName.append( temp ); |
261 typefaceMetricsFileName.append(".xml"); |
261 typefaceMetricsFileName.append(".xml"); |
262 |
262 |
263 QFile *file = new QFile(typefaceMetricsFileName); |
263 QFile *file = new QFile(typefaceMetricsFileName); |
264 if( !(file && file->exists()) ) { |
264 if( !(file && file->exists()) ) { |
265 typefaceMetricsFileName = writablePath(); |
265 typefaceMetricsFileName = writablePath(); |
266 typefaceMetricsFileName.append(QDir::separator()); |
266 typefaceMetricsFileName.append(QDir::separator()); |
267 typefaceMetricsFileName.append(TYPEFACE_METRICS_FILE_STEM); |
267 typefaceMetricsFileName.append(TYPEFACE_METRICS_FILE_STEM); |
268 typefaceMetricsFileName.append( temp ); |
268 typefaceMetricsFileName.append( temp ); |
269 typefaceMetricsFileName.append(".xml"); |
269 typefaceMetricsFileName.append(".xml"); |
270 } |
270 } |
271 delete file; |
271 delete file; |
272 |
272 |
273 #ifdef HBTYPEFACEINFO_DEBUG_ENABLE |
273 #ifdef HBTYPEFACEINFO_DEBUG_ENABLE |
274 qDebug("HbDownsizeInfo::readTypefaceMetricsFile: typeface metric filename: %s", |
274 qDebug("HbDownsizeInfo::readTypefaceMetricsFile: typeface metric filename: %s", |
275 typefaceMetricsFileName.toAscii().constData()); |
275 typefaceMetricsFileName.toAscii().constData()); |
276 #endif |
276 #endif |
277 parser->setFilePath(typefaceMetricsFileName); |
277 parser->setFilePath(typefaceMetricsFileName); |
278 |
278 |
279 if (parser->init()){ |
279 if (parser->init()){ |
280 #ifdef HBTYPEFACEINFO_DEBUG_ENABLE |
280 #ifdef HBTYPEFACEINFO_DEBUG_ENABLE |
363 |
363 |
364 |
364 |
365 void HbTypefaceInfoDatabase::outputMetrics( HbTypefaceInfoItem *typeFaceInfoItem ) const |
365 void HbTypefaceInfoDatabase::outputMetrics( HbTypefaceInfoItem *typeFaceInfoItem ) const |
366 { |
366 { |
367 QString filePath = writablePath(); |
367 QString filePath = writablePath(); |
368 QDir dir(filePath); |
368 QDir dir(filePath); |
369 if(!dir.exists()) { |
369 if(!dir.exists()) { |
370 dir.mkpath(filePath + QDir::separator() ); |
370 dir.mkpath(filePath + QDir::separator() ); |
371 } |
371 } |
372 |
372 |
373 filePath.append(QDir::separator()); |
373 filePath.append(QDir::separator()); |
374 filePath.append("typeface_metrics_"); |
374 filePath.append("typeface_metrics_"); |
375 |
375 |
376 QString temp = typeFaceInfoItem->mFamily; |
376 QString temp = typeFaceInfoItem->mFamily; |