[comp.sys.amiga.tech] Urgent Font Questions

ofer@bach.Berkeley.EDU (Jonathan Dubman) (07/25/88)

I have to finish a quick & dirty font program in the next few days.  The
program has to pick out certain characters from an existing font in a certain
order and save them under a new name.

1.	How do I write out a font file given the TextFont structure in memory?
	Say I change around a few characters in Diamond and want to resave the
	font on disk...  It begins with a 3F3 which means it is some kind of
	load module?  No comprendo.

2.	What is the difference between XSize and charBitWidth?

3.	What do CharSpace and CharKern REALLY mean?  Given a certain
	charBitWidth and CharSpace CharKern,
		(a) how many bits are stored in the bitmap?
		(b) how many bits are displayed?

Your help is GREATLY appreciated. 

	-Jonathan Dubman
	 Overworked UC Berkeley student

hutch@net1.ucsd.edu (Jim Hutchison) (08/03/88)

<25204@ucbvax.BERKELEY.EDU> ofer@bach.Berkeley.EDU (Jonathan Dubman) writes:
>[...]  The
>program has to pick out certain characters from an existing font in a certain
>order and save them under a new name.

Basicly you are making a new font from an old one.  A couple of notables
for you.  first, fonts are loadable hunks.  Second, I still don't fully
understand them.  I have gone this route to convert some fonts I desperately
needed to generate from an alternate form.  Since both the original form
and names are copyrighted, let that end here.

>1.	How do I write out a font file given the TextFont structure in memory?
>	Say I change around a few characters in Diamond and want to resave the
>	font on disk...  It begins with a 3F3 which means it is some kind of
>	load module?  No comprendo.

Name.font is a header with a font count followed by headers for each font.

Rows in the font data are long word aligned.

There is a hunk header, and a hunk trailer (which contains relocation
information).

>2.	What is the difference between XSize and charBitWidth?

XSize is the maximum size.  In the case of a proportional font, this
is what you get when you ask for it in the default fixed type.  The
bit width is the width of the character in the bitmap.  Characters
are located by CharLoc (bit offset) and set are "charBitWidth" wide.

>3.	What do CharSpace and CharKern REALLY mean?  Given a certain
>	charBitWidth and CharSpace CharKern,
>		(a) how many bits are stored in the bitmap?
>		(b) how many bits are displayed?

CharKern is supposedly (RKM) how far into the text block the character
starts.  This is not real kerning, no gentle reaching of the A under
the B (BA).  It is proportional spacing (which is very nice).  CharSpace
is for space from the front of the letter block.  CharSpace is a mystery
to me.

Special note, you may not immediately be aware of this.  The bitmaps are
stored scanline fashion.  With the first row of the bitmap being the
first row of *all* of the glyphs.  Holy character generators Batman!

Here comes the painful part.  With 25+ pixel hi fonts, I had to add a
few extra dead rows to the font data.  I don't know why.  I saw some
evidence of this in the sample font, so I tried it.  At 25 it was 2
extra rows, this worked also for up to 40.  At 60 I had problems again.

Where am I going wrong.

>	-Jonathan Dubman
>	 Overworked UC Berkeley student

Student?  Is that why I'm working so hard.  D*mn, I guess I'd
better graduate.

Hope this helps.

/*    Jim Hutchison   		UUCP:	{dcdwest,ucbvax}!cs!net1!hutch
		    		ARPA:	JHutchison@ucsd.edu		*/

kodiak@amiga.UUCP (Robert R. Burns) (08/08/88)

In article <1076@ucsd.EDU> hutch@net1.UUCP (Jim Hutchison) writes:
)>25204@ucbvax.BERKELEY.EDU> ofer@bach.Berkeley.EDU (Jonathan Dubman) writes:

...

First, some general comments

Fonts are amiga load files that, when loaded, look like the diskfont
structure described in include/libraries/diskfont.h.  That structure
is in essence a header in front of the text font structure described
in include/graphics/text.h

)Name.font is a header with a font count followed by headers for each font.

