For Programmers: Free Programming Magazines  


Home > Archive > PostScript > December 2006 > Making a font from another font









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Making a font from another font
Nobody

2006-12-17, 7:04 pm

Hi, I would like to create some virtual font from a Type 1 font
that should behave exactly as the original one except for one
thing: the characters should be print according to a -1 1 scale.
Warning:
[-1 0 0 1 0 0] makefont
does not what I want, since it reverses the printing direction.
For instance: (ABCDE) show
should print ABCDE in this very same order but each letter should
be horizontally mirrored. How can I do that?
ray

2006-12-17, 7:04 pm

On Sun, 17 Dec 2006 19:04:14 +0100, Nobody wrote:

> Hi, I would like to create some virtual font from a Type 1 font
> that should behave exactly as the original one except for one
> thing: the characters should be print according to a -1 1 scale.
> Warning:
> [-1 0 0 1 0 0] makefont
> does not what I want, since it reverses the printing direction.
> For instance: (ABCDE) show
> should print ABCDE in this very same order but each letter should
> be horizontally mirrored. How can I do that?


Are you familiar with the family of books Adobe puts out about PS? I'm
talking the 'green book' the 'red boot' the 'blue book'. One of them is
basically a cookbook and has examples of digging in and modifying fonts -
I think it would have what you need. Try a nearby university library,
technical library or inter-library loan.

Jim Land

2006-12-18, 4:12 am

ray <ray@zianet.com> wrote in news:pan.2006.12.17.20.54.07.463279
@zianet.com:

> Are you familiar with the family of books Adobe puts out about PS? I'm
> talking the 'green book' the 'red boot' the 'blue book'. One of them is
> basically a cookbook and has examples of digging in and modifying fonts -
> I think it would have what you need. Try a nearby university library,
> technical library or inter-library loan.


Also available as PDF. See:
http://www.geocities.com/SiliconVal...rogramming.html
François Robert

2006-12-18, 8:06 am

Nobody <nobody@glyphotronix.org> wrote in news:20061217190058.W14219
@localhost.my.domain:

> Hi, I would like to create some virtual font from
> a Type 1 font that should behave exactly as the
> original one except for one thing: the characters
> should be print according to a -1 1 scale.
> Warning:
> [-1 0 0 1 0 0] makefont
> does not what I want, since it reverses the printing
> direction.
> For instance: (ABCDE) show
> should print ABCDE in this very same order but each
> letter should be horizontally mirrored. How can I do that?


You need to change the font's glyph metrics.
A similar question was asked here, but the issue was to place the
letters on their side :

http://groups.google.com/group/comp...owse_thread/thr
ead/caf0e2b37eb866a0/63bc29b296a52254
________________________________________
_______________
François Robert
(to mail me, reverse character order in reply address)
John Deubert

2006-12-19, 7:10 pm

In article <20061217190058.W14219@localhost.my.domain>, Nobody
<nobody@glyphotronix.org> wrote:

> Hi, I would like to create some virtual font from a Type 1 font
> that should behave exactly as the original one except for one
> thing: the characters should be print according to a -1 1 scale.
> Warning:
> [-1 0 0 1 0 0] makefont
> does not what I want, since it reverses the printing direction.
> For instance: (ABCDE) show
> should print ABCDE in this very same order but each letter should
> be horizontally mirrored. How can I do that?


One approach would be to make a Type 3 font that uses the original
font, but reverses the characters. For example:

% ========== Cut here ==============
/Times-Roman findfont % Get the T-R font dict
dup length dict begin % Create a new dict that size
/basefont exch def % Save the T-R dict in our new dict

/FontType 3 def % Put font stuff into the new dict
/FontMatrix [ 1 0 0 1 0 0 ] def
/FontBBox basefont /FontBBox get def
/Encoding basefont /Encoding get def


/char 1 string def % A scratch string

% Remember the BuildChar proc is called for each character
% in the string.
/BuildChar % stack: <<fdict>> cc => ---
{
exch begin % Put the fdict on the dict stack
basefont setfont % Set our font to 1-pt T-R
char 0 3 -1 roll put % Put the char code into scratch str.
char stringwidth % Find the "width" of the character
2 copy setcharwidth % Use the result for setcharwidth
moveto % Do a "moveto" by the width of the char
-1 1 scale % Reverse the x scale
char show % and print the character
end % Remove the fdict from the dict stack
} bind def

% Now convert the dictionary to a font dictionary:
/Times-Reverse currentdict definefont pop
end % Remove the dict from the dict stack

% Now, let's try it out...
/Times-Reverse 36 selectfont
72 600 moveto
(This be a test) show

showpage


% ========== Cut here ==============

The above can probably be tightened up some, but is intended for
clarity. (Also, the above is written to be pretty easily turned into a
"FindFontReversed" procedure.)

Note that the key to the above solution is the curious fact that a
font's character definition can itself do a setfont and so print
characters in another font. Cute.

Hope this helps. Unless anyone has any objections, this may become a
topic for a new Acumen Journal article.

- John

--
John Deubert Acumen Training
john @ acumentraining.com PostScript & PDF training
949-248-1241 http://www.acumentraining.com
Read the Acumen Journal for PostScript tips & tricks!
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com