Page 1 of 1
microsoft ttf fonts can not be used in the Linux
Posted: Fri May 29, 2020 6:46 pm
by dibor
Hello.
Here example showing the problem:
Code: Select all
FontName$ = "Times New Roman"
If OpenWindow(0, 0, 0, 300, 160, "Loading font...", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
Result = FontRequester(FontName$, 14, 0, RGB(0, 0, 0), #PB_Font_Bold)
If LoadFont(1, SelectedFontName(), SelectedFontSize() )
SetGadgetFont(#PB_Default, FontID(1))
TextGadget(0, 10, 10, 300, 40, SelectedFontName()+" "+Str(SelectedFontSize()) )
EndIf
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
The font Previews fine when using the FontRequester but does not display as "Times New Roman" in the Text Gadget.
Tested with 64bit PureBasic latest version on Ubuntu 20.04 64 bit and Suse Enterprise Desktop 15.1 64 bit.
Code works under Windoz and OSX
Thank you.
Re: microsoft ttf fonts can not be used in the Linux
Posted: Sat May 30, 2020 5:48 am
by Oma
For better fault isolation it should be mentioned that
FontName$ = "TimesNewRoman" or
FontName$ = "Times"
can be found better.
However,
FontName$ = "Source Code Pro" as .ttf
(with spaces in the name) is set correctly.
Re: microsoft ttf fonts can not be used in the Linux
Posted: Sat May 30, 2020 2:40 pm
by dibor
Hi Oma.
With FontName$ = "TimesNewRoman" or FontName$ = "Times" also doesn't works.
Not going to change source working on Win and MacOS.
I hope author will check the problem.
CUL
Re: microsoft ttf fonts can not be used in the Linux
Posted: Tue Nov 17, 2020 3:40 pm
by Fred
Seems to work here in both gtk and QT. Can anybody else confirm ?
Re: microsoft ttf fonts can not be used in the Linux
Posted: Tue Nov 17, 2020 5:13 pm
by deeproot
Does not appear to work on my system with GTK2/GTK3. But does work with QT!
Using the test code above and GTK- Times New Roman is listed and highlighted but when selected the window shows a substituted sans-serif font of similar size.
If certain other fonts are chosen, for example DejaVu Serif or a Noto Serif, they work OK. With LibreOffice on the same machine Times New Roman works. The MS ttf fonts exist under /usr/share/fonts/truetype/
However - fonts in Linux are still something of a mystery to me

. Tested with MX Linux, no explicit font changes made since install.
Re: microsoft ttf fonts can not be used in the Linux
Posted: Tue Nov 17, 2020 8:04 pm
by DarkDragon
Is the font installed and the fontconfig cache rebuilt? The command fc-cache rebuilds it. You can also try to find the font with fc-match or grep it from fc-list output.
Some font packages forget to call fc-cache afterwards. Most applications rely on a correct fontconfig cache.
Re: microsoft ttf fonts can not be used in the Linux
Posted: Tue Nov 17, 2020 9:26 pm
by deeproot
DarkDragon wrote:Is the font installed and the fontconfig cache rebuilt? The command fc-cache rebuilds it. You can also try to find the font with fc-match or grep it from fc-list output.
I didn't know about that - thanks very much!
Unfortunately fc-cache did not change the result. Times New Roman and other MS fonts do appear in the fc-list output.
I don't use these on Linux myself - but I guess they should work.
Re: microsoft ttf fonts can not be used in the Linux
Posted: Mon Dec 07, 2020 1:53 pm
by dibor
Fred wrote:Seems to work here in both gtk and QT. Can anybody else confirm ?
Hello.
With 5.73 version also doesn't works.
What to do?

Re: microsoft ttf fonts can not be used in the Linux
Posted: Mon Dec 07, 2020 4:56 pm
by deeproot
Hello dibor
Yes you are correct - previously tested with a Beta and re-tested with 5.73 LTS. Same result as above - works with QT, does not work with GTK2/GTK3.
My best suggestion for now - Do you really need the MS fonts for your Linux program? There are some good and much safer alternatives. Liberation, DejaVu and FreeSerif/FreeSans appear to be pre-installed on almost all Linux systems. Noto fonts and probably a few others are also common.
My personal approach for a big project that exists on all 3 platforms is to have a common Procedure that sets all fonts to enumerated constants. Then for Windows, Linux and Mac this procedure uses font-name equivalents which are as safe as possible for each platform. Also perhaps we should not assume that proprietary MS fonts will be installed on every customer's Linux system, even though they should work if available.
Re: microsoft ttf fonts can not be used in the Linux
Posted: Mon Dec 07, 2020 5:52 pm
by dibor
Hi deeproot.
Tnx for answer.
Yes, look like this is a good way.
For Windoz and MacOS MS fonts, for Linux other.
But anyway, author should be informed about this bug.
Best Wishes.
Re: microsoft ttf fonts can not be used in the Linux
Posted: Wed Jan 03, 2024 2:17 pm
by Fred
We're using standard requester and font command here, so it's more likely to be a GTK limitation. I moving this topic in Linux in case of other people get the same issue.
Re: microsoft ttf fonts can not be used in the Linux
Posted: Wed Jan 03, 2024 3:06 pm
by juergenkulow