mirror of
https://invent.kde.org/graphics/okular
synced 2024-08-25 02:45:38 +00:00
further implementation of Type1 fonts (proper font encoding still missing)
svn path=/trunk/kdegraphics/kdvi/; revision=216435
This commit is contained in:
parent
23c22cffaf
commit
ffa1589e69
|
@ -19,7 +19,8 @@ class TeXFont {
|
|||
public:
|
||||
TeXFont(TeXFontDefinition *_parent)
|
||||
{
|
||||
parent = _parent;
|
||||
parent = _parent;
|
||||
errorMessage = QString::null;
|
||||
};
|
||||
|
||||
virtual ~TeXFont();
|
||||
|
@ -37,7 +38,11 @@ class TeXFont {
|
|||
// in by the constructor, or set to 0.0, if the font format does not
|
||||
// contain checksums.
|
||||
Q_UINT32 checksum;
|
||||
|
||||
|
||||
// If the font or if some glyphs could not be loaded, error messages
|
||||
// will be put here.
|
||||
QString errorMessage;
|
||||
|
||||
protected:
|
||||
glyph glyphtable[TeXFontDefinition::max_num_of_chars_in_font];
|
||||
TeXFontDefinition *parent;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include <qfile.h>
|
||||
|
||||
#include "../config.h"
|
||||
#include "dviwin.h"
|
||||
#include "fontpool.h"
|
||||
#include "kdvi.h"
|
||||
#ifdef HAVE_FREETYPE
|
||||
|
|
|
@ -23,7 +23,7 @@ typedef void (dviWindow::*set_char_proc)(unsigned int, unsigned int);
|
|||
#include <qstring.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "dviwin.h"
|
||||
//#include "dviwin.h"
|
||||
#include "glyph.h"
|
||||
|
||||
class TeXFont;
|
||||
|
|
159
TeXFont_PFB.cpp
159
TeXFont_PFB.cpp
|
@ -32,35 +32,28 @@ TeXFont_PFB::TeXFont_PFB(TeXFontDefinition *parent)
|
|||
kdDebug(4300) << "TeXFont_PFB::TeXFont_PFB( parent=" << parent << ")" << endl;
|
||||
#endif
|
||||
|
||||
fatalErrorInFontLoading = false;
|
||||
|
||||
int error = FT_New_Face( parent->font_pool->FreeType_library, parent->filename.local8Bit(), 0, &face );
|
||||
|
||||
|
||||
if ( error == FT_Err_Unknown_File_Format ) {
|
||||
kdError(4300) << "The font file " << parent->filename << " could be opened and read, but it appears that its font format is unsupported." << endl;
|
||||
exit(0); // @@@
|
||||
errorMessage = i18n("The font file %1 could be opened and read, but its font format is unsupported.").arg(parent->filename);
|
||||
kdError(4300) << errorMessage << endl;
|
||||
fatalErrorInFontLoading = true;
|
||||
return;
|
||||
} else
|
||||
if ( error ) {
|
||||
kdError(4300) << "The font file " << parent->filename << " is broken, or it could not be opened or read." << endl;
|
||||
exit(0); // @@@
|
||||
errorMessage = i18n("The font file %1 is broken, or it could not be opened or read.").arg(parent->filename);
|
||||
kdError(4300) << errorMessage << endl;
|
||||
fatalErrorInFontLoading = true;
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
int has_encoding = 0;
|
||||
for (int i = 0; i < face->num_charmaps; ++i)
|
||||
for (int j = 0; accepted_platform_ids[j] != -1; ++j)
|
||||
if (face->charmaps[i]->platform_id == accepted_platform_ids[j] && face->charmaps[i]->encoding_id == accepted_encoding_ids[j]){
|
||||
FT_Set_Charmap (face, face->charmaps[i]);
|
||||
has_encoding = 1;
|
||||
goto done_encoding;
|
||||
}
|
||||
done_encoding:
|
||||
if (!has_encoding)
|
||||
kdError(4300) << "The font file " << parent->filename << " has no good encoding." << endl;
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
TeXFont_PFB::~TeXFont_PFB()
|
||||
{
|
||||
// @@@@ Missing: Free resources!
|
||||
}
|
||||
|
||||
|
||||
|
@ -69,74 +62,104 @@ glyph *TeXFont_PFB::getGlyph(unsigned int ch, bool generateCharacterPixmap)
|
|||
#ifdef DEBUG_PFB
|
||||
kdDebug(4300) << "TeXFont_PFB::getGlyph( ch=" << ch << ", '" << (char)(ch) << "', generateCharacterPixmap=" << generateCharacterPixmap << " )" << endl;
|
||||
#endif
|
||||
|
||||
|
||||
// Paranoia checks
|
||||
if (ch >= TeXFontDefinition::max_num_of_chars_in_font) {
|
||||
kdError(4300) << "TeXFont_PFB::getGlyph(): Argument is too big." << endl;
|
||||
return glyphtable;
|
||||
}
|
||||
|
||||
|
||||
// This is the address of the glyph that will be returned.
|
||||
struct glyph *g = glyphtable+ch;
|
||||
|
||||
if (fatalErrorInFontLoading == true)
|
||||
return g;
|
||||
|
||||
if ((generateCharacterPixmap == true) && (g->shrunkenCharacter.isNull())) {
|
||||
unsigned int res = (unsigned int)(parent->displayResolution_in_dpi+0.5);
|
||||
double characterSize_in_printers_points_by_64 = (long int)(parent->scaled_size_in_DVI_units * 64.0 / (1<<16) + 0.5); // Only approximate, may vary from file to file!!!! @@@@@
|
||||
|
||||
int error = FT_Set_Char_Size(face, /* handle to face object */
|
||||
0, /* char_width in 1/64th of points */
|
||||
characterSize_in_printers_points_by_64, /* char_height in 1/64th of points (reminder: 1 pt = 1/72 inch) */
|
||||
res, /* horizontal device resolution */
|
||||
res ); /* vertical device resolution */
|
||||
if (error)
|
||||
kdError(4300) << "B" << endl;
|
||||
int error;
|
||||
unsigned int res = (unsigned int)(parent->displayResolution_in_dpi/parent->enlargement +0.5);
|
||||
// Character height in 1/64th of points (reminder: 1 pt = 1/72 inch)
|
||||
// Only approximate, may vary from file to file!!!! @@@@@
|
||||
long int characterSize_in_printers_points_by_64 = (long int)(parent->scaled_size_in_DVI_units * 64.0 / (1<<16) + 0.5);
|
||||
error = FT_Set_Char_Size(face, 0, characterSize_in_printers_points_by_64, res, res );
|
||||
if (error) {
|
||||
QString msg = i18n("FreeType reported an error when setting the character size for font file %1.").arg(parent->filename);
|
||||
if (errorMessage.isEmpty())
|
||||
errorMessage = msg;
|
||||
kdError(4300) << msg << endl;
|
||||
g->shrunkenCharacter.resize(1,1);
|
||||
g->shrunkenCharacter.fill(QColor(255, 255, 255));
|
||||
return g;
|
||||
}
|
||||
|
||||
// load glyph image into the slot and erase the previous one
|
||||
// error = FT_Load_Glyph(face, ch, FT_LOAD_NO_HINTING );
|
||||
error = FT_Load_Glyph(face, ch, 0 ); // @@@
|
||||
//error = FT_Load_Glyph(face, FT_Get_Char_Index(face, ch), FT_LOAD_NO_HINTING );
|
||||
if (error)
|
||||
kdError(4300) << "Cannot load glyph #" << ch << " for font " << parent->filename << endl;
|
||||
if (parent->font_pool->getUseFontHints() == true)
|
||||
error = FT_Load_Glyph(face, ch, FT_LOAD_DEFAULT );
|
||||
else
|
||||
error = FT_Load_Glyph(face, ch, FT_LOAD_NO_HINTING );
|
||||
if (error) {
|
||||
QString msg = i18n("FreeType is unable to load glyph #%1 from font file %2.").arg(ch).arg(parent->filename);
|
||||
if (errorMessage.isEmpty())
|
||||
errorMessage = msg;
|
||||
kdError(4300) << msg << endl;
|
||||
g->shrunkenCharacter.resize(1,1);
|
||||
g->shrunkenCharacter.fill(QColor(255, 255, 255));
|
||||
return g;
|
||||
}
|
||||
|
||||
// convert to an anti-aliased bitmap
|
||||
error = FT_Render_Glyph( face->glyph, ft_render_mode_normal );
|
||||
if (error)
|
||||
kdError(4300) << "D" << endl;
|
||||
if (error) {
|
||||
QString msg = i18n("FreeType is unable to render glyph #%1 from font file %2.").arg(ch).arg(parent->filename);
|
||||
if (errorMessage.isEmpty())
|
||||
errorMessage = msg;
|
||||
kdError(4300) << msg << endl;
|
||||
g->shrunkenCharacter.resize(1,1);
|
||||
g->shrunkenCharacter.fill(QColor(255, 255, 255));
|
||||
return g;
|
||||
}
|
||||
|
||||
FT_GlyphSlot slot = face->glyph;
|
||||
|
||||
QImage imgi(slot->bitmap.width, slot->bitmap.rows, 32);
|
||||
imgi.setAlphaBuffer(true);
|
||||
uchar *srcScanLine = slot->bitmap.buffer;
|
||||
for(int row=0; row<slot->bitmap.rows; row++) {
|
||||
uchar *destScanLine = imgi.scanLine(row);
|
||||
for(int col=0; col<slot->bitmap.width; col++) {
|
||||
destScanLine[4*col+0] = 0;
|
||||
destScanLine[4*col+1] = 0;
|
||||
destScanLine[4*col+2] = 0;
|
||||
destScanLine[4*col+3] = srcScanLine[col];
|
||||
|
||||
if ((slot->bitmap.width == 0) || (slot->bitmap.rows == 0)) {
|
||||
QString msg = i18n("Glyph #%1 from font file %2 is empty.").arg(ch).arg(parent->filename);
|
||||
if (errorMessage.isEmpty())
|
||||
errorMessage = msg;
|
||||
kdError(4300) << msg << endl;
|
||||
g->shrunkenCharacter.resize( 15, 15 );
|
||||
g->shrunkenCharacter.fill(QColor(255, 0, 0));
|
||||
g->x2 = 0;
|
||||
g->y2 = 15;
|
||||
} else {
|
||||
QImage imgi(slot->bitmap.width, slot->bitmap.rows, 32);
|
||||
imgi.setAlphaBuffer(true);
|
||||
uchar *srcScanLine = slot->bitmap.buffer;
|
||||
for(int row=0; row<slot->bitmap.rows; row++) {
|
||||
uchar *destScanLine = imgi.scanLine(row);
|
||||
for(int col=0; col<slot->bitmap.width; col++) {
|
||||
destScanLine[4*col+0] = 0;
|
||||
destScanLine[4*col+1] = 0;
|
||||
destScanLine[4*col+2] = 0;
|
||||
destScanLine[4*col+3] = srcScanLine[col];
|
||||
}
|
||||
srcScanLine += slot->bitmap.pitch;
|
||||
}
|
||||
srcScanLine += slot->bitmap.pitch;
|
||||
g->shrunkenCharacter.convertFromImage ( imgi, 0);
|
||||
g->x2 = -slot->bitmap_left;
|
||||
g->y2 = slot->bitmap_top;
|
||||
}
|
||||
g->shrunkenCharacter.convertFromImage ( imgi, 0);
|
||||
|
||||
if (g->shrunkenCharacter.isNull()) {
|
||||
kdError() << "Width = " << g->shrunkenCharacter.width() << " & " << slot->bitmap.width << endl;
|
||||
kdError() << "Height = " << g->shrunkenCharacter.height() << " & " << slot->bitmap.rows << endl;
|
||||
kdError() << "face->glyph->metrics.horiAdvance = " << face->glyph->metrics.horiAdvance << endl;
|
||||
|
||||
g->shrunkenCharacter.resize( 5, 5 );
|
||||
g->shrunkenCharacter.fill(QColor(255, 100, 100));
|
||||
}
|
||||
|
||||
// Load glyph width, if that hasn't been done yet.
|
||||
if (g->dvi_advance_in_units_of_design_size_by_2e20 == 0) {
|
||||
int error = FT_Load_Glyph(face, ch, FT_LOAD_NO_SCALE );
|
||||
if (error) {
|
||||
QString msg = i18n("FreeType is unable to load metric for glyph #%1 from font file %2.").arg(ch).arg(parent->filename);
|
||||
if (errorMessage.isEmpty())
|
||||
errorMessage = msg;
|
||||
kdError(4300) << msg << endl;
|
||||
g->dvi_advance_in_units_of_design_size_by_2e20 = 1;
|
||||
}
|
||||
|
||||
g->x2 = -slot->bitmap_left;
|
||||
g->y2 = slot->bitmap_top;
|
||||
|
||||
// load glyph image into the slot and erase the previous one
|
||||
error = FT_Load_Glyph(face, ch, FT_LOAD_NO_SCALE );
|
||||
if (error)
|
||||
kdError(4300) << "E" << endl;
|
||||
|
||||
g->dvi_advance_in_units_of_design_size_by_2e20 = ((Q_INT32)(1<<20) * (Q_INT32)face->glyph->metrics.horiAdvance) / (Q_INT32)face->units_per_EM;
|
||||
}
|
||||
|
||||
|
|
|
@ -34,6 +34,7 @@ class TeXFont_PFB : public TeXFont {
|
|||
|
||||
private:
|
||||
FT_Face face;
|
||||
bool fatalErrorInFontLoading;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -52,7 +52,9 @@
|
|||
#include <kdebug.h>
|
||||
#include <klocale.h>
|
||||
#include <qbitmap.h>
|
||||
#include <qfile.h>
|
||||
#include <qimage.h>
|
||||
#include <qpainter.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
|
18
dviwin.cpp
18
dviwin.cpp
|
@ -53,7 +53,7 @@ QPainter foreGroundPaint; // QPainter used for text
|
|||
|
||||
//------ now comes the dviWindow class implementation ----------
|
||||
|
||||
dviWindow::dviWindow(double zoom, int mkpk, QWidget *parent, const char *name )
|
||||
dviWindow::dviWindow(double zoom, QWidget *parent, const char *name )
|
||||
: QWidget( parent, name )
|
||||
{
|
||||
#ifdef DEBUG_DVIWIN
|
||||
|
@ -90,7 +90,6 @@ dviWindow::dviWindow(double zoom, int mkpk, QWidget *parent, const char *name )
|
|||
qApp->connect(font_pool, SIGNAL(new_kpsewhich_run(QString)), info, SLOT(clear(QString)));
|
||||
}
|
||||
|
||||
setMakePK( mkpk );
|
||||
editorCommand = "";
|
||||
|
||||
// Calculate the horizontal resolution of the display device. @@@
|
||||
|
@ -141,7 +140,6 @@ dviWindow::dviWindow(double zoom, int mkpk, QWidget *parent, const char *name )
|
|||
animationCounter = 0;
|
||||
timerIdent = 0;
|
||||
|
||||
setMetafontMode( DefaultMFMode );
|
||||
resize(0,0);
|
||||
}
|
||||
|
||||
|
@ -220,14 +218,7 @@ void dviWindow::setShowHyperLinks( bool flag )
|
|||
drawPage();
|
||||
}
|
||||
|
||||
|
||||
void dviWindow::setMakePK( bool flag )
|
||||
{
|
||||
makepk = flag;
|
||||
font_pool->setMakePK(makepk);
|
||||
}
|
||||
|
||||
|
||||
#ifdef doof
|
||||
void dviWindow::setMetafontMode( unsigned int mode )
|
||||
{
|
||||
#ifdef DEBUG_DVIWIN
|
||||
|
@ -241,7 +232,7 @@ void dviWindow::setMetafontMode( unsigned int mode )
|
|||
shrinkfactor = MFResolutions[MetafontMode]/(xres*_zoom);
|
||||
font_pool->setDisplayResolution( xres*_zoom );
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
void dviWindow::setPaper(double width_in_cm, double height_in_cm)
|
||||
{
|
||||
|
@ -263,6 +254,7 @@ void dviWindow::drawPage()
|
|||
kdDebug(4300) << "dviWindow::drawPage()" << endl;
|
||||
#endif
|
||||
|
||||
shrinkfactor = MFResolutions[font_pool->getMetafontMode()]/(xres*_zoom);
|
||||
setCursor(arrowCursor);
|
||||
|
||||
// Stop any animation which may be in progress
|
||||
|
@ -654,7 +646,7 @@ double dviWindow::setZoom(double zoom)
|
|||
if (zoom > ZoomLimits::MaxZoom/1000.0)
|
||||
zoom = ZoomLimits::MaxZoom/1000.0;
|
||||
|
||||
shrinkfactor = MFResolutions[MetafontMode]/(xres*zoom);
|
||||
shrinkfactor = MFResolutions[font_pool->getMetafontMode()]/(xres*zoom);
|
||||
_zoom = zoom;
|
||||
|
||||
font_pool->setDisplayResolution( xres*zoom );
|
||||
|
|
12
dviwin.h
12
dviwin.h
|
@ -23,6 +23,7 @@
|
|||
|
||||
#include "bigEndianByteReader.h"
|
||||
#include "dvi_init.h"
|
||||
#include "fontpool.h"
|
||||
#include "psgs.h"
|
||||
#include "selection.h"
|
||||
|
||||
|
@ -101,7 +102,7 @@ class dviWindow : public QWidget, bigEndianByteReader
|
|||
Q_OBJECT
|
||||
|
||||
public:
|
||||
dviWindow( double zoom, int makepk, QWidget *parent=0, const char *name=0 );
|
||||
dviWindow( double zoom, QWidget *parent=0, const char *name=0 );
|
||||
~dviWindow();
|
||||
|
||||
class dvifile *dviFile;
|
||||
|
@ -119,9 +120,6 @@ public:
|
|||
void setShowHyperLinks( bool flag );
|
||||
bool showHyperLinks(void) { return _showHyperLinks; };
|
||||
void setEditorCommand( QString command ) { editorCommand = command; };
|
||||
void setMakePK( bool flag );
|
||||
int makePK(void) { return makepk; };
|
||||
void setMetafontMode( unsigned int );
|
||||
void setPaper(double w, double h);
|
||||
bool correctDVI(QString filename);
|
||||
|
||||
|
@ -147,7 +145,7 @@ public:
|
|||
void html_anchor_special(QString cp);
|
||||
void draw_page(void);
|
||||
|
||||
class fontPool *font_pool;
|
||||
fontPool *font_pool;
|
||||
|
||||
double xres; // horizontal resolution of the display device in dots per inch.
|
||||
double paper_width_in_cm; // paper width in centimeters
|
||||
|
@ -305,11 +303,9 @@ private:
|
|||
/** List of anchors in a document */
|
||||
QMap<QString, DVI_Anchor> anchorList;
|
||||
|
||||
double fontPixelPerDVIunit() {return dviFile->cmPerDVIunit * MFResolutions[MetafontMode]/2.54;};
|
||||
double fontPixelPerDVIunit() {return dviFile->cmPerDVIunit * MFResolutions[font_pool->getMetafontMode()]/2.54;};
|
||||
|
||||
int makepk;
|
||||
QPixmap *pixmap;
|
||||
unsigned int MetafontMode;
|
||||
int ChangesPossible;
|
||||
unsigned int current_page;
|
||||
|
||||
|
|
|
@ -340,8 +340,8 @@ void dviWindow::draw_part(double current_dimconv, bool is_vfmacro)
|
|||
line_boundary_encountered = true;
|
||||
}
|
||||
command_pointer += 11 * 4;
|
||||
currinf.data.dvi_h = MFResolutions[MetafontMode] << 16; // Reminder: DVI-coordinates start at (1",1") from top of page
|
||||
currinf.data.dvi_v = MFResolutions[MetafontMode];
|
||||
currinf.data.dvi_h = MFResolutions[font_pool->getMetafontMode()] << 16; // Reminder: DVI-coordinates start at (1",1") from top of page
|
||||
currinf.data.dvi_v = MFResolutions[font_pool->getMetafontMode()];
|
||||
currinf.data.pxl_v = int(currinf.data.dvi_v/shrinkfactor);
|
||||
currinf.data.w = currinf.data.x = currinf.data.y = currinf.data.z = 0;
|
||||
break;
|
||||
|
@ -606,7 +606,7 @@ void dviWindow::draw_page(void)
|
|||
// Mark hyperlinks in blue. We draw a blue line under the
|
||||
// character whose width is equivalent to 0.5 mm, but at least
|
||||
// one pixel.
|
||||
int h = (int)(MFResolutions[MetafontMode]*0.05/(2.54*shrinkfactor) + 0.5);
|
||||
int h = (int)(MFResolutions[font_pool->getMetafontMode()]*0.05/(2.54*shrinkfactor) + 0.5);
|
||||
h = (h < 1) ? 1 : h;
|
||||
for(unsigned int i=0; i<hyperLinkList.size(); i++) {
|
||||
int x = hyperLinkList[i].box.left();
|
||||
|
|
152
fontpool.cpp
152
fontpool.cpp
|
@ -7,14 +7,14 @@
|
|||
#include <kdebug.h>
|
||||
#include <kinstance.h>
|
||||
#include <klocale.h>
|
||||
#include <kmessagebox.h>
|
||||
#include <kprocess.h>
|
||||
#include <qapplication.h>
|
||||
#include <kmessagebox.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "fontpool.h"
|
||||
#include "fontprogress.h"
|
||||
#include "xdvi.h"
|
||||
#include "TeXFont.h"
|
||||
|
||||
// List of permissible MetaFontModes which are supported by kdvi.
|
||||
|
||||
|
@ -75,69 +75,65 @@ fontPool::~fontPool(void)
|
|||
}
|
||||
|
||||
|
||||
unsigned int fontPool::setMetafontMode( unsigned int mode )
|
||||
void fontPool::setParameters( unsigned int _metafontMode, bool _makePK, bool _enlargeFonts, bool _useType1Fonts, bool _useFontHints )
|
||||
{
|
||||
#ifdef DEBUG_FONTPOOL
|
||||
kdDebug(4300) << "fontPool::setMetafontMode( " << mode << " ) called" << endl;
|
||||
#endif
|
||||
|
||||
if (mode >= NumberOfMFModes) {
|
||||
kdError(4300) << "fontPool::setMetafontMode called with argument " << mode
|
||||
<< " which is more than the allowed value of " << NumberOfMFModes-1 << endl;
|
||||
if (_metafontMode >= NumberOfMFModes) {
|
||||
kdError(4300) << "fontPool::setMetafontMode called with argument " << _metafontMode
|
||||
<< " which is more than the allowed value of " << NumberOfMFModes-1 << endl;
|
||||
kdError(4300) << "setting mode to " << MFModes[DefaultMFMode] << " at "
|
||||
<< MFResolutions[DefaultMFMode] << "dpi" << endl;
|
||||
mode = DefaultMFMode;
|
||||
<< MFResolutions[DefaultMFMode] << "dpi" << endl;
|
||||
_metafontMode = DefaultMFMode;
|
||||
}
|
||||
MetafontMode = mode;
|
||||
|
||||
TeXFontDefinition *fontp = fontList.first();
|
||||
while(fontp != 0 ) {
|
||||
fontp->reset();
|
||||
fontp = fontList.next();
|
||||
|
||||
bool kpsewhichNeeded = false;
|
||||
|
||||
// Check if a new run of kpsewhich is required
|
||||
if ( (_metafontMode != MetafontMode) || (_useType1Fonts != useType1Fonts) ) {
|
||||
TeXFontDefinition *fontp = fontList.first();
|
||||
while(fontp != 0 ) {
|
||||
fontp->reset();
|
||||
fontp = fontList.next();
|
||||
}
|
||||
kpsewhichNeeded = true;
|
||||
}
|
||||
|
||||
check_if_fonts_filenames_are_looked_up();
|
||||
return mode;
|
||||
}
|
||||
|
||||
|
||||
void fontPool::setMakePK(bool flag)
|
||||
{
|
||||
makepk = flag;
|
||||
|
||||
// If we just disabled font generation, there is nothing left to do.
|
||||
if (flag == false)
|
||||
return;
|
||||
|
||||
|
||||
// If we enable font generation, we look for fonts which have not
|
||||
// yet been loaded, mark them as "not yet looked up" and try once
|
||||
// more.
|
||||
TeXFontDefinition *fontp =fontList.first();
|
||||
while(fontp != 0 ) {
|
||||
if (fontp->filename.isEmpty() )
|
||||
fontp->flags &= ~TeXFontDefinition::FONT_KPSE_NAME;
|
||||
fontp=fontList.next();
|
||||
}
|
||||
check_if_fonts_filenames_are_looked_up();
|
||||
}
|
||||
|
||||
|
||||
void fontPool::setEnlargeFonts( bool flag )
|
||||
{
|
||||
enlargeFonts = flag;
|
||||
|
||||
double displayResolution = displayResolution_in_dpi;
|
||||
if (enlargeFonts == true)
|
||||
displayResolution *= 1.1;
|
||||
|
||||
TeXFontDefinition *fontp = fontList.first();
|
||||
while(fontp != 0 ) {
|
||||
fontp->setDisplayResolution(displayResolution * fontp->enlargement);
|
||||
fontp=fontList.next();
|
||||
// yet been loaded, mark them as "not yet looked up" and try to run
|
||||
// kpsewhich once more.
|
||||
if ((_makePK == true) && (_makePK != makepk)) {
|
||||
TeXFontDefinition *fontp =fontList.first();
|
||||
while(fontp != 0 ) {
|
||||
if (fontp->filename.isEmpty() )
|
||||
fontp->flags &= ~TeXFontDefinition::FONT_KPSE_NAME;
|
||||
fontp=fontList.next();
|
||||
}
|
||||
kpsewhichNeeded = true;
|
||||
}
|
||||
|
||||
// Do something that causes re-rendering of the dvi-window
|
||||
emit fonts_have_been_loaded();
|
||||
// Check if glyphs need to be cleared
|
||||
if ((_enlargeFonts != enlargeFonts) || (_useFontHints != useFontHints)) {
|
||||
double displayResolution = displayResolution_in_dpi;
|
||||
if (_enlargeFonts == true)
|
||||
displayResolution *= 1.1;
|
||||
TeXFontDefinition *fontp = fontList.first();
|
||||
while(fontp != 0 ) {
|
||||
fontp->setDisplayResolution(displayResolution * fontp->enlargement);
|
||||
fontp=fontList.next();
|
||||
}
|
||||
}
|
||||
|
||||
MetafontMode = _metafontMode;
|
||||
makepk = _makePK;
|
||||
enlargeFonts = _enlargeFonts;
|
||||
useType1Fonts = _useType1Fonts;
|
||||
useFontHints = _useFontHints;
|
||||
|
||||
// Initiate a new concurrently running process of kpsewhich, if
|
||||
// necessary. Otherwise, let the dvi window be redrawn
|
||||
if (kpsewhichNeeded == true)
|
||||
check_if_fonts_filenames_are_looked_up();
|
||||
else
|
||||
emit fonts_have_been_loaded();
|
||||
}
|
||||
|
||||
|
||||
|
@ -183,7 +179,7 @@ QString fontPool::status(void)
|
|||
return i18n("The fontlist is currently empty.");
|
||||
|
||||
text.append("<table WIDTH=\"100%\" NOSAVE >");
|
||||
text.append( QString("<tr><td><b>%1</b></td> <td><b>%2</b></td> <td><b>%3</b></td> <td><b>%4</b></td></tr>").arg(i18n("Name")).arg(i18n("Enlargement")).arg(i18n("Type")).arg(i18n("Filename")) );
|
||||
text.append( QString("<tr><td><b>%1</b></td> <td><b>%2</b></td> <td><b>%3</b></td> <td><b>%4</b></td> <td><b>%5</b></td></tr>").arg(i18n("Name")).arg(i18n("Enlargement")).arg(i18n("Type")).arg(i18n("Filename")).arg(i18n("Comment")) );
|
||||
|
||||
TeXFontDefinition *fontp = fontList.first();
|
||||
while ( fontp != 0 ) {
|
||||
|
@ -194,7 +190,10 @@ QString fontPool::status(void)
|
|||
else
|
||||
type = i18n("regular");
|
||||
|
||||
tmp << QString ("<tr><td>%1</td> <td>%2%</td> <td>%3</td> <td>%4</td></tr>").arg(fontp->fontname).arg((int)(fontp->enlargement*100 + 0.5)).arg(type).arg(fontp->filename);
|
||||
if (fontp->font == 0)
|
||||
tmp << QString ("<tr><td>%1</td> <td>%2%</td> <td>%3</td> <td>%4</td> <td>%5</td></tr>").arg(fontp->fontname).arg((int)(fontp->enlargement*100 + 0.5)).arg(type).arg(fontp->filename).arg("");
|
||||
else
|
||||
tmp << QString ("<tr><td>%1</td> <td>%2%</td> <td>%3</td> <td>%4</td> <td>%5</td></tr>").arg(fontp->fontname).arg((int)(fontp->enlargement*100 + 0.5)).arg(type).arg(fontp->filename).arg(fontp->font->errorMessage);
|
||||
fontp=fontList.next();
|
||||
}
|
||||
|
||||
|
@ -335,12 +334,12 @@ void fontPool::start_kpsewhich(void)
|
|||
case 0:
|
||||
// In the first pass, we look for PK fonts, and also for virtual fonts.
|
||||
#ifdef HAVE_FREETYPE
|
||||
if (!fontp->fontname.contains("cmsy")) // @@@@ Special treatment for buggy (?) font
|
||||
if (useType1Fonts == true) {
|
||||
*proc << KShellProcess::quote(QString("%1.pfb").arg(fontp->fontname));
|
||||
#ifdef DEBUG_FONTPOOL
|
||||
if (!fontp->fontname.contains("cmsy")) // @@@@ Special treatment for buggy (?) font
|
||||
shellProcessCmdLine += KShellProcess::quote(QString("%1.pfb").arg(fontp->fontname)) + " ";
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
*proc << KShellProcess::quote(QString("%1.vf").arg(fontp->fontname));
|
||||
*proc << KShellProcess::quote(QString("%2.%1pk").arg(MFResolutions[MetafontMode]).arg(fontp->fontname));
|
||||
|
@ -350,7 +349,16 @@ void fontPool::start_kpsewhich(void)
|
|||
#endif
|
||||
break;
|
||||
case 1:
|
||||
// In the second pass, we generate PK fonts
|
||||
// In the second pass, we generate PK fonts, but be also look
|
||||
// for PFB fonts, as they might be used by virtual fonts.
|
||||
#ifdef HAVE_FREETYPE
|
||||
if (useType1Fonts == true) {
|
||||
*proc << KShellProcess::quote(QString("%1.pfb").arg(fontp->fontname));
|
||||
#ifdef DEBUG_FONTPOOL
|
||||
shellProcessCmdLine += KShellProcess::quote(QString("%1.pfb").arg(fontp->fontname)) + " ";
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
*proc << KShellProcess::quote(QString("%2.%1pk").arg(MFResolutions[MetafontMode]).arg(fontp->fontname));
|
||||
#ifdef DEBUG_FONTPOOL
|
||||
shellProcessCmdLine += KShellProcess::quote(QString("%2.%1pk").arg(MFResolutions[MetafontMode]).arg(fontp->fontname)) + " ";
|
||||
|
@ -515,7 +523,7 @@ void fontPool::kpsewhich_terminated(KProcess *)
|
|||
config->setGroup("kdvi");
|
||||
config->writeEntry( "MakePK", true );
|
||||
config->sync();
|
||||
setMakePK(1); // That will start kpsewhich again.
|
||||
setParameters( MetafontMode, true, enlargeFonts, useType1Fonts, useFontHints ); // That will start kpsewhich again.
|
||||
return;
|
||||
}
|
||||
} else
|
||||
|
@ -532,11 +540,21 @@ void fontPool::kpsewhich_terminated(KProcess *)
|
|||
void fontPool::setDisplayResolution( double _displayResolution_in_dpi )
|
||||
{
|
||||
#ifdef DEBUG_FONTPOOL
|
||||
kdDebug(4300) << "fontPool::setDisplayResolution( displayResolution_in_dpi=" << _displayResolution_in_dpi << " ) called" <<endl;
|
||||
kdDebug(4300) << "fontPool::setDisplayResolution( displayResolution_in_dpi=" << _displayResolution_in_dpi << " ) called" << endl;
|
||||
#endif
|
||||
|
||||
displayResolution_in_dpi = _displayResolution_in_dpi;
|
||||
setEnlargeFonts( enlargeFonts );
|
||||
double displayResolution = displayResolution_in_dpi;
|
||||
if (enlargeFonts == true)
|
||||
displayResolution *= 1.1;
|
||||
|
||||
TeXFontDefinition *fontp = fontList.first();
|
||||
while(fontp != 0 ) {
|
||||
fontp->setDisplayResolution(displayResolution * fontp->enlargement);
|
||||
fontp=fontList.next();
|
||||
}
|
||||
|
||||
// Do something that causes re-rendering of the dvi-window
|
||||
emit fonts_have_been_loaded();
|
||||
}
|
||||
|
||||
|
||||
|
|
32
fontpool.h
32
fontpool.h
|
@ -61,28 +61,43 @@ Q_OBJECT
|
|||
fontpool.cpp. Returns the mode number of the mode which was
|
||||
actually set ---if an invalid argument is given, this will be
|
||||
the DefaultMFMode as defined in fontPool.h */
|
||||
unsigned int setMetafontMode( unsigned int );
|
||||
// unsigned int setMetafontMode( unsigned int );
|
||||
|
||||
/** Return the currently set MetafontMode */
|
||||
void setParameters( unsigned int MetaFontMode, bool makePK, bool enlargeFonts, bool useType1Fonts, bool useFontHints );
|
||||
|
||||
/** Returns the currently set MetafontMode */
|
||||
|
||||
unsigned int getMetafontMode(void) {return MetafontMode;};
|
||||
|
||||
/** Sets whether fonts will be generated by running MetaFont, or a
|
||||
similar programm. If (flag == 0), fonts will not be generated,
|
||||
otherwise they will. */
|
||||
void setMakePK( bool flag );
|
||||
// void setMakePK( bool flag );
|
||||
|
||||
/** Sets whether glyphs will be enlarged or not. If (flag == 0),
|
||||
glyphs will not be enlarged, otherwise they will. */
|
||||
void setEnlargeFonts( bool flag );
|
||||
// void setEnlargeFonts( bool flag );
|
||||
|
||||
/** Sets the resolution of the output device. */
|
||||
void setDisplayResolution( double _displayResolution_in_dpi );
|
||||
|
||||
/** Sets the resolution of the output device and determines if font hinting should be used. */
|
||||
// void setUseFontHints( bool _useFontHinting );
|
||||
|
||||
/** Determines if Adobe Type 1 (*.pfb) fonts should be used or not */
|
||||
// void setUseType1Fonts( bool _useType1Fonts );
|
||||
|
||||
/** Returns the status of enlargeFonts. If the return value is ==
|
||||
0, glyphs will not be enlarged, otherwise they will. */
|
||||
bool getEnlargeFonts() {return enlargeFonts;};
|
||||
|
||||
/** If return value is true, font hinting should be used if
|
||||
possible */
|
||||
bool getUseFontHints(void) {return useFontHints;};
|
||||
|
||||
/** If return value is true, Type 1 fonts will be used, if available */
|
||||
bool getUseType1Fonts(void) {return useType1Fonts;};
|
||||
|
||||
/** This method adds a font to the list. If the font is not
|
||||
currently loaded, it's file will be located and font::load_font
|
||||
will be called. Since this is done using a concurrently running
|
||||
|
@ -124,6 +139,7 @@ Q_OBJECT
|
|||
FT_Library FreeType_library;
|
||||
#endif
|
||||
|
||||
|
||||
signals:
|
||||
/** Emitted to indicate that the progress dialog should show up now. */
|
||||
void show_progress(void);
|
||||
|
@ -216,6 +232,14 @@ public slots:
|
|||
or not. If enlargeFonts==0, then fonts are NOT enlarged. */
|
||||
bool enlargeFonts;
|
||||
|
||||
/** This flag is used by PFB fonts to determine if the FREETYPE
|
||||
engine should use hinted fonts or not */
|
||||
bool useFontHints;
|
||||
|
||||
/** This flag is used to determine Type1 fonts should be loaded at
|
||||
all or not */
|
||||
bool useType1Fonts;
|
||||
|
||||
/** This integer determines the Metafont-Mode which is used in
|
||||
generating bitmaps. The value must satisfy 0 <= MetafontMode <
|
||||
NumberOfMFModes, and refers to an entry in the lists
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include <ktip.h>
|
||||
#include <qtimer.h>
|
||||
|
||||
#include "../config.h"
|
||||
#include "fontpool.h"
|
||||
#include "kdvi_multipage.h"
|
||||
#include "kviewpart.h"
|
||||
|
@ -70,7 +71,7 @@ KDVIMultiPage::KDVIMultiPage(QWidget *parentWidget, const char *widgetName, QObj
|
|||
|
||||
printer = 0;
|
||||
document_history.clear();
|
||||
window = new dviWindow( 1.0, true, scrollView());
|
||||
window = new dviWindow( 1.0, scrollView());
|
||||
preferencesChanged();
|
||||
|
||||
connect( window, SIGNAL( setStatusBarText( const QString& ) ), this, SIGNAL( setStatusBarText( const QString& ) ) );
|
||||
|
@ -335,15 +336,9 @@ void KDVIMultiPage::preferencesChanged()
|
|||
int mfmode = config->readNumEntry( "MetafontMode", DefaultMFMode );
|
||||
if (( mfmode < 0 ) || (mfmode >= NumberOfMFModes))
|
||||
config->writeEntry( "MetafontMode", mfmode = DefaultMFMode );
|
||||
window->setMetafontMode( mfmode );
|
||||
|
||||
bool makepk = config->readBoolEntry( "MakePK", true );
|
||||
if ( makepk != window->makePK() )
|
||||
window->setMakePK( makepk );
|
||||
|
||||
bool enlargeFonts = config->readBoolEntry( "enlarge_for_readability", true );
|
||||
if (enlargeFonts != window->font_pool->getEnlargeFonts())
|
||||
window->font_pool->setEnlargeFonts(enlargeFonts);
|
||||
|
||||
bool showPS = config->readBoolEntry( "ShowPS", true );
|
||||
if (showPS != window->showPS())
|
||||
|
@ -353,15 +348,10 @@ void KDVIMultiPage::preferencesChanged()
|
|||
if (showHyperLinks != window->showHyperLinks())
|
||||
window->setShowHyperLinks(showHyperLinks);
|
||||
|
||||
/*
|
||||
bool usePFBFonts = config->readBoolEntry( "UsePFB", true );
|
||||
if (showHyperLinks != window->showHyperLinks())
|
||||
window->setShowHyperLinks(showHyperLinks);
|
||||
bool useType1Fonts = config->readBoolEntry( "UseType1Fonts", true );
|
||||
bool useFontHints = config->readBoolEntry( "UseFontHints", true );
|
||||
|
||||
bool usePFBFontHints = config->readBoolEntry( "UsePFBFontHints", true );
|
||||
if (showHyperLinks != window->showHyperLinks())
|
||||
window->setShowHyperLinks(showHyperLinks);
|
||||
*/
|
||||
window->font_pool->setParameters(mfmode, makepk, enlargeFonts, useType1Fonts, useFontHints);
|
||||
|
||||
window->setEditorCommand( config->readEntry( "EditorCommand", "" ));
|
||||
}
|
||||
|
@ -489,7 +479,7 @@ bool KDVIMultiPage::print(const QStringList &pages, int current)
|
|||
// feature of KDirWatch, I dare not say. We remedy that problem by
|
||||
// using a timer: when reload() was called on a bad file, we
|
||||
// automatically come back (via the timerEvent() function) every
|
||||
// second and check if the file becaome good. If so, we stop the
|
||||
// second and check if the file became good. If so, we stop the
|
||||
// timer. It may well happen that KDirWatch calls us several times
|
||||
// while we are waiting for the file to become good, but that does not
|
||||
// do any harm.
|
||||
|
|
|
@ -40,8 +40,8 @@ optionDialogFontsWidget::optionDialogFontsWidget( QWidget* parent, const char*
|
|||
metafontMode->setCurrentItem( config->readNumEntry( "MetafontMode" , DefaultMFMode ));
|
||||
|
||||
#ifdef HAVE_FREETYPE
|
||||
usePFBCheckBox->setChecked( config->readBoolEntry( "UsePFB", true ) );
|
||||
useFontHintingCheckBox->setChecked( config->readBoolEntry( "UsePFBFontHints", true ) );
|
||||
usePFBCheckBox->setChecked( config->readBoolEntry( "UseType1Fonts", true ) );
|
||||
useFontHintingCheckBox->setChecked( config->readBoolEntry( "UseFontHints", true ) );
|
||||
useFontHintingCheckBox->setEnabled(usePFBCheckBox->isChecked());
|
||||
#else
|
||||
usePFBCheckBox->setChecked(false);
|
||||
|
@ -70,8 +70,8 @@ void optionDialogFontsWidget::apply(void)
|
|||
{
|
||||
config->setGroup("kdvi");
|
||||
#ifdef HAVE_FREETYPE
|
||||
config->writeEntry( "UsePFB", usePFBCheckBox->isChecked() );
|
||||
config->writeEntry( "UsePFBFontHints", useFontHintingCheckBox->isChecked() );
|
||||
config->writeEntry( "UseType1Fonts", usePFBCheckBox->isChecked() );
|
||||
config->writeEntry( "UseFontHints", useFontHintingCheckBox->isChecked() );
|
||||
#endif
|
||||
config->writeEntry( "MetafontMode", metafontMode->currentItem() );
|
||||
config->writeEntry( "MakePK", fontGenerationCheckBox->isChecked() );
|
||||
|
|
12
special.cpp
12
special.cpp
|
@ -183,8 +183,8 @@ void dviWindow::epsf_special(QString cp)
|
|||
|
||||
if (PostScriptOutPutString) {
|
||||
if (QFile::exists(EPSfilename)) {
|
||||
double PS_H = (currinf.data.dvi_h*300.0)/(65536*MFResolutions[MetafontMode])-300;
|
||||
double PS_V = (currinf.data.dvi_v*300.0)/MFResolutions[MetafontMode] - 300;
|
||||
double PS_H = (currinf.data.dvi_h*300.0)/(65536*MFResolutions[font_pool->getMetafontMode()])-300;
|
||||
double PS_V = (currinf.data.dvi_v*300.0)/MFResolutions[font_pool->getMetafontMode()] - 300;
|
||||
PostScriptOutPutString->append( QString(" %1 %2 moveto\n").arg(PS_H).arg(PS_V) );
|
||||
PostScriptOutPutString->append( "@beginspecial " );
|
||||
PostScriptOutPutString->append( QString(" %1 @llx").arg(llx) );
|
||||
|
@ -259,8 +259,8 @@ void dviWindow::quote_special(QString cp)
|
|||
#endif
|
||||
|
||||
if (PostScriptOutPutString) {
|
||||
double PS_H = (currinf.data.dvi_h*300.0)/(65536*MFResolutions[MetafontMode])-300;
|
||||
double PS_V = (currinf.data.dvi_v*300.0)/MFResolutions[MetafontMode] - 300;
|
||||
double PS_H = (currinf.data.dvi_h*300.0)/(65536*MFResolutions[font_pool->getMetafontMode()])-300;
|
||||
double PS_V = (currinf.data.dvi_v*300.0)/MFResolutions[font_pool->getMetafontMode()] - 300;
|
||||
PostScriptOutPutString->append( QString(" %1 %2 moveto\n").arg(PS_H).arg(PS_V) );
|
||||
PostScriptOutPutString->append( " @beginspecial @setspecial \n" );
|
||||
PostScriptOutPutString->append( cp );
|
||||
|
@ -275,8 +275,8 @@ void dviWindow::ps_special(QString cp)
|
|||
#endif
|
||||
|
||||
if (PostScriptOutPutString) {
|
||||
double PS_H = (currinf.data.dvi_h*300.0)/(65536*MFResolutions[MetafontMode])-300;
|
||||
double PS_V = (currinf.data.dvi_v*300.0)/MFResolutions[MetafontMode] - 300;
|
||||
double PS_H = (currinf.data.dvi_h*300.0)/(65536*MFResolutions[font_pool->getMetafontMode()])-300;
|
||||
double PS_V = (currinf.data.dvi_v*300.0)/MFResolutions[font_pool->getMetafontMode()] - 300;
|
||||
|
||||
if (cp.find("ps::[begin]", 0, false) == 0) {
|
||||
PostScriptOutPutString->append( QString(" %1 %2 moveto\n").arg(PS_H).arg(PS_V) );
|
||||
|
|
Loading…
Reference in a new issue