🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: adobe.postscript.programming
7 messages
7 total messages Started by jdaw1 Thu, 13 Nov 2008 05:28
Auto-kerning
#120
Author: jdaw1
Date: Thu, 13 Nov 2008 05:28
6 lines
1550 bytes
A PostScript program being written will need to show some text, quite
large, in Times Bold, some of it in all CAPITALS. The text should be
kerned—especially sequences like “WAY”. But I have no font metrics
files; no pre-computed kerning pairs. Is there any way to have the
PostScript do the kerning automatically? Please, is there any public
code or data that can be fed to kshow?
Re: Auto-kerning
#121
Author: Jeffrey H. Coffield
Date: Thu, 13 Nov 2008 15:26
16 lines
1957 bytes

jdaw1 wrote:
> A PostScript program being written will need to show some text, quite
> large, in Times Bold, some of it in all CAPITALS. The text should be
> kerned�especially sequences like �WAY�. But I have no font metrics
> files; no pre-computed kerning pairs. Is there any way to have the
> PostScript do the kerning automatically? Please, is there any public
> code or data that can be fed to kshow?

Here is one public source for the kern table. How you get that to kshow
would take a little time.

http://ctan.binkerton.com/macros/text1/compugraphics_8600/etb.fontinfo

Jeff Coffield
Re: Auto-kerning
#122
Author: jdaw1
Date: Thu, 13 Nov 2008 22:46
8 lines
1548 bytes
> Here is one public source for the kern table.
>
> http://ctan.binkerton.com/macros/text1/compugraphics_8600/etb.fontinfo

Wow, thank you. Do you know in what units are the kerning? That is,
the line
> kern W+A -54/10
means I kern by -5.4 points at what point size?
Re: Auto-kerning
#124
Author: Jeffrey H. Coffield
Date: Fri, 14 Nov 2008 02:33
19 lines
2131 bytes

jdaw1 wrote:
>> Here is one public source for the kern table.
>>
>> http://ctan.binkerton.com/macros/text1/compugraphics_8600/etb.fontinfo
> 
> Wow, thank you. Do you know in what units are the kerning? That is,
> the line
>> kern W+A -54/10
> means I kern by -5.4 points at what point size?

There are references to a 100 unit coordinate system in some kern tables
so (-54/10)/100*font-size seems to work. I seems odd the me on closer
inspection of the above fontinfo file that all the entries are +54/n or
-54/n. I did a little more digging to see if I could find another kern
table to compare to but nothing jumped out at me.

Jeff.
Re: Auto-kerning
#125
Author: Jeffrey H. Coffield
Date: Fri, 14 Nov 2008 02:45
34 lines
2551 bytes

jdaw1 wrote:
>> Here is one public source for the kern table.
>>
>> http://ctan.binkerton.com/macros/text1/compugraphics_8600/etb.fontinfo
> 
> Wow, thank you. Do you know in what units are the kerning? That is,
> the line
>> kern W+A -54/10
> means I kern by -5.4 points at what point size?

On digging deeper (you got me curious) I realized that what you need is
the .afm (Adobe Font Metric) file. Putting that into Google leads to this:

http://github.com/sandal/prawn/tree/57cbf8cdb7df0108c7a8d0499937844d07ee4a26/data/fonts/Times-Bold.afm

The relevant entry here is KPX W A -120. This is in a 1000 unit
coordinate space like the rest of the font info so for a 100 point font
I get -120/1000 * 100 = -12.

This piece of postscript looks pretty good to me:

/Times-Bold 100 selectfont
100 100 moveto
{= = -12.0 0 rmoveto} (WA) kshow
showpage

Obviously some work would need to be done to convert the info in the
.afm file into what kshow needs. (I do Postscript on a contract
programming basis.)

Jeff Coffield
www.digitalsynergyinc.com
Re: Auto-kerning
#126
Author: jdaw1
Date: Fri, 14 Nov 2008 03:38
4 lines
1572 bytes
Several people on this group have provided help that is fast, accurate
and friendly. Please include yourself in that set. Thank you.

Next: faffing with encodings to convert 65 to /A.
Re: Auto-kerning
#127
Author: jdaw1
Date: Mon, 17 Nov 2008 03:21
175 lines
6411 bytes
Thank you for your help. Much of my PostScript code handles that which
I call a compound string, this being any of:
-- A string;
-- The name of a glyph;
-- Any array of compound objects;
-- Code that does any of:
-- -- Leave on the stack ≥0 compound objects;
-- -- Move the currentpoint by a distance proportional to
CurrentFontSize (e.g., for kerning or superscripting);
-- -- Change the typeface (probably with selectfont), the size of the
new typeface being proportional to CurrentFontSize;
-- -- Change the current colour (usually with setgray or setrgbcolor);
-- -- Generate the path of a shape (without calling newpath or making
any changes to the clipping path), the shape's position being
determined by the currentpoint, and its size being proportional to
CurrentFontSize;
-- -- Optionally paint said shape with an unbinded call to any of
fill, eofill, stroke, ufill, ueofill, shfill.

