Font Preview

For discussions about programming, programming questions/advice, and projects that don't really have anything to do with Puppy.
Message
Author
User avatar
misko_2083
Posts: 114
Joined: Tue 08 Nov 2016, 13:42

#61 Post by misko_2083 »

step wrote:Fifth update here. It incorporates MochiMoppel's script (thanks MochiMoppel) with some additions. This is my last planned update for this script. Thanks everyone for the fun!
I've fixed your fourth script and added some most recent changes although not all.
A little safer method to read conf file.

------

As far as I noticed the only fonts not displaying correctly are the ones with the non-standard styles.
Perhaps we can get the list of all the suported font stiles, check against the current and, if it's not in the list, default to "Regular" :?:
Attachments
yad-fontview1.bz2
(4.89 KiB) Downloaded 98 times

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

#62 Post by vovchik »

Dear misko,

Thanks. Looks good to me!

With kind regards,
vovchik

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

#63 Post by step »

As regards getting a list of supported styles, with [1] and [2], you should be able to list all the valid combinations of font STYLE-OPTIONS.

[1]: https://developer.gnome.org/pangomm/sta ... ption.html
Defines a font_name, which includes STYLE-OPTIONS.

[2]:https://developer.gnome.org/pygtk/stabl ... guage.html
Enumerates the allowed values for each of the WORD descriptions in [1].

Extracted from [1]:

Code: Select all

Pango::FontDescription::FontDescription	(	const Glib::ustring & 	font_name	)
explicit
Constructs a font description from a string representation.

font_name must have the form "[FAMILY-LIST] [STYLE-OPTIONS] [SIZE]", where FAMILY-LIST is a comma separated list of families optionally terminated by a comma, STYLE_OPTIONS is a whitespace separated list of words where each WORD describes one of style, variant, weight, or stretch, and SIZE is an decimal number (size in points). Any one of the options may be absent. If FAMILY-LIST is absent, then the family_name field of the resulting font description will be initialized to 0. If STYLE-OPTIONS is missing, then all style options will be set to the default values. If SIZE is missing, the size in the resulting font description will be set to 0.
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#64 Post by fredx181 »

@step, MochiMoppel pointed out at the beginning of this thread "fclist produces duplicates when font folders are symlinked."
I simply added "u" to the sort command at line 382 of your fifth update:

Code: Select all

 LC_ALL=C sort -fszu .....
And no duplicates are showing for me.

EDIT: But maybe it's your purpose showing all listed, then please ignore this.

Fred

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

#65 Post by step »

Hi Fred, thanks for pointing that out...
fredx181 wrote:@step, MochiMoppel pointed out at the beginning of this thread "fclist produces duplicates when font folders are symlinked."
I simply added "u" to the sort command at line 382 of your fifth update:

Code: Select all

 LC_ALL=C sort -fszu .....
And no duplicates are showing for me.
Forgive my lengthy answer, there's a short summary at the end if you don't have the time. I considered duplicates before and decided not to discard them by design. My reasons are that one can have different revisions of the same font file (I do), and can have multiple fonts in the same physical file (I do).

Code: Select all

LINE 382:

# fc-list -f '%{file|basename}\n%{file}\n%{index}\b' | tr '\b' '\0' | LC_ALL=C sort -fsz -t $'\n' -k1,1n -k1,1 -k3,3n
Let me point out that fc-list on line 382 produces a unique key for each _font_ (not just for the font _file_). Fc-list extracts basename+fullpathname+index. You'd think that fullpathname is unique enough, as there can't be two files with the same full path in Linux, but when the font file is a True Type font Collection file (TTC) only the index discriminates among the fonts inside the file because basename and fullpathname are all the same.

I fail to understand why one would want to symlink folders under /usr/share/fonts and other XDG_DATA directories. I think the symlinks would produce more data for fontconfig to shuffle but no benefit.

Setting my consideration aside, let's see what changing -fnz to -fnzu on line 382 does. Indeed it discards duplicated font files residing in symlinked _folders_. However, it also discards all fonts but the first one (index=0) in a TTC file. That's undesirable.

