[tex-k] ttf2pk and freetype (-lttf)

Werner LEMBERG wl at gnu.org
Wed Apr 2 07:21:02 CEST 2008


From: Peter Breitenlohner <peb at mppmu.mpg.de>
Subject: Re: ttf2pk and freetype (-lttf)
Date: Tue, 1 Apr 2008 17:15:14 +0200 (CEST)

> On Tue, 1 Apr 2008, Werner LEMBERG wrote:
> 
> > Yes, there have been some efforts to do that:
> >
> >  http://chem.skku.ac.kr/~wkpark/project/ktug/ttf2pk-freetype2_20030314.tgz
> >
> > I've never used it, nor do I know the status of it.
> 
> Thanks a lot, I'll have a look.

Some other links and patches I received:

. I was told here are extensions to create OVP/OVF files.

    http://ftp.ktug.or.kr/pub/ktug/freetype/contrib/

. Patrice Dumas sent to me a few weeks ago a patch which gives the
  differences between TeXLive and ttf2pk's CVS freetype1-contrib
  repository.  Attached.

. Dominique Unruh contributed this a few years ago:

    I have written (and attached) a patch to ttf2tfm [attached].  It
    adds a command line switch '-1 FONT' to ttf2tfm. When this switch
    is given (in subfont mode), only the file FONT.tfm is generated.

    This allows on-demand-generation of tfm-files in mktextfm using
    e.g. (assuming teTeX's scripts)

      if (ttf2pk -t -q $NAME) >/dev/null 2>&1; then
        cmd="mktextfm.ttf2tfm $NAME"
      elif [...]

    and the attached script mktextfm.ttf2tfm.


    Werner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ttf2pk.diff.bz2
Type: application/octet-stream
Size: 4223 bytes
Desc: not available
Url : http://tug.org/pipermail/tex-k/attachments/20080402/f5ef87bc/attachment.obj 
-------------- next part --------------
--- ttf2tfm.c.orig	Tue Apr 23 13:06:49 2002
+++ ttf2tfm.c	Tue Apr 23 13:44:19 2002
@@ -281,6 +281,7 @@
 -V SCFILE[.vpl]     like -v, but synthesize smallcaps as lowercase\n\
 -x                  rotate subfont glyphs by 90 degrees\n\
 -y REAL             move rotated glyphs down by a factor of REAL [0.25]\n\
+-1 FONT             only generates tfm for font FONT (FONT must not have suffix)\n\
 --help              print this message and exit\n\
 --version           print version number and exit\n\
 "
@@ -426,6 +427,14 @@
       fnt->inencname = newstring(argv[3]);
       break;
 
+    case '1':
+      if (argc <= 3)
+	oops("Missing parameter for -1 option.");
+      if (fnt->only_one_subfont)
+	free(fnt->only_one_subfont);
+      fnt->only_one_subfont = newstring(argv[3]);
+      break;
+
     case 'T':
       if (argc <= 3)
         oops("Missing parameter for -T option.");
@@ -677,6 +686,12 @@
       fnt->subfont_ligs = False;
     }
 
