Page 1 of 1

How to prevent font change in editor gadget? Bug?

Posted: Thu Feb 13, 2014 8:42 am
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

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

Posted: Thu Feb 13, 2014 9:13 am
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.

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

Posted: Fri Feb 14, 2014 1:43 am
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.

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

Posted: Fri Feb 14, 2014 3:35 pm
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.

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

Posted: Sat Feb 15, 2014 1:05 am
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.

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

Posted: Sat Feb 15, 2014 1:50 am
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:

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

Posted: Sat Feb 15, 2014 6:55 am
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