[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Adding /dotlessj to Type 1 fonts
I've found a clever way to add the /dotlessj character to
existing Type 1 and Type 5 fonts.
You just have to add a character metric data line for /dotlessj
into the Adobe Font Metric (.afm) file of the font, based on the
information provided for /j and /dotlessi, e.g.,
C -1 ; WX 278 ; N dotlessj ; B -70 -218 194 460 ;
Then, rebuild the TeX font metric files (.tfm) and virtual font
(.vf) files using your favorite utility (e.g., afm2tfm, fontinst,
aftopl).
[ I've written an awk script to edit the .afm automatically, but
I believe this could be done automatically by fontinst without
having to modify the .afm file. I guess afm2tfm could easily
be modified to determined the metric of /dotlessj as well... ]
Finally, you just have to edit the psfonts.map entry of the font
to add the command "AddDotlessj", which is defined in the procset
dotlessj.pro, e.g.,
ptmr8r Times-Roman "AddDotlessj TeXBase1Encoding ReEncodeFont"
<8r.enc <dotlessj.pro
Salut!
Bernard
.----------------------------------------+-----------------------------------.
| Bernard Desruisseaux, M.Sc. | mailto:bernard@cs.mcgill.ca |
| School of Comp. Sc., Universite McGill | http://www.cs.mcgill.ca/~bernard/ |
+----------------------------------------+-----------------------------------+
| "Cela ne pourra pas toujours ne pas arriver" -- Gaston Miron |
`----------------------------------------------------------------------------'
#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.1).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 1996-12-09 20:56 EST by <bernard@bachii>.
# Source directory was `/home/bernard/lib/ps/bernard/dotlessj'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode name
# ------ ---------- ------------------------------------------
# 3657 -rw------- dotlessj.lpro
# 785 -rw------- dotlessj.pro
# 1230 -rwx------ dotlessj.awk
#
touch -am 1231235999 $$.touch >/dev/null 2>&1
if test ! -f 1231235999 && test -f $$.touch; then
shar_touch=touch
else
shar_touch=:
echo
echo 'WARNING: not restoring timestamps. Consider getting and'
echo "installing GNU \`touch', distributed in GNU File Utilities..."
echo
fi
rm -f 1231235999 $$.touch
#
# ============= dotlessj.lpro ==============
if test -f 'dotlessj.lpro' && test X"$1" != X"-c"; then
echo 'x - skipping dotlessj.lpro (file already exists)'
else
echo 'x - extracting dotlessj.lpro (text)'
sed 's/^X//' << 'SHAR_EOF' > 'dotlessj.lpro' &&
%!PS-Adobe-3.0 Resource-Procset
%%Title: ($RCSfile: dotlessj.lpro,v $)
%%Creator: ($Author: bernard $)
%%CreationDate: ($Date: 1996/12/08 19:52:24 $)
%%Version: ($Revision: 1.1 $)
%%Copyright: (c) 1996 by Bernard Desruisseaux. All rights reserved.
%%For: Bernard Desruisseaux (bernard@cs.mcgill.ca, bernardd@cst.ca)
%%EndComments
%%BeginProlog
%%BeginResource: procset adddotlessj.lpro
X
TeXDict begin
X
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Procedure : CharBBox
%-----------------------------------------------------------------------
% Description : Returns the bounding box of a string.
%-----------------------------------------------------------------------
% Operand Stack : str => llx lly urx ury
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/CharBBox {
X gsave
X newpath
X 0 0 moveto
X false charpath
X flattenpath
X pathbbox
X grestore
} def
X
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Procedure : ClipBBox
%-----------------------------------------------------------------------
% Description : Clip bounding box.
%-----------------------------------------------------------------------
% Operand Stack : llx lly urx ury => _
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/ClipBBox {
X newpath
X 4 2 roll 2 copy moveto
X dup 4 index exch lineto
X 4 2 roll dup 3 1 roll lineto
X 2 index exch lineto
X pop pop
X closepath
X clip
} def
X
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Procedure : AddDotlessj
%-----------------------------------------------------------------------
% Description : Extends an existing Type 1 or Type 5 font with a
% /dotlessj ``charstring procedure'' based on the
% orignal /j procedure.
%-----------------------------------------------------------------------
% Dict. stack : fontdict
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
/AddDotlessj {
X %%
X % Make sure it is Type 1 or Type 5 and
X % that /dotlessj is not already defined.
X %%
X FontType dup 1 eq exch 5 eq or CharStrings /dotlessj known not and {
X /CharStrings
X %%
X % Create a new CharStrings dict. with capacity of 1 more element.
X %%
X CharStrings dup length 1 add dict dup
X begin
X %%
X % Copy all original charstring procedures
X %%
X exch { def } forall
X %%
X % Define new /dotlessj charstring procedure
X %%
X /dotlessj {
X pop
X gsave
X FontName findfont
X 1 1 index /FontMatrix get 0 get div scalefont setfont
X %%
X % Compute the wx, wy, llx, lly, urx of /j.
X %%
X (j) stringwidth
X (j) CharBBox pop
X %%
X % Compute the ury of /e, or /dotlessi if found in Encoding.
X %%
X (e) currentfont /Encoding get 0 1 255 {
X 2 copy get /dotlessi eq { 2 index 0 3 -1 roll put exit }
X { pop } ifelse
X } for pop
X CharBBox 4 1 roll pop pop pop
X grestore
X 4 copy 10 4 roll
X setcachedevice
X ClipBBox
X 0 0 moveto
X FontMatrix matrix invertmatrix concat
X (j) show
X } def
X end def
X } if
} def
X
end
%%EndResource
%%EndProlog
SHAR_EOF
$shar_touch -am 1209205396 'dotlessj.lpro' &&
chmod 0600 'dotlessj.lpro' ||
echo 'restore of dotlessj.lpro failed'
shar_count="`wc -c < 'dotlessj.lpro'`"
test 3657 -eq "$shar_count" ||
echo "dotlessj.lpro: original size 3657, current size $shar_count"
fi
# ============= dotlessj.pro ==============
if test -f 'dotlessj.pro' && test X"$1" != X"-c"; then
echo 'x - skipping dotlessj.pro (file already exists)'
else
echo 'x - extracting dotlessj.pro (text)'
sed 's/^X//' << 'SHAR_EOF' > 'dotlessj.pro' &&
%!
TeXDict begin /CharBBox{gsave newpath 0 0 moveto false charpath
flattenpath pathbbox grestore}def /ClipBBox{newpath 4 2 roll 2 copy
moveto dup 4 index exch lineto 4 2 roll dup 3 1 roll lineto 2 index exch
lineto pop pop closepath clip}def /AddDotlessj{FontType dup 1 eq exch 5
eq or CharStrings /dotlessj known not and{/CharStrings CharStrings dup
length 1 add dict dup begin exch{def}forall /dotlessj{pop gsave FontName
findfont 1 1 index /FontMatrix get 0 get div scalefont setfont(j)
stringwidth(j)CharBBox pop(e)currentfont /Encoding get 0 1 255{2 copy
get /dotlessi eq{2 index 0 3 -1 roll put exit}{pop}ifelse}for pop
CharBBox 4 1 roll pop pop pop grestore 4 copy 10 4 roll setcachedevice
ClipBBox 0 0 moveto FontMatrix matrix invertmatrix concat(j)show}def end
def}if}def end
SHAR_EOF
$shar_touch -am 1209205496 'dotlessj.pro' &&
chmod 0600 'dotlessj.pro' ||
echo 'restore of dotlessj.pro failed'
shar_count="`wc -c < 'dotlessj.pro'`"
test 785 -eq "$shar_count" ||
echo "dotlessj.pro: original size 785, current size $shar_count"
fi
# ============= dotlessj.awk ==============
if test -f 'dotlessj.awk' && test X"$1" != X"-c"; then
echo 'x - skipping dotlessj.awk (file already exists)'
else
echo 'x - extracting dotlessj.awk (text)'
sed 's/^X//' << 'SHAR_EOF' > 'dotlessj.awk' &&
#!/usr/bin/awk -f
########################################################################
# $Id: dotlessj.awk,v 1.1 1996/12/08 19:52:24 bernard Exp bernard $
#-----------------------------------------------------------------------
# Description: Adds a character metric data line for /dotlessj to an
# Adobe Font Metric (.afm) file, based on the information
# provided for /j and /dotlessi.
#-----------------------------------------------------------------------
# Usage : dotlessj.awk Times-Roman.afm > Times-Roman-Dotlessj.afm
#-----------------------------------------------------------------------
# Author : Bernard Desruisseaux (bernard@cs.mcgill.ca)
#-----------------------------------------------------------------------
# Copyright : (c) 1996 by Bernard Desruisseaux. All rights reserved.
########################################################################
BEGIN { found = 0; }
$8 == "j" { wxj = $5; llxj = $11; llyj = $12; urxj = $13; }
$8 == "dotlessi" { uryi = $14; }
$8 == "dotlessj" { found = 1; }
/^EndCharMetrics/{
X if (! found)
X printf("C -1 ; WX %d ; N dotlessj ; B %d %d %d %d ;\n", wxj, llxj, llyj, urxj, uryi);
}
{ print; }
##EOF
SHAR_EOF
$shar_touch -am 1208151396 'dotlessj.awk' &&
chmod 0700 'dotlessj.awk' ||
echo 'restore of dotlessj.awk failed'
shar_count="`wc -c < 'dotlessj.awk'`"
test 1230 -eq "$shar_count" ||
echo "dotlessj.awk: original size 1230, current size $shar_count"
fi
exit 0