Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #2262 > unrolled thread

How change character Metrics?

Started byMartin Leese <please@see.Web.for.e-mail.INVALID>
First post2015-05-13 18:48 -0600
Last post2015-05-14 11:52 -0600
Articles 7 — 3 participants

Back to article view | Back to comp.lang.postscript


Contents

  How change character Metrics? Martin Leese <please@see.Web.for.e-mail.INVALID> - 2015-05-13 18:48 -0600
    Re: How change character Metrics? luser- -droog <mijoryx@yahoo.com> - 2015-05-13 23:50 -0700
      Re: How change character Metrics? Martin Leese <please@see.Web.for.e-mail.INVALID> - 2015-05-14 11:26 -0600
        Re: How change character Metrics? Martin Leese <please@see.Web.for.e-mail.INVALID> - 2015-05-14 15:45 -0600
          Re: How change character Metrics? Martin Leese <please@see.Web.for.e-mail.INVALID> - 2015-05-15 09:24 -0600
    Re: How change character Metrics? ken <ken@spamcop.net> - 2015-05-14 07:56 +0100
      Re: How change character Metrics? Martin Leese <please@see.Web.for.e-mail.INVALID> - 2015-05-14 11:52 -0600

#2262 — How change character Metrics?

FromMartin Leese <please@see.Web.for.e-mail.INVALID>
Date2015-05-13 18:48 -0600
SubjectHow change character Metrics?
Message-ID<mj0rb8$qbb$1@dont-email.me>
Hi,

I want to close up the characters in some
text, and can not work out how to do this.
There will be text at many different
orientations, so I decided that to do this
in the character coordinate system would be
preferred.  This looks like a job for the
Metrics dictionary inside the font
dictionary.

I have never tried kerning before;
suggestions for alternative approaches
would be welcome.

Here is the PostScript I have:

%!
% PostScript code to test kerning of font.
%
/tempMetrics 2 dict def
tempMetrics /S [0.0 0.5] put
tempMetrics /P [0.0 0.5] put

/CenturySchL-Bold findfont 20 dict copy dup /Metrics tempMetrics put 22 
scalefont setfont
100 100 moveto (SPAM) show
showpage

In Ghostscript, this gives:
     Error: /invalidfont in --scalefont--

If I replace the line above with:
     /CenturySchL-Bold findfont 22 scalefont setfont
then it works fine.

If I replace the line above with:
     /CenturySchL-Bold findfont 20 dict copy 22 scalefont setfont
then it fails with the same Error.

I copy the existing font into a new dict
because if I use dup then the font is
readonly and the put generates an error.  I
create an empty dict of 20 key value pairs
because that is the maxlength of the font
dictionary I am copying.

Many thanks for any advice you can give.

-- 
Regards,
Martin Leese
E-mail: please@see.Web.for.e-mail.INVALID
Web: http://members.tripod.com/martin_leese/

[toc] | [next] | [standalone]


#2263

Fromluser- -droog <mijoryx@yahoo.com>
Date2015-05-13 23:50 -0700
Message-ID<d187407b-2f2a-47ad-8d8a-e6717b021447@googlegroups.com>
In reply to#2262
On Wednesday, May 13, 2015 at 7:48:46 PM UTC-5, Martin Leese wrote:
> Hi,
> 
> I want to close up the characters in some
> text, and can not work out how to do this.
> There will be text at many different
> orientations, so I decided that to do this
> in the character coordinate system would be
> preferred.  This looks like a job for the
> Metrics dictionary inside the font
> dictionary.
> 
> I have never tried kerning before;
> suggestions for alternative approaches
> would be welcome.
> 
> Here is the PostScript I have:
> 
> %!
> % PostScript code to test kerning of font.
> %
> /tempMetrics 2 dict def
> tempMetrics /S [0.0 0.5] put
> tempMetrics /P [0.0 0.5] put
> 
> /CenturySchL-Bold findfont 20 dict copy dup /Metrics tempMetrics put 22 
> scalefont setfont

You need to call `definefont` with your modified font
dictionary, and then you can use the return value
or call `findfont` again with the new name (definefont
takes a /name parameter btw).

[toc] | [prev] | [next] | [standalone]


#2267

FromMartin Leese <please@see.Web.for.e-mail.INVALID>
Date2015-05-14 11:26 -0600
Message-ID<mj2lq6$nd9$1@dont-email.me>
In reply to#2263
luser- -droog wrote:

> You need to call `definefont` with your modified font
> dictionary, and then you can use the return value
> or call `findfont` again with the new name (definefont
> takes a /name parameter btw).

Excellent, many thanks for your help.  My
working code currently looks like:

%!
% PostScript code to test kerning of font.
%
/tempMetrics 2 dict def
tempMetrics /S [0 560] put
tempMetrics /P [0 500] put

/CenturySchL-Bold findfont 20 dict copy
dup /FontName /SPAMFont put
dup /Metrics tempMetrics put
dup /FID undef  % PostScript Level 2
/SPAMFont exch definefont
88 scalefont setfont
100 550 moveto (SPAM) show
showpage

