[comp.windows.ms.programmer] Lining up rows and columns of characters

jdb@reef.cis.ufl.edu (Brian K. W. Hook) (03/22/91)

A program that I am writing lets you create a special kind of diagram that
is very maze like but everything is described using a letter...e.g.

AAAAAACAAAABBBBB
AAAACCCAAAABAAAB
AAAACAAAAAABBABB
AAAAAAAAAABBBBAA

Now, the problem is that when I do a TextOut or a DrawText, the letters do
not align themselves correctly vertically because of the fonts.  This
becoming a very important issue...is there a way to make the characters
line up (assign 8x8 bit maps to everything?)....

Anything to solve this problem would be appreciated,

Brian

curt@cctb.wa.com (Curt Johnson) (03/23/91)

In article <27561@uflorida.cis.ufl.EDU> jdb@reef.cis.ufl.edu (Brian K. W. Hook) writes:
| Now, the problem is that when I do a TextOut or a DrawText, the letters do
| not align themselves correctly vertically because of the fonts.  This
| becoming a very important issue...is there a way to make the characters
| line up (assign 8x8 bit maps to everything?)....

You want to use a font with fixed spacing.

Try:

SelectObject(hdc, GetStockObject(OEM_FIXED_FONT)); // or SYSTEM_FIXED_FONT or ANSI_FIXED_FONT

For more information, see the Petzold book, pages 654-655.


Curt Johnson == curt@cctb.wa.com

LIBCRN@BYUVM.BITNET (03/25/91)

In article <27561@uflorida.cis.ufl.EDU> jdb@reef.cis.ufl.edu (Brian K. W. Hook)
writes:
>| Now, the problem is that when I do a TextOut or a DrawText, the letters do
>| not align themselves correctly vertically because of the fonts.  This
>| becoming a very important issue...is there a way to make the characters
>| line up (assign 8x8 bit maps to everything?)....

>You want to use a font with fixed spacing.

>Try:

>SelectObject(hdc, GetStockObject(OEM_FIXED_FONT)); // or SYSTEM_FIXED_FONT or
>ANSI_FIXED_FONT

>For more information, see the Petzold book, pages 654-655.

>Curt Johnson == curt@cctb.wa.com

   There is another solution.  Instead of using a fixed font, split your
output strings into a number of fields (each collumn should be a seperate
field).  Then when you draw the string on the screen, instead of calling
TextOut() once for the entire string, you call it a number of times (as
many times as you have collumns).  Each time that you call TextOut(), you
supply it with the part of the output string which corresponds with the
collumn you are drawing at that time.  It takes a little more work, but if
you do it this way, you can still use proportional fonts instead of those
ugly fixed fonts.

--Cory (libcrn@byuvm.bitnet)

curt@cctb.wa.com (Curt Johnson) (03/29/91)

In article <91084.073252LIBCRN@BYUVM.BITNET> LIBCRN@BYUVM.BITNET writes:
| In article <27561@uflorida.cis.ufl.EDU> jdb@reef.cis.ufl.edu (Brian K. W. Hook)
| writes:
| >| Now, the problem is that when I do a TextOut or a DrawText, the letters do
| >| not align themselves correctly vertically because of the fonts.  This
| >| becoming a very important issue...is there a way to make the characters
| >| line up (assign 8x8 bit maps to everything?)....
| 
| >You want to use a font with fixed spacing.
| 
|    There is another solution.  Instead of using a fixed font, split your
| output strings into a number of fields (each collumn should be a seperate
| field).  Then when you draw the string on the screen, instead of calling
| TextOut() once for the entire string, you call it a number of times (as
| many times as you have collumns).  Each time that you call TextOut(), you
| supply it with the part of the output string which corresponds with the
| collumn you are drawing at that time.  It takes a little more work, but if
| you do it this way, you can still use proportional fonts instead of those
| ugly fixed fonts.

If I remember correctly, the specific problem Brian was solve was printing
a two-dimensional map of something using characters (i.e. each column is
one character wide).  For a case like this I think the visual appearance of
the fixed fonts is fine.

Curt Johnson == curt@cctb.wa.com