I’ve installed some great Fonts on my system, and they render really well in the Canvas control with all the standard syntax, e.g.:
Sub Paint(g As Graphics)
g.Bold = True
g.Italic = True
g.TextFont = "Helvetica"
g.TextSize = 18
g.DrawString("I love XOJO!", 10, 50)
However, many fonts have different weights, more than simply “Bold”, and I’m curious if these can be accessed.
For instance, if I have a font collection named “Roboto Mono” I have great success using g.TextFont = "Roboto Mono", and can even use g.Bold = True and get the expected results.
My confusion comes in knowing how to access the other versions of the font.
The collection of .TTF’s that I’ve installed may look like this…
…and I believe be default when I use “Roboto Mono” the font used is ‘RobotoMono-Regular.ttf’, and when I set the ‘bold’ attribute it’s likely using ‘RobotoMono-Bold.ttf’.
My primary question is can I use .TextFont to refer to any of the other weights/versions of the font set, or is only ‘Regular’, ‘Italic’, and ‘Bold’ available?
You have to use what the system thinks the display name is. I’m unsure, but I feel like this could vary between operating systems.
Try g.TextFont = "Roboto Mono Medium" as I’ve had success with custom fonts and different weights like this. You may be able to use Font Book.app on Mac to help get the right display name.
/usr/share/fonts/truetype/kacst/KacstFarsi.ttf File name
: Separator
KacstFarsi Font name (note, remove the initial space)
: Separator
style= Medium The font ‘style’
I believe I’ve answered my own question, so to be thorough here’s what I’ve found…
In the host OS, using a word processing application, I’m able to see the font “DejaVu Serif”, which has a ‘style’ named “Condensed”. Using the fc-list command I was able to find the following line, which I was able to identify the name “DejaVu Serif Condensed”, which worked when used with g.TextFont = "DejaVu Serif Condensed"