Bug 75820 - Overwrites essential Fontmap file of ghostscript-x11 package
Summary: Overwrites essential Fontmap file of ghostscript-x11 package
Status: RESOLVED WORKSFORME
Alias: None
Product: kcontrol
Classification: Miscellaneous
Component: kcmfontinst (show other bugs)
Version: unspecified
Platform: openSUSE Linux
: NOR major
Target Milestone: ---
Assignee: Craig Drummond
URL:
Keywords:
: 77681 (view as bug list)
Depends on:
Blocks:
 
Reported: 2004-02-22 11:35 UTC by Andreas Kilgus
Modified: 2004-03-29 21:43 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments
Fontmap from ghostscript-x11 RPM (222 bytes, text/plain)
2004-02-26 03:08 UTC, Andreas Kilgus
Details
Fontmap.cpp (17.08 KB, text/x-c++src)
2004-02-27 00:27 UTC, Craig Drummond
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Kilgus 2004-02-22 11:35:37 UTC
Version:            (using KDE KDE 3.2.0)
Installed from:    SuSE RPMs
OS:          Linux

As soon as I change the installed fonts kcmfontinst generates new Fontmap files. Unfortunately /usr/lib/ghostscript/7.05/lib/Fontmap is one of them and contains 0 Bytes after kcmfontinst was used. This file belongs to ghostscript-x11 and normally consists of a number of includes to provide ghostscript with the proper info about installed fonts listed in other "Fontmap" files. After kcmfontinst overwriting this file neither printing nor viewing most of the available postscript/pdf files with kghostscript will work anymore because of ghostscript not finding necessary fonts.
Comment 1 Andreas Kilgus 2004-02-23 02:21:44 UTC
I forgot to mention: Two other users were able to reproduce this behaviour of kcmfontinst. See the german speaking newsgroup de.comp.os.unix.apps.kde, starting at M-ID <llmjg1-f44.ln1@usenet.fuenfsieben.de>.
Comment 2 Craig Drummond 2004-02-23 09:55:39 UTC
Hmmm.... All kcmfontinst is doing is adding its system-wide fontmap file to
the ghostscript one. Anyway, before kcmfontinst is run your
/usr/share/ghostscript/<version>/lib/Fontmap should look something like (from SuSE 8.2):


%!
% See Fontmap.GS for the syntax of real Fontmap files.
(Fontmap.X11-auto) .runlibfile
(Fontmap.GS) .runlibfile
(Fontmap.kanji) .runlibfile
(Fontmap.rus) .runlibfile
(Fontmap.CID) .runlibfile
(Fontmap.greek) .runlibfile

And after:


%!
% See Fontmap.GS for the syntax of real Fontmap files.
(/etc/fonts/Fontmap) .runlibfile
(Fontmap.X11-auto) .runlibfile
(Fontmap.GS) .runlibfile
(Fontmap.kanji) .runlibfile
(Fontmap.rus) .runlibfile
(Fontmap.CID) .runlibfile
(Fontmap.greek) .runlibfile



...the original can probably be restored by re-installing the ghostscript
RPMs. Can you try the following?

1. Restore your fontmap back to the original
2. Download the source for kdebase3.2
3. Edit kdebase-3.2/kcontrol/kfontist/lib/Fontmap.cpp - on line 449 theres
the following:

                        ofstream
out(QFile::encodeName(CGlobal::cfg().getGhostscriptFile()));

                        if(out)
                            out << buffer;

    ...please change this to:

                        if (added)
                        {
                            ofstream
out(QFile::encodeName(CGlobal::cfg().getGhostscriptFile()));

                            if(out)
                                out << buffer;
                        }

    ...this will stop kcmfontinst from createing the Ghostscipt fontmap file
unless it has added /etc/fonts/Fontmap to it.

4. Run ./configure in kdebase-3.2
5. Run make install in kdebase-3.2/kcontrol/kfontist
6. touch /usr/X11R6/lib/X11/fonts/truetype/<some font in here>   (this is to
force kcmfontinst to reconfigure this folder).
6. Run kcmfontinst in admin mode again.

And let me know if this works. All I can assume is that there was some error
when trying to read the original Fontmap file - so nothing was read in, and
nothing added. And when the file was written back, there was nothing to write
back. If this is so, the above change should fix this.

Craig.

Comment 3 Andreas Kilgus 2004-02-26 03:06:16 UTC
> ...the original can probably be restored by re-installing the ghostscript
> RPMs.

Yes, that's the way I convinced my printers to print again. ;-)

