Improve DrawString Quality on 480 X 640 Pocket PCs

  • Thread starter Avonelle Lovhaug
  • Start date
A

Avonelle Lovhaug

Part of my .NET CF application are some custom controls which I am
creating with some simple graphics commands (DrawString,
DrawRectangle, etc.) Ever since I started using my new device (an
hx4700 iPAQ) for testing, it has been clear that the text quality is
not nearly as sharp as the text contained on the built-in controls.

Is there anything I can do to improve the quality of text created
using DrawString (or an alternative to DrawString)? I've tried using
the OpenNETCF library and the FontEx class and set ClearType = True,
but that doesn't seem to improve anything. Here's a snippet of code
(not that I think I'm doing anything particularly fancy or
different...)

Dim fnt As FontEx
Dim _pen As PenEx

fnt = New FontEx(FontName, FontSize, FontStyle.Bold)
fnt.ClearType = True
_pen = New PenEx(Color.Black)

g = g.FromControl(m_HeadingPicture)

Dim rc As Rectangle
For iDayOfWeek = 1 To 7
PositionOnPanelX = ((iDayOfWeek - 1) * DayWidth)

strHeading = htHeadings.Item(iDayOfWeek)

'Determine length of text for heading
'TextSize = g.MeasureString(strHeading, m_fontSmall)
TextSize = g.MeasureString(strHeading, fnt)
'Determine position to start, based on length of text and
available space to be displayed
intPositionX = (DayWidth / 2) - (TextSize.Width / 2)


rc = New Rectangle(PositionOnPanelX + intPositionX, 1, DayWidth,
TextSize.Height)

With g
'Draw border
'.DrawRectangle(m_pen, PositionOnPanelX, PositionOnPanelY,
DayWidth - 1, MonthTopAfterTitle - 1)
.DrawRectangle(_pen, PositionOnPanelX, PositionOnPanelY,
DayWidth - 1, MonthTopAfterTitle - 1)

'Write day of the week
'.DrawString(strHeading, m_fontLarge, m_brushText,
PositionOnPanelX + intPositionX, 1)
.DrawString(strHeading, fnt, Color.Black, rc)

End With
g.CopyGraphics(m_HeadingPicture, rc)

Next

--------------------
I didn't include everything (so this probably won't compile or
anything)...I just wanted to show the related code that I'm using in
case there is something obviously flawed in what I am doing. Any
suggestions would be greatly appreciated.

Thanks,

--Avonelle
 
P

Paul G. Tobey [eMVP]

You'll have to be more specific than that. What font, specifically, are you
using? At what size? I've never noticed any difference between the text
quality in, say, an EDIT control set up with managed and unmanaged code, so
it sounds to me like you are using a strange size or an unusual font.

Paul T.
 
A

Avonelle Lovhaug

Oops, sorry:

The font name is Tahoma, and the size is 6.0. Does that help?


Thanks for the assistance,

--Avonelle
 
P

Peter Foot [MVP]

Is your app using Pixel Doubling to fit the VGA screen. This would explain
the "blockyness" of the fonts. See this article for details on how to mark
your application as hi-dpi aware:-
http://msdn.microsoft.com/library/e...ing_orientation_and_resolution_aware_apps.asp

Peter

--
Peter Foot
Windows Embedded MVP
www.inthehand.com | www.opennetcf.org

Do have an opinion on the effectiveness of Microsoft Windows Mobile and
Embedded newsgroups? Let us know!
https://www.windowsembeddedeval.com/community/newsgroups
 
P

Paul G. Tobey [eMVP]

And sizing fonts that small is going to give you a certain amount of grainy
appearance. There just aren't enough pixels in the available character
space to make nice curves on glyphs at that size. I'd guess that Peter has
the handle on your problem, though.

Paul T.
 
A

Avonelle Lovhaug

Thank you for the replies. I've reviewed the material, but I'm not sure
if/how it helps me, since it generally references things in C++, and I'm
developing in VB.NET.

Also, I have some additional information, which may provide some clues.
I have found that text is not blurry (yes, even at size=6!) if the text
is drawn directly on my custom control. What I was doing previously was
to create an in-memory bitmap, draw things on the bitmap, and then used
graphics.DrawImage (or set the bitmap equal to the image property of a
PictureBox if I needed to support scrolling).

The good news is - my text is no longer blurry. The bad news is...now
I've got a flicker. I wonder if these are my only choices...

Thanks,

--Avonelle
 
Top