Pfontview - A simple lightweight TrueType font viewer

Window managers, icon programs, widgets, etc.
Message
Author
User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

Pfontview - A simple lightweight TrueType font viewer

#1 Post by thunor »

Pfontview enables the previewing of TrueType fonts.

Requirements
Gtkdialog >= 0.8.2 - http://code.google.com/p/gtkdialog/
fc-query - part of fontconfig - http://fontconfig.org/

fc-query
I'm using Slacko 5.3.3 and it comes with fontconfig but fc-query is not included within the fontconfig builtin, so Slacko 5.3.3 users at least will require it but I've compiled fc-query on my computer and then processed it with "strip --strip-unneeded" which I've attached below -- place it in ~/my-applications/bin or /usr/bin, you decide. If you want to compile it then run "fc-list -V" to get the version of fontconfig on your computer so that you can download the correct source package, use the recommended configure options settings from the INSTALL file but change --prefix=/usr to --prefix=/tmp/fontconfig, make and then make install. You'll find fc-query in /tmp/fontconfig/usr/bin.

pfontview [Updated 2012-11-08 to version 0.1.3]
Source code package: http://code.google.com/p/gtkdialog/downloads/list

Pet package:
  • Download the source package, extract it and change into the directory.
  • Type "make DESTDIR=pfontview-0.x.x install"
  • Type "dir2pet pfontview-0.x.x" and keep pressing Enter until the "GUI window" appears and then press the "Generate..." button.
  • Click on pfontview-0.x.x.pet to install.
How to use it
pfontview expects a ttf file but you're unlikely to be using this on the command-line so make this the default application for ttf files. In ROX-Filer you'd achieve this by right-clicking a ttf file and selecting "Set Run Action..." and entering pfontview "$@".

Internationalisation
funci18nApply contains the few strings that will require translating for other languages and if you attempt it then dump your text here and I'll add it to the project.

fc-query extracts font information not only in English but in whatever languages (I guess) that the font supports, so "Bold" can be "Negreta", "fed", "Fett", "Gras" etc. which I'm assuming that I'm supposed to be using as a developer when I request bold on a non-English computer. So, if the font information outputs "Bold" in your native language then I'll use it, else I request the English equivalent which will be available. I guess we'll find out now if my assumption is correct :P

Regards,
Thunor
Attachments
pfontview-0.1.2.png
pfontview-0.1.2
(16.39 KiB) Downloaded 4469 times
fc_query-0.8.2-i686.tar.gz
Built on Slacko 5.3.3, stripped with --strip-unneeded
(2.77 KiB) Downloaded 1669 times
Last edited by thunor on Fri 09 Nov 2012, 01:38, edited 2 times in total.

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#2 Post by disciple »

Thanks, this works rather well.

I've always wanted a decent solution for previewing fonts using the system font rendering settings, but I had trouble coming up with a proper solution, and it wasn't a really high priority :)

I'm wondering - do you create the symlink in ~/.fonts specifically so that other programs can access an "uninstalled" font when it is open, like on Windows?
Have you looked at whether it is possible to avoid temporary config or font files like this, by somehow specifying an additional font directory (the location of the ttf file) on the fly?
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#3 Post by disciple »

Oh, there is a bug :(
With a lot of fonts it states the correct style and family, but it doesn't actually display the correct font, instead it displays the system default font (in my case "sans") instead. Also for these fonts if I click the font button the system default font is selected...

Looking at the "FontQuery" files generated, I notice that the "Full name" of the fonts that don't work all seem to include a colon, whereas the "Full name" of the fonts that do work don't include a colon.
e.g. this font does not display:

Code: Select all

 	fullname: "Dancin LET Plain:1.0"(s)
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#4 Post by thunor »

Thanks for your feedback disciple.

The process is very simple: place a symlink to a ttf file into ~/.fonts and then use fc-query to query that file and create a font name from family + style. This font name is used in three different ways:

1. in a gtkrc file to style the preview edit widget.
2. in Pango markup within the main text widget (GtkLabel).
3. in the fontbutton widget if you have it shown.

All this can be seen within the files in the temporary folder /tmp/pfontview.XXXXXXXX so you can see exactly what is being requested.

I too have experienced fonts that gtk refuses to initialise to, and that's three different ways it refuses as listed above. As you've noted yourself, when the font doesn't show, the fontbutton will have "sans regular 10" selected because it's the default font, but it is possible to manually select the font that gtk refuses to initialise to.

I don't know why gtk refuses to initialise to certain fonts even though you can manually select them via the fontbutton. I've even placed the font into ~./fonts, fixed the font name in pfontview e.g. ~/.fonts/bernhc.ttf, rebooted and it still won't show.

The fact is it does work but gtk refuses to initialise to certain fonts, so the method is good but something isn't right. But where do I start to troubleshoot that? I'd like to try it on another Linux distribution but I don't currently have another installed, so maybe a reader can assist with that.

For me using Slacko 5.3.3, gtk won't initialise to this font: http://www.eborg2.com/Fonts/FontsB/BERNHC.TTF

If you place that into ~/.fonts, reboot or restart X, open the folder and click on the file you'll actually be viewing an installed font if installing means placing into ~/.fonts -- it still won't show.

I don't have another application to view fonts and I can always check using the fontbutton so at the moment it's 100% better than having no font viewer.

Regards,
Thunor

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#5 Post by vovchik »

Dear thunor,

You are on the right track. I once did this thing: http://www.murga-linux.com/puppy/viewtopic.php?t=69107, and discovered that there are "funky" fonts, either because of their internal names or wierd glyph layouts. Please have a look, so we can understand this problem.

With kind regards,
vovchik

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#6 Post by disciple »

I'd like to try it on another Linux distribution but I don't currently have another installed, so maybe a reader can assist with that.
I am running Arch ;)
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#7 Post by thunor »