Again, see .../diskfont.h.  Workbench 1.3 (RSN) has a tool FixFonts to create
these font contents files.

)Rows in the font data are long word aligned.

Just word aligned.

)There is a hunk header, and a hunk trailer (which contains relocation
)information).

(the relocation information for all the pointers in the font structure)

)>2.	What is the difference between XSize and charBitWidth?
)
)XSize is the maximum size.

No.  XSize is the nominal size.  For non-proprotional fonts, is the same as
the kern+space for every character.  Note that a recent (1.3 "Courier")
clarification of the meaning of "non-proportional" lets dots be rendered
outside the XSize-wide character cell.

)                            In the case of a proportional font, this
)is what you get when you ask for it in the default fixed type.

Huh?  Gibberish.

)                                                                The
)bit width is the width of the character in the bitmap.  Characters
)are located by CharLoc (bit offset) and set are "charBitWidth" wide.

i.e. the width of the bits set for the character in the bitmap.
See below.
    
)
)>3.	What do CharSpace and CharKern REALLY mean?  Given a certain
)>	charBitWidth and CharSpace CharKern,
)>		(a) how many bits are stored in the bitmap?
)>		(b) how many bits are displayed?
)
)CharKern is supposedly (RKM) how far into the text block the character
)starts.

See below.

)         This is not real kerning, no gentle reaching of the A under
)the B (BA).
                      ^^^^

It's not "character pair" kerning.  A "kern" is the little piece of lead
that hangs outside the type.  Amiga fonts can do that with pixels.  They
just don't do it according to their neighbors.

)             It is proportional spacing (which is very nice).

No, proportional spacing poorly describes the CharKern facility.
The effect of CharSpace might be viewed as the proportional space part,
but really CharKern and CharSpace might be best viewed as CharKernSpaceLeft,
and CharKernSpaceRight.  See below.

)is for space from the front of the letter block.  CharSpace is a mystery
)to me.

Here's the "below".  The characters are from garnet/16

---------------------------------
character bits stored in the font
---------------------------------

	         @@@
	@@@@@@  @                @@       @@
	  @@   @@               @ @@     @ 
	  @@   @@                  @@   @
	  @@   @@                   @@ @
	  @@   @@                    @@
	  @@   @@                    @@@
	  @@   @@                   @  @@
	  @@   @                   @    @@ @
	@@@@@@@@@@@               @      @@
	           @@@           @
	              @@@    @@@@
	                 @@@@

	<----><--------------><-------------->    

charloc 0,6,  6,16,           22,16	"location and width of dots"
kern	0,    1,              -2	"add to CP before placing dots"
space   7,    13,             15	"add to above result to get new CP"

Note that in this example, as in real life, the characters need not be stored
in the strike font in any particular order.

-------------------------------
how each character would render
-------------------------------


	    @@@       
	   @          @@@@@@  @@       @@
	  @@            @@   @ @@     @
	  @@            @@      @@   @
	  @@            @@       @@ @
	  @@            @@        @@
	  @@            @@        @@@
	  @@            @@       @  @@
	  @             @@      @    @@ @
	 @@@@@        @@@@@@   @      @@
	      @@@             @
	         @@@    @ @@@@
	            @@@@

	+<------------+-> <------------->+
	1	      <---->+            2
	33                333

    1. graphics current position before rendering characters
    2. graphics current position after rendering the characters
    +. intermediate positions


)Here comes the painful part.  With 25+ pixel hi fonts, I had to add a
)few extra dead rows to the font data.  I don't know why.  I saw some
)evidence of this in the sample font, so I tried it.  At 25 it was 2
)extra rows, this worked also for up to 40.  At 60 I had problems again.
    
I'm not familiar with this problem.  It does not appear in fonts I've
worked with.

Hope this all helps.
-- 
| / _  _|' _ |/    Bob Burns               .  .    . . .---.  .
|/ (_)(_)|(_\|\    USENET: amiga!kodiak   / \ |\  /| | | __  / \
|\   Kodiak    \                  _______/ A \| \/ |_|_|___|/ A \
| \ Software                    "Dedicated to the Science of Fun"\_________