fontencoding.cpp.svn-base

来自「okular」· SVN-BASE 代码 · 共 97 行

SVN-BASE
97
字号
// -*- Mode: C++; c-basic-offset: 2; indent-tabs-mode: nil; c-brace-offset: 0; -*-// fontEncoding.cpp//// Part of KDVI - A DVI previewer for the KDE desktop environment//// (C) 2003 Stefan Kebekus// Distributed under the GPL#include <config.h>#ifdef HAVE_FREETYPE#include "fontEncoding.h"#include "kvs_debug.h"#include <QFile>#include <QProcess>#include <QStringList>#include <QTextStream>//#define DEBUG_FONTENCfontEncoding::fontEncoding(const QString &encName){#ifdef DEBUG_FONTENC  kDebug(kvs::dvi) << "fontEncoding( " << encName << " )" << endl;#endif  _isValid = false;  // Use kpsewhich to find the encoding file.  QProcess kpsewhich;  kpsewhich.setReadChannelMode(QProcess::MergedChannels);  kpsewhich.start("kpsewhich",                  QStringList() << encName,                  QIODevice::ReadOnly|QIODevice::Text);  if (!kpsewhich.waitForStarted()) {    kError(kvs::dvi) << "fontEncoding::fontEncoding(...): kpsewhich could not be started." << endl;    return;  }  // We wait here while the external program runs concurrently.  kpsewhich.waitForFinished(-1);  const QString encFileName = QString(kpsewhich.readAll()).trimmed();  if (encFileName.isEmpty()) {    kError(kvs::dvi) << QString("fontEncoding::fontEncoding(...): The file '%1' could not be found by kpsewhich.").arg(encName) << endl;    return;  }#ifdef DEBUG_FONTENC  kDebug(kvs::dvi) << "FileName of the encoding: " << encFileName << endl;#endif  QFile file( encFileName );  if ( file.open( QIODevice::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.trimmed();    // Find the name of the encoding    encodingFullName = fileContent.section('[', 0, 0).simplified().mid(1);#ifdef DEBUG_FONTENC    kDebug(kvs::dvi) << "encodingFullName: " << encodingFullName << endl;#endif    fileContent = fileContent.section('[', 1, 1).section(']',0,0).simplified();    QStringList glyphNameList = fileContent.split('/', QString::SkipEmptyParts);    int i = 0;    for ( QStringList::Iterator it = glyphNameList.begin(); (it != glyphNameList.end())&&(i<256); ++it ) {      glyphNameVector[i] = (*it).simplified();#ifdef DEBUG_FONTENC      kDebug(kvs::dvi) << i << ": " << glyphNameVector[i] << endl;#endif      i++;    }    for(; i<256; i++)      glyphNameVector[i] = ".notdef";  } else {    kError(kvs::dvi) << QString("fontEncoding::fontEncoding(...): The file '%1' could not be opened.").arg(encFileName) << endl;    return;  }  _isValid = true;}#endif // HAVE_FREETYPE

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?