There's more. If you set up an experiment similar to the one shown below, where in addition to symlinking a folder I have also symlinked a file therein, and add -u to -fnz, you will discover that the duplicated _file_ isn't discarded (at least it isn't with the version of GNU sort that is installed in my system).

Code: Select all

cd /usr/share/fonts/X11
# ln -sT TTF DUP
# ln -s DejaVuSans.ttf TTF/DUP.ttf
# stat --printf "%i\t%N\n" -- {DUP,TTF}/{DejaVuSans,DUP}.ttf
5792    'DUP/DejaVuSans.ttf'
34216   'DUP/DUP.ttf' -> 'DejaVuSans.ttf'
5792    'TTF/DejaVuSans.ttf'
34216   'TTF/DUP.ttf' -> 'DejaVuSans.ttf'
The reason is to be found in the way GNU sort options work.
info sort wrote: ...
The following options affect the ordering of output lines. They may
be specified globally or as part of a specific key field. If no key
fields are specified, global options apply to comparison of entire
lines; otherwise the global options are inherited by key fields that do
not specify any special options of their own. In pre-POSIX versions of
‘sort’, global options affect only later key fields, so portable shell
scripts should specify global options first.
Line 382 specifies three key fields, k1,1n, k1,1 and k3,3n. With -u added globally to -fnz, uniqueness is applied to the second key only, that is to k1,1, which is the basename. That's why most TTC fonts will be missing.
EDIT: But maybe it's your purpose showing all listed, then please ignore this.
Yes, showing all listed was my purpose. And I couldn't ignore you very good question :)

In summary:

I prefer to leave the script as is because it can display versions of the same font and TTC font files correctly, and because in my system I don't symlink folders under /usr/share/X11/fonts.

For people who do, and don't use TTC or font versions, your edit is good.
Last edited by step on Thu 04 Jun 2020, 18:27, edited 1 time in total.
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#66 Post by MochiMoppel »

step wrote:I prefer to leave the script as is because it can display versions of the same font and TTC font files correctly, and because in my system I don't symlink folders under /usr/share/X11/fonts.
That may be the case for Fatdog users, but as far as I understand woof-CE the directory /usr/share/X11/fonts/TTF is still symlinked to /usr/share/fonts/default/TTF and in older Puppies even more symlinks exist.

I'm not sure if TTC files should be supported. Is TCC supported by the GTK font dialog? Do any free versions exist? AFAIK you can either buy them from Microsoft (expensive!) or "borrow" them from a Windows installation.

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

#67 Post by step »

MochiMoppel wrote:Is TCC supported by the GTK font dialog? Do any free versions exist?
I don't know an answer to either of your questions.
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#68 Post by fredx181 »

step wrote:Yes, showing all listed was my purpose.
Ah, I had that feeling already :wink: Thanks for the detailed explanation !
Is TCC supported by the GTK font dialog?
Looks like it is, I have one, batang.tcc and it's split into several (which indeed shows only without the "u" at the sort command), see pic.
yad --font displays it well too.

Fred
Attachments
batang.tcc.png
batang.tcc
(76.19 KiB) Downloaded 257 times

jamesbond
Posts: 3433
Joined: Mon 26 Feb 2007, 05:02
Location: The Blue Marble

#69 Post by jamesbond »

step wrote:
MochiMoppel wrote:Is TCC supported by the GTK font dialog? Do any free versions exist?
I don't know an answer to either of your questions.
The answer to both questions are "YES". For the second question, you can convert any font file into TTC yourself, here's a tool to do that (Note: description in Japanese): unitettc
Fatdog64 forum links: [url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Latest version[/url] | [url=https://cutt.ly/ke8sn5H]Contributed packages[/url] | [url=https://cutt.ly/se8scrb]ISO builder[/url]

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

#70 Post by step »

misko_2083 wrote:As far as I noticed the only fonts not displaying correctly are the ones with the non-standard styles.
Perhaps we can get the list of all the suported font stiles, check against the current and, if it's not in the list, default to "Regular" :?:
Good observation, I just ran a simple test. I found this fontset Y.OzFont (from the same site in jamesbond's link) that displays as DejaVu on my system but it's supposed to display as handwriting. yad-fontview derives its style as "R". So I saved the pango markup, replaced "Regular" for "R" and looked again at pango rendering and, yes, this time it was handwriting (see picture).
However, I doubt that replacing with "Regular" can be a fix-all. I think the correct style name is to be given. In this test I used "Regular" because I read it in the output of fc-query. Here it is:

Code: Select all

# fc-query YOzRSXM.otf
Pattern has 24 elts (size 32)
family: "YOzSXM Pr6N"(s) "YOzSXM Pr6N R"(s)
familylang: "ja"(s) "en"(s)
style: "R"(s) "Regular"(s)
stylelang: "ja"(s) "ja"(s)
fullname: "YOzSXM Pr6N R"(s)
fullnamelang: "ja"(s)
...
edited on 2020-06-06: the hyphothesis presented in the remainder of this post is superseded by the correct explanation presented in http://murga-linux.com/puppy/viewtopic.php?t=118940.

What you see there is the English name of this font is "YOzSXM Pr6N R" and the English style name is UNDEFINED. Even though humans can read that "Regular" is the English style name, the font file declares that the style language of the second style is "ja" instead of "en". This font file is buggy and needs to be fixed before it can display correctly in an English locale, like my system's.

I suspect that in a computer configured with a Japanese locale, setting LANGUAGEID="ja" at the beginning of yad-fontview, and running the test again, pango would render the handwriting font right away because the "ja" elements of font family and style would be consistent with the locale language. I can't practically test my conjecture.
Attachments
screen-20200602.png
(38.25 KiB) Downloaded 230 times
Last edited by step on Sat 06 Jun 2020, 22:16, edited 1 time in total.
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#71 Post by MochiMoppel »

jamesbond wrote:
step wrote:
MochiMoppel wrote:Is TCC supported by the GTK font dialog? Do any free versions exist?
I don't know an answer to either of your questions.
The answer to both questions are "YES". For the second question, you can convert any font file into TTC yourself, here's a tool to do that (Note: description in Japanese): unitettc
Thank you. I didn't find any TTC files at the linked site (all zipped collections contained OTF or TTF files) but the tool allowed me to create a TTC test file. So no problem for GTK font dialog and no problem for fc-list and fc-query. That's good.
fredx181 wrote: I have one, batang.tcc and it's split into several (which indeed shows only without the "u" at the sort command), see pic.
My little script (my original version, not step's adaption )does use uniq and I bet your four different fonts, all sharing the same basename, would still show in the list.

@step: I still don't see a good reason for duplicates. As already mentioned links are a fact of Puppies so keeping duplicates adds nothing but clutter, TTC can't be a reason too as fc-list will create distinctly different output for each font in the TTC file. Remains your point of keeping "different revisions of the same font file". I don't understand why you don't simply change the file name for each variant, indicating what's in the file. Wouldn't this make life much easier?

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

#72 Post by step »

MochiMoppel wrote:I don't understand why you don't simply change the file name for each variant, indicating what's in the file. Wouldn't this make life much easier?
It's easier for me to rename the folder that contains the variants.
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

User avatar
fredx181
Posts: 4448
Joined: Wed 11 Dec 2013, 12:37
Location: holland

#73 Post by fredx181 »

MochiMoppel wrote:fredx181 wrote:
I have one, batang.tcc and it's split into several (which indeed shows only without the "u" at the sort command), see pic.

My little script (my original version, not step's adaption )does use uniq and I bet your four different fonts, all sharing the same basename, would still show in the list.
Yes, indeed, it does, all four.

Fred

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#74 Post by MochiMoppel »

Just an observation: The fourth update fixed the issue with apostrophes in family names, the fifth update brought the issue back. Apostrophes are now deleted, resulting in invalid family names. Misko's version displays correctly.

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

#75 Post by step »

Thank you for your report, I'll fix this regression.
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

#76 Post by step »

Update here. It fixes the regression reported by MochiMoppel.
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

User avatar
MochiMoppel
Posts: 2084
Joined: Wed 26 Jan 2011, 09:06
Location: Japan

#77 Post by MochiMoppel »

Bug persists in the Compare window.

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

#78 Post by step »

Thank you for your report. Fixed in the new update available here.
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

step
Posts: 1349
Joined: Fri 04 May 2012, 11:20

#79 Post by step »

The new update here includes a fix for the mistery of the failing fonts and other small changes.
Attachments
yad-fontview-sample_sheet_22_2020-06-07.png
At last!
(23.69 KiB) Downloaded 80 times
[url=http://murga-linux.com/puppy/viewtopic.php?t=117546]Fatdog64-810[/url]|[url=http://goo.gl/hqZtiB]+Packages[/url]|[url=http://goo.gl/6dbEzT]Kodi[/url]|[url=http://goo.gl/JQC4Vz]gtkmenuplus[/url]

Post Reply