Re: Print Preview (again?)
This is a multi-part message in MIME format.
------=_NextPart_000_0015_01C8AADA.7A9C3870
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi Joe
There's definitely a quantum jump, even if I increase the .lfHeight =
value directly, it 'sticks' at certain sizes.
In Word I can zoom out to 28% which exactly matches my preview pane. =
There, I can go from 40 to 41 and the text gets slightly bigger, bit =
still looks good.
I'm doing this at the moment:
dc.SetMapMode(MM_ISOTROPIC);
CRect rect;
GetClientRect(&rect);
dc.SetWindowExt(MM2DeviceUnits(210), MM2DeviceUnits(297));
dc.SetViewportExt(rect.Width(), rect.Height());
Greg
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message =
news:28qg1455q95opfpr0e2srv7jbg07jtdm4q@4ax.com...
It depends on the mapping mode you are using. Word works in twips, =
for example.
Ultiimately, it deals with pixel roundoff; whatever font size 40 and =
41 are round to the
same pixel count, but 43 is probably one pixel larger. Remember the =
preview is running at
a much smaller size and hence the roundoff issues will be more =
pronounced.
joe
On Wed, 30 Apr 2008 12:52:14 +0100, "GC" <gc@freeuk.co.uk> wrote:
Thanks for that Joe. I've now tried using map modes instead and it =
looks a
lot better but I'm back where I started (when I simply scaled the font =
size)
in as much as increasing the font size from say 40 to 41 doesn't =
result in a
bigger preview font. It 'waits' until it gets to 43.
How can I achieve this? (Microsoft Word can do it!).
Greg
"Joseph M. Newcomer" <newcomer@flounder.com> wrote in message
news:ltgf14tpus0on0bj51vdb66icckdbcg6ai@4ax.com...
Essentially, StretchBlt will do just about the worst job you can =
imagine
for this
(actually, it doesn't matter what you're trying to do, StretchBlt =
will
probably do it
wrong). I would have simply set the map mode so that the image will =
fill
the preview
space and use whatever I get. The nice thing about this is that the =
font
will be rendered
using the ClearType best-approximation instead of being uglified by
StretchBlt.
joe
On Tue, 29 Apr 2008 15:33:43 +0100, "GC" <gc@freeuk.co.uk> wrote:
Hi
I'm getting very confused with trying to draw a small print preview =
box.
I'm
trying to draw fonts the exact proportionate size. Because I can't =
show
fractional font sizes on screen, I'm trying to draw it into a memory =
DC
(quite big?) then StretchBlt it down onto my box (I don't mind if =
it's a
bit pixelly as long as it's in proportion).
This code works after a fashion but what do my values need to be? Do =
I
need
to set the map mode to a higher value? It comes about 1/3 size.
Thanks for any advice,
Greg Chapman
void CA4Page::OnPaint()
{
CPaintDC dc(this);
CDC memDC;
memDC.CreateCompatibleDC(&dc);
// ??? memDC.SetMapMode(MM_HIMETRIC);
int deviceRes = memDC.GetDeviceCaps(LOGPIXELSY);
CRect rect;
this->GetClientRect(&rect);
// this is roughly 210 x 297 ie a mm to a pixel
CRect memRect(0,0, 2100, 2970);
// nice big one for best resolution?
CBitmap bmp;
bmp.CreateCompatibleBitmap(&memDC, memRect.Width(), =
memRect.Height());
memDC.SelectObject(&bmp);
LOGFONT fontStruct;
// this fills out the struct
Utilities::FillFontStruct("Times New Roman", 0, 0, 4, fontStruct);
CString str("Hello World");
CFont font;
int pointSize = 60;
fontStruct.lfHeight = (int)-MulDiv(pointSize, deviceRes, 72);
font.CreateFontIndirect(&fontStruct);
memDC.SelectObject(&font);
memDC.DrawText(str, memRect, 0);
dc.StretchBlt(rect.left, rect.top, rect.Width(), rect.Height(),
&memDC, 0, 0, memRect.Width(), memRect.Height(),
SRCCOPY);
}
------=_NextPart_000_0015_01C8AADA.7A9C3870
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; =
charset=iso-8859-1">
<META content="MSHTML 6.00.6000.16640" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><FONT face=Arial>Hi Joe</FONT></DIV>
<DIV><FONT face=Arial>There's definitely a quantum jump, even if I =
increase the
..lfHeight value directly, it 'sticks' at certain sizes. </FONT></DIV>
<DIV><FONT face=Arial>In Word I can zoom out to 28% which exactly =
matches my
preview pane. There, I can go from 40 to 41 and the text gets slightly =
bigger,
bit still looks good.</FONT></DIV>
<DIV><FONT face=Arial>I'm doing this at the moment:</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT
face="Courier New"> dc.SetMapMode(MM_ISOTROPIC);<BR></FONT></DIV>
<DIV><FONT face="Courier New"> CRect
rect;<BR> GetClientRect(&rect);<BR> </FONT><FONT =
face=Arial><FONT
face="Courier =
New"> <BR> dc.SetWindowExt(MM2DeviceUnits(210),
MM2DeviceUnits(297));<BR> dc.SetViewportExt(rect.Width(),
rect.Height());</FONT></FONT></DIV>
<DIV><FONT face="Courier New"></FONT> </DIV>
<DIV><FONT face="Courier New">Greg</FONT></DIV>
<DIV><FONT face=Arial><FONT face="Courier =
New"></FONT></FONT> </DIV>
<DIV><FONT face=Arial><FONT face="Courier New"></FONT> </DIV>
<DIV><BR></DIV></FONT>
<DIV><FONT face=Arial>"Joseph M. Newcomer" <</FONT><A
href="mailto:newcomer@flounder.com"><FONT
face=Arial>newcomer@flounder.com</FONT></A><FONT face=Arial>> =
wrote in
message </FONT><A =
href="news:28qg1455q95opfpr0e2srv7jbg07jtdm4q@4ax.com"><FONT
face=Arial>news:28qg1455q95opfpr0e2srv7jbg07jtdm4q@4ax.com</FONT></A><F=
ONT
face=Arial>...</FONT></DIV><FONT face=Arial>> It depends on the =
mapping mode
you are using. Word works in twips, for example.<BR>> =
Ultiimately, it
deals with pixel roundoff; whatever font size 40 and 41 are round to =
the<BR>>
same pixel count, but 43 is probably one pixel larger. Remember =
the
preview is running at<BR>> a much smaller size and hence the roundoff =
issues
will be more pronounced.<BR>> joe<BR>> <BR>> On Wed, 30 Apr =
2008
12:52:14 +0100, "GC" <</FONT><A href="mailto:gc@freeuk.co.uk"><FONT =
face=Arial>gc@freeuk.co.uk</FONT></A><FONT face=Arial>> =
wrote:<BR>>
<BR>>>Thanks for that Joe. I've now tried using map modes instead =
and it
looks a <BR>>>lot better but I'm back where I started (when I =
simply
scaled the font size) <BR>>>in as much as increasing the font size =
from
say 40 to 41 doesn't result in a <BR>>>bigger preview font. It =
'waits'
until it gets to 43.<BR>>>How can I achieve this? (Microsoft Word =
can do
it!).<BR>>>Greg<BR>>><BR>>><BR>>>"Joseph M. =
Newcomer"
<</FONT><A href="mailto:newcomer@flounder.com"><FONT
face=Arial>newcomer@flounder.com</FONT></A><FONT face=Arial>> =
wrote in
message
<BR>>>news:ltgf14tpus0on0bj51vdb66icckdbcg6ai@4ax.com...<BR>>>=
;>
Essentially, StretchBlt will do just about the worst job you can imagine =
<BR>>>> for this<BR>>>> (actually, it doesn't matter =
what
you're trying to do, StretchBlt will <BR>>>> probably do
it<BR>>>> wrong). I would have simply set the map mode so =
that
the image will fill <BR>>>> the preview<BR>>>> space =
and use
whatever I get. The nice thing about this is that the font
<BR>>>> will be rendered<BR>>>> using the ClearType
best-approximation instead of being uglified by <BR>>>>
StretchBlt.<BR>>>> joe<BR>>>><BR>>>> On Tue, =
29 Apr
2008 15:33:43 +0100, "GC" <</FONT><A =
href="mailto:gc@freeuk.co.uk"><FONT
face=Arial>gc@freeuk.co.uk</FONT></A><FONT face=Arial>>
wrote:<BR>>>><BR>>>>>Hi<BR>>>>>I'm =
getting very
confused with trying to draw a small print preview box.
<BR>>>>>I'm<BR>>>>>trying to draw fonts the =
exact
proportionate size. Because I can't show<BR>>>>>fractional =
font
sizes on screen, I'm trying to draw it into a memory
DC<BR>>>>>(quite big?) then StretchBlt it down onto my =
box (I
don't mind if it's a<BR>>>>>bit pixelly as long as it's in
proportion).<BR>>>>>This code works after a fashion but what =
do my
values need to be? Do I <BR>>>>>need<BR>>>>>to =
set the
map mode to a higher value? It comes about 1/3 =
size.<BR>>>>>Thanks
for any advice,<BR>>>>>Greg
Chapman<BR>>>>><BR>>>>>void
CA4Page::OnPaint()<BR>>>>>{<BR>>>>> CPaintDC
dc(this);<BR>>>>> CDC memDC;<BR>>>>>
memDC.CreateCompatibleDC(&dc);<BR>>>>> // ???
memDC.SetMapMode(MM_HIMETRIC);<BR>>>>> int deviceRes =
memDC.GetDeviceCaps(LOGPIXELSY);<BR>>>>><BR>>>>>&=
nbsp;
CRect rect;<BR>>>>>
this->GetClientRect(&rect);<BR>>>>> // this is =
roughly 210 x
297 ie a mm to a pixel<BR>>>>><BR>>>>> CRect
memRect(0,0, 2100, 2970);<BR>>>>> // nice big one for best
resolution?<BR>>>>><BR>>>>> CBitmap
bmp;<BR>>>>> bmp.CreateCompatibleBitmap(&memDC, =
memRect.Width(),
memRect.Height());<BR>>>>>
memDC.SelectObject(&bmp);<BR>>>>><BR>>>>> =
LOGFONT
fontStruct;<BR>>>>> // this fills out the =
struct<BR>>>>>
Utilities::FillFontStruct("Times New Roman", 0, 0, 4,
fontStruct);<BR>>>>><BR>>>>> CString str("Hello
World");<BR>>>>><BR>>>>> CFont =
font;<BR>>>>>
int pointSize = 60;<BR>>>>><BR>>>>> =
fontStruct.lfHeight
= (int)-MulDiv(pointSize, deviceRes, 72);<BR>>>>>
font.CreateFontIndirect(&fontStruct);<BR>>>>>
memDC.SelectObject(&font);<BR>>>>> memDC.DrawText(str, =
memRect,
0);<BR>>>>><BR>>>>> dc.StretchBlt(rect.left, =
rect.top,
rect.Width(),
rect.Height(),<BR>>>>> &nb=
sp;
&memDC, 0, 0, memRect.Width(),
memRect.Height(),<BR>>>>> =
SRCCOPY);<BR>>>>>}<BR>>>>><BR></FONT></BODY></HTM=
L>
------=_NextPart_000_0015_01C8AADA.7A9C3870--