+    if (fnt->only_one_subfont)
+    {
+      warning("Ignoring `-1' switch for non-subfont.");
+      fnt->only_one_subfont = 0;
+    }
+
     if (fnt->rotate)
     {
       warning("Ignoring `-x' switch for non-subfont.");
@@ -793,14 +808,18 @@
 
   if (font.sfdname)
   {
+    int found_subfont = 0;
     while (get_sfd(&font))
     {
       char *temp;
       int i, start, end, len;
 
-
       get_tfm_fullname(&font);
 
+      if (font.only_one_subfont)
+	if (strcmp(font.fullname,font.only_one_subfont))
+	  continue;
+
       /*
        *   Extract base name of sfd file.
        */
@@ -841,10 +860,16 @@
         font.fontspace = transform(500, 0, font.efactor, font.slant);
 
       if (buildtfm(&font))
+      {
         writetfm(&font);
+	found_subfont = 1;
+      }
     }
 
     close_sfd();
+
+    if (!found_subfont && font.only_one_subfont)
+      oops("No subfont called '%s' generated",font.only_one_subfont);
   }
   else
   {
--- ttf2tfm.h.orig	Fri Apr 14 19:53:50 2000
+++ ttf2tfm.h	Tue Apr 23 13:16:42 2002
@@ -225,6 +225,7 @@
   char *slantparam;
   char *fontindexparam;
   char *y_offsetparam;
+  char *only_one_subfont;
 };
 typedef struct _Font Font;
 
--- newobj.c.orig	Tue Apr 23 13:28:08 2002
+++ newobj.c	Tue Apr 23 13:28:12 2002
@@ -336,6 +336,7 @@
   fnt->pidparam = NULL;
   fnt->eidparam = NULL;
   fnt->y_offsetparam = NULL;
+  fnt->only_one_subfont = NULL;
 
   for (i = 0; i < 256; i++)
   {
-------------- next part --------------
#!/bin/sh

# Written by Dominique Unruh <dominique at unruh.de>, 2002, GPL

# Usage: mktextfm.ttf2tfm FONT
# FONT may not have a suffix

TEMPFILE="temp-runttf2tfm-$RANDOM-1.tmp"
TEMPFILE2="temp-runttf2tfm-$RANDOM-2.tmp"
ttf2pk -t "$1" | tail -2 >"$TEMPFILE"
DESIRED="$1"
cat $TEMPFILE
read -a TTFONTSLINE <"$TEMPFILE"
rm "$TEMPFILE"
FONT="${TTFONTSLINE[0]}"
TTFFILE="${TTFONTSLINE[1]}"
set -- "${TTFONTSLINE[@]}"
shift; shift
declare -a ARGS
while [ "$#" -gt 0 ]; do
    case "$1" in
	*=*) KEY="${1%=*}"; VAL="${1#*=}";;
	*) KEY="$1"
	   test "$2" = "=" || exit 2
	   VAL="$3"
	   shift; shift;;
    esac; shift

    #echo "KEY:VAL: $KEY:$VAL"
    ADD1=; ADD2="$VAL"; DOADD2=1
    case "$KEY" in
	Slant) ADD1="-s";;
	Extend) ADD1=-e;;
	Encoding) ADD1=-p;;
	Fontindex) ADD1=-f;;
	Pid) ADD1=-P;;
	Eid) ADD1=-E;;
	Replacement) ADD1=-R;;
	Y-Offset) ADD1=-y;;
	PS|Rotate) DOADD2=
	    case "$KEY=$VAL" in
		PS=Yes) ADD1=-n;;
		PS=Only) ADD1=-N;;
		Rotate=Yes) ADD1=-x;;
		*) echo "Unknown value in '$KEY=$VAL' in ttfonts.map" >&2
		    exit 6;;
	    esac;;
	*) echo "Unknown key '$KEY' in ttfonts.map" >&2; exit 3;;
    esac
    ARGS[${#ARGS[*]}]="$ADD1"
    test -n "$DOADD2" && ARGS[${#ARGS[*]}]="$ADD2"
done

echo >&2 running: ttf2tfm "$TTFFILE" -1 "$DESIRED"  "${ARGS[@]}" "$FONT"
ttf2tfm "$TTFFILE" -1 "$DESIRED" "${ARGS[@]}" "$FONT" >"$TEMPFILE" 2>"$TEMPFILE2"
TTF2TFM_RC=$?
cat "$TEMPFILE2"

if grep -q 'WARNING: Unknown option `-1 ' "$TEMPFILE2"; then
    grep '^[^[:space:]]\+:$' "$TEMPFILE" | while read FILE; do
	FILE="${FILE%:}"
	test "$FILE" = "$DESIRED" || rm -f "$FILE.tfm"
    done
fi

rm "$TEMPFILE" "$TEMPFILE2"

exit $TTF2TFM_RC



More information about the tex-k mailing list