I've have a feeling that I've walked out onto a minefield and you're all there in the middle waving at me :P

vovchik: I tried Pfont2 and it works. I set ttf "@" as the default action in ROX and it opens the preview window when I click on a ttf file.

disciple: Great, then we can rule out the problem being anything puppy related."fullname" from fc-query I have found to be unreliable because it can be junk. family + style constitute a valid font description.

I wrote a simple gtk app to do the same thing as pfontview but the fonts that don't show still don't show. I did some research on the net and it is my opinion that Pango -- the gtk font renderer -- doesn't like certain fonts and we won't understand why until somebody writes a gtk app that deals with Pango in code because at the moment there's no feedback as to why the fonts aren't acceptable.

I have 23 fonts out of 213 (11%) that gtk/Pango refuse to initialise widgets to. Five of these are definitely suspect since the text in the style field is the author's mutterings. Of the remainder there are oddities for example "Demi Bold" which I don't see Pango accepting as a valid weight, and things like "Ext Condensed" when it should be "Extra-Condensed". I'm going to guess that we'll find Pango won't render certain fonts because they have some irregularities, some non-standard attributes.

Therefore pfontview is as good as it gets using gtk/Pango and gtkdialog. I'll have a play with Pango in C.

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#8 Post by thunor »

I didn't find anything within the Pango API to assist with getting feedback on fonts that gtk/Pango doesn't like and all I found on the gnome mailing list was "I don't know", so I've tried something else.

Do I need to create yet another font viewer thread? Probably not, so I'll upload it here. I've called it imaginatively sfontview because it uses SDL + SDL_ttf and that's it, so you'll have SDL anyway and you may have SDL_ttf too since many games use it.

sfontview shows everything I've tried except wingding type fonts which I've found vovchik's Pfont2 ttf2png based viewer doesn't render either. Maybe I'll modify pfontview's menu to include links to Pfont2 and sfontview if they're installed to give a complete solution.

There's no point in me making a package since it's one tiny binary which you can compile yourself. There are instructions within the source file but I'll print them here anyway:

Code: Select all

Compile with:
gcc -Wall sfontview.c -o sfontview `sdl-config --cflags --libs` -lSDL_ttf

Strip with:
strip --strip-unneeded sfontview

Place the sfontview binary into ~/my-applications/bin or /usr/local/bin.
Place sfontview.bmp into /usr/share/pixmaps or /usr/local/share/pixmaps.

Don't forget that ESC will also close the window so you can quickly click through lots of fonts with one hand hovering over the ESC key.
Attachments
sfontview-0.1.1.png
sfontview-0.1.1
(15.19 KiB) Downloaded 4511 times
sfontview-0.1.1.tar.gz
[Updated 2012-10-31 to version 0.1.1] Source code, i686 binary and window manager icon included
(9.56 KiB) Downloaded 1520 times
Last edited by thunor on Wed 31 Oct 2012, 17:53, edited 1 time in total.

User avatar
vovchik
Posts: 1507
Joined: Tue 24 Oct 2006, 00:02
Location: Ukraine

#9 Post by vovchik »

Dear thunor,

I am glad you are looking at this, too. I really did not understand why pango refused fc-list descriptions - even properly filtered ones - for a number of fonts. It could be a weirdness in the ttf standard - which M$ promoted - and some things are dicey there. Some ttf fonts contain escape sequences in their names, I discovered, and those need processing. Your prog workes nicely. Thanks :)

With kind regards,
vovchik

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#10 Post by disciple »

In case anyone is interested, Pfontview also opens .fon files as well as (some ;) ).ttf files.
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

User avatar
BarryK
Puppy Master
Posts: 9392
Joined: Mon 09 May 2005, 09:23
Location: Perth, Western Australia
Contact:

#11 Post by BarryK »

Hi, I tried Pfontview 0.1.1, didn't work for me:

http://bkhome.org/blog/?viewDetailed=03079

I am running Precise Puppy 5.4..
[url]https://bkhome.org/news/[/url]

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#12 Post by thunor »

Thanks for the feedback guys. I won't waste any more time with gtk/Pango then :) I'm quite happily using sfontview now anyway.

Interesting results though from our Arch, Slacko and Precise distros.

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#13 Post by 01micko »

