LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-07-2017, 12:47 PM   #1
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
How to get a list of all scalable fonts matching certain criteria


I am writing a script that will create an image, with imagemagick:
plain text from a command output, rendered in a random font & colors.
the script is working well, but my brain is running hot on how to get a (fairly) reliable list of fonts matching the following criteria:
- support for latin 1 charset at the very least - this means to exclude symbolic fonts and all non-latin fonts
- NOT monospaced
- scalable (basically, not a bitmap font)
- outline (basically, not a bitmap font)

which should leave me with a sane choice of sans & serif fonts.

what i tried so far:

Code:
fc-match -s Sans family scalable|grep 'scalable=True'
fc-match -s Serif family scalable|grep 'scalable=True'
works, but does not exclude monospaced and non-latin fonts.

Code:
fc-list :lang=de:outline=True:scalable=True family spacing | grep -vE 'Mono|Symbol|Courier|:spacing='
trickier to explain.
returns a list of font's family, and its 'spacing' attribute.
the spacing attribute is usually only defined on monospaced fonts (or so i assume from what i see), so inverse grepping for that should eliminate some monospaced fonts already.
however, quite a few monospaced fonts are still left. I'm trying - very inelegantly - to filter them out by reverse grepping for telltale names, like 'Mono' or 'Courier'.
Similarly for symbolic/wingdings etc. fonts, by reverse grepping 'Symbol'.
Very inelegant, and doesn't work as expected anyway.

I am mostly working with man pages here; web searches were unsuccesful so far.

fontconfig:
I don't know how to define a "pattern" that would
a) list all fonts that match the "Sans" criterium
AND
b) filter out unwanted fonts, see above.
???
so, in effect, a combination of both approaches outlined above.

Anything else besides fontconfig and its fc-* utilities?

thanks.
 
Old 04-08-2017, 03:47 PM   #2
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
xlslist and fc-list are the two more common ways to list available fonts. You can use -f for fc-list to output only certain parts on a one liner.

Code:
fc-list :lang=de:outline=True:scalable=True -f "fullname: %{fullname}    postscriptname: %{postscriptname}     family: %{family}     spacing: %{spacing}\n"
Or look at and search long form with:

$ fc-list -v | less
 
Old 04-09-2017, 02:43 AM   #3
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872

Original Poster
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
my system does not have xlslist installed or as a separate package; it does have the 'xlsfonts' command, though.
but that seems to be just for so-called xfonts? i.e., not outlined, bitmapped? I am only interested in outlined&scalable fonts.

I did some more research, and it would seem that fontconfig is the only package that provides tools for the job.
Unfortunately, all documentation i found (online and locally) is either very basic, or for developers in C.

thanks for more usage examples for fc-list.

It still does not solve my problem; please compare the 2 code blocks from my first post, and what i think they're doing:
  1. the fc-match line uses the magic word "Sans" or "Serif" to list all fonts that match that characteristics (maybe similar to Firefox' font selection dialog) - the crucial point here being that it filters out a) most monospaced fonts (*), and b) certain icon/webdings/wingdings fonts
  2. the fc-list command lists fonts that have certain characterics, but there's no characteristic that says "Not monospaced", or "Not an icon font".

My thought is, if only i could combine those 2 results somehow?


tl;dr: are there any better tutorials/resources/end-user documentation for the fontconfig utilities?
the man pages all seem to be falling short of describing the "pattern" used to get a list of fonts.

(*) example: fc-match -s Sans family | grep -iE 'fixed|mono'
Fira Mono for Powerline
Fixedsys Excelsior 3.01\-L2
DejaVu Sans Mono
Liberation Mono
Misc Fixed
Misc Fixed Wide
Misc Fixed
Misc Fixed
- BUT i have many more monospaced fonts than that.
 
Old 04-09-2017, 08:11 AM   #4
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
$ xlsfonts

Must have been tired. But different output, the type you would pass to xterm with -fn and -fb.
 
Old 04-16-2017, 04:32 AM   #5
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872

Original Poster
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
There doesn't seem to be a good solution for this.

i managed to refine my original query a little:
Code:
fc-list :lang=de:outline=True:scalable=True -f "%{family[0]}\n"
this will output a newline separated list of html- or pango-usable font names that fulfils the criteria:
  • supports german language. an arbitrary choice; i just want to get all fonts that have more than just basic english (ascii) support, but not such fonts that do not have any latin support
  • outline & scalable: both more or less the same => NO bitmap fonts
  • family[0]: sometimes the family consists of more than one name, this filters out all but the first
i realized i do not mind monospaced fonts in the list.

one problem remains:
symbolic fonts.
after hours of searching i found no indication that or how they advertise themselves as such.

so i just grep the result to filter out fonts i do not want:
Code:
... | grep -wvE 'Estrangelo|D050000L|Symbol|Symbols|Serto|Syriac'
(there are some other fonts that are actually non-latin, but default to monospace for latin, which results in too much boring plain monospace, so out with it)

documentation used:
Code:
man fc-list
man fc-match
man FcPatternFormat
file:///usr/share/doc/fontconfig/fontconfig-user.html
 
Old 04-16-2017, 04:52 AM   #6
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
Yeah, fonts are a hot mess no matter how you do them. As I try to get fontforge to export a .TTF or .OTF font, only to have it open an empty font of what it just exported. So much for this @font-face technology, which apparently needs your font in half a dozen formats to be cross platform compatible. None of which seems possible in free software without the secret handshake. Unless you start with a valid TTF or OTF font.
 
Old 04-16-2017, 02:36 PM   #7
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872

Original Poster
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
^ you mean for webdesign?
i never had problems with that.

fontsquirrel used to have a really good tutorial & online generator... it's still there:
https://www.fontsquirrel.com/tools/webfont-generator
the magic is in the CSS.
 
Old 04-17-2017, 09:29 AM   #8
CVAlkan
Member
 
Registered: Nov 2012
Location: Northwest suburbs of Chicago
Distribution: Ubuntu & Mint LTS, Manjaro Rolling; Android
Posts: 242

Rep: Reputation: Disabled
Hi:

At the moment, I don't have time to dig into this, but you may want to take a look at:
http://www.antikytherapubs.com/i18n.htm

From there, select the "Evaluating Fonts for use in Multi-lingual Documents" entry. This incorporates a shell script (which you'll need to copy and paste into a separate file and make it executable).

The script will most likely need to be modified somewhat for your exact purposes, but it covers a lot of the ground you're looking at and may give you some ideas of how to get the list you want ...

I hope this helps.

Frank
 
Old 04-17-2017, 11:11 AM   #9
Shadow_7
Senior Member
 
Registered: Feb 2003
Distribution: debian
Posts: 4,137
Blog Entries: 1

Rep: Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874Reputation: 874
Quote:
Originally Posted by ondoho View Post
^ you mean for webdesign?
i never had problems with that.
Yes. Trying to get the @font-face to work for a custom bitmap font created as a .BDF to work. I've gotten past the sanitizer, but the rendered page is still blank visually. When you open the generated font in fontforge it's blank, but you can see it again if you select "View -> 20 pixel bitmap", which is not the default view when opened. Nevermind that whole .svg, .woff, .ttf, .otf, mess to have some illusion of browser compatibility.

There doesn't seem to be a clean non-commercial route to take going from iso10646-1 to truetype. Granted that my route is basically a more flexible mimic of what hex2bdf does via bash script(s). But it seems even hex2bdf wouldn't work in this instance. Passing the sanitizer was more information than I cared to know. 0x00-0x1f and 0x7f-0x9f removed, quadratic layers, and whatnot. Still not sure what the secret sauce is, all lower case names, names < 8 chars, that realm of constant guessing until something works. Or until I know enough about ttf fonts to create one without fontforge, thus bypassing the .bdf step entirely. But OT for the OP.
 
Old 04-17-2017, 11:15 AM   #10
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872

Original Poster
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
^ thanks a lot.
this will require deeper involvement, i will certainly give some feedback later.
 
  


Reply

Tags
fonts



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] AWK: Remove of Lines matching from a supplied List of Objects? CaptainDerp Linux - Newbie 12 05-30-2013 08:39 AM
Rename files matching a list Qu3ry Programming 34 07-22-2009 06:59 PM
How do I list all the fonts that are installed and available to me? roystonlodge DamnSmallLinux 3 08-02-2008 09:54 AM
list files NOT matching a pattern smart_sagittari Linux - Newbie 9 05-20-2005 05:32 AM
Fonts question: how to get a full list of fonts in Abiword vharishankar Linux - Software 1 03-17-2005 11:11 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 02:37 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration