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

Re: Improve DrawString Quality on 480 X 640 Pocket PCs by Paul

Paul
Wed Oct 06 12:54:29 CDT 2004

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.

"Avonelle Lovhaug" <alovhaug@yahoo.com> wrote in message
news:e71bdf0.0410060940.632939d6@posting.google.com...
> 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