(OLD) (ARCHIVED) Puppy Linux Discussion Forum Forum Index (OLD) (ARCHIVED) Puppy Linux Discussion Forum
Puppy HOME page : puppylinux.com
"THE" alternative forum : puppylinux.info

This forum can also be accessed as http://oldforum.puppylinux.com
It is now read-only and serves only as archives.

Please register over the NEW forum
https://forum.puppylinux.com
and continue your work there. Thank you.

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups    
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

The time now is Thu 21 Jan 2021, 05:03
All times are UTC - 4
 Forum index » Off-Topic Area » Programming
Font Preview
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies. View previous topic :: View next topic
Page 5 of 6 [79 Posts]   Goto page: Previous 1, 2, 3, 4, 5, 6 Next
Author Message
misko_2083


Joined: 08 Nov 2016
Posts: 114

PostPosted: Mon 01 Jun 2020, 16:11    Post subject:
Subject description: update 5 20200601
 

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" Question
yad-fontview1.bz2
Description 
bz2

 Download 
Filename  yad-fontview1.bz2 
Filesize  4.89 KB 
Downloaded  160 Time(s) 
Back to top
View user's profile Send private message 
vovchik


Joined: 23 Oct 2006
Posts: 1538
Location: Ukraine

PostPosted: Mon 01 Jun 2020, 16:43    Post subject:  

Dear misko,

Thanks. Looks good to me!

With kind regards,
vovchik
Back to top
View user's profile Send private message 
step

Joined: 04 May 2012
Posts: 1352

PostPosted: Mon 01 Jun 2020, 17:05    Post subject:  

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/stable/classPango_1_1FontDescription.html
Defines a font_name, which includes STYLE-OPTIONS.

[2]:https://developer.gnome.org/pygtk/stable/pango-markup-language.html
Enumerates the allowed values for each of the WORD descriptions in [1].

Extracted from [1]:
Code:

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.

_________________
Fatdog64-810|+Packages|Kodi|gtkmenuplus
Back to top
View user's profile Send private message 
fredx181


Joined: 11 Dec 2013
Posts: 4481
Location: holland

PostPosted: Tue 02 Jun 2020, 05:03    Post subject:  

@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:
 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

_________________
Dog Linux website
Tinylinux blog by wiak
Back to top
View user's profile Send private message 
step

Joined: 04 May 2012
Posts: 1352

PostPosted: Tue 02 Jun 2020, 08:05    Post subject:  

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:
 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:

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:

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.

Quote:

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 Smile

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.

_________________
Fatdog64-810|+Packages|Kodi|gtkmenuplus

Last edited by step on Thu 04 Jun 2020, 14:27; edited 1 time in total
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 2084
Location: Japan

PostPosted: Tue 02 Jun 2020, 09:33    Post subject:  

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.
Back to top
View user's profile Send private message 
step

Joined: 04 May 2012
Posts: 1352

PostPosted: Tue 02 Jun 2020, 11:12    Post subject:  

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.
_________________
Fatdog64-810|+Packages|Kodi|gtkmenuplus
Back to top
View user's profile Send private message 
fredx181


Joined: 11 Dec 2013
Posts: 4481
Location: holland

PostPosted: Tue 02 Jun 2020, 11:49    Post subject:  

step wrote:
Yes, showing all listed was my purpose.

Ah, I had that feeling already Wink Thanks for the detailed explanation !
Quote:
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
batang.tcc.png
 Description   batang.tcc
 Filesize   76.19 KB
 Viewed   316 Time(s)

batang.tcc.png


_________________
Dog Linux website
Tinylinux blog by wiak
Back to top
View user's profile Send private message 
jamesbond

Joined: 26 Feb 2007
Posts: 3475
Location: The Blue Marble

PostPosted: Tue 02 Jun 2020, 12:02    Post subject:  

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: Latest version | Contributed packages | ISO builder
Back to top
View user's profile Send private message 
step

Joined: 04 May 2012
Posts: 1352

PostPosted: Tue 02 Jun 2020, 15:02    Post subject:
Subject description: update 5 20200601
 

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" Question

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:

# 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.
screen-20200602.png
 Description   
 Filesize   38.25 KB
 Viewed   287 Time(s)

screen-20200602.png


_________________
Fatdog64-810|+Packages|Kodi|gtkmenuplus

Last edited by step on Sat 06 Jun 2020, 18:16; edited 1 time in total
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 2084
Location: Japan

PostPosted: Tue 02 Jun 2020, 22:13    Post subject:  

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?
Back to top
View user's profile Send private message 
step

Joined: 04 May 2012
Posts: 1352

PostPosted: Wed 03 Jun 2020, 01:49    Post subject:  

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.
_________________
Fatdog64-810|+Packages|Kodi|gtkmenuplus
Back to top
View user's profile Send private message 
fredx181


Joined: 11 Dec 2013
Posts: 4481
Location: holland

PostPosted: Wed 03 Jun 2020, 04:19    Post subject:  

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

_________________
Dog Linux website
Tinylinux blog by wiak
Back to top
View user's profile Send private message 
MochiMoppel


Joined: 26 Jan 2011
Posts: 2084
Location: Japan

PostPosted: Thu 04 Jun 2020, 02:51    Post subject:  

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.
Back to top
View user's profile Send private message 
step

Joined: 04 May 2012
Posts: 1352

PostPosted: Thu 04 Jun 2020, 03:17    Post subject:  

Thank you for your report, I'll fix this regression.
_________________
Fatdog64-810|+Packages|Kodi|gtkmenuplus
Back to top
View user's profile Send private message 
Display posts from previous:   Sort by:   
Page 5 of 6 [79 Posts]   Goto page: Previous 1, 2, 3, 4, 5, 6 Next
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies. View previous topic :: View next topic
 Forum index » Off-Topic Area » Programming
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group
[ Time: 1.1760s ][ Queries: 12 (1.0052s) ][ GZIP on ]