Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Line spacing with CDC::DrawText(..), how??

310 views
Skip to first unread message

Telia

unread,
Jul 12, 2000, 3:00:00 AM7/12/00
to
I want to change the inter-line spacing when doing some explicit printing on
a prepressed paper.
How can I inc/dec the spacing, CDC has no support, neither has CFont.

Can someone please enlighten me, I've seached the help for hours now!!

/Mikael Grev, Uppsala Sweden, gr...@telia.com

Mikael Grev

unread,
Jul 12, 2000, 3:00:00 AM7/12/00
to
Update: I mean CDC:TextOut of course..

"Telia" <gr...@telia.com> wrote in message
news:mT5b5.659$652....@newsc.telia.net...

Feng Yuan

unread,
Jul 12, 2000, 3:00:00 AM7/12/00
to
You were right. It's not supported by DrawText, or even DrawTextEx.

But, why using DrawText, especially for printing. DrawText/DrawTextEx
are simple-minded text formating function designed for simple UI text
displaying. Implement your own solution, which should be device
resolution independent in text formating, or read my coming book.

Feng Yuan

www.phptr.com/ptrbooks/ptr_0130869856.html

David Wilkinson

unread,
Jul 12, 2000, 3:00:00 AM7/12/00
to

Telia:

I'm not sure I understand your question. DrawText() takes a LPRECT
argument (aka CRect*). For each line you can move the rectangle down:

rect+=CPoint(0, nSpacing);

By changing the value of nSpacing, you change the spacing. Of course
nSpacing is not the spacing, it is the distance between the tops of
successive lines. but you get the idea.

HTH,

David Wilkinson

===============

Joseph M. Newcomer

unread,
Jul 12, 2000, 3:00:00 AM7/12/00
to
The spacing is determined by what code you write to do the printing.
Since you get to write the code, you get to define the spacing. You
can print stuff anywhere you want on the page. Just compute the
coordinates and do a TextOut. CDC and CFont have "no support" because
there is no reason to have any such support; neither CDC nor CFont (at
least directly) have anything to do with line spacing. Generally, for
ordinary printing, you often use the CFont height to compute the line
spacing, but you can use any other means of computing it that you feel
like.
joe

On Wed, 12 Jul 2000 21:59:46 GMT, "Telia" <gr...@telia.com> wrote:

>I want to change the inter-line spacing when doing some explicit printing on
>a prepressed paper.
>How can I inc/dec the spacing, CDC has no support, neither has CFont.
>
>Can someone please enlighten me, I've seached the help for hours now!!
>
>/Mikael Grev, Uppsala Sweden, gr...@telia.com
>

Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www3.pgh.net/~newcomer
MVP Tips: http://www3.pgh.net/~newcomer/mvp_tips.htm

Feng Yuan

unread,
Jul 13, 2000, 3:00:00 AM7/13/00
to
Actually, I think it's possible to use DrawText and control line height,
with extra code.

Feng Yuan

Telia

unread,
Jul 13, 2000, 3:00:00 AM7/13/00
to
Thanks for all the answers!

I think wasn't that clear of what I exactly meant.

I'm using just one call to:

CDC::DrawText(text, CRect(the whole page), DT_WORDBREAK)

to make MFC write over several lines. Some lines are to be wrapped and some
just ends with /r/n, hence a new line. The text can be a whole letter (or
A4).
I thought maybe there was a way to specify the "inter_line spacing" since it
whould've been so simple for Msoft to implement in the DrawText method. But
I seem to be out of luck, I guess writing my own linebreaker is the way to
go!?

/Mikael Grev, Sweden


"Telia" <gr...@telia.com> wrote in message
news:mT5b5.659$652....@newsc.telia.net...

Dan Cernat

unread,
Jul 13, 2000, 3:00:00 AM7/13/00
to
Have a look at LOGFONT structure and CFont::CreateFontIndirect. I didn't try
it but I think you ca use this. Modify the lfHeight member of LOGFONT
without modifying the lfWidth member. You man need to use negative values
for lfHeight. Once again, take a look at LOGFONT and lfHeight.
CFont::CreateFontIndirect creates a CFont from a LOGFONT structure.

Dan

Telia <gr...@telia.com> wrote in message

news:nTib5.714$652....@newsc.telia.net...

Telia

unread,
Jul 13, 2000, 3:00:00 AM7/13/00
to
Thanks for your suggestion!

However this only changed the Fonts size, not the spacing between the lines.

/Mikael Grev, Sweden

"Dan Cernat" <dce...@pqria.com> wrote in message
news:Ycjb5.27974$qS3....@tor-nn1.netcom.ca...

Joseph M. Newcomer

unread,
Jul 13, 2000, 3:00:00 AM7/13/00
to
Well, that's the problem. The line wrapping makes some naive
assumptions about what you intend. If you intend something else, you
can't use the technique you are using; you have to write the lines
yourself. Note that changing parameters such as tmHeight can have no
effect on the font.
joe

On Thu, 13 Jul 2000 12:47:15 GMT, "Telia" <gr...@telia.com> wrote:

>Thanks for all the answers!
>
>I think wasn't that clear of what I exactly meant.
>
>I'm using just one call to:
>
>CDC::DrawText(text, CRect(the whole page), DT_WORDBREAK)
>
>to make MFC write over several lines. Some lines are to be wrapped and some
>just ends with /r/n, hence a new line. The text can be a whole letter (or
>A4).
>I thought maybe there was a way to specify the "inter_line spacing" since it
>whould've been so simple for Msoft to implement in the DrawText method. But
>I seem to be out of luck, I guess writing my own linebreaker is the way to
>go!?
>
>/Mikael Grev, Sweden
>
>
>"Telia" <gr...@telia.com> wrote in message
>news:mT5b5.659$652....@newsc.telia.net...
>> I want to change the inter-line spacing when doing some explicit printing
>on
>> a prepressed paper.
>> How can I inc/dec the spacing, CDC has no support, neither has CFont.
>>
>> Can someone please enlighten me, I've seached the help for hours now!!
>>
>> /Mikael Grev, Uppsala Sweden, gr...@telia.com
>>
>>
>

Joseph M. Newcomer [MVP]

Richard L. Chen

unread,
Jul 15, 2000, 3:00:00 AM7/15/00
to
I think that the currently selected font would determine the line space in
DrawText. If you have specified DT_EXTERNALLEADING in the nFormat
parameter, the height of the line includes external leading part of the
font. So, before calling DrawText, select your preferred font.

rlc


Telia <gr...@telia.com> wrote in message

news:LZjb5.720$652....@newsc.telia.net...


> Thanks for your suggestion!
>
> However this only changed the Fonts size, not the spacing between the
lines.
>
> /Mikael Grev, Sweden
>
> "Dan Cernat" <dce...@pqria.com> wrote in message
> news:Ycjb5.27974$qS3....@tor-nn1.netcom.ca...
> > Have a look at LOGFONT structure and CFont::CreateFontIndirect. I didn't
> try
> > it but I think you ca use this. Modify the lfHeight member of LOGFONT
> > without modifying the lfWidth member. You man need to use negative
values
> > for lfHeight. Once again, take a look at LOGFONT and lfHeight.
> > CFont::CreateFontIndirect creates a CFont from a LOGFONT structure.
> >
> > Dan
> >

> > Telia <gr...@telia.com> wrote in message

> > news:nTib5.714$652....@newsc.telia.net...

0 new messages