[bugfix] now it works
This commit is contained in:
parent
1233ec1f2c
commit
11b9978ef1
2
bin/generate-pfa.pe
Normal file
2
bin/generate-pfa.pe
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
Open($1);
|
||||||
|
Generate($fontname + ".pfa");
|
69
bin/groff_addfont.sh
Normal file → Executable file
69
bin/groff_addfont.sh
Normal file → Executable file
|
@ -4,37 +4,66 @@
|
||||||
set -e
|
set -e
|
||||||
# generate pfa
|
# generate pfa
|
||||||
|
|
||||||
FONTPATH=$1
|
if [ "$#" -lt 2 ]; then
|
||||||
|
CMD=$(basename "$0")
|
||||||
|
echo "Usage: $CMD <*.ttf/ttc/otf> <style>"
|
||||||
|
echo " regular : $CMD sarasa-ui-sc-regular.ttf R"
|
||||||
|
echo " italic : $CMD sarasa-ui-sc-italic.ttf I"
|
||||||
|
echo " bold : $CMD sarasa-ui-sc-bold.ttf B"
|
||||||
|
echo " bold italic : $CMD sarasa-ui-sc-bolditalic.ttf BI"
|
||||||
|
echo
|
||||||
|
echo "note: the suffix of groff_name (R/I/B/BI) is essential!"
|
||||||
|
fi
|
||||||
|
|
||||||
|
DIR=$(dirname "$(readlink -f "$0")")
|
||||||
|
FONTPATH=$(readlink -f "$1")
|
||||||
# with R B I suffix
|
# with R B I suffix
|
||||||
GROFFNAME=$2
|
STYLE=$2
|
||||||
|
GROFF_CURRENT=$(readlink -f /usr/share/groff/current)
|
||||||
|
GROFF_SITEFONT=/usr/share/groff/site-font
|
||||||
|
|
||||||
TMPDIR="$(mktemp -d)"
|
TMPDIR="$(mktemp -d)"
|
||||||
|
trap 'rm -rf '"$TMPDIR"';cd -' EXIT
|
||||||
cd "$TMPDIR"
|
cd "$TMPDIR"
|
||||||
|
echo "Change working directory to: $(pwd)"
|
||||||
|
|
||||||
fontforge -c 'Open($1);Generate($fontname + ".pfa");' "$FONTPATH"
|
echo "Using fontforge to generate PFA"
|
||||||
AFM=$(ls *.afm)
|
fontforge -script "$DIR/generate-pfa.pe" "$FONTPATH" >/dev/null 2>&1
|
||||||
PFA=$(ls *.pfa)
|
AFM=$(ls ./*.afm)
|
||||||
afmtodit "$AFM" textmap "$GROFFNAME"
|
PFA=$(ls ./*.pfa)
|
||||||
INA=$(awk '$1 == "internalname" { print $2; exit; }')
|
|
||||||
sudo mkdir -p /usr/share/groff/site-font/devps
|
|
||||||
#sudo mkdir -p /usr/share/groff/site-font/devpdf
|
FONTNAME=$(awk '$1 == "FamilyName" {print substr($0, 12)}' "$AFM" | sed -r 's/\s+//g')
|
||||||
|
GROFFNAME=$FONTNAME$STYLE
|
||||||
|
echo "Converting to groff font"
|
||||||
|
afmtodit "$AFM" "$GROFF_CURRENT/font/devps/generate/textmap" "$GROFFNAME" >/dev/null 2>&1
|
||||||
|
INA=$(awk '$1 == "internalname" { print $2; exit; }' "$GROFFNAME")
|
||||||
|
echo "groff name : $GROFFNAME"
|
||||||
|
echo "internalname : $INA"
|
||||||
|
|
||||||
|
echo "Copying to $GROFF_SITEFONT"
|
||||||
|
sudo mkdir -p $GROFF_SITEFONT/devps
|
||||||
sudo cp "$PFA" "$GROFFNAME" /usr/share/groff/site-font/devps
|
sudo cp "$PFA" "$GROFFNAME" /usr/share/groff/site-font/devps
|
||||||
sudo ln -sf "/usr/share/groff/site-font/devps/$PFA" "/usr/share/groff/site-font/devpdf/$PFA"
|
|
||||||
|
echo "Adding font to downloadable list"
|
||||||
|
if ! grep "$PFA" "$GROFF_CURRENT/font/devps/download" ; then
|
||||||
|
printf '%s\t%s\n' "$INA" "$PFA" | sudo tee -a "$GROFF_CURRENT/font/devps/download" >/dev/null
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Done, now you may use this font in your .ms file:"
|
||||||
|
echo " .ds FAM $FONTNAME"
|
||||||
|
echo
|
||||||
|
echo "Then, use following command to generate pdf file:"
|
||||||
|
echo " groff -ms -U -Kutf8 input.ms > tmp.ps"
|
||||||
|
echo " ps2pdf tmp.ps output.pdf"
|
||||||
|
echo
|
||||||
|
|
||||||
|
#sudo ln -sf "/usr/share/groff/site-font/devps/$PFA" "/usr/share/groff/site-font/devpdf/$PFA"
|
||||||
#sudo ln -sf "/usr/share/groff/site-font/devps/$GROFFNAME" "/usr/share/groff/site-font/devpdf/$GROFFNAME"
|
#sudo ln -sf "/usr/share/groff/site-font/devps/$GROFFNAME" "/usr/share/groff/site-font/devpdf/$GROFFNAME"
|
||||||
|
|
||||||
GROFF_CURRENT=$(readlink -f /usr/share/groff/current)
|
|
||||||
if ! grep "$PFA" "$GROFF_CURRENT/font/devps/download" ; then
|
|
||||||
printf '%s\t%s\n' "$INA" "$PFA" >> "$GROFF_CURRENT/font/devps/download"
|
|
||||||
fi
|
|
||||||
#if ! grep "$PFA" "$GROFF_CURRENT/font/devpdf/download" ; then
|
#if ! grep "$PFA" "$GROFF_CURRENT/font/devpdf/download" ; then
|
||||||
#printf '\t%s\t%s\n' "$GROFFNAME" "$PFA" >> "$GROFF_CURRENT/font/devpdf/download"
|
#printf '\t%s\t%s\n' "$GROFFNAME" "$PFA" >> "$GROFF_CURRENT/font/devpdf/download"
|
||||||
#fi
|
#fi
|
||||||
|
|
||||||
cd -
|
|
||||||
rm -rf "$TMPDIR"
|
|
||||||
|
|
||||||
# groff -ms -U -Kutf8 input.ms > tmp.ps
|
|
||||||
# ps2pdf tmp.ps output.ms
|
|
||||||
|
|
||||||
# to insert picture: convert input.jpg output.pdf
|
# to insert picture: convert input.jpg output.pdf
|
||||||
# in msfile use: .PICPDF output.pdf
|
# in msfile use: .PICPDF output.pdf
|
||||||
|
|
Loading…
Reference in New Issue
Block a user