[Github-comments] [geany/geany] choose font: classify families into monospace/proportional (#1928)

VictorelPetrovich notifications at xxxxx
Sun Aug 26 04:40:43 UTC 2018


So that is why I was never able to specify in Geany, in the font dialog, the style (bold/italic etc) for a font family. Makes sense.

Yesterday I decided to  adventure in the world of programming :) , and after 2 days of staring on GTK documentation, put together some `coding ideas` for all this filtering. 
_Disclaimer: I'm not a programmer, I only have rudimentary C knowledge, and never ever before had to deal with Gtk or anything like that... So most likely much of the "code" below is simply wrong, but maybe somehow it will still help a tiny bit the person who will actually implement this filtering._ 

Any feedback welcome!

So, I just assumed a 2 check-buttons style for selecting monospace vs proportional, without bothering with further styling, or correct placing within the Geany overall code (for which I don't have a clue).

On terminology and labels choice:
Different pages disagree on whether "duospaced" fonts are monospace or not; so perhaps "fixed-width" vs "variable-width" is a better option... But that's not so relevant for now.
//https://developer.gnome.org/pango/stable/pango-Fonts.html#pango-font-family-is-monospace
// https://en.wikipedia.org/wiki/Monospaced_font
// https://en.wikipedia.org/wiki/Typeface#Proportion
//https://en.wikipedia.org/wiki/Duospaced_font

 To filter out unused faces ("styles" in my Geany font chooser) for a family:
 a tricky part may be that some font families don't contain "normal" faces, but say only  Bold  faces ; (selecting such font actually makes the text bold in Geany; example in my installation: `Adobe Caslo Pro Bold` only has 2 named styles: Bold and Bold Italic ; or `Aharoni` and many others  ). So they cannot be filtered out by asking the style and weight of a face to be specifically "normal". (see below [this](https://developer.gnome.org/pango/stable/pango-Fonts.html#PangoFontDescription-struct) 

Maybe one can instead make the filter allow a font only if it is the first encountered face of a family. This assumes that the [gtk_font_chooser_set_filter_func] (https://developer.gnome.org/gtk3/stable/GtkFontChooser.html#gtk-font-chooser-set-filter-func)  runs over some list of all fonts (all faces of all families, for a given platform), and that list is sorted by family, and also all fonts of a family are sorted so that a font with "normal" style/weight (IF any present for the particular family) appears before fonts with bold/slanted etc style/weight. 

Maybe it's a naive assumption, but seems plausible. Anyway, that is what I have assumed bellow...

I have included the filtering out of the unneeded faces/styles in the same function that filters based on checking-state of the buttons. I'm aware this is very inefficient, because this filtering will be done everytime the fontChooser dialog is launched and the checkbuttons activated -- instead of a single filtering of the uneeded styles once and for all, for a given Geany installation, and save the info in a local file, and to be consulted when Fontchooser dialog starts.
But I've no idea, for now, how to do that . (Maybe related to [PangoFontMap or PangoFontSet](https://developer.gnome.org/pango/stable/pango-Fonts.html) )
And anyway, this is just some ideas...

Low and behold, `coding horror` follows :)


-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/issues/1928#issuecomment-416013558
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20180825/adb58719/attachment.html>


More information about the Github-comments mailing list