2003-06-17 06:42:22 +00:00
|
|
|
// fontEncoding.cpp
|
|
|
|
//
|
|
|
|
// Part of KDVI - A DVI previewer for the KDE desktop environemt
|
|
|
|
//
|
|
|
|
// (C) 2003 Stefan Kebekus
|
|
|
|
// Distributed under the GPL
|
|
|
|
|
|
|
|
#include <../config.h>
|
|
|
|
#ifdef HAVE_FREETYPE
|
|
|
|
|
|
|
|
#include <kdebug.h>
|
|
|
|
#include <kprocio.h>
|
|
|
|
#include <qfile.h>
|
|
|
|
#include <qstringlist.h>
|
|
|
|
|
|
|
|
#include "fontEncoding.h"
|
|
|
|
|
|
|
|
//#define DEBUG_FONTENC
|
|
|
|
|
|
|
|
fontEncoding::fontEncoding(const QString &encName)
|
|
|
|
{
|
|
|
|
#ifdef DEBUG_FONTENC
|
2003-06-20 08:13:42 +00:00
|
|
|
kdDebug(4700) << "fontEncoding( " << encName << " )" << endl;
|
2003-06-17 06:42:22 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// Use kpsewhich to find the encoding file.
|
|
|
|
KProcIO proc;
|
|
|
|
QString encFileName;
|
|
|
|
proc << "kpsewhich" << encName;
|
2003-06-20 08:13:42 +00:00
|
|
|
if (proc.start(KProcess::Block) == false) {
|
|
|
|
kdError(4700) << "fontEncoding::fontEncoding(...): kpsewhich could not be started." << endl;
|
|
|
|
return;
|
|
|
|
}
|
2003-06-17 06:42:22 +00:00
|
|
|
proc.readln(encFileName);
|
|
|
|
encFileName = encFileName.stripWhiteSpace();
|
2003-06-20 08:13:42 +00:00
|
|
|
if (encFileName.isEmpty()) {
|
|
|
|
kdError(4700) << QString("fontEncoding::fontEncoding(...): The file '%1' could not be found by kpsewhich.").arg(encName) << endl;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2003-06-17 06:42:22 +00:00
|
|
|
#ifdef DEBUG_FONTENC
|
2003-06-20 08:13:42 +00:00
|
|
|
kdDebug(4700) << "FileName of the encoding: " << encFileName << endl;
|
2003-06-17 06:42:22 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
QFile file( encFileName );
|
|
|
|
if ( file.open( IO_ReadOnly ) ) {
|
|
|
|
// Read the file (excluding comments) into the QString variable
|
|
|
|
// 'fileContent'
|
|
|
|
QTextStream stream( &file );
|
|
|
|
QString fileContent;
|
|
|
|
while ( !stream.atEnd() )
|
|
|
|
fileContent += stream.readLine().section('%', 0, 0); // line of text excluding '\n' until first '%'-sign
|
|
|
|
file.close();
|
|
|
|
|
|
|
|
fileContent = fileContent.stripWhiteSpace();
|
|
|
|
|
|
|
|
// Find the name of the encoding
|
|
|
|
encodingFullName = fileContent.section(' ', 0, 0).mid(1);
|
|
|
|
#ifdef DEBUG_FONTENC
|
2003-06-20 08:13:42 +00:00
|
|
|
kdDebug(4700) << "encodingFullName: " << encodingFullName << endl;
|
2003-06-17 06:42:22 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
fileContent = fileContent.section('[', 1, 1).section(']',0,0).simplifyWhiteSpace();
|
|
|
|
QStringList glyphNameList = QStringList::split( '/', fileContent );
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
for ( QStringList::Iterator it = glyphNameList.begin(); it != glyphNameList.end(); ++it ) {
|
|
|
|
glyphNameVector[i] = (*it).simplifyWhiteSpace();
|
|
|
|
#ifdef DEBUG_FONTENC
|
2003-06-20 08:13:42 +00:00
|
|
|
kdDebug(4700) << i << ": " << glyphNameVector[i] << endl;
|
2003-06-17 06:42:22 +00:00
|
|
|
#endif
|
|
|
|
i++;
|
|
|
|
}
|
2003-06-20 08:13:42 +00:00
|
|
|
} else {
|
|
|
|
kdError(4700) << QString("fontEncoding::fontEncoding(...): The file '%1' could not be opened.").arg(encFileName) << endl;
|
|
|
|
return;
|
2003-06-17 06:42:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endif // HAVE_FREETYPE
|