[links] New font generation scripts (with automatic accent merging!)
Edward Rosten
edrosten at lanl.gov
Wed Apr 11 18:20:14 MDT 2007
Hi all,
I've attached a new set of font generation scripts. The main end difference is
that this system automatically merges accents over the glyphs, and doesn't
require manual GIMPing afterwards.
run as follows:
put all the files in a directory and do:
./fontgen latin.map CenturySchL-Italic
to generate a latin font for New Century Schoolbook, italc. The output glyphs
are in ./tmp/
I've tested it with italic font, by copying the glyphs in to
links/graphics/font/century_school-medium-italic-serif-vari
and using the aliases file from century_school-bold-roman-serif-vari, and
running generate_font.
My links now has an italic font.
The font is not complete, since I only have created the latin map (copied from
clip.c), and not all the accent positions are correct, but it's a pretty decent
start.
If you create any updated maps (and accent positions), or need any help, please
let me know!
It works as follows:
A .map file (only latin.map is provided, but it is derived from clip.c)
specifies mappings and merges. The format should be fairly self explanatory.
In the mapping section, everything after the 3rd column is ignored.
In the merge section, the 4th column (if present) specifies the vertival
alignment of the accent and the 5th column (if present) specifies the
horizontal alignment.
If they are not present, the system makes a guess, which is reasonable in the
majority of cases.
The possible vertical alignments are:
bottom Print the fonts on the same baseline (accents align
properly with lower case letters)
capital Push the glyph up a bit so that accents align with
capital letters
glmid Strip all space from around the accent, and place
the glyph in the lower middle
gmid As above, but placed in the middle
gumid As above, but in the upper middle region
The possible horizontal alignments are:
left Aligh the left of the accent and letter cells
(includes white space)
right As above, but right aligned right
centre As above but centred.
More alignments could be added easily, but I haven't done it yet.
I used the parameters from the current font generating system in fontgen, but
for some reason, the sizes came out a bit different, so it has slightly
different parameters.
-Ed
-------------- next part --------------
mkdir tmp
export mag=4
#was 1703
export hundred_dpi=1850
export height=120
export top=43
hdpi=`expr $hundred_dpi '*' $mag '/' 100`
vdpi=`expr $hundred_dpi '*' $mag '/' 100`
awk -f process_mapping.awk $1 |
while read ch acc va ha out
do
fout=tmp/$out.png
gs -sDEVICE=pgmraw -q -dNOPAUSE -dBATCH -sPAPERSIZE=a4 -r"$hdpi"x"$vdpi" \
-dCH=$ch -dACC=$acc -dh_align="($ha)" -dv_align="($va)" -dFN="/$2" \
-sOutputFile=- letters.ps | pnmcrop -left -right -white | pnminvert | pnmscale -reduce $mag | pnmcut -height $height -top $top | pnmtopng > $fout
#pnmcrop fails if the image is all background.
if ! pngtopnm $fout | pnmcrop > /dev/null
then
rm $fout
fi
echo $fout
done
-------------- next part --------------
MAPPING
161 0xa1
162 0xa2
163 0xa3
165 0xa5
167 0xa7
171 0xab
172 0x2039
173 0x203a
174 0xfb01
175 0xfb02
177 0x2013
178 0x2020
179 0x2021
182 0xb6
183 0x2022
187 0xbb
188 0x2026
189 0x2030
191 0xbf
196 0x2dc
208 0x2014
225 0xc6
232 0x141
233 0xd8
234 0x152
235 0x2116
241 0xe6
248 0x142
249 0xf8
250 0x153
251 0xdf
193 0x300 GRA /* ` */
194 0xb4 ACU /* ' */
195 0x2c6 CIR /* ^ */
196 0x2dc TIL /* ~ */
197 0xaf MAC /* - above */
198 0x306 LSC /* lower semicircle above */
199 0x2d9
199 0xb7 DOT /* . above */
200 0xa8 UML /* .. above */
202 0x2da
202 0xb0 RIN /* o above */
203 0xb8 CED /* (5 without the top stroke) under */
205 0x30b DAC /* " */
206 0x2db OGO /* left-right mirrored J under (ogonek) */
207 0x2c7 CAR /* v above */
MERGE
+ - 0xb1 glmid
A GRA 0xc0
A ACU 0xc1
A CIR 0xc2
A TIL 0xc3
A UML 0xc4
A RIN 0xc5
C CED 0xc7 bottom
E GRA 0xc8
E ACU 0xc9
E CIR 0xca
E UML 0xcb
I GRA 0xcc
I ACU 0xcd
I CIR 0xce
I UML 0xcf
D - 0xd0 bottom left
N TIL 0xd1
O GRA 0xd2
O ACU 0xd3
O CIR 0xd4
O TIL 0xd5
O UML 0xd6
U GRA 0xd9
U ACU 0xda
U CIR 0xdb
U UML 0xdc
Y ACU 0xdd
a GRA 0xe0
a ACU 0xe1
a CIR 0xe2
a TIL 0xe3
a UML 0xe4
a RIN 0xe5
c CED 0xe7 bottom
e GRA 0xe8
e ACU 0xe9
e CIR 0xea
e UML 0xeb
i GRA 0xec
i ACU 0xed
i CIR 0xee
i UML 0xef
n TIL 0xf1
o GRA 0xf2
o ACU 0xf3
o CIR 0xf4
o TIL 0xf5
o UML 0xf6
u GRA 0xf9
u ACU 0xfa
u CIR 0xfb
u UML 0xfc
y ACU 0xfd
y UML 0xff
A MAC 0x100
a MAC 0x101
A LSC 0x102
a LSC 0x103
A OGO 0x104 bottom right
a OGO 0x105 bottom right
C ACU 0x106
c ACU 0x107
C CIR 0x108
c CIR 0x109
C DOT 0x10a
c DOT 0x10b
C CAR 0x10c
c CAR 0x10d
D CAR 0x10e
d 0x27 0x10f
D - 0x110 bottom left
d - 0x111 glmid right
E MAC 0x112
e MAC 0x113
E LSC 0x114
e LSC 0x115
E DOT 0x116
e DOT 0x117
E OGO 0x118 bottom
e OGO 0x119 bottom
E CAR 0x11a
e CAR 0x11b
G CIR 0x11c
g CIR 0x11d
G LSC 0x11e
g LSC 0x11f
G DOT 0x120
g DOT 0x121
H CIR 0x124
h CIR 0x125
H _ 0x126 glmid
h - 0x127 glmid left
I TIL 0x128
i TIL 0x129
I MAC 0x12a
i MAC 0x12b
I LSC 0x12c
i LSC 0x12d
I OGO 0x12e bottom
i OGO 0x12f bottom
I DOT 0x130
I J 0x132 bottom right
i j 0x133 bottom right
J CIR 0x134
j CIR 0x135
L ACU 0x139
l ACU 0x13a
L 0x27 0x13d
l 0x27 0x13e
N ACU 0x143
n ACU 0x144
N CAR 0x147
n CAR 0x148
O MAC 0x14c
o MAC 0x14d
O LSC 0x14e
o LSC 0x14f
O DAC 0x150
o DAC 0x151
R ACU 0x154
r ACU 0x155
R CAR 0x158
r CAR 0x159
S ACU 0x15a
s ACU 0x15b
S CIR 0x15c
s CIR 0x15d
S CED 0x15e bottom
s CED 0x15f bottom
S CAR 0x160
s CAR 0x161
T CED 0x162 bottom
t CED 0x163 bottom
T CAR 0x164
t 0x27 0x165
T - 0x166
t - 0x167
U TIL 0x168
u TIL 0x169
U MAC 0x16a
u MAC 0x16b
U LSC 0x16c
u LSC 0x16d
U RIN 0x16e
u RIN 0x16f
U DAC 0x170
u DAC 0x171
U OGO 0x172 bottom
u OGO 0x173 bottom
W CIR 0x174
w CIR 0x175
Y CIR 0x176
y CIR 0x177
Y UML 0x178
Z ACU 0x179
z ACU 0x17a
Z DOT 0x17b
z DOT 0x17c
Z CAR 0x17d
z CAR 0x17e
A CAR 0x1cd
a CAR 0x1ce
I CAR 0x1cf
i CAR 0x1d0
O CAR 0x1d1
o CAR 0x1d2
U CAR 0x1d3
u CAR 0x1d4
G CAR 0x1e6
g CAR 0x1e7
K CAR 0x1e8
k CAR 0x1e9
O OGO 0x1ea bottom
o OGO 0x1eb bottom
j CAR 0x1f0
G ACU 0x1f4
g ACU 0x1f5
N GRA 0x1f8
n GRA 0x1f9
-------------- next part --------------
A non-text attachment was scrubbed...
Name: letters.ps
Type: application/postscript
Size: 2901 bytes
Desc:
Url : http://linuxfromscratch.org/pipermail/links-list/attachments/20070411/09683ba0/attachment-0001.ps
-------------- next part --------------
BEGIN{
for(i=0; i < 256; i++)
{
ord[sprintf("%c", i)] = i
map[i] = i
}
}
NF==0{next}
/MAPPING/{
is_mapping=1
next
}
/MERGE/{
for(i=0; i < 256; i++)
print i, 0, "bottom", "left", sprintf("%04x", map[i])
is_merge=1
next
}
is_mapping{
map[$1] = strtonum($2)
if($3 != "")
defs[$3] = $1+0
}
is_merge{
if($2 in defs)
acc=defs[$2]
else if($2~/^0x/)
acc = strtonum($2)
else
acc=ord[$2]
out=strtonum($3)
if($4 == "")
if($1~/[A-Z]/)
valign="capital"
else
valign="bottom"
else
valign=$4
if($5 == "")
halign="centre"
else
halign=$5
print ord[$1], acc, valign, halign, sprintf("%04x", out)
}
More information about the links-list
mailing list