mirror of
https://invent.kde.org/graphics/okular
synced 2024-09-19 07:51:27 +00:00
further improve font rendering, virtual fonts are now displayed 50% faster
svn path=/trunk/kdegraphics/kdvi/; revision=222420
This commit is contained in:
parent
0eb0c5e7a1
commit
a557c99724
|
@ -553,7 +553,7 @@ bool dviWindow::setFile(QString fname, QString ref, bool sourceMarker)
|
||||||
command_pointer = end_pointer = 0;
|
command_pointer = end_pointer = 0;
|
||||||
|
|
||||||
memset((char *) &currinf.data, 0, sizeof(currinf.data));
|
memset((char *) &currinf.data, 0, sizeof(currinf.data));
|
||||||
currinf.fonttable = dviFile->tn_table;
|
currinf.fonttable = &(dviFile->tn_table);
|
||||||
currinf._virtual = NULL;
|
currinf._virtual = NULL;
|
||||||
draw_part(65536.0*fontPixelPerDVIunit(), false);
|
draw_part(65536.0*fontPixelPerDVIunit(), false);
|
||||||
|
|
||||||
|
|
2
dviwin.h
2
dviwin.h
|
@ -96,7 +96,7 @@ struct drawinf {
|
||||||
TeXFontDefinition *fontp;
|
TeXFontDefinition *fontp;
|
||||||
set_char_proc set_char_p;
|
set_char_proc set_char_p;
|
||||||
|
|
||||||
QIntDict<TeXFontDefinition> fonttable;
|
QIntDict<TeXFontDefinition> *fonttable;
|
||||||
TeXFontDefinition *_virtual;
|
TeXFontDefinition *_virtual;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -228,7 +228,7 @@ void dviWindow::set_vf_char(unsigned int cmd, unsigned int ch)
|
||||||
currinf.data.y = 0;
|
currinf.data.y = 0;
|
||||||
currinf.data.z = 0;
|
currinf.data.z = 0;
|
||||||
|
|
||||||
currinf.fonttable = currinf.fontp->vf_table;
|
currinf.fonttable = &(currinf.fontp->vf_table);
|
||||||
currinf._virtual = currinf.fontp;
|
currinf._virtual = currinf.fontp;
|
||||||
Q_UINT8 *command_ptr_sav = command_pointer;
|
Q_UINT8 *command_ptr_sav = command_pointer;
|
||||||
Q_UINT8 *end_ptr_sav = end_pointer;
|
Q_UINT8 *end_ptr_sav = end_pointer;
|
||||||
|
@ -284,7 +284,7 @@ void dviWindow::draw_part(double current_dimconv, bool is_vfmacro)
|
||||||
(this->*currinf.set_char_p)(ch, ch);
|
(this->*currinf.set_char_p)(ch, ch);
|
||||||
} else
|
} else
|
||||||
if (FNTNUM0 <= ch && ch <= (unsigned char) (FNTNUM0 + 63)) {
|
if (FNTNUM0 <= ch && ch <= (unsigned char) (FNTNUM0 + 63)) {
|
||||||
currinf.fontp = currinf.fonttable[ch - FNTNUM0];
|
currinf.fontp = currinf.fonttable->find(ch - FNTNUM0);
|
||||||
if (currinf.fontp == NULL) {
|
if (currinf.fontp == NULL) {
|
||||||
errorMsg = i18n("The DVI code referred to font #%1, which was not previously defined.").arg(ch - FNTNUM0);
|
errorMsg = i18n("The DVI code referred to font #%1, which was not previously defined.").arg(ch - FNTNUM0);
|
||||||
return;
|
return;
|
||||||
|
@ -495,7 +495,7 @@ void dviWindow::draw_part(double current_dimconv, bool is_vfmacro)
|
||||||
case FNT1:
|
case FNT1:
|
||||||
case FNT2:
|
case FNT2:
|
||||||
case FNT3:
|
case FNT3:
|
||||||
currinf.fontp = currinf.fonttable[readUINT(ch - FNT1 + 1)];
|
currinf.fontp = currinf.fonttable->find(readUINT(ch - FNT1 + 1));
|
||||||
if (currinf.fontp == NULL) {
|
if (currinf.fontp == NULL) {
|
||||||
errorMsg = i18n("The DVI code referred to a font which was not previously defined.");
|
errorMsg = i18n("The DVI code referred to a font which was not previously defined.");
|
||||||
return;
|
return;
|
||||||
|
@ -504,7 +504,7 @@ void dviWindow::draw_part(double current_dimconv, bool is_vfmacro)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case FNT4:
|
case FNT4:
|
||||||
currinf.fontp = currinf.fonttable[readINT(ch - FNT1 + 1)];
|
currinf.fontp = currinf.fonttable->find(readINT(ch - FNT1 + 1));
|
||||||
if (currinf.fontp == NULL) {
|
if (currinf.fontp == NULL) {
|
||||||
errorMsg = i18n("The DVI code referred to a font which was not previously defined.");
|
errorMsg = i18n("The DVI code referred to a font which was not previously defined.");
|
||||||
return;
|
return;
|
||||||
|
@ -612,7 +612,7 @@ void dviWindow::draw_page(void)
|
||||||
command_pointer = end_pointer = 0;
|
command_pointer = end_pointer = 0;
|
||||||
|
|
||||||
memset((char *) &currinf.data, 0, sizeof(currinf.data));
|
memset((char *) &currinf.data, 0, sizeof(currinf.data));
|
||||||
currinf.fonttable = dviFile->tn_table;
|
currinf.fonttable = &(dviFile->tn_table);
|
||||||
currinf._virtual = 0;
|
currinf._virtual = 0;
|
||||||
draw_part(65536.0*fontPixelPerDVIunit(), false);
|
draw_part(65536.0*fontPixelPerDVIunit(), false);
|
||||||
if (HTML_href != 0) {
|
if (HTML_href != 0) {
|
||||||
|
|
14
fontpool.cpp
14
fontpool.cpp
|
@ -45,7 +45,6 @@ fontPool::fontPool(void)
|
||||||
|
|
||||||
proc = 0;
|
proc = 0;
|
||||||
makepk = true; // By default, fonts are generated
|
makepk = true; // By default, fonts are generated
|
||||||
enlargeFonts = true; // By default, fonts are enlarged
|
|
||||||
displayResolution_in_dpi = 100.0; // A not-too-bad-default
|
displayResolution_in_dpi = 100.0; // A not-too-bad-default
|
||||||
MetafontMode = DefaultMFMode;
|
MetafontMode = DefaultMFMode;
|
||||||
fontList.setAutoDelete(TRUE);
|
fontList.setAutoDelete(TRUE);
|
||||||
|
@ -124,7 +123,7 @@ fontPool::~fontPool(void)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void fontPool::setParameters( unsigned int _metafontMode, bool _makePK, bool _enlargeFonts, bool _useType1Fonts, bool _useFontHints )
|
void fontPool::setParameters( unsigned int _metafontMode, bool _makePK, bool _useType1Fonts, bool _useFontHints )
|
||||||
{
|
{
|
||||||
if (_metafontMode >= NumberOfMFModes) {
|
if (_metafontMode >= NumberOfMFModes) {
|
||||||
kdError(4300) << "fontPool::setMetafontMode called with argument " << _metafontMode
|
kdError(4300) << "fontPool::setMetafontMode called with argument " << _metafontMode
|
||||||
|
@ -160,10 +159,8 @@ void fontPool::setParameters( unsigned int _metafontMode, bool _makePK, bool _en
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if glyphs need to be cleared
|
// Check if glyphs need to be cleared
|
||||||
if ((_enlargeFonts != enlargeFonts) || (_useFontHints != useFontHints)) {
|
if (_useFontHints != useFontHints) {
|
||||||
double displayResolution = displayResolution_in_dpi;
|
double displayResolution = displayResolution_in_dpi;
|
||||||
if (_enlargeFonts == true)
|
|
||||||
displayResolution *= 1.1;
|
|
||||||
TeXFontDefinition *fontp = fontList.first();
|
TeXFontDefinition *fontp = fontList.first();
|
||||||
while(fontp != 0 ) {
|
while(fontp != 0 ) {
|
||||||
fontp->setDisplayResolution(displayResolution * fontp->enlargement);
|
fontp->setDisplayResolution(displayResolution * fontp->enlargement);
|
||||||
|
@ -173,7 +170,6 @@ void fontPool::setParameters( unsigned int _metafontMode, bool _makePK, bool _en
|
||||||
|
|
||||||
MetafontMode = _metafontMode;
|
MetafontMode = _metafontMode;
|
||||||
makepk = _makePK;
|
makepk = _makePK;
|
||||||
enlargeFonts = _enlargeFonts;
|
|
||||||
useType1Fonts = _useType1Fonts;
|
useType1Fonts = _useType1Fonts;
|
||||||
useFontHints = _useFontHints;
|
useFontHints = _useFontHints;
|
||||||
|
|
||||||
|
@ -204,8 +200,6 @@ class TeXFontDefinition *fontPool::appendx(QString fontname, Q_UINT32 checksum,
|
||||||
// If font doesn't exist yet, we have to generate a new font.
|
// If font doesn't exist yet, we have to generate a new font.
|
||||||
|
|
||||||
double displayResolution = displayResolution_in_dpi;
|
double displayResolution = displayResolution_in_dpi;
|
||||||
if (enlargeFonts == true)
|
|
||||||
displayResolution *= 1.1;
|
|
||||||
|
|
||||||
fontp = new TeXFontDefinition(fontname, displayResolution*enlargement, checksum, scale, this, enlargement);
|
fontp = new TeXFontDefinition(fontname, displayResolution*enlargement, checksum, scale, this, enlargement);
|
||||||
if (fontp == 0) {
|
if (fontp == 0) {
|
||||||
|
@ -597,7 +591,7 @@ void fontPool::kpsewhich_terminated(KProcess *)
|
||||||
config->setGroup("kdvi");
|
config->setGroup("kdvi");
|
||||||
config->writeEntry( "MakePK", true );
|
config->writeEntry( "MakePK", true );
|
||||||
config->sync();
|
config->sync();
|
||||||
setParameters( MetafontMode, true, enlargeFonts, useType1Fonts, useFontHints ); // That will start kpsewhich again.
|
setParameters( MetafontMode, true, useType1Fonts, useFontHints ); // That will start kpsewhich again.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
|
@ -618,8 +612,6 @@ void fontPool::setDisplayResolution( double _displayResolution_in_dpi )
|
||||||
#endif
|
#endif
|
||||||
displayResolution_in_dpi = _displayResolution_in_dpi;
|
displayResolution_in_dpi = _displayResolution_in_dpi;
|
||||||
double displayResolution = displayResolution_in_dpi;
|
double displayResolution = displayResolution_in_dpi;
|
||||||
if (enlargeFonts == true)
|
|
||||||
displayResolution *= 1.1;
|
|
||||||
|
|
||||||
TeXFontDefinition *fontp = fontList.first();
|
TeXFontDefinition *fontp = fontList.first();
|
||||||
while(fontp != 0 ) {
|
while(fontp != 0 ) {
|
||||||
|
|
34
fontpool.h
34
fontpool.h
|
@ -62,36 +62,24 @@ Q_OBJECT
|
||||||
fontpool.cpp. Returns the mode number of the mode which was
|
fontpool.cpp. Returns the mode number of the mode which was
|
||||||
actually set ---if an invalid argument is given, this will be
|
actually set ---if an invalid argument is given, this will be
|
||||||
the DefaultMFMode as defined in fontPool.h */
|
the DefaultMFMode as defined in fontPool.h */
|
||||||
// unsigned int setMetafontMode( unsigned int );
|
|
||||||
|
|
||||||
void setParameters( unsigned int MetaFontMode, bool makePK, bool enlargeFonts, bool useType1Fonts, bool useFontHints );
|
/** Sets whether fonts will be generated by running MetaFont, or a
|
||||||
|
similar programm. If (flag == 0), fonts will not be generated,
|
||||||
|
otherwise they will. */
|
||||||
|
|
||||||
|
/** Determines if Adobe Type 1 (*.pfb) fonts should be used or not */
|
||||||
|
|
||||||
|
/** Sets the resolution of the output device and determines if font hinting should be used. */
|
||||||
|
|
||||||
|
void setParameters( unsigned int MetaFontMode, bool makePK, bool useType1Fonts, bool useFontHints );
|
||||||
|
|
||||||
/** Returns the currently set MetafontMode */
|
/** Returns the currently set MetafontMode */
|
||||||
|
|
||||||
unsigned int getMetafontMode(void) {return 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 );
|
|
||||||
|
|
||||||
/** Sets whether glyphs will be enlarged or not. If (flag == 0),
|
|
||||||
glyphs will not be enlarged, otherwise they will. */
|
|
||||||
// void setEnlargeFonts( bool flag );
|
|
||||||
|
|
||||||
/** Sets the resolution of the output device. */
|
/** Sets the resolution of the output device. */
|
||||||
void setDisplayResolution( double _displayResolution_in_dpi );
|
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
|
/** If return value is true, font hinting should be used if
|
||||||
possible */
|
possible */
|
||||||
bool getUseFontHints(void) {return useFontHints;};
|
bool getUseFontHints(void) {return useFontHints;};
|
||||||
|
@ -234,10 +222,6 @@ public slots:
|
||||||
are NOT generated. */
|
are NOT generated. */
|
||||||
bool makepk;
|
bool makepk;
|
||||||
|
|
||||||
/** This flag determines whether the glyphs should be enlarged by 10%
|
|
||||||
or not. If enlargeFonts==0, then fonts are NOT enlarged. */
|
|
||||||
bool enlargeFonts;
|
|
||||||
|
|
||||||
/** This flag is used by PFB fonts to determine if the FREETYPE
|
/** This flag is used by PFB fonts to determine if the FREETYPE
|
||||||
engine should use hinted fonts or not */
|
engine should use hinted fonts or not */
|
||||||
bool useFontHints;
|
bool useFontHints;
|
||||||
|
|
|
@ -350,8 +350,6 @@ void KDVIMultiPage::preferencesChanged()
|
||||||
config->writeEntry( "MetafontMode", mfmode = DefaultMFMode );
|
config->writeEntry( "MetafontMode", mfmode = DefaultMFMode );
|
||||||
|
|
||||||
bool makepk = config->readBoolEntry( "MakePK", true );
|
bool makepk = config->readBoolEntry( "MakePK", true );
|
||||||
bool enlargeFonts = config->readBoolEntry( "enlarge_for_readability", true );
|
|
||||||
|
|
||||||
bool showPS = config->readBoolEntry( "ShowPS", true );
|
bool showPS = config->readBoolEntry( "ShowPS", true );
|
||||||
if (showPS != window->showPS())
|
if (showPS != window->showPS())
|
||||||
window->setShowPS(showPS);
|
window->setShowPS(showPS);
|
||||||
|
@ -363,7 +361,7 @@ void KDVIMultiPage::preferencesChanged()
|
||||||
bool useType1Fonts = config->readBoolEntry( "UseType1Fonts", true );
|
bool useType1Fonts = config->readBoolEntry( "UseType1Fonts", true );
|
||||||
bool useFontHints = config->readBoolEntry( "UseFontHints", true );
|
bool useFontHints = config->readBoolEntry( "UseFontHints", true );
|
||||||
|
|
||||||
window->font_pool->setParameters(mfmode, makepk, enlargeFonts, useType1Fonts, useFontHints);
|
window->font_pool->setParameters(mfmode, makepk, useType1Fonts, useFontHints);
|
||||||
|
|
||||||
window->setEditorCommand( config->readEntry( "EditorCommand", "" ));
|
window->setEditorCommand( config->readEntry( "EditorCommand", "" ));
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,7 +57,6 @@ optionDialogFontsWidget::optionDialogFontsWidget( QWidget* parent, const char*
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
fontGenerationCheckBox->setChecked( config->readBoolEntry( "MakePK", true ) );
|
fontGenerationCheckBox->setChecked( config->readBoolEntry( "MakePK", true ) );
|
||||||
fontEnlargementCheckBox->setChecked( config->readBoolEntry( "enlarge_for_readability", true ) );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
optionDialogFontsWidget::~optionDialogFontsWidget()
|
optionDialogFontsWidget::~optionDialogFontsWidget()
|
||||||
|
@ -75,7 +74,6 @@ void optionDialogFontsWidget::apply(void)
|
||||||
#endif
|
#endif
|
||||||
config->writeEntry( "MetafontMode", metafontMode->currentItem() );
|
config->writeEntry( "MetafontMode", metafontMode->currentItem() );
|
||||||
config->writeEntry( "MakePK", fontGenerationCheckBox->isChecked() );
|
config->writeEntry( "MakePK", fontGenerationCheckBox->isChecked() );
|
||||||
config->writeEntry( "enlarge_for_readability", fontEnlargementCheckBox->isChecked() );
|
|
||||||
config->sync();
|
config->sync();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>259</width>
|
<width>259</width>
|
||||||
<height>241</height>
|
<height>299</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="caption">
|
<property name="caption">
|
||||||
|
@ -120,14 +120,6 @@
|
||||||
</widget>
|
</widget>
|
||||||
</vbox>
|
</vbox>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QCheckBox">
|
|
||||||
<property name="name">
|
|
||||||
<cstring>fontEnlargementCheckBox</cstring>
|
|
||||||
</property>
|
|
||||||
<property name="text">
|
|
||||||
<string>Enlarge fonts for better readability</string>
|
|
||||||
</property>
|
|
||||||
</widget>
|
|
||||||
<spacer>
|
<spacer>
|
||||||
<property name="name">
|
<property name="name">
|
||||||
<cstring>spacer2</cstring>
|
<cstring>spacer2</cstring>
|
||||||
|
|
Loading…
Reference in a new issue