Sfontview works fine here in Slacko beta. I have over 215 fonts in my .wine install (MSoffice is installed) and only wingdings don't show. (full SDL is included, Slackware bundles all)
Attachments
fonts.png
(52.37 KiB) Downloaded 4720 times
Puppy Linux Blog - contact me for access

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#14 Post by thunor »

BarryK wrote:Hi, I tried Pfontview 0.1.1, didn't work for me:

http://bkhome.org/blog/?viewDetailed=03079

I am running Precise Puppy 5.4..
BarryK: Sorry, I didn't initially visit the link and I assumed you meant that the fonts weren't rendering, so I'm downloading Precise to see what that error is.

Mick: Thanks for the feedback.

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#15 Post by thunor »

pfontview updated to 0.1.2:
* Added a Tools menu with access to Pfont2 and Sfontview if installed.
* Added a requirements check for fc-query and gtkdialog >= 0.8.2.

sfontview updated to 0.1.1:
* Added an optional window manager icon to be placed into /usr/share/pixmaps or /usr/local/share/pixmaps.
* Included the SDL_main stuff.

I have additionally installed Precise 5.4 and pfontview behaves exactly the same as it does on Slacko 5.3.3 i.e. gtk/Pango refuses to initialise widgets to certain fonts. I've been downloading a few more fonts and I've found a few more within installed games and the Java runtime and I can report that 29 out of 260 (11%) particular fonts that I have won't show using pfontview. The good news is that if you suspect you're looking at the default DejaVuSans and you have sfontview or pfont2 installed then you can access them directly through pfontview's menu.

It's swings and roundabouts really isn't it :) I like the text entry box using gtk/Pango and the fact that wingding type fonts show, but then I like the success rate of SDL_ttf.

Has anybody written anything using the Freetype 2 API? Then you could dispense with SDL_ttf and you'd have a viewer that could be bundled with Puppy.

Regards,
Thunor

disciple
Posts: 6984
Joined: Sun 21 May 2006, 01:46
Location: Auckland, New Zealand

#16 Post by disciple »

I like the text entry box using gtk/Pango
I like the fact that you actually get the font rendered the same way all your actual applications will render it :)
Unless it's possible to get sfontview to consider fontconfig settings...?
Do you know a good gtkdialog program? Please post a link here

Classic Puppy quotes

ROOT FOREVER
GTK2 FOREVER

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#17 Post by 01micko »

Thunor

I am experiencing an issue with the mktemp binary.

In pfontview, I get this

Code: Select all

# pfontview AGENCY.TTF
mktemp: invalid option -- '-'
Usage: mktemp [-V] | [-dqtu] [-p prefix] [template]
Couldn't create temporary directory.
It seems that the --directory option isn't supported by mktemp. Slacko is using wary's mktemp but slackware's has the same behaviour. It's part of the 'bin' package in slackware.

In coreutils, slackware ships with mktemp-gnu, which does recognise that option. But this is not built into Puppy.

Any ideas?

Thanks
Puppy Linux Blog - contact me for access

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#18 Post by thunor »

01micko wrote:Thunor

I am experiencing an issue with the mktemp binary.

In pfontview, I get this

Code: Select all

# pfontview AGENCY.TTF
mktemp: invalid option -- '-'
Usage: mktemp [-V] | [-dqtu] [-p prefix] [template]
Couldn't create temporary directory.
It seems that the --directory option isn't supported by mktemp. Slacko is using wary's mktemp but slackware's has the same behaviour. It's part of the 'bin' package in slackware.

In coreutils, slackware ships with mktemp-gnu, which does recognise that option. But this is not built into Puppy.

Any ideas?

Thanks
I've had a look at a couple of man pages and I think "--tmpdir" is the problem so you could try "-t" instead. I've just tested mktemp -d -t test.XXXXXXXX on Slacko 5.3.3 and it works as expected.

Let me know if it solves the issue for you and I'll modify the source code.

Cheers,
Thunor

User avatar
01micko
Posts: 8741
Joined: Sat 11 Oct 2008, 13:39
Location: qld
Contact:

#19 Post by 01micko »

thunor wrote: I've had a look at a couple of man pages and I think "--tmpdir" is the problem so you could try "-t" instead. I've just tested mktemp -d -t test.XXXXXXXX on Slacko 5.3.3 and it works as expected.

Let me know if it solves the issue for you and I'll modify the source code.

Cheers,
Thunor
yes of course, I did mean "--tmpdir" :oops:

Anyway, I did try -t and it did work. :)

Thanks

PS, I might ship both in next slacko, small enough.
Attachments
fonts.jpg
(58.49 KiB) Downloaded 1049 times
Puppy Linux Blog - contact me for access

User avatar
thunor
Posts: 350
Joined: Thu 14 Oct 2010, 15:24
Location: Minas Tirith, in the Pelennor Fields fighting the Easterlings
Contact:

#20 Post by thunor »

01micko wrote:...
Anyway, I did try -t and it did work. :)

Thanks

PS, I might ship both in next slacko, small enough.
Thanks Mick, I've updated the pfontview source package. That would be great to have it in slacko :)

Cheers.

Post Reply