Changing the FontName and removing the FID
are not necessary.

-- 
Regards,
Martin Leese
E-mail: please@see.Web.for.e-mail.INVALID
Web: http://members.tripod.com/martin_leese/

[toc] | [prev] | [next] | [standalone]


#2269

FromMartin Leese <please@see.Web.for.e-mail.INVALID>
Date2015-05-14 15:45 -0600
Message-ID<mj34vq$l62$1@dont-email.me>
In reply to#2267
Martin Leese wrote:
...
> Changing the FontName and removing the FID
> are not necessary.

I have just downloaded a copy of the
PostScript Language Reference Manual: Third
Edition.  This states that:

     In LanguageLevel 1, an FID entry must
     not previously exist in the dictionary
     presented to definefont.

So my posted code will not work on
PostScript Level 1 interpreters.

Unfortunately, in Level 1 there is no easy
way of removing a key and value from a
dictionary (undef being Level 2).  As I
make a copy of an existing font dictionary,
a solution would be to copy over the keys
one at a time and to simply not copy FID.

On the other hand, I suspect few people
care about Level 1 anymore

-- 
Regards,
Martin Leese
E-mail: please@see.Web.for.e-mail.INVALID
Web: http://members.tripod.com/martin_leese/

[toc] | [prev] | [next] | [standalone]


#2272

FromMartin Leese <please@see.Web.for.e-mail.INVALID>
Date2015-05-15 09:24 -0600
Message-ID<mj532a$pnt$1@dont-email.me>
In reply to#2269
Martin Leese wrote:
...
> So my posted code will not work on
> PostScript Level 1 interpreters.
...
> On the other hand, I suspect few people
> care about Level 1 anymore

It seems that I care.  Here is code that
should work even at PostScript Level 1:

%!
% PostScript code to test kerning of font.
%
/tempFont 20 dict def  % Font dictionary
/tempMetrics 2 dict def  % Kerning dictionary
tempMetrics /S [0 570] put
tempMetrics /P [0 520] put

/CenturySchL-Bold findfont {
     exch dup /FID ne {
         exch tempFont 3 1 roll put  % key is not /FID so copy
     } {
         pop pop  % key is /FID so discard
     } ifelse
} forall
tempFont /FontName /SPAMFont put
tempFont /Metrics tempMetrics put
/SPAMFont tempFont definefont
88 scalefont setfont
100 550 moveto (SPAM) show
showpage

Changing the FontName is not necessary.

-- 
Regards,
Martin Leese
E-mail: please@see.Web.for.e-mail.INVALID
Web: http://members.tripod.com/martin_leese/

[toc] | [prev] | [next] | [standalone]


#2264

Fromken <ken@spamcop.net>
Date2015-05-14 07:56 +0100
Message-ID<MPG.2fbe576c3f326fac9898f8@usenet.plus.net>
In reply to#2262
In article <mj0rb8$qbb$1@dont-email.me>, please@see.Web.for.e-
mail.INVALID says...

> preferred.  This looks like a job for the
> Metrics dictionary inside the font
> dictionary.
> 
> I have never tried kerning before;
> suggestions for alternative approaches
> would be welcome.

Use one of the other show operators instead, eg kshow ("kern-show") 
whish is intended for the job of kerning.

Depending on exactly what it is you want to do you could also use ashow, 
widthshow, or awidthshow

			Ken

[toc] | [prev] | [next] | [standalone]


#2268

FromMartin Leese <please@see.Web.for.e-mail.INVALID>
Date2015-05-14 11:52 -0600
Message-ID<mj2nar$ts4$1@dont-email.me>
In reply to#2264
ken wrote:
> In article <mj0rb8$qbb$1@dont-email.me>, please@see.Web.for.e-
> mail.INVALID says...
> 
>> preferred.  This looks like a job for the
>> Metrics dictionary inside the font
>> dictionary.
>>
>> I have never tried kerning before;
>> suggestions for alternative approaches
>> would be welcome.
> 
> Use one of the other show operators instead, eg kshow ("kern-show") 
> whish is intended for the job of kerning.
> 
> Depending on exactly what it is you want to do you could also use ashow, 
> widthshow, or awidthshow

There will be text at many different
orientations, so to do this in the character
coordinate system is preferred.

kshow appears to work in the user coordinate
system.  ashow definately works in the user
coordinate system and not the character
coordinate system.  widthshow could work in
either coordinate system.  (awidthshow simply
combines ashow and widthshow into a single
operation.)

This is according to the PostScript Language
Reference Manual: Second Edition (Third
Printing, May 1991), published by Adobe.
This manual could be clearer when it
describes kshow and widthshow.

Anyway, see my separate post in this thread
for working code using font Metrics and show.

-- 
Regards,
Martin Leese
E-mail: please@see.Web.for.e-mail.INVALID
Web: http://members.tripod.com/martin_leese/

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.postscript


csiph-web