[comp.sys.amiga.programmer] Here's an EASY one Char Set Interp

v089pfrb@ubvmsd.cc.buffalo.edu (Jeffrey C Murphy) (04/15/91)

In article <18fa0585.ARN1913@prolix.pub.uu.oz.au>, dac@prolix.pub.uu.oz.au (Andrew Clayton) writes...
>In article <1097@cbmger.UUCP>, Peter Kittel GERMANY writes:

[much deleting]

>Harking back to my original question; there are bitmaps for each character in
>a font, available [somehow] via pointers to structures in the font.  I need to

[much more deleting]

>format, I pass a string to my program, and it uses the character passed as a
>jump into the font structure, and then I examine what bitmap is available, and

[and even some more deleting]

 Ok. If I understand you correctly you are looking for a pointer to where the
font bitmaps are stored. Ok? When you call OpenFont() or OpenDiskFont() they
will return a pointer to a TextFont structure containing info on the font
(or a null if it could not locate the font). The TextFont structure looks like
this:

struct TextFont {
   struct Node TextNode;
   struct Message tf_Message
   UWORD tf_YSize;
   UBYTE tf_Style;
   UBYTE tf_Flags;
   UWORD tf_XSize;
   UWORD tf_Baseline;
   UWORD tf_BoldSmear;
   UWORD tf_Accessors;
   UBYTE tf_LoChar;
   UBYTE tf_HiChar;
   APTR tf_CharData;
   UWORD tf_Modulo;
   APTR tf_CharLoc;
   APTR tf_CharSpace;
   APTR tf_CharKern;
};


 Ok. "tf_CharData" contains a pointer to the memory location where the 
bitmap for the font is kept. Figuring out how it is stored is another matter.
From "Amiga Programmer's Handbook" (an old book I know...) page 309:
[paraphrased kindof to cut down on typing :) ]

  tf_Modulo. This param contains the number of bytes per font character line.
  The bit data for each font are organized with the bits of the top line of the 
  first character adjacent to the bits of the top line of the second character.
  This param tells the system where to find the info for the next line of a
  character. For example, if the bit-packed character set needs 20 words
  of 16 bits each to hold the top line of all characters in the set, then
  tf_Modulo is set to 40. The system must add 40 to the character matrix pointer
  to go from the first line to the second to the third... etc... for each 
  character. 

  tf_CharLoc. This is a pointer to a memory location where an array of paired
  values exists for each character in the font. The array is arranged in two-
  word sets; the first is the bit offset into the bitpacked array for this 
  character, and the second word is the width of the specific character in 
  bits.

 So you have to set up a textAttr structure and call Open(Disk)Font() with
a pointer to this structure. Then, in return, you get a pointer to the 
TextFont structure which you use to access the font's bitmap. 
 Hope this answered your original question.

l8r
jm  

dac@prolix.pub.uu.oz.au (Andrew Clayton) (04/15/91)

In article <70793@eerie.acsu.Buffalo.EDU>, Jeffrey C Murphy writes:

> In article <18fa0585.ARN1913@prolix.pub.uu.oz.au>, dac@prolix.pub.uu.oz.au (Andrew Clayton) writes...

> >Harking back to my original question; there are bitmaps for each character in
> >a font, available [somehow] via pointers to structures in the font.  I need to
> 
> >format, I pass a string to my program, and it uses the character passed as a
> >jump into the font structure, and then I examine what bitmap is available, and
> 
>  Ok. If I understand you correctly you are looking for a pointer to where the
> font bitmaps are stored. Ok? When you call OpenFont() or OpenDiskFont() they
> will return a pointer to a TextFont structure containing info on the font
> (or a null if it could not locate the font). The TextFont structure looks like
> this:

Yep.  I pored over the (1.1) Rom Kernal Reference Manual, and found out all
about tf_Chardata and tf_Charloc. Getting hold of these with Arexx is proving
to be a headache.

What I _really_ want to do, is go to the Rastport to find the window I'm
using, and then use that's copy of the textfont pointer to leap into the
textfont structure, then I can do fancy fonts and be able to enlarge those
with no extra effort, if you see what I mean.

[Textfont structure deleted]

And thankyou for including that. I can get Arexx to tell me the address of
FONTS [say c2x(Showlist('a',FONTS,A))], and using that address, I can use
IMPORT to look at memory.

The 'clue' that I needed was the existence of the 'IMPORT' command in Arexx; I
pored over the manual, page by page, looking for something to READ MEMORY. It
took me a while to find it. :-(

[interesting bits about Charloc and tf_Modulo deleted]

>  So you have to set up a textAttr structure and call Open(Disk)Font() with
> a pointer to this structure. Then, in return, you get a pointer to the 
> TextFont structure which you use to access the font's bitmap. 

Yes, that makes sense. 

I think I'll throw away the Arexx idea, and us a language that understands
structures [in other words, I'll cheat and use Modula 2, which has all the
include files defined already - I would have liked to do it in Arexx though.
Sigh.]

>  Hope this answered your original question.

If it had come one day earlier, it would have saved me a lot more time.
Thankyou very much for your explanation, it was exactly what I wanted. 

> jm  

Dac
--