microsoft ttf fonts can not be used in the Linux

Linux specific forum
dibor
Enthusiast
Enthusiast
Posts: 125
Joined: Wed May 20, 2020 5:19 pm
Location: The 3rd planet in the Solar System
Contact:

microsoft ttf fonts can not be used in the Linux

Post 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.
Mac Studio M1Max, PB 6.03Arm64 and x64.
Macbook Air M2, PB 6.03Arm64 and x64.
Windows 10, PB 6.03 x64 and x86.
Oma
Enthusiast
Enthusiast
Posts: 312
Joined: Thu Jun 26, 2014 9:17 am
Location: Germany

Re: microsoft ttf fonts can not be used in the Linux

Post 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.
PureBasic 5.4-5.7, Linux: (X/L/K)Ubuntus+Mint - Windows XP (32Bit)
PureBasic Linux-API-Library & Viewer: http://www.chabba.de
dibor
Enthusiast
Enthusiast
Posts: 125
Joined: Wed May 20, 2020 5:19 pm
Location: The 3rd planet in the Solar System
Contact:

Re: microsoft ttf fonts can not be used in the Linux

Post 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
Mac Studio M1Max, PB 6.03Arm64 and x64.
Macbook Air M2, PB 6.03Arm64 and x64.
Windows 10, PB 6.03 x64 and x86.
Fred
Administrator
Administrator
Posts: 16616
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: microsoft ttf fonts can not be used in the Linux

Post by Fred »

Seems to work here in both gtk and QT. Can anybody else confirm ?
deeproot
Enthusiast
Enthusiast
Posts: 269
Joined: Thu Dec 17, 2009 12:00 pm
Location: Llangadog, Wales, UK
Contact:

Re: microsoft ttf fonts can not be used in the Linux

Post 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 :wink:. Tested with MX Linux, no explicit font changes made since install.
DarkDragon
Addict
Addict
Posts: 2218
Joined: Mon Jun 02, 2003 9:16 am
Location: Germany
Contact:

Re: microsoft ttf fonts can not be used in the Linux

Post 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.
bye,
Daniel
deeproot
Enthusiast
Enthusiast
Posts: 269
Joined: Thu Dec 17, 2009 12:00 pm
Location: Llangadog, Wales, UK
Contact:

Re: microsoft ttf fonts can not be used in the Linux

Post 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.
dibor
Enthusiast
Enthusiast
Posts: 125
Joined: Wed May 20, 2020 5:19 pm
Location: The 3rd planet in the Solar System
Contact:

Re: microsoft ttf fonts can not be used in the Linux

Post 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? :(
Mac Studio M1Max, PB 6.03Arm64 and x64.
Macbook Air M2, PB 6.03Arm64 and x64.
Windows 10, PB 6.03 x64 and x86.
deeproot
Enthusiast
Enthusiast
Posts: 269
Joined: Thu Dec 17, 2009 12:00 pm
Location: Llangadog, Wales, UK
Contact:

Re: microsoft ttf fonts can not be used in the Linux

Post 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.
dibor
Enthusiast
Enthusiast
Posts: 125
Joined: Wed May 20, 2020 5:19 pm
Location: The 3rd planet in the Solar System
Contact:

Re: microsoft ttf fonts can not be used in the Linux

Post 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.
Mac Studio M1Max, PB 6.03Arm64 and x64.
Macbook Air M2, PB 6.03Arm64 and x64.
Windows 10, PB 6.03 x64 and x86.
Fred
Administrator
Administrator
Posts: 16616
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Re: microsoft ttf fonts can not be used in the Linux

Post 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.
Post Reply