Recent

Author Topic: WinCE font Problem  (Read 12889 times)

wsandor

  • Newbie
  • Posts: 1
WinCE font Problem
« on: June 04, 2010, 09:10:09 am »
I am writing a program for WinCE. It is working fine except one thing: I can't change the font.
For exemple, If I set 'Courier New' as a font for a label in the designer, then there I see the text of the label with this font. However on the device (WinCE 5.0) the label is shown with the default (Tahoma) font. The same is, if I try to write a text to a bitmap. It is always with Tahoma. In the device Tahoma and Courier New fonts are installed as a default. I can install new fonts (either copying them to the Fonts directory or in the program with AddFontResource)  other applications see them and can use them, but unfortunately  my Lazarus application can't use them. Any idea?   (I've tried it with Lazarus 0.9.26 and 0.9.28 with the same result)
Thanks for advance.

*** modified ****

I managed to bypass the problem (at least to write text to a bitmap with the desired font), here is some sample code:

var
  lf: LOGFONT;
  fnt: HFONT;
  orig: HGDIOBJ;
  Bmp: Graphics.Bitmap;

begin
lf.lfHeight:= fontSize;
lf.lfFaceName:= fontFace;
// other font properties could be set here...
Bmp.Canvas.Changing;
fnt:= CreateFontIndirect(lf);
orig:= SelectObject(Bmp.Canvas.Handle, fnt);
Windows.ExtTextOutW(Bmp.Canvas.Handle, .....
      (Write out the text to the canvas, with the selected font)
SelectObject(Bmp.Canvas.Handlre, orig);
DeleteObject(fnt);
Bmp.Canvas.Changed;
end;


« Last Edit: April 04, 2011, 02:54:58 pm by wsandor »

vgoudreault

  • New Member
  • *
  • Posts: 11
Re: WinCE font Problem
« Reply #1 on: September 01, 2010, 06:37:40 am »
I share your impression (and surprise) as I found out the same thing with my application.
I wrote a small test project to check a few things (by the way, the TPageControl will have the page tab index appear at the bottom, rather than the top, so I had to replace those with buttons and perform that page swapping logic myself in code to maintain commonality between WinCE and Windows. At least, on WinCE, the TButtons appear in the color specified, while on Windows, they are always light gray, no matter what...), and here is what I fond. On my WinCE machine
- default font is tahoma
- default italic font appears as Verdana (!), a rather fancy script
- only other font that will actually appear is courrier

At one point, I will consider have a widget offer a selection of font (from a combobox) to dynamically change the font of a caption, so that I could systematically test them all and find which, if any, will actually appear.

Unless some real expert comes around with an answer, we may have to live with rather bland fonts on pocket machines...


A.S.

  • Jr. Member
  • **
  • Posts: 76
Re: WinCE font Problem
« Reply #2 on: October 25, 2010, 02:24:37 pm »
To use Courier font (that is already installed on smart device) it is not sufficient to setup Font.Name := 'Courier'. On wince device you should set Font.Pitch to ptFixed

felipemdc

  • Administrator
  • Hero Member
  • *
  • Posts: 3538
Re: WinCE font Problem
« Reply #3 on: December 10, 2010, 12:59:24 pm »
To use Courier font (that is already installed on smart device) it is not sufficient to setup Font.Name := 'Courier'. On wince device you should set Font.Pitch to ptFixed

Could you give a code which will select courier? I just tryed here with name = 'Courier' and ptFixed and it still didn't select Courier ...

 

TinyPortal © 2005-2018