> ...this will stop kcmfontinst from createing the Ghostscipt fontmap file
> unless it has added /etc/fonts/Fontmap to it.

Well, this looks rather like a workaround than like a solution, doesn't it? I'll attach my Fontmap file - so you can have a look at why it apparently can't be read and analyzed in a useful way...

...and this is unfortunately the only help I can offer at the moment. I applied the changes you suggested to the source code and tried to compile a new binary:

> 4. Run ./configure in kdebase-3.2 
> 5. Run make install in kdebase-3.2/kcontrol/kfontist 

leads to:

| make[1]: *** Keine Regel vorhanden, um das Target
| »../../fonts/libkxftconfig.la«,
| benötigt von »libkfontinst.la«, zu erstellen.  Schluss.
| make[1]: Leaving directory
| `/usr/src/packages/SOURCES/kdebase-3.2.0/kcontrol/kfontinst/lib'
| make: *** [install-recursive] Fehler 1

(= no rule to build target ../../fonts/libkxftconfig.la, required by
libkfontinst.la)

Next I modified the source RPM and fired a rpm -bb kdebase3.spec - without success, too. 
Comment 4 Andreas Kilgus 2004-02-26 03:08:10 UTC
Created attachment 4891 [details]
Fontmap from ghostscript-x11 RPM
Comment 5 Craig Drummond 2004-02-26 12:34:09 UTC
> > ...this will stop kcmfontinst from createing the Ghostscipt fontmap file
> > unless it has added /etc/fonts/Fontmap to it.
>
> Well, this looks rather like a workaround than like a solution, doesn't it?

Well as I said, that would be the only reason for a blank Fontmap file being 
generated.

> I'll attach my Fontmap file - so you can have a look at why it apparently
> can't be read and analyzed in a useful way...

Its *exactly* the same as on my SuSE8.2 system - although without the 
kfontinst added line.

> leads to:
> | make[1]: *** Keine Regel vorhanden, um das Target
> | »../../fonts/libkxftconfig.la«,
> | benötigt von »libkfontinst.la«, zu erstellen.  Schluss.
> | make[1]: Leaving directory
> | `/usr/src/packages/SOURCES/kdebase-3.2.0/kcontrol/kfontinst/lib'
> | make: *** [install-recursive] Fehler 1
>
> (= no rule to build target ../../fonts/libkxftconfig.la, required by
> libkfontinst.la)

You need to compile kdebase/kcontrol/fonts and then kdebase/kcontrol/kfontinst

Craig.

Comment 6 Andreas Kilgus 2004-02-26 14:41:00 UTC
>> I'll attach my Fontmap file - so you can have a look at why it apparently 
>> can't be read and analyzed in a useful way... 
> 
> Its *exactly* the same as on my SuSE8.2 system - although without the 
> kfontinst added line. 

In the meanwhile compilation and installation of the patched kcmfontinst now
worked on my machine and ghostscripts Fontmap file remains sane after a run
of kcmfontinst - but "(/etc/fonts/Fontmap) .runlibfile" isn't added to the
list of includes.
  
So while kcmfontinst doesn't "destroy" this file anymore - on the other hand
it still doesn't do its job completely as intended, or am I wrong with this
interpretation of the current situation?

Greetings
Andi
Comment 7 Craig Drummond 2004-02-27 00:27:58 UTC
> In the meanwhile compilation and installation of the patched kcmfontinst
> now worked on my machine and ghostscripts Fontmap file remains sane after a
> run of kcmfontinst - but "(/etc/fonts/Fontmap) .runlibfile" isn't added to
> the list of includes.
>
> So while kcmfontinst doesn't "destroy" this file anymore - on the other
> hand it still doesn't do its job completely as intended, or am I wrong with
> this interpretation of the current situation?

Nope. you're 100% correct - thats what the fix does, preventing an empty 
Fontmap being created.

OK, after a little experimenting - I too had this error. Please try modifying 
kdebase/kcontrol/kfontinst/lib/Fontmap.cpp at about line number 406 add a 
"in.clear();" - as follows:

                    in.clear();
                    in.seekg(0, ios::end);
                    int size= (streamoff) in.tellg();
                    in.seekg(0, ios::beg);

