Board index » delphi » Newbie: Justification of text using canvas.textout?
des...@nexus.interealm.com (David Montgomery)
![]() Delphi Developer |
Tue, 28 Jul 1998 03:00:00 GMT
|
des...@nexus.interealm.com (David Montgomery)
![]() Delphi Developer |
Tue, 28 Jul 1998 03:00:00 GMT
Newbie: Justification of text using canvas.textout?
This seems like it should be an easy thing to do, but I want to be able to
right and left justify lines of text I send to the printer using Canvas.TextOut. I know I can measure the width of the string I am printing, but I can't figure out how to dynamically add spaces to the line to line the text up on the right and left. Am I going about this the wrong way? I definitely don't want to use a Thanks, David Montgomery |
Greyja
![]() Delphi Developer |
Tue, 28 Jul 1998 03:00:00 GMT
Re:Newbie: Justification of text using canvas.textout?Quotedes...@nexus.interealm.com (David Montgomery) wrote: your justification questions, here's a few lines of code to right-justify a string, FWIW: function Spaces(n : byte) : string; ... function RightJustified(var S : string; Width : byte) : string; ... const begin --- |
Jochen Heyla
![]() Delphi Developer |
Wed, 29 Jul 1998 03:00:00 GMT
Re:Newbie: Justification of text using canvas.textout?In article <4fe6t1$...@spieg.interealm.com>, des...@nexus.interealm.com (David Montgomery) says: Quote
you have several options: 1.What you seem to want to do: Add spaces in a loop, testing for the new width, until the string is where you want it to be. Ok, but not receommended. 2.Once you have the width, adjust the x coordinate s.t. x+width is at the right edge. This should be easy. Good luck! Jochen ________________________________________________________________________ |
Jim Wal
![]() Delphi Developer |
Thu, 30 Jul 1998 03:00:00 GMT
Re:Newbie: Justification of text using canvas.textout?Don't think in terms of adding spaces to the text! If the width of your print area is 6 inches, and you wanted to right justify text that was 4 inches wide, shouldn't you just start printing the line two inches (6 - 4 = 2) from the left side? var begin In article <4fe6t1$...@spieg.interealm.com>, Quote>This seems like it should be an easy thing to do, but I want to be able to |
Bengt Richt
![]() Delphi Developer |
Thu, 30 Jul 1998 03:00:00 GMT
Re:Newbie: Justification of text using canvas.textout?Quote>des...@nexus.interealm.com (David Montgomery) wrote: the x,y position, so as to avoid the problem of how many extra space characters to insert where. If you do extra-space and x position calculations in floating point, and use Round(floatingX) in the textout, you will be within 1/2 pixel. You'll have to decide whether to measure and preserve original You might want to put extra space after periods that precede space If you are not already doing so, you may want to operate on Quote>>Am I going about this the wrong way? I definitely don't want to use a a paragraph shouldn't be much harder than describing it in detail. I'm sure this wheel has been re-invented regularly. If you find HTH. |
Mike Mill
![]() Delphi Developer |
Sat, 01 Aug 1998 03:00:00 GMT
Re:Newbie: Justification of text using canvas.textout?Quotedes...@nexus.interealm.com (David Montgomery) wrote: Anyhow, it as a program in it to do just what you want. You can use it as info to do all kinds of justification by doing pixel offsets(which is the correct way), setting up columns and so on. You can also turn it into a unit to make a pretty good text formating and printing system. Mike Miller |
David Montgome
![]() Delphi Developer |
Mon, 03 Aug 1998 03:00:00 GMT
Re:Newbie: Justification of text using canvas.textout?QuoteIn article <1996Feb13.153016.27...@nosc.mil>, mille...@hqamc.safb.af.mil (Mike Miller) wrote: close, but with no luck. Do you happen to know the author's name, or anything else that could help me find it? Thanks, David |
1. Newbie: Justification of text using the printer object
2. How to write text with transparent background on a canvas with TextOut()
3. Rotate text with ...Canvas->TextOut
4. Xylol - Printing RichEdit using Canvas.TextOut
5. Using TImage.Canvas.textout Help Please
6. Transparent Font Color in canvas using TextOut
7. Limit to the number of Canvas.Textout statements available per Printer.Canvas
8. How to edit text on TImage while using Textout