<blockquote>
<p>"fixed-width" vs "variable-width" is a better option...</p>
</blockquote>
<p>Well, even so called monospaced fonts are not fixed width if <a href="https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms" rel="nofollow">wide Unicode characters</a> are present.</p>
<blockquote>
<p>some font families don't contain "normal" faces,</p>
</blockquote>
<p>Maybe just skip them, any syntactic entity identified by bolding or italics will not be distinguishable with those fonts, only show them when "all" is selected.</p>
<blockquote>
<p>"normal" style/weight (IF any present for the particular family) appears before fonts with bold/slanted etc style/weight.</p>
</blockquote>
<p>The ordering of fonts in my chooser generally follows that rule, but not always, eg Freeserif goes Bold Italic, Italic, Regular, Bold.  Since I suspect the ordering in the chooser is the same as the enumeration from Pango this would indicate that may not be a good assumption.  If its not documented to be in that order you can't assume it.</p>
<blockquote>
<p>I have included the filtering out of the unneeded faces/styles in the same function that filters based on checking-state of the buttons.</p>
</blockquote>
<p>Thats the way to do it, the cost of filtering will be insignificant compared to the cost of the chooser loading and rendering its sample text in every font available.</p>
<p>There is no way to make the standard dialogs use a list of fonts you have compiled, they will always consult the platforms font machinery, which can vary between platforms (win, lin, osx) and sometimes on the platform for different font types, eg True Type vs Open Type vs Adobe fonts.  This is the correct method since your list will not reflect fonts installed later.  Just forget about trying to optimise it, first get it right, then optimise if needed.</p>
<p>Havn't looked at your code in detail since you need to adjust your algorithm on the basis that regular won't always be first.  However the basic idea of the filter function passed the button state via the user data is correct.  A note on the user data, don't use fixed lengths for strings, someone will always overflow it, use dynamic strings.</p>

<p style="font-size:small;-webkit-text-size-adjust:none;color:#666;">—<br />You are receiving this because you are subscribed to this thread.<br />Reply to this email directly, <a href="https://github.com/geany/geany/issues/1928#issuecomment-416015101">view it on GitHub</a>, or <a href="https://github.com/notifications/unsubscribe-auth/ABDrJ9gHYRh8uPhkAq5GWW1Ey44I38PYks5uUjHZgaJpZM4WGvIU">mute the thread</a>.<img src="https://github.com/notifications/beacon/ABDrJ7MT916VZMzHblar9QDCmcrkdy-Cks5uUjHZgaJpZM4WGvIU.gif" height="1" width="1" alt="" /></p>
<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/geany/geany","title":"geany/geany","subtitle":"GitHub repository","main_image_url":"https://assets-cdn.github.com/images/email/message_cards/header.png","avatar_image_url":"https://assets-cdn.github.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/geany/geany"}},"updates":{"snippets":[{"icon":"PERSON","message":"@elextr in #1928: \u003e  \"fixed-width\" vs \"variable-width\" is a better option... \r\n\r\nWell, even so called monospaced fonts are not fixed width if [wide Unicode characters](https://en.wikipedia.org/wiki/Halfwidth_and_fullwidth_forms) are present.\r\n\r\n\u003e some font families don't contain \"normal\" faces,\r\n\r\nMaybe just skip them, any syntactic entity identified by bolding or italics will not be distinguishable with those fonts, only show them when \"all\" is selected.\r\n\r\n\u003e  \"normal\" style/weight (IF any present for the particular family) appears before fonts with bold/slanted etc style/weight.\r\n\r\nThe ordering of fonts in my chooser generally follows that rule, but not always, eg Freeserif goes Bold Italic, Italic, Regular, Bold.  Since I suspect the ordering in the chooser is the same as the enumeration from Pango this would indicate that may not be a good assumption.  If its not documented to be in that order you can't assume it.\r\n\r\n\u003e I have included the filtering out of the unneeded faces/styles in the same function that filters based on checking-state of the buttons.\r\n\r\nThats the way to do it, the cost of filtering will be insignificant compared to the cost of the chooser loading and rendering its sample text in every font available.\r\n\r\nThere is no way to make the standard dialogs use a list of fonts you have compiled, they will always consult the platforms font machinery, which can vary between platforms (win, lin, osx) and sometimes on the platform for different font types, eg True Type vs Open Type vs Adobe fonts.  This is the correct method since your list will not reflect fonts installed later.  Just forget about trying to optimise it, first get it right, then optimise if needed.\r\n\r\nHavn't looked at your code in detail since you need to adjust your algorithm on the basis that regular won't always be first.  However the basic idea of the filter function passed the button state via the user data is correct.  A note on the user data, don't use fixed lengths for strings, someone will always overflow it, use dynamic strings."}],"action":{"name":"View Issue","url":"https://github.com/geany/geany/issues/1928#issuecomment-416015101"}}}</script>
<script type="application/ld+json">[
{
"@context": "http://schema.org",
"@type": "EmailMessage",
"potentialAction": {
"@type": "ViewAction",
"target": "https://github.com/geany/geany/issues/1928#issuecomment-416015101",
"url": "https://github.com/geany/geany/issues/1928#issuecomment-416015101",
"name": "View Issue"
},
"description": "View this Issue on GitHub",
"publisher": {
"@type": "Organization",
"name": "GitHub",
"url": "https://github.com"
}
},
{
"@type": "MessageCard",
"@context": "http://schema.org/extensions",
"hideOriginalBody": "false",
"originator": "AF6C5A86-E920-430C-9C59-A73278B5EFEB",
"title": "Re: [geany/geany] choose font: classify families into monospace/proportional (#1928)",
"sections": [
{
"text": "",
"activityTitle": "**elextr**",
"activityImage": "https://assets-cdn.github.com/images/email/message_cards/avatar.png",
"activitySubtitle": "@elextr",
"facts": [

]
}
],
"potentialAction": [
{
"name": "Add a comment",
"@type": "ActionCard",
"inputs": [
{
"isMultiLine": true,
"@type": "TextInput",
"id": "IssueComment",
"isRequired": false
}
],
"actions": [
{
"name": "Comment",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"IssueComment\",\n\"repositoryFullName\": \"geany/geany\",\n\"issueId\": 1928,\n\"IssueComment\": \"{{IssueComment.value}}\"\n}"
}
]
},
{
"name": "Close issue",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"IssueClose\",\n\"repositoryFullName\": \"geany/geany\",\n\"issueId\": 1928\n}"
},
{
"targets": [
{
"os": "default",
"uri": "https://github.com/geany/geany/issues/1928#issuecomment-416015101"
}
],
"@type": "OpenUri",
"name": "View on GitHub"
},
{
"name": "Unsubscribe",
"@type": "HttpPOST",
"target": "https://api.github.com",
"body": "{\n\"commandName\": \"MuteNotification\",\n\"threadId\": 370864660\n}"
}
],
"themeColor": "26292E"
}
]</script>