...or use the attatched file. Hopefully this will rectify the situation. (This 
time you'll just need to recompile (all of) kdebase/kcontrol/kfontinst)

Also, in the previous email I said to touch a font, instead just 
touch /usr/X11R6/lib/X11/fonts/truetype/Fontmap.cpp - and use kcontrol (as 
root) to browse into the "truetype" folder (this will cause the Fontmap code 
to be re-run).

>
> Greetings
> Andi

Craig.

p.s. Sorry if I'm a little slow at replying, etc. - my wife just gave birth to 
our 1st baby on Monday night. So I'm not getting too much sleep...




Created an attachment (id=4909)
Fontmap.cpp
Comment 8 Andreas Kilgus 2004-02-27 16:13:17 UTC
> p.s. Sorry if I'm a little slow at replying, etc. - my wife just gave birth
> to our 1st baby on Monday night. So I'm not getting too much sleep...

Congratulations! I hope everybody's well - apart from being permanently
overtired. ;-)

Concerning the bug: The new version of kfontinst did it - Fontmap now contains
the desired line inserted by kfontinst.

BTW: Where has gone the GUI to adjust kfontinst's settings (place of
ghostscript installation, ...)?
Comment 9 Craig Drummond 2004-02-27 22:31:20 UTC
> > p.s. Sorry if I'm a little slow at replying, etc. - my wife just gave
> > birth to our 1st baby on Monday night. So I'm not getting too much
> > sleep...
>
> Congratulations! I hope everybody's well - apart from being permanently
> overtired. ;-)

Yeah, everythings fine. Actually managed to get some sleep last night!

>
> Concerning the bug: The new version of kfontinst did it - Fontmap now
> contains the desired line inserted by kfontinst.

Excellent. I wonder why it worked before! I'll apply the changes later this 
weekend.

>
> BTW: Where has gone the GUI to adjust kfontinst's settings (place of
> ghostscript installation, ...)?

It guesses them automatically - by looking for certain files in some 
predefined locations. These can be overridden by editing 
$KDEHOME/share/config/kfontinstrc

Craig.

Comment 10 jkyro 2004-02-27 23:06:39 UTC
I can confirm this behavior with Fedora Core 1. I had exactly the same problem, and worked around it by reinstalling ghostscript.
Comment 11 Craig Drummond 2004-02-27 23:13:18 UTC
On Friday 27 February 2004 22:06, jkyro@pp.htv.fi wrote:
> ------- You are receiving this mail because: -------
> You are the assignee for the bug, or are watching the assignee.
>
> http://bugs.kde.org/show_bug.cgi?id=75820
>
>
>
>
> ------- Additional Comments From jkyro pp htv fi  2004-02-27 23:06 -------
> I can confirm this behavior with Fedora Core 1. I had exactly the same
> problem, and worked around it by reinstalling ghostscript.

Yeah - please use the Fontmap.cpp file attatched previously, and recompile. 
Alternatively, edit 
your /usr/local/share/ghostscript/<version>/lib/Fontmap.cpp and add

(/etc/fonts/Fontmap) .runlibfile

...before anyother ".runlibfile" statement. This will prevent kfontinst from 
modifying the file - as it will already contain what kfontinst is trying to 
add.

e.g. BEFORE:

%! 
 % See Fontmap.GS for the syntax of real Fontmap files. 
 (Fontmap.X11-auto) .runlibfile 
 (Fontmap.GS) .runlibfile 

 
AFTER: 
 
 %! 
 % See Fontmap.GS for the syntax of real Fontmap files. 
 (/etc/fonts/Fontmap) .runlibfile 
 (Fontmap.X11-auto) .runlibfile 
 (Fontmap.GS) .runlibfile 


"(/etc/fonts/Fontmap) .runlibfile " *must* be the first one after the comment 
lines (those starting with %)

Sorry for the bug!

Craig.

Comment 12 Andreas Kilgus 2004-02-29 19:59:35 UTC
> > BTW: Where has gone the GUI to adjust kfontinst's settings (place of
> > ghostscript installation, ...)?
>
> It guesses them automatically - by looking for certain files in some
> predefined locations. These can be overridden by editing
> $KDEHOME/share/config/kfontinstrc

While I always apreciate if software tries not to bother me with settings it
can find out itself, I also like it very much if it's very easy to tell the
software that it misguessed something (just in case *g*) and how I want it to
be instead of the software's guess.

As you already had implemented a GUI I wonder why it just vanished - I don't
think that an automatic and manual editing exclude each other. It's always
nice to have the choice (without looking for configuration files to edit). ;-)

Hm, as this has been my first contact with bugzilla: The above is something
to report as "wish", correct? And what happens with the bug we were talking
about? Do I have to mark it as resolved, is this something you have to do or what or how, erm, ... :-)

Andi
Comment 13 Craig Drummond 2004-02-29 22:17:42 UTC
> While I always apreciate if software tries not to bother me with settings
> it can find out itself, I also like it very much if it's very easy to tell
> the software that it misguessed something (just in case *g*) and how I want
> it to be instead of the software's guess.
>
> As you already had implemented a GUI I wonder why it just vanished - I
> don't think that an automatic and manual editing exclude each other. It's
> always nice to have the choice (without looking for configuration files to
> edit). ;-)

The reason being that the kcontrol module is now just a front-end for the 
"fonts:/" io-slave. i.e. Typing (as non-root) "fonts:/Personal" will list 
your user fonts, and "fonts:/System" will show the system-wide fonts.

While I can see your point about adjusting the settings via a GUI - its not 
the usual case. On most systems gs is installed in the same location.
>
> Hm, as this has been my first contact with bugzilla: The above is something
> to report as "wish", correct? And what happens with the bug we were talking
> about? Do I have to mark it as resolved, is this something you have to do
> or what or how, erm, ... :-)

The above would be a "wishlist" item - and you should create a new error about 
this. Using bugs.kde.org you should be able to close this one.

>
> Andi

Thanks for reporting the bug, and helping me verify the fix!

Craig.

Comment 14 Andreas Kilgus 2004-03-02 00:54:19 UTC
[revitalization of GUI for settings]
> The above would be a "wishlist" item - and you should create a new error
> about this.

Ok, I'll think about it.

> Using bugs.kde.org you should be able to close this one. 

[X] Done.

> Thanks for reporting the bug, and helping me verify the fix! 
 
Thanks for your software - so what's a bug report and a little bit compiling
worth compared to your engagement?

Greetings
Andi
Comment 15 Craig Drummond 2004-03-22 18:02:56 UTC
> On Mon, 22 Mar 2004, Craig Drummond wrote:
> 
> > OK. You're right - it's not reading the existing fonts.scale. But it
> does
> > read the existing fonts.dir (and, afterall, this is the only one really
> used by
> > X). So, if you specify the encoding in fonts.dir it will not be
> overwritten.
> 
> Hmm, I've never tested this because all documentation recommends that
> fonts.scale should be provided and included by the font creator.

That's because traditionally fonts.dir is created by mkfontdir. mkfontdir
only knows how to read bitmap fonts -as these actually have the xlfd
(name-dpi-encoding, etc) embedded in them.  So to get scaleable fonts recognised the
user hand to hand create a fonts.scale file - mkfontdir would then read this
when creating fonts.dir and append the info. (mkfontscale can now be used for
creating fonts.scale files).

So the usual process would be:

1. Run mkfontscale to create fonts.scale from Type1 and TTF fonts
2. Run mkfontdir to create fonts.dir by reading bitmap fonts and
fonts.scale.

Kfontist however creates both directly - it doesn't use either tool.
fonts.scale is only created just in case you later run mkfontdir by hand.

> 
> > But, it should read both. I'll make the necessary changes.
> 
> Oh, thank you very much!
> 
> Andreas
> 

CC'ing this to the bug report...

Comment 16 Craig Drummond 2004-03-22 18:07:09 UTC
> I've just tested this with KDE 3.1 and Solaris 9.
> My fonts.dir specifies "iso8859-5" but the newly generated fonts.dir
> in ~/.kde/share/fonts/Type1/ has encoding "adobe-fontspecific".

Sorry, the behaviour I mentioned was KDE3.2 specific!

> 
> Andreas
> 

Comment 17 Craig Drummond 2004-03-22 22:23:42 UTC
Oops... wrong bug report.

Comment 18 Craig Drummond 2004-03-22 22:24:04 UTC
On Monday 22 March 2004 17:07, Craig Drummond wrote:
> ------- You are receiving this mail because: -------
> You are the assignee for the bug, or are watching the assignee.
>
> http://bugs.kde.org/show_bug.cgi?id=75820
>
>
>
>
> ------- Additional Comments From Craig.Drummond gmx net  2004-03-22 18:07
> -------
>
> > I've just tested this with KDE 3.1 and Solaris 9.
> > My fonts.dir specifies "iso8859-5" but the newly generated fonts.dir
> > in ~/.kde/share/fonts/Type1/ has encoding "adobe-fontspecific".
>
> Sorry, the behaviour I mentioned was KDE3.2 specific!
>
> > Andreas

Oops... wrong bug report.

Comment 19 Rex Dieter 2004-03-29 21:27:48 UTC
fixed(?) in kde-3.2.1
Comment 20 Rex Dieter 2004-03-29 21:43:46 UTC
*** Bug 77681 has been marked as a duplicate of this bug. ***