Next define a KernTriples array to be an array, of length an integer
multiple of 3, resembling
[
/A /C -55
/A /Cacute -55
...
]
and set AdobeFontMetrics-TimesBold to the kerning data  above for
Times-Bold.

Then, with the definitions below and  and the kerning list in posts
above,
  [(Ch) /acircumflex (teau L) /eacute (oville-Barton)]
  dup == AdobeFontMetrics-TimesBold exch InsertKernCode ==
outputs
  [(Ch) /acircumflex (teau L) /eacute (oville-Barton)]
  [(Ch) /acircumflex (teau L) /eacute (o) {-10 CurrentFontSize mul
1000 div 0 rmoveto} (ville-Barton)]





% [KernTriples] CompoundString  InsertKernCode  NewCompoundString
/InsertKernCode
{
	1 dict begin
	/MostRecentGlyph /Null def
	1 InsertKernCodeRec
	end
} bind def  % InsertKernCode

% [KernTriples] CompoundString NoExecDepth  InsertKernCodeRec
NewCompoundString
/InsertKernCodeRec
{
	4 dict begin
	/NoExecDepth exch def
	/param exch def
	/KernTriples exch def

	% Glyph|Int Glyph|Int  KernAmount  Number
	/KernAmount
	{
		3 dict begin
		/Glyph1 exch def
		/Glyph0 exch def
		Glyph1 type /integertype eq {/Glyph1 ThisEncoding Glyph1 get def} if
		Glyph0 type /integertype eq {/Glyph0 ThisEncoding Glyph0 get def} if
		0
		0  3  KernTriples length 1 sub
		{
			/kt exch def
			Glyph0 KernTriples kt get eq
			{
				Glyph1 KernTriples kt 1 add get eq
				{
					pop
					KernTriples kt 2 add get
					exit
				} if  % Glyph1 KernTriples kt 1 add get eq
			} if  % Glyph0 KernTriples kt get eq
		} for  % KernTriples
		end
	} def  % KernAmount

	[ /param load  NoExecDepth  InsertKernCodeRecRec ]
	dup length 1 eq {0 get} if
	end
} def  % InsertKernCodeRec

/InsertKernCodeRecRec
{
	3 dict begin
	/NoExecDepth exch def
	/param exch def
	/ThisEncoding currentfont /Encoding get def  % redone here in case
code changes currentfont
	/param load xcheck
	{
		NoExecDepth 0 gt
		{
			{  1 dict begin /MostRecentGlyph /MostRecentGlyph def KernTriples  /
param  /NoExecDepth  InsertKernCodeRec end }
			%  0   1    2          3                4          5
6          7          8                9         10
			dup length array copy cvx
			dup  4  MostRecentGlyph  put
			dup  6  KernTriples  put
			dup  7  /param load  put  % replace /param with its current value,
a not-quite // operation
			dup  8  NoExecDepth 1 sub  put
		}
		{
			[ /param load execU ]  0  InsertKernCodeRecRec
		} ifelse  % NoExecDepth 0 gt
	}
	{
	param type /stringtype eq
	{
		MostRecentGlyph /Null ne
		{
			MostRecentGlyph  param 0 get  KernAmount
			dup 0 eq {pop}
			{
				{/KernAmount CurrentFontSize mul 1000 div 0 rmoveto}
				dup length array copy cvx
				dup  0  4 -1 roll  put
			} ifelse  % ... KernAmount ... 0 eq
		} if  % MostRecentGlyph /Null ne
		/ThisPieceStart 0 def
		0  1  param length 2 sub
		{
			/i exch def
			param i get  param i 1 add get  KernAmount
			dup 0 eq {pop}
			{
				{/KernAmount CurrentFontSize mul 1000 div 0 rmoveto}
				dup length array copy cvx
				dup  0  4 -1 roll  put
				param  ThisPieceStart  i ThisPieceStart sub 1 add  getinterval
exch
				/ThisPieceStart i 1 add def
			} ifelse  % ... KernAmount ... 0 eq
		} for
		param  ThisPieceStart  param length ThisPieceStart sub  getinterval
		/MostRecentGlyph ThisEncoding param dup length 1 sub get get store
	}
	{
	param type /nametype eq
	{
		MostRecentGlyph  param  KernAmount
		dup 0 eq {pop}
		{
			{/KernAmount CurrentFontSize mul 1000 div 0 rmoveto}
			dup length array copy cvx
			dup  0  4 -1 roll  put
		} ifelse  % ... KernAmount ... 0 eq
		/MostRecentGlyph param store
		param
	}
	{
	param type /arraytype eq
	{
		param {NoExecDepth  InsertKernCodeRecRec} forall
	}
	{
		(Error: InsertKernCodeRec parameter neither executable nor string
nor name nor array, being) OutputToLog
		/param load OutputToLog
	} ifelse  % /arraytype
	} ifelse  % /nametype
	} ifelse  % /stringtype
	} ifelse  % xcheck
	end
} bind def  % InsertKernCodeRecRec
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads