sdushantha / fontpreview

Highly customizable and minimal font previewer written in bash
MIT License
916 stars 39 forks source link

[Feature Request] Implement title with font name and style elements (or Postscript name) #38

Open emk2203 opened 4 years ago

emk2203 commented 4 years ago

Please implement a title in the font preview window, which should show the font name and style or the postscript name.

Use case

Fonts have often misleading names, sometimes still in the DOS 8.3 naming convention. For similar-looking fonts, it's not easy to see which font it really is if you don't see the real font name embedded in the font. Font names like bookosb.ttf and bookosbi.ttf don't tell much if you need a certain font, for example in LibreOffice which shows the real font names and not the file names.

Example code

fc-scan --format "%{fullname[$(( $(sed -E 's/^(.*)en.*/\1/;s/[^,]//g' <<<"$(fc-scan --format "%{fullnamelang}\n" /mnt/Fonts/bookosb.ttf)" | wc -c) -1 ))]}\n" /mnt/Fonts/bookosb.ttf

is a way to retrieve the font name wherever fontconfig is installed, so practically everywhere on Linux. The complex line is necessary because a simple fc-scan --format "%{fullname}\n" would return something like

Bookman Old Style Negreta,Bookman Old Style tučné,Bookman Old Style fed,Bookman Old Style Fett,Bookman Old Style Έντονα,Bookman Old Style Bold,Bookman Old Style Negrita,Bookman Old Style Lihavoitu,Bookman Old Style Gras,Bookman Old Style Félkövér,Bookman Old Style Grassetto,Bookman Old Style Vet,Bookman Old Style Halvfet,Bookman Old Style Pogrubiony,Bookman Old Style Negrito,Bookman Old Style Полужирный,Bookman Old Style Fet,Bookman Old Style Kalın,Bookman Old Style Krepko,Bookman Old Style Lodia

instead of just

Bookman Old Style Bold

Alternatively, fc-scan --format "%{postscriptname}\n" is simpler, but returns

which needs to be parsed by the user to get the proper name for linux use.

sdushantha commented 4 years ago

This seems like a really nice idea, but unfortunately I am not able to work on this project for some time because I currently do not have access to a Linux machine. I will be able to work on this in a month or two.

sdushantha commented 4 years ago

@emk2203 Are you sure the complex line is necessary? Because it works fine for me: image

I am using Manjaro Linux, which distro are you on?

emk2203 commented 4 years ago

The issue is not with the distribution (I use Ubuntu 20.04), but with the fonts used:

fc-scan --format "%{fullname}\n" .fonts with Microsoft Bookman Old Style (my reference here) gives

Bookman Old Style
Bookman Old Style Negreta,Bookman Old Style tučné,Bookman Old Style fed,Bookman Old Style Fett,Bookman Old Style Έντονα,Bookman Old Style Bold,Bookman Old Style Negrita,Bookman Old Style Lihavoitu,Bookman Old Style Gras,Bookman Old Style Félkövér,Bookman Old Style Grassetto,Bookman Old Style Vet,Bookman Old Style Halvfet,Bookman Old Style Pogrubiony,Bookman Old Style Negrito,Bookman Old Style Полужирный,Bookman Old Style Fet,Bookman Old Style Kalın,Bookman Old Style Krepko,Bookman Old Style Lodia
Bookman Old Style Negreta cursiva,Bookman Old Style tučné kurzíva,Bookman Old Style fed kursiv,Bookman Old Style Fett Kursiv,Bookman Old Style Έντονα Πλάγια,Bookman Old Style Bold Italic,Bookman Old Style Negrita Cursiva,Bookman Old Style Lihavoitu Kursivoi,Bookman Old Style Gras Italique,Bookman Old Style Félkövér dőlt,Bookman Old Style Grassetto Corsivo,Bookman Old Style Vet Cursief,Bookman Old Style Halvfet Kursiv,Bookman Old Style Pogrubiona kursywa,Bookman Old Style Negrito Itálico,Bookman Old Style Полужирный Курсив,Bookman Old Style Tučná kurzíva,Bookman Old Style Fet Kursiv,Bookman Old Style Kalın İtalik,Bookman Old Style Krepko poševno,Bookman Old Style Lodi etzana
Bookman Old Style Cursiva,Bookman Old Style kurzíva,Bookman Old Style kursiv,Bookman Old Style Πλάγια,Bookman Old Style Italic,Bookman Old Style Kursivoitu,Bookman Old Style Italique,Bookman Old Style Dőlt,Bookman Old Style Corsivo,Bookman Old Style Cursief,Bookman Old Style Kursywa,Bookman Old Style Itálico,Bookman Old Style Курсив,Bookman Old Style İtalik,Bookman Old Style Poševno,Bookman Old Style Etzana

with ls -l

emk2203@E6540:~$ ls -l .fonts
insgesamt 632
-rw-r--r-- 1 emk2203 emk2203 162460 Mai  4 15:54 bookosbi.ttf
-rw-r--r-- 1 emk2203 emk2203 154576 Mai  4 15:54 bookosb.ttf
-rw-r--r-- 1 emk2203 emk2203 161020 Mai  4 15:54 bookosi.ttf
-rw-r--r-- 1 emk2203 emk2203 160940 Mai  4 15:54 bookos.ttf

So, with fonts which contain only English language description, it is no problem. Whenever you get a font which contains descriptions in many languages, like most professional fonts, it's looking ugly and confusing. That's the reason for the complex line.

Most OSS fonts don't have this issue, but there are still enough who have, like Free Mono. It's in the gnu-free-fonts package in Arch.

sdushantha commented 4 years ago

Ah okay that makes sense. I will start working on this as soon as I can :+1:

aeghn commented 4 years ago

What about this?

p-200624_193121

sdushantha commented 4 years ago

Ooo fancy :sparkles: