How to prevent font change in editor gadget? Bug?

Everything else that doesn't fall into one of the other PB categories.
User avatar
Kukulkan
Addict
Addict
Posts: 1422
Joined: Mon Jun 06, 2005 2:35 pm
Location: germany
Contact:

How to prevent font change in editor gadget? Bug?

Post by Kukulkan »

Hello,

I pre-define an EditorGadget() with content containing some Asian characters. Sadly, this changes the font and it is really not nice looking (compile in Unicode mode!):

Code: Select all

If OpenWindow(0, 0, 0, 322, 150, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  LoadFont(0, "Arial", 12)
  EditorGadget(0, 8, 8, 306, 133)
  SetGadgetFont(0, FontID(0))
  c.s = "> Recipients: abc@xyz.com" + #CR$
  c.s + "> Sent: 20. Jun 2013  10:59" + #CR$
  c.s + "> Attachments: Test_请收藏我们的网.pdf" + #CR$
  c.s + "> " + #CR$
  c.s + "> Test message to myself" + #CR$
  SetGadgetText(0, c.s)
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
FreeFont(0)
CloseWindow(0)
Looks like this:
Image

How to prevent the obvious font change? My customers complain as it looks very ugly.

Kukulkan
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8453
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: How to prevent font change in editor gadget? Bug?

Post by netmaestro »

There won't be an easy solution to that one imho. It's because there are no asian characters available in your chosen font and the control is switching to the fallback font. It's not unique to PureBasic edit controls, it's how a Windows edit control responds to not having the characters it needs available. Rather than display nothing or junk, it's falling back to a font it knows has the characters. Your best bet would be to find a font somewhere that everyone likes that does contain the asian characters, then it won't fall back. I'm not an expert on such things so maybe someone will have a better answer for you.
BERESHEIT
User avatar
electrochrisso
Addict
Addict
Posts: 989
Joined: Mon May 14, 2007 2:13 am
Location: Darling River

Re: How to prevent font change in editor gadget? Bug?

Post by electrochrisso »

I did a search, using my Font Lister program I made in PB, and found the first fall back font was SimSum, I think this might be installed on all Win machines these days.

Code: Select all

If OpenWindow(0, 0, 0, 322, 150, "EditorGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
  LoadFont(0, "SimSun", 12)
  EditorGadget(0, 8, 8, 306, 133)
  SetGadgetFont(0, FontID(0))
  c.s = "> Recipients: abc@xyz.com" + #CR$
  c.s + "> Sent: 20. Jun 2013  10:59" + #CR$
  c.s + "> Attachments: Test_请收藏我们的网.pdf" + #CR$
  c.s + "> Attachments: Test_请收藏我们的网.pdf" + #CR$
  SetGadgetText(0, c.s)
  Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
FreeFont(0)
CloseWindow(0)
To make it universal to all users on all platforms, perhaps you could include a suitable font file and get PB to load it, and use that one.
PureBasic! Purely the best 8)
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: How to prevent font change in editor gadget? Bug?

Post by IdeasVacuum »

SimSum, I think this might be installed on all Win machines these days
Not the case unfortunately. In fact, the only font guaranteed to cover the necessary Unicode and is distributed with all Windows versions is Microsoft Sans Serif (note, not the same font as MS Sans Serif).

There is a really nice distributable Arial Unicode font, but the license is expense: http://www.ascenderfonts.com/font/arial-unicode.aspx
To make it universal to all users on all platforms, perhaps you could include a suitable font file and get PB to load it, and use that one.
That is good advice, the only way to guarantee that the User sees what you expect them to see.
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
User avatar
electrochrisso
Addict
Addict
Posts: 989
Joined: Mon May 14, 2007 2:13 am
Location: Darling River

Re: How to prevent font change in editor gadget? Bug?

Post by electrochrisso »

Unfortunately Microsoft Sans Serif does not work for me, I found Arial Unicode MS works, and can be purchased from MS for $165, same price as ascenderfonts, if the price is justified. If MS Office has been installed on the users computer, this font should have been installed.
Perhaps this link might be of use http://dejavu-fonts.org/wiki/Main_Page have not tried them, and don't know if Asian characters are included, I wonder if Open Office or the like have a suitable open source fonts available.
PureBasic! Purely the best 8)
User avatar
netmaestro
PureBasic Bullfrog
PureBasic Bullfrog
Posts: 8453
Joined: Wed Jul 06, 2005 5:42 am
Location: Fort Nelson, BC, Canada

Re: How to prevent font change in editor gadget? Bug?

Post by netmaestro »

I found the free SimHei font here: http://cooltext.com/Fonts-Unicode-Chinese

This is what the test code looks like with it:

Image

Looks pretty good to me for a free solution. :mrgreen:
BERESHEIT
User avatar
electrochrisso
Addict
Addict
Posts: 989
Joined: Mon May 14, 2007 2:13 am
Location: Darling River

Re: How to prevent font change in editor gadget? Bug?

Post by electrochrisso »

netmaestro wrote:I found the free SimHei font here: http://cooltext.com/Fonts-Unicode-Chinese
Good find NM, I have bookmarked cooltext, there be some cool text to create, when I need some ideas. :D
PureBasic! Purely the best 8)
Post Reply