ref: a929ba9b205c9756f1c0d3c261185e3bacf7fdad
parent: 994d7747fb075447818af6cfdd40e1a493257c5a
author: Werner Lemberg <[email protected]>
date: Sun Jun 25 02:47:11 EDT 2000
applying formatting again
--- a/config/modules.mk
+++ b/config/modules.mk
@@ -51,7 +51,7 @@
#
ifneq ($(findstring $(PLATFORM),dos win32 win16 os2),)
OPEN_MODULE := @echo #
- CLOSE_MODULE := >> $(subst /,\,$(FT_MODULE_LIST))
+ CLOSE_MODULE := >> $(subst $(SEP),$(HOSTSEP),$(FT_MODULE_LIST))
else
OPEN_MODULE := @echo "
CLOSE_MODULE := " >> $(FT_MODULE_LIST)
--- a/config/unix/config.guess
+++ b/config/unix/config.guess
@@ -1,8 +1,10 @@
#! /bin/sh
# Attempt to guess a canonical system name.
-# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
# Free Software Foundation, Inc.
-#
+
+version='2000-06-13'
+
# This file is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
@@ -23,8 +25,7 @@
# the same distribution terms that you use for the rest of that program.
# Written by Per Bothner <[email protected]>.
-# The master version of this file is at the FSF in /home/gd/gnu/lib.
-# Please send patches to <[email protected]>.
+# Please send patches to <[email protected]>.
#
# This script attempts to guess a canonical system name similar to
# config.sub. If it succeeds, it prints the system name on stdout, and
@@ -37,6 +38,46 @@
# (but try to keep the structure clean).
#
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of this system.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -V, --version print version number, then exit"
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case "$1" in
+ --version | --vers* | -V )
+ echo "$version" ; exit 0 ;;
+ --help | --h* | -h )
+ echo "$usage"; exit 0 ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ exec >&2
+ echo "$me: invalid option $1"
+ echo "$help"
+ exit 1 ;;
+ * )
+ break ;;
+ esac
+done
+
+if test $# != 0; then
+ echo "$me: too many arguments$help" >&2
+ exit 1
+fi
+
# Use $HOST_CC if defined. $CC may point to a cross-compiler
if test x"$CC_FOR_BUILD" = x; then
if test x"$HOST_CC" != x; then
@@ -68,6 +109,43 @@
# Note: order is significant - the case branches are not exclusive.
case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+ *:NetBSD:*:*)
+ # Netbsd (nbsd) targets should (where applicable) match one or
+ # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+ # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
+ # switched to ELF, *-*-netbsd* would select the old
+ # object file format. This provides both forward
+ # compatibility and a consistent mechanism for selecting the
+ # object file format.
+ # Determine the machine/vendor (is the vendor relevant).
+ case "${UNAME_MACHINE}" in
+ amiga) machine=m68k-cbm ;;
+ arm32) machine=arm-unknown ;;
+ atari*) machine=m68k-atari ;;
+ sun3*) machine=m68k-sun ;;
+ mac68k) machine=m68k-apple ;;
+ macppc) machine=powerpc-apple ;;
+ hp3[0-9][05]) machine=m68k-hp ;;
+ ibmrt|romp-ibm) machine=romp-ibm ;;
+ *) machine=${UNAME_MACHINE}-unknown ;;
+ esac
+ # The Operating System including object format.
+ if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+ | grep __ELF__ >/dev/null
+ then
+ # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+ # Return netbsd for either. FIX?
+ os=netbsd
+ else
+ os=netbsdelf
+ fi
+ # The OS release
+ release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+ # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+ # contains redundant information, the shorter form:
+ # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+ echo "${machine}-${os}${release}"
+ exit 0 ;;
alpha:OSF1:*:*)
if test $UNAME_RELEASE = "V4.0"; then
UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
@@ -77,41 +155,51 @@
# A Xn.n version is an unreleased experimental baselevel.
# 1.2 uses "1.2" for uname -r.
cat <<EOF >$dummy.s
+ .data
+\$Lformat:
+ .byte 37,100,45,37,120,10,0 # "%d-%x\n"
+
+ .text
.globl main
+ .align 4
.ent main
main:
- .frame \$30,0,\$26,0
- .prologue 0
- .long 0x47e03d80 # implver $0
- lda \$2,259
- .long 0x47e20c21 # amask $2,$1
- srl \$1,8,\$2
- sll \$2,2,\$2
- sll \$0,3,\$0
- addl \$1,\$0,\$0
- addl \$2,\$0,\$0
- ret \$31,(\$26),1
+ .frame \$30,16,\$26,0
+ ldgp \$29,0(\$27)
+ .prologue 1
+ .long 0x47e03d80 # implver \$0
+ lda \$2,-1
+ .long 0x47e20c21 # amask \$2,\$1
+ lda \$16,\$Lformat
+ mov \$0,\$17
+ not \$1,\$18
+ jsr \$26,printf
+ ldgp \$29,0(\$26)
+ mov 0,\$16
+ jsr \$26,exit
.end main
EOF
$CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
if test "$?" = 0 ; then
- ./$dummy
- case "$?" in
- 7)
+ case `./$dummy` in
+ 0-0)
UNAME_MACHINE="alpha"
;;
- 15)
+ 1-0)
UNAME_MACHINE="alphaev5"
;;
- 14)
+ 1-1)
UNAME_MACHINE="alphaev56"
;;
- 10)
+ 1-101)
UNAME_MACHINE="alphapca56"
;;
- 16)
+ 2-303)
UNAME_MACHINE="alphaev6"
;;
+ 2-307)
+ UNAME_MACHINE="alphaev67"
+ ;;
esac
fi
rm -f $dummy.s $dummy
@@ -129,9 +217,6 @@
Amiga*:UNIX_System_V:4.0:*)
echo m68k-cbm-sysv4
exit 0;;
- amiga:NetBSD:*:*)
- echo m68k-cbm-netbsd${UNAME_RELEASE}
- exit 0 ;;
amiga:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
@@ -162,9 +247,6 @@
arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
echo arm-acorn-riscix${UNAME_RELEASE}
exit 0;;
- arm32:NetBSD:*:*)
- echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
- exit 0 ;;
SR2?01:HI-UX/MPP:*:*)
echo hppa1.1-hitachi-hiuxmpp
exit 0;;
@@ -221,15 +303,12 @@
aushp:SunOS:*:*)
echo sparc-auspex-sunos${UNAME_RELEASE}
exit 0 ;;
- atari*:NetBSD:*:*)
- echo m68k-atari-netbsd${UNAME_RELEASE}
- exit 0 ;;
atari*:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
# The situation for MiNT is a little confusing. The machine name
# can be virtually everything (everything which is not
- # "atarist" or "atariste" at least should have a processor
+ # "atarist" or "atariste" at least should have a processor
# > m68000). The system name ranges from "MiNT" over "FreeMiNT"
# to the lowercase version "mint" (or "freemint"). Finally
# the system name "TOS" denotes a system which is actually not
@@ -253,15 +332,9 @@
*:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
echo m68k-unknown-mint${UNAME_RELEASE}
exit 0 ;;
- sun3*:NetBSD:*:*)
- echo m68k-sun-netbsd${UNAME_RELEASE}
- exit 0 ;;
sun3*:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
- mac68k:NetBSD:*:*)
- echo m68k-apple-netbsd${UNAME_RELEASE}
- exit 0 ;;
mac68k:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
@@ -274,9 +347,6 @@
powerpc:machten:*:*)
echo powerpc-apple-machten${UNAME_RELEASE}
exit 0 ;;
- macppc:NetBSD:*:*)
- echo powerpc-apple-netbsd${UNAME_RELEASE}
- exit 0 ;;
RISC*:Mach:*:*)
echo mips-dec-mach_bsd4.3
exit 0 ;;
@@ -292,6 +362,7 @@
mips:*:*:UMIPS | mips:*:*:RISCos)
sed 's/^ //' << EOF >$dummy.c
#ifdef __cplusplus
+#include <stdio.h> /* for printf() prototype */
int main (int argc, char *argv[]) {
#else
int main (argc, argv) int argc; char *argv[]; {
@@ -331,7 +402,7 @@
AViiON:dgux:*:*)
# DG/UX returns AViiON for all architectures
UNAME_PROCESSOR=`/usr/bin/uname -p`
- if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110]
+ if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
then
if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
[ ${TARGET_BINARY_INTERFACE}x = x ]
@@ -408,7 +479,7 @@
ibmrt:4.4BSD:*|romp-ibm:BSD:*)
echo romp-ibm-bsd4.4
exit 0 ;;
- ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC NetBSD and
+ ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and
echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to
exit 0 ;; # report: romp-ibm BSD 4.3
*:BOSX:*:*)
@@ -429,6 +500,8 @@
9000/[34]?? ) HP_ARCH=m68k ;;
9000/[678][0-9][0-9])
sed 's/^ //' << EOF >$dummy.c
+
+ #define _HPUX_SOURCE
#include <stdlib.h>
#include <unistd.h>
@@ -553,11 +626,14 @@
-e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
exit 0 ;;
CRAY*TS:*:*:*)
- echo t90-cray-unicos${UNAME_RELEASE}
+ echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;;
CRAY*T3E:*:*:*)
- echo alpha-cray-unicosmk${UNAME_RELEASE}
+ echo alpha-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
exit 0 ;;
+ CRAY*SV1:*:*:*)
+ echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+ exit 0 ;;
CRAY-2:*:*:*)
echo cray2-cray-unicos
exit 0 ;;
@@ -569,13 +645,10 @@
F301:UNIX_System_V:*:*)
echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'`
exit 0 ;;
- hp3[0-9][05]:NetBSD:*:*)
- echo m68k-hp-netbsd${UNAME_RELEASE}
- exit 0 ;;
hp300:OpenBSD:*:*)
echo m68k-unknown-openbsd${UNAME_RELEASE}
exit 0 ;;
- i?86:BSD/386:*:* | i?86:BSD/OS:*:*)
+ i?86:BSD/386:*:* | i?86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
exit 0 ;;
sparc*:BSD/OS:*:*)
@@ -585,17 +658,8 @@
echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
exit 0 ;;
*:FreeBSD:*:*)
- if test -x /usr/bin/objformat; then
- if test "elf" = "`/usr/bin/objformat`"; then
- echo ${UNAME_MACHINE}-unknown-freebsdelf`echo ${UNAME_RELEASE}|sed -e 's/[-_].*//'`
- exit 0
- fi
- fi
echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
exit 0 ;;
- *:NetBSD:*:*)
- echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*//'`
- exit 0 ;;
*:OpenBSD:*:*)
echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
exit 0 ;;
@@ -623,6 +687,9 @@
*:GNU:*:*)
echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
exit 0 ;;
+ i*86:Minix:*:*)
+ echo ${UNAME_MACHINE}-pc-minix
+ exit 0 ;;
*:Linux:*:*)
# The BFD linker knows what the default object file format is, so
@@ -644,6 +711,10 @@
echo "${UNAME_MACHINE}-pc-linux-gnuaout"
exit 0
;;
+ elf_i?86)
+ echo "${UNAME_MACHINE}-pc-linux"
+ exit 0
+ ;;
i?86coff)
echo "${UNAME_MACHINE}-pc-linux-gnucoff"
exit 0
@@ -657,7 +728,7 @@
exit 0
;;
elf32arm*)
- echo "${UNAME_MACHINE}-unknown-linux-gnu"
+ echo "${UNAME_MACHINE}-unknown-linux-gnuoldld"
exit 0
;;
armelf_linux*)
@@ -668,7 +739,7 @@
echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
exit 0
;;
- elf32ppc)
+ elf32ppc | elf32ppclinux)
# Determine Lib Version
cat >$dummy.c <<EOF
#include <features.h>
@@ -695,51 +766,65 @@
if test "$?" = 0 ; then
LIBC="libc1"
fi
- fi
+ fi
rm -f $dummy.c $dummy
echo powerpc-unknown-linux-gnu${LIBC}
exit 0
;;
+ shelf_linux)
+ echo "${UNAME_MACHINE}-unknown-linux-gnu"
+ exit 0
+ ;;
esac
if test "${UNAME_MACHINE}" = "alpha" ; then
- sed 's/^ //' <<EOF >$dummy.s
- .globl main
- .ent main
- main:
- .frame \$30,0,\$26,0
- .prologue 0
- .long 0x47e03d80 # implver $0
- lda \$2,259
- .long 0x47e20c21 # amask $2,$1
- srl \$1,8,\$2
- sll \$2,2,\$2
- sll \$0,3,\$0
- addl \$1,\$0,\$0
- addl \$2,\$0,\$0
- ret \$31,(\$26),1
- .end main
+ cat <<EOF >$dummy.s
+ .data
+ \$Lformat:
+ .byte 37,100,45,37,120,10,0 # "%d-%x\n"
+
+ .text
+ .globl main
+ .align 4
+ .ent main
+ main:
+ .frame \$30,16,\$26,0
+ ldgp \$29,0(\$27)
+ .prologue 1
+ .long 0x47e03d80 # implver \$0
+ lda \$2,-1
+ .long 0x47e20c21 # amask \$2,\$1
+ lda \$16,\$Lformat
+ mov \$0,\$17
+ not \$1,\$18
+ jsr \$26,printf
+ ldgp \$29,0(\$26)
+ mov 0,\$16
+ jsr \$26,exit
+ .end main
EOF
LIBC=""
$CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
if test "$?" = 0 ; then
- ./$dummy
- case "$?" in
- 7)
+ case `./$dummy` in
+ 0-0)
UNAME_MACHINE="alpha"
;;
- 15)
+ 1-0)
UNAME_MACHINE="alphaev5"
;;
- 14)
+ 1-1)
UNAME_MACHINE="alphaev56"
;;
- 10)
+ 1-101)
UNAME_MACHINE="alphapca56"
;;
- 16)
+ 2-303)
UNAME_MACHINE="alphaev6"
;;
+ 2-307)
+ UNAME_MACHINE="alphaev67"
+ ;;
esac
objdump --private-headers $dummy | \
@@ -753,6 +838,7 @@
elif test "${UNAME_MACHINE}" = "mips" ; then
cat >$dummy.c <<EOF
#ifdef __cplusplus
+#include <stdio.h> /* for printf() prototype */
int main (int argc, char *argv[]) {
#else
int main (argc, argv) int argc; char *argv[]; {
@@ -768,6 +854,8 @@
EOF
$CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0
rm -f $dummy.c $dummy
+ elif test "${UNAME_MACHINE}" = "s390"; then
+ echo s390-ibm-linux && exit 0
else
# Either a pre-BFD a.out linker (linux-gnuoldld)
# or one that does not give us useful --help.
@@ -789,6 +877,7 @@
cat >$dummy.c <<EOF
#include <features.h>
#ifdef __cplusplus
+#include <stdio.h> /* for printf() prototype */
int main (int argc, char *argv[]) {
#else
int main (argc, argv) int argc; char *argv[]; {
@@ -860,7 +949,11 @@
echo ${UNAME_MACHINE}-pc-sysv32
fi
exit 0 ;;
+ i?86:*DOS:*:*)
+ echo ${UNAME_MACHINE}-pc-msdosdjgpp
+ exit 0 ;;
pc:*:*:*)
+ # Left here for compatibility:
# uname -m prints for DJGPP always 'pc', but it prints nothing about
# the processor, so we play safe by assuming i386.
echo i386-pc-msdosdjgpp
@@ -974,9 +1067,27 @@
*:Rhapsody:*:*)
echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
exit 0 ;;
+ *:Darwin:*:*)
+ echo `uname -p`-apple-darwin${UNAME_RELEASE}
+ exit 0 ;;
+ *:procnto*:*:* | *:QNX:[0123456789]*:*)
+ if test "${UNAME_MACHINE}" = "x86pc"; then
+ UNAME_MACHINE=pc
+ fi
+ echo `uname -p`-${UNAME_MACHINE}-nto-qnx
+ exit 0 ;;
*:QNX:*:4*)
- echo i386-qnx-qnx${UNAME_VERSION}
+ echo i386-pc-qnx
exit 0 ;;
+ NSR-W:NONSTOP_KERNEL:*:*)
+ echo nsr-tandem-nsk${UNAME_RELEASE}
+ exit 0 ;;
+ BS2000:POSIX*:*:*)
+ echo bs2000-siemens-sysv
+ exit 0 ;;
+ DS/*:UNIX_System_V:*:*)
+ echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+ exit 0 ;;
esac
#echo '(No uname command or uname output not recognized.)' 1>&2
@@ -1116,6 +1227,47 @@
esac
fi
-#echo '(Unable to guess system type)' 1>&2
+cat >&2 <<EOF
+$0: unable to guess system type
+The $version version of this script cannot recognize your system type.
+Please download the most up to date version of the config scripts:
+
+ ftp://ftp.gnu.org/pub/gnu/config/
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <[email protected]> in order to provide the needed
+information to handle your system.
+
+config.guess version = $version
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo = `(hostinfo) 2>/dev/null`
+/bin/universe = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "version='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
--- a/config/unix/config.sub
+++ b/config/unix/config.sub
@@ -1,6 +1,10 @@
#! /bin/sh
# Configuration validation subroutine script, version 1.1.
-# Copyright (C) 1991, 92-97, 1998, 1999 Free Software Foundation, Inc.
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
+# Free Software Foundation, Inc.
+
+version='2000-06-20'
+
# This file is (in principle) common to ALL GNU software.
# The presence of a machine in this file suggests that SOME GNU software
# can handle that machine. It does not imply ALL GNU software can.
@@ -25,6 +29,8 @@
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
+# Please send patches to <[email protected]>.
+#
# Configuration subroutine to validate and canonicalize a configuration type.
# Supply the specified configuration type as an argument.
# If it is invalid, we print an error message on stderr and exit with code 1.
@@ -45,23 +51,54 @@
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
# It is wrong to echo any other type of specification.
-if [ x$1 = x ]
-then
- echo Configuration name missing. 1>&2
- echo "Usage: $0 CPU-MFR-OPSYS" 1>&2
- echo "or $0 ALIAS" 1>&2
- echo where ALIAS is a recognized configuration type. 1>&2
- exit 1
-fi
+me=`echo "$0" | sed -e 's,.*/,,'`
-# First pass through any local machine types.
-case $1 in
- *local*)
- echo $1
- exit 0
- ;;
- *)
- ;;
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+ $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+ -h, --help print this help, then exit
+ -V, --version print version number, then exit"
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+ case "$1" in
+ --version | --vers* | -V )
+ echo "$version" ; exit 0 ;;
+ --help | --h* | -h )
+ echo "$usage"; exit 0 ;;
+ -- ) # Stop option processing
+ shift; break ;;
+ - ) # Use stdin as input.
+ break ;;
+ -* )
+ exec >&2
+ echo "$me: invalid option $1"
+ echo "$help"
+ exit 1 ;;
+
+ *local*)
+ # First pass through any local machine types.
+ echo $1
+ exit 0;;
+
+ * )
+ break ;;
+ esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+ exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+ exit 1;;
esac
# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
@@ -68,7 +105,7 @@
# Here we must recognize all the valid KERNEL-OS combinations.
maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
case $maybe_os in
- linux-gnu*)
+ nto-qnx* | linux-gnu*)
os=-$maybe_os
basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
;;
@@ -94,7 +131,7 @@
-convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
- -apple)
+ -apple | -axis)
os=
basic_machine=$1
;;
@@ -169,15 +206,19 @@
tahoe | i860 | ia64 | m32r | m68k | m68000 | m88k | ns32k | arc | arm \
| arme[lb] | pyramid | mn10200 | mn10300 | tron | a29k \
| 580 | i960 | h8300 \
+ | x86 | ppcbe | mipsbe | mipsle | shbe | shle | armbe | armle \
| hppa | hppa1.0 | hppa1.1 | hppa2.0 | hppa2.0w | hppa2.0n \
- | alpha | alphaev[4-7] | alphaev56 | alphapca5[67] \
- | we32k | ns16k | clipper | i370 | sh | powerpc | powerpcle \
+ | hppa64 \
+ | alpha | alphaev[4-8] | alphaev56 | alphapca5[67] \
+ | alphaev6[78] \
+ | we32k | ns16k | clipper | i370 | sh | sh[34] \
+ | powerpc | powerpcle \
| 1750a | dsp16xx | pdp11 | mips16 | mips64 | mipsel | mips64el \
| mips64orion | mips64orionel | mipstx39 | mipstx39el \
| mips64vr4300 | mips64vr4300el | mips64vr4100 | mips64vr4100el \
| mips64vr5000 | miprs64vr5000el | mcore \
| sparc | sparclet | sparclite | sparc64 | sparcv9 | v850 | c4x \
- | thumb | d10v | fr30)
+ | thumb | d10v | fr30 | avr)
basic_machine=$basic_machine-unknown
;;
m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | z8k | v70 | h8500 | w65 | pj | pjl)
@@ -186,7 +227,7 @@
# We use `pc' rather than `unknown'
# because (1) that's what they normally are, and
# (2) the word "unknown" tends to confuse beginning users.
- i[34567]86)
+ i[234567]86)
basic_machine=$basic_machine-pc
;;
# Object if more than one company name word.
@@ -196,13 +237,16 @@
;;
# Recognize the basic CPU types with company name.
# FIXME: clean up the formatting here.
- vax-* | tahoe-* | i[34567]86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \
+ vax-* | tahoe-* | i[234567]86-* | i860-* | ia64-* | m32r-* | m68k-* | m68000-* \
| m88k-* | sparc-* | ns32k-* | fx80-* | arc-* | arm-* | c[123]* \
| mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* \
| power-* | none-* | 580-* | cray2-* | h8300-* | h8500-* | i960-* \
| xmp-* | ymp-* \
- | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* | hppa2.0n-* \
- | alpha-* | alphaev[4-7]-* | alphaev56-* | alphapca5[67]-* \
+ | x86-* | ppcbe-* | mipsbe-* | mipsle-* | shbe-* | shle-* | armbe-* | armle-* \
+ | hppa-* | hppa1.0-* | hppa1.1-* | hppa2.0-* | hppa2.0w-* \
+ | hppa2.0n-* | hppa64-* \
+ | alpha-* | alphaev[4-8]-* | alphaev56-* | alphapca5[67]-* \
+ | alphaev6[78]-* \
| we32k-* | cydra-* | ns16k-* | pn-* | np1-* | xps100-* \
| clipper-* | orion-* \
| sparclite-* | pdp11-* | sh-* | powerpc-* | powerpcle-* \
@@ -210,9 +254,10 @@
| mips64el-* | mips64orion-* | mips64orionel-* \
| mips64vr4100-* | mips64vr4100el-* | mips64vr4300-* | mips64vr4300el-* \
| mipstx39-* | mipstx39el-* | mcore-* \
- | f301-* | armv*-* | t3e-* \
+ | f301-* | armv*-* | s390-* | sv1-* | t3e-* \
| m88110-* | m680[01234]0-* | m683?2-* | m68360-* | z8k-* | d10v-* \
- | thumb-* | v850-* | d30v-* | tic30-* | c30-* | fr30-* )
+ | thumb-* | v850-* | d30v-* | tic30-* | c30-* | fr30-* \
+ | bs2000-* | tic54x-* | c54x-*)
;;
# Recognize the various machine names and aliases which stand
# for a CPU type and a company and sometimes even an OS.
@@ -310,6 +355,9 @@
crds | unos)
basic_machine=m68k-crds
;;
+ cris | cris-* | etrax*)
+ basic_machine=cris-axis
+ ;;
da30 | da30-*)
basic_machine=m68k-da30
;;
@@ -464,9 +512,6 @@
basic_machine=i386-unknown
os=-mingw32
;;
- i386-qnx | qnx)
- basic_machine=i386-qnx
- ;;
iris | iris4d)
basic_machine=mips-sgi
case $os in
@@ -513,6 +558,10 @@
mips3*)
basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
;;
+ mmix*)
+ basic_machine=mmix-knuth
+ os=-mmixware
+ ;;
monitor)
basic_machine=m68k-rom68k
os=-coff
@@ -585,6 +634,9 @@
np1)
basic_machine=np1-gould
;;
+ nsr-tandem)
+ basic_machine=nsr-tandem
+ ;;
op50n-* | op60c-*)
basic_machine=hppa1.1-oki
os=-proelf
@@ -617,7 +669,7 @@
pentium | p5 | k5 | k6 | nexen)
basic_machine=i586-pc
;;
- pentiumpro | p6 | 6x86)
+ pentiumpro | p6 | 6x86 | athlon)
basic_machine=i686-pc
;;
pentiumii | pentium2)
@@ -626,7 +678,7 @@
pentium-* | p5-* | k5-* | k6-* | nexen-*)
basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
- pentiumpro-* | p6-* | 6x86-*)
+ pentiumpro-* | p6-* | 6x86-* | athlon-*)
basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
;;
pentiumii-* | pentium2-*)
@@ -729,6 +781,10 @@
sun386 | sun386i | roadrunner)
basic_machine=i386-sun
;;
+ sv1)
+ basic_machine=sv1-cray
+ os=-unicos
+ ;;
symmetry)
basic_machine=i386-sequent
os=-dynix
@@ -737,6 +793,10 @@
basic_machine=t3e-cray
os=-unicos
;;
+ tic54x | c54x*)
+ basic_machine=tic54x-unknown
+ os=-coff
+ ;;
tx39)
basic_machine=mipstx39-unknown
;;
@@ -838,6 +898,9 @@
we32k)
basic_machine=we32k-att
;;
+ sh3 | sh4)
+ base_machine=sh-unknown
+ ;;
sparc | sparcv9)
basic_machine=sparc-sun
;;
@@ -918,12 +981,25 @@
| -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
| -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
| -mingw32* | -linux-gnu* | -uxpv* | -beos* | -mpeix* | -udk* \
- | -interix* | -uwin* | -rhapsody* | -opened* | -openstep* | -oskit*)
+ | -interix* | -uwin* | -rhapsody* | -darwin* | -opened* \
+ | -openstep* | -oskit*)
# Remember, each alternative MUST END IN *, to match a version number.
;;
+ -qnx*)
+ case $basic_machine in
+ x86-* | i[34567]86-*)
+ ;;
+ *)
+ os=-nto$os
+ ;;
+ esac
+ ;;
+ -nto*)
+ os=-nto-qnx
+ ;;
-sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
| -windows* | -osx | -abug | -netware* | -os9* | -beos* \
- | -macos* | -mpw* | -magic* | -mon960* | -lnews*)
+ | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
;;
-mac*)
os=`echo $os | sed -e 's|mac|macos|'`
@@ -940,6 +1016,9 @@
-opened*)
os=-openedition
;;
+ -wince*)
+ os=-wince
+ ;;
-osfrose*)
os=-osfrose
;;
@@ -964,6 +1043,9 @@
-ns2 )
os=-nextstep2
;;
+ -nsk)
+ os=-nsk
+ ;;
# Preserve the version number of sinix5.
-sinix5.*)
os=`echo $os | sed -e 's|sinix|sysv|'`
@@ -977,9 +1059,6 @@
-oss*)
os=-sysv3
;;
- -qnx)
- os=-qnx4
- ;;
-svr4)
os=-sysv4
;;
@@ -1230,3 +1309,11 @@
esac
echo $basic_machine$os
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "version='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
--- a/config/win32/w32-lcc.mk
+++ b/config/win32/w32-lcc.mk
@@ -119,7 +119,8 @@
# librarian library_file {list of object files}
#
$(FT_LIBRARY): $(OBJECTS_LIST)
- lcclib /out:$(subst /,\\,$@) $(subst /,\\,$(OBJECTS_LIST))
+ lcclib /out:$(subst $(SEP),$(HOSTSEP),$@) \
+ $(subst $(SEP),$(HOSTSEP),$(OBJECTS_LIST))
endif
--- a/docs/tutorial/index.html
+++ b/docs/tutorial/index.html
@@ -94,7 +94,7 @@
<li>
<p>Load each modules that FreeType knows about in the library.
This means that by default, your new <tt>library</tt> object is able
- to handle TrueType, Type 1, CID-keyed & OpenType/CFF fonts
+ to handle TrueType, Type 1, CID-keyed & OpenType/CFF fonts
gracefully.</p>
</li>
</ul>
@@ -240,7 +240,8 @@
FreeType 2 reference manual in order to learn how to use it.</p>
<p>Note that providing a custom stream might also be used to access a
- TrueType font embedded in a Postscript Type42 wrapper..</p>
+ TrueType font embedded in a Postscript Type 42 wrapper.</p>
+
<hr>
<h3>
@@ -487,27 +488,26 @@
</li>
<li>
<p>If there is a glyph image in another format (e.g. a vectorial
- outline), load it in the glyph slot. Then, scale it to the
- current size, unless the <tt>FT_LOAD_NO_SCALE</tt> flag is
- set.</p>
+ outline), load it in the glyph slot. Then, scale it to the
+ current size, unless the <tt>FT_LOAD_NO_SCALE</tt> flag is
+ set.</p>
</li>
<li>
- <p>If the glyph image was loaded and scaled, try to grid-fit it (which
- dramatically improves its quality) unless the flag
+ <p>If the glyph image was loaded and scaled, try to grid-fit it
+ (which dramatically improves its quality) unless the flag
<tt>FT_LOAD_NO_HINTING</tt> is set.</p>
</li>
-
<li>
- <p>If the glyph image is scalable, transform it through the current
- transform (that can be set with <tt>FT_Set_Transform</tt>).</p>
+ <p>If the glyph image is scalable, transform it through the
+ current transform (which can be set with
+ <tt>FT_Set_Transform()</tt>).</p>
</li>
-
<li>
- <p>Finally, if the <tt>FT_LOAD_RENDER</tt> flag is set, convert the
- glyph image into a bitmap. By default, this means a 1-bit
- monochrome bitmap, unless <tt>FT_LOAD_ANTI_ALIAS</tt> is set,
- where an 8-bit 256-gray-levels anti-aliased bitmap is generated.
- </p>
+ <p>Finally, if the <tt>FT_LOAD_RENDER</tt> flag is set, convert
+ the glyph image into a bitmap. By default, this means a 1-bit
+ monochrome bitmap, unless <tt>FT_LOAD_ANTI_ALIAS</tt> is set,
+ in which case an 8-bit 256-gray-levels anti-aliased bitmap is
+ generated.</p>
</li>
</ul>
--- a/src/base/ftextend.c
+++ b/src/base/ftextend.c
@@ -143,6 +143,7 @@
FT_Int n = registry->num_extensions;
FT_Extension_Class* cur = registry->classes + n;
+
if ( n >= FT_MAX_EXTENSIONS )
return FT_Err_Too_Many_Extensions;
--- a/src/base/ftglyph.c
+++ b/src/base/ftglyph.c
@@ -210,8 +210,8 @@
/* transform the outline -- note that the original metrics are NOT */
/* transformed by this, only the outline points themselves... */
FT_Outline_Translate( &face->glyph->outline,
- origin_x,
- origin_y );
+ origin_x,
+ origin_y );
/* compute the size in pixels of the outline */
FT_Outline_Get_CBox( &face->glyph->outline, &cbox );
--- a/src/base/ftmm.c
+++ b/src/base/ftmm.c
@@ -48,7 +48,7 @@
func = (FT_Get_MM_Func)driver->root.clazz->get_interface(
- FT_MODULE(driver), "get_mm" );
+ FT_MODULE( driver ), "get_mm" );
if ( func )
error = func( face, master );
}
@@ -77,7 +77,7 @@
func = (FT_Set_MM_Design_Func)driver->root.clazz->get_interface(
- FT_MODULE(driver), "set_mm_design" );
+ FT_MODULE( driver ), "set_mm_design" );
if ( func )
error = func( face, num_coords, coords );
}
@@ -106,7 +106,7 @@
func = (FT_Set_MM_Blend_Func)driver->root.clazz->get_interface(
- FT_MODULE(driver), "set_mm_blend" );
+ FT_MODULE( driver ), "set_mm_blend" );
if ( func )
error = func( face, num_coords, coords );
}
--- a/src/base/ftobjs.c
+++ b/src/base/ftobjs.c
@@ -23,7 +23,9 @@
#include <freetype/tttables.h>
+#include <string.h> /* for strcmp() */
+
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
@@ -325,38 +327,43 @@
/*************************************************************************/
/*************************************************************************/
- /**************************************************************************
- *
- * The glyph loader is a simple object which is used to load a set of
- * glyphs easily. It is critical for the correct loading of composites.
- *
- * Ideally, one can see it as a stack of abstract "glyph" objects.
- *
- * loader.base is really the bottom of the stack. It describes a
- * single glyph image made of the juxtaposition of several
- * glyphs (those 'in the stack')
- *
- * loader.current describes the top of the stack, on which a new
- * glyph can be loaded.
- *
- * Rewind clears the stack
- * Prepare means set up "loader.current" for addition of a new glyph image
- * Add means add the 'current' glyph image to the 'base' one, and
- * prepare for another one..
- *
- * the glyph loader is now a base object. Each driver used to re-implement
- * it in one way or the other, which wasted code and energy..
- *
- *************************************************************************/
- /* create a new glyph loader */
- BASE_FUNC(FT_Error) FT_GlyphLoader_New( FT_Memory memory,
- FT_GlyphLoader* *aloader )
+ /*************************************************************************/
+ /* */
+ /* The glyph loader is a simple object which is used to load a set of */
+ /* glyphs easily. It is critical for the correct loading of composites. */
+ /* */
+ /* Ideally, one can see it as a stack of abstract `glyph' objects. */
+ /* */
+ /* loader.base Is really the bottom of the stack. It describes a */
+ /* single glyph image made of the juxtaposition of */
+ /* several glyphs (those `in the stack'). */
+ /* */
+ /* loader.current Describes the top of the stack, on which a new */
+ /* glyph can be loaded. */
+ /* */
+ /* Rewind Clears the stack. */
+ /* Prepare Set up `loader.current' for addition of a new glyph */
+ /* image. */
+ /* Add Add the `current' glyph image to the `base' one, */
+ /* and prepare for another one. */
+ /* */
+ /* The glyph loader is now a base object. Each driver used to */
+ /* re-implement it in one way or the other, which wasted code and */
+ /* energy. */
+ /* */
+ /*************************************************************************/
+
+
+ /* create a new glyph loader */
+ BASE_FUNC( FT_Error ) FT_GlyphLoader_New( FT_Memory memory,
+ FT_GlyphLoader** aloader )
{
FT_GlyphLoader* loader;
FT_Error error;
- if (!ALLOC(loader, sizeof(*loader)))
+
+ if ( !ALLOC( loader, sizeof ( *loader ) ) )
{
loader->memory = memory;
*aloader = loader;
@@ -365,12 +372,13 @@
}
- /* rewind the glyph loader - reset counters to 0 */
- BASE_FUNC(void) FT_GlyphLoader_Rewind( FT_GlyphLoader* loader )
+ /* rewind the glyph loader - reset counters to 0 */
+ BASE_FUNC( void ) FT_GlyphLoader_Rewind( FT_GlyphLoader* loader )
{
FT_GlyphLoad* base = &loader->base;
FT_GlyphLoad* current = &loader->current;
+
base->outline.n_points = 0;
base->outline.n_contours = 0;
base->num_subglyphs = 0;
@@ -379,11 +387,13 @@
}
- /* reset the glyph loader, frees all allocated tables and starts from zero */
- BASE_FUNC(void) FT_GlyphLoader_Reset( FT_GlyphLoader* loader )
+ /* reset the glyph loader, frees all allocated tables */
+ /* and starts from zero */
+ BASE_FUNC( void ) FT_GlyphLoader_Reset( FT_GlyphLoader* loader )
{
FT_Memory memory = loader->memory;
+
FREE( loader->base.outline.points );
FREE( loader->base.outline.tags );
FREE( loader->base.outline.contours );
@@ -398,13 +408,14 @@
}
- /* delete a glyph loader */
- BASE_FUNC(void) FT_GlyphLoader_Done( FT_GlyphLoader* loader )
+ /* delete a glyph loader */
+ BASE_FUNC( void ) FT_GlyphLoader_Done( FT_GlyphLoader* loader )
{
- if (loader)
+ if ( loader )
{
FT_Memory memory = loader->memory;
+
FT_GlyphLoader_Reset(loader);
FREE( loader );
}
@@ -411,56 +422,59 @@
}
- /* re-adjust the 'current' outline fields */
- static void FT_GlyphLoader_Adjust_Points( FT_GlyphLoader* loader )
+ /* re-adjust the `current' outline fields */
+ static void FT_GlyphLoader_Adjust_Points( FT_GlyphLoader* loader )
{
FT_Outline* base = &loader->base.outline;
FT_Outline* current = &loader->current.outline;
+
current->points = base->points + base->n_points;
current->tags = base->tags + base->n_points;
current->contours = base->contours + base->n_contours;
/* handle extra points table - if any */
- if (loader->use_extra)
- loader->current.extra_points = loader->base.extra_points + base->n_points;
+ if ( loader->use_extra )
+ loader->current.extra_points =
+ loader->base.extra_points + base->n_points;
}
-
- BASE_FUNC(FT_Error) FT_GlyphLoader_Create_Extra( FT_GlyphLoader* loader )
+ BASE_FUNC( FT_Error ) FT_GlyphLoader_Create_Extra(
+ FT_GlyphLoader* loader )
{
FT_Error error;
FT_Memory memory = loader->memory;
+
if ( !ALLOC_ARRAY( loader->base.extra_points,
loader->max_points, FT_Vector ) )
{
loader->use_extra = 1;
- FT_GlyphLoader_Adjust_Points(loader);
+ FT_GlyphLoader_Adjust_Points( loader );
}
return error;
}
-
-
- /* re-adjust the 'current' subglyphs field */
- static void FT_GlyphLoader_Adjust_Subglyphs( FT_GlyphLoader* loader )
+ /* re-adjust the `current' subglyphs field */
+ static void FT_GlyphLoader_Adjust_Subglyphs( FT_GlyphLoader* loader )
{
FT_GlyphLoad* base = &loader->base;
FT_GlyphLoad* current = &loader->current;
+
current->subglyphs = base->subglyphs + base->num_subglyphs;
}
- /* ensure that we can add n_points and n_contours to our glyph. this */
- /* function reallocates its outline tables if necessary. Note that */
- /* it DOESN'T change the number of points within the loader !! */
- BASE_FUNC(FT_Error) FT_GlyphLoader_Check_Points( FT_GlyphLoader* loader,
- FT_UInt n_points,
- FT_UInt n_contours )
+ /* Ensure that we can add `n_points' and `n_contours' to our glyph. this */
+ /* function reallocates its outline tables if necessary. Note that it */
+ /* DOESN'T change the number of points within the loader! */
+ BASE_FUNC( FT_Error ) FT_GlyphLoader_Check_Points(
+ FT_GlyphLoader* loader,
+ FT_UInt n_points,
+ FT_UInt n_contours )
{
FT_Memory memory = loader->memory;
FT_Error error = FT_Err_Ok;
@@ -470,18 +484,21 @@
FT_UInt new_max;
+
/* check points & tags */
new_max = base->n_points + current->n_points + n_points;
- if (new_max > loader->max_points)
+ if ( new_max > loader->max_points )
{
- new_max = (new_max+7) & -8;
- if ( REALLOC_ARRAY( base->points, base->n_points, new_max, FT_Vector ) ||
- REALLOC_ARRAY( base->tags, base->n_points, new_max, FT_Byte ) )
+ new_max = ( new_max + 7 ) & -8;
+ if ( REALLOC_ARRAY( base->points, base->n_points,
+ new_max, FT_Vector ) ||
+ REALLOC_ARRAY( base->tags, base->n_points,
+ new_max, FT_Byte ) )
goto Exit;
if ( loader->use_extra &&
- REALLOC_ARRAY( loader->base.extra_points, base->n_points, new_max,
- FT_Vector ) )
+ REALLOC_ARRAY( loader->base.extra_points, base->n_points,
+ new_max, FT_Vector ) )
goto Exit;
adjust = 1;
@@ -491,10 +508,11 @@
/* check contours */
new_max = base->n_contours + current->n_contours +
n_contours;
- if (new_max > loader->max_contours)
+ if ( new_max > loader->max_contours )
{
- new_max = (new_max+3) & -4;
- if (REALLOC_ARRAY( base->contours, base->n_contours, new_max, FT_Short ))
+ new_max = ( new_max + 3 ) & -4;
+ if ( REALLOC_ARRAY( base->contours, base->n_contours,
+ new_max, FT_Short ) )
goto Exit;
adjust = 1;
@@ -501,7 +519,7 @@
loader->max_contours = new_max;
}
- if (adjust)
+ if ( adjust )
FT_GlyphLoader_Adjust_Points( loader );
Exit:
@@ -509,11 +527,12 @@
}
- /* ensure that we can add n_subglyphs to our glyph. this function */
- /* reallocates its subglyphs table if necessary. Note that it DOES */
- /* NOT change the number of subglyphs within the loader !! */
- BASE_FUNC(FT_Error) FT_GlyphLoader_Check_Subglyphs( FT_GlyphLoader* loader,
- FT_UInt n_subs )
+ /* Ensure that we can add `n_subglyphs' to our glyph. this function */
+ /* reallocates its subglyphs table if necessary. Note that it DOES */
+ /* NOT change the number of subglyphs within the loader! */
+ BASE_FUNC( FT_Error ) FT_GlyphLoader_Check_Subglyphs(
+ FT_GlyphLoader* loader,
+ FT_UInt n_subs )
{
FT_Memory memory = loader->memory;
FT_Error error = FT_Err_Ok;
@@ -522,12 +541,13 @@
FT_GlyphLoad* base = &loader->base;
FT_GlyphLoad* current = &loader->current;
+
new_max = base->num_subglyphs + current->num_subglyphs + n_subs;
- if (new_max > loader->max_subglyphs)
+ if ( new_max > loader->max_subglyphs )
{
- new_max = (new_max+1) & -2;
- if (REALLOC_ARRAY( base->subglyphs, base->num_subglyphs,
- new_max, FT_SubGlyph ))
+ new_max = ( new_max + 1 ) & -2;
+ if ( REALLOC_ARRAY( base->subglyphs, base->num_subglyphs,
+ new_max, FT_SubGlyph ) )
goto Exit;
loader->max_subglyphs = new_max;
@@ -540,11 +560,12 @@
}
- /* prepare loader for the addition of a new glyph on top of the base one */
- BASE_FUNC(void) FT_GlyphLoader_Prepare( FT_GlyphLoader* loader )
+ /* prepare loader for the addition of a new glyph on top of the base one */
+ BASE_FUNC( void ) FT_GlyphLoader_Prepare( FT_GlyphLoader* loader )
{
FT_GlyphLoad* current = &loader->current;
+
current->outline.n_points = 0;
current->outline.n_contours = 0;
current->num_subglyphs = 0;
@@ -554,8 +575,8 @@
}
- /* add current glyph to the base image - and prepare for another */
- BASE_FUNC(void) FT_GlyphLoader_Add( FT_GlyphLoader* loader )
+ /* add current glyph to the base image - and prepare for another */
+ BASE_FUNC( void ) FT_GlyphLoader_Add( FT_GlyphLoader* loader )
{
FT_GlyphLoad* base = &loader->base;
FT_GlyphLoad* current = &loader->current;
@@ -564,6 +585,7 @@
FT_UInt n_base_points = base->outline.n_points;
FT_UInt n;
+
base->outline.n_points += current->outline.n_points;
base->outline.n_contours += current->outline.n_contours;
base->num_subglyphs += current->num_subglyphs;
@@ -577,27 +599,33 @@
}
- BASE_FUNC(FT_Error) FT_GlyphLoader_Copy_Points( FT_GlyphLoader* target,
- FT_GlyphLoader* source )
+ BASE_FUNC( FT_Error ) FT_GlyphLoader_Copy_Points(
+ FT_GlyphLoader* target,
+ FT_GlyphLoader* source )
{
FT_Error error;
FT_UInt num_points = source->base.outline.n_points;
FT_UInt num_contours = source->base.outline.n_contours;
+
error = FT_GlyphLoader_Check_Points( target, num_points, num_contours );
- if (!error)
+ if ( !error )
{
FT_Outline* out = &target->base.outline;
FT_Outline* in = &source->base.outline;
+
- MEM_Copy( out->points, in->points, num_points * sizeof(FT_Vector) );
- MEM_Copy( out->tags, in->tags, num_points * sizeof(char) );
- MEM_Copy( out->contours, in->contours, num_contours * sizeof(short) );
+ MEM_Copy( out->points, in->points,
+ num_points * sizeof ( FT_Vector ) );
+ MEM_Copy( out->tags, in->tags,
+ num_points * sizeof ( char ) );
+ MEM_Copy( out->contours, in->contours,
+ num_contours * sizeof ( short ) );
- /* do we need to copy the extra points ? */
- if (target->use_extra && source->use_extra)
+ /* do we need to copy the extra points? */
+ if ( target->use_extra && source->use_extra )
MEM_Copy( target->base.extra_points, source->base.extra_points,
- num_points * sizeof(FT_Vector) );
+ num_points * sizeof ( FT_Vector ) );
out->n_points = num_points;
out->n_contours = num_contours;
@@ -604,11 +632,11 @@
FT_GlyphLoader_Adjust_Points( target );
}
+
return error;
}
-
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
@@ -628,10 +656,11 @@
FT_Memory memory = driver->root.memory;
FT_Error error = FT_Err_Ok;
- if (FT_DRIVER_USES_OUTLINES(driver))
+
+ if ( FT_DRIVER_USES_OUTLINES( driver ) )
error = FT_GlyphLoader_New( memory, &slot->loader );
- if (!error && clazz->init_slot)
+ if ( !error && clazz->init_slot )
error = clazz->init_slot( slot );
return error;
@@ -638,12 +667,12 @@
}
- static void ft_glyphslot_clear( FT_GlyphSlot slot )
+ static void ft_glyphslot_clear( FT_GlyphSlot slot )
{
/* clear all public fields in the glyph slot */
- MEM_Set( &slot->metrics, 0, sizeof(slot->metrics) );
- MEM_Set( &slot->outline, 0, sizeof(slot->outline) );
- MEM_Set( &slot->bitmap, 0, sizeof(slot->bitmap) );
+ MEM_Set( &slot->metrics, 0, sizeof ( slot->metrics ) );
+ MEM_Set( &slot->outline, 0, sizeof ( slot->outline ) );
+ MEM_Set( &slot->bitmap, 0, sizeof ( slot->bitmap ) );
slot->bitmap_left = 0;
slot->bitmap_top = 0;
@@ -659,30 +688,29 @@
}
- static void ft_glyphslot_done( FT_GlyphSlot slot )
+ static void ft_glyphslot_done( FT_GlyphSlot slot )
{
FT_Driver driver = slot->face->driver;
FT_Driver_Class* clazz = driver->clazz;
FT_Memory memory = driver->root.memory;
+
/* free bitmap buffer if needed */
if ( slot->flags & ft_glyph_own_bitmap )
FREE( slot->bitmap.buffer );
/* free glyph loader */
- if (FT_DRIVER_USES_OUTLINES(driver))
+ if ( FT_DRIVER_USES_OUTLINES( driver ) )
{
FT_GlyphLoader_Done( slot->loader );
slot->loader = 0;
}
- if (clazz->done_slot)
+ if ( clazz->done_slot )
clazz->done_slot( slot );
}
-
-
/*************************************************************************/
/* */
/* <Function> */
@@ -703,16 +731,16 @@
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
-
FT_EXPORT_FUNC( FT_Error ) FT_New_GlyphSlot( FT_Face face,
FT_GlyphSlot* aslot )
{
- FT_Error error;
- FT_Driver driver;
- FT_Driver_Class* clazz;
- FT_Memory memory;
- FT_GlyphSlot slot;
+ FT_Error error;
+ FT_Driver driver;
+ FT_Driver_Class* clazz;
+ FT_Memory memory;
+ FT_GlyphSlot slot;
+
*aslot = 0;
if ( !face || !aslot || !face->driver )
@@ -728,7 +756,7 @@
slot->face = face;
error = ft_glyphslot_init( slot );
- if (error)
+ if ( error )
{
ft_glyphslot_done( slot );
FREE( slot );
@@ -766,15 +794,17 @@
FT_GlyphSlot* parent;
FT_GlyphSlot cur;
+
/* Remove slot from its parent face's list */
parent = &slot->face->glyph;
cur = *parent;
+
while ( cur )
{
if ( cur == slot )
{
*parent = cur->next;
- ft_glyphslot_done(slot);
+ ft_glyphslot_done( slot );
FREE( slot );
break;
}
@@ -784,11 +814,10 @@
}
+ /* forward declaration */
+ static FT_Renderer ft_lookup_glyph_renderer( FT_GlyphSlot slot );
- /* forward declaration */
- static FT_Renderer ft_lookup_glyph_renderer( FT_GlyphSlot slot );
-
/*************************************************************************/
/* */
/* <Function> */
@@ -796,8 +825,8 @@
/* */
/* <Description> */
/* A function used to set the transformation that is applied to glyph */
- /* images just before they're converted to bitmaps in a glyph slot */
- /* when FT_Render_Glyph is called.. */
+ /* images just before they are converted to bitmaps in a glyph slot */
+ /* when FT_Render_Glyph() is called. */
/* */
/* <InOut> */
/* face :: A handle to the source face object. */
@@ -882,10 +911,9 @@
/* transformed with the information passed to a previous call to */
/* FT_Set_Transform. */
/* */
- /* Note that this also transforms the "face.glyph.advance" field, */
- /* but **NOT** the values in "face.glyph.metrics".. */
+ /* Note that this also transforms the `face.glyph.advance' field, but */
+ /* *not* the values in `face.glyph.metrics'. */
/* */
-
FT_EXPORT_FUNC( FT_Error ) FT_Load_Glyph( FT_Face face,
FT_UInt glyph_index,
FT_Int load_flags )
@@ -894,6 +922,7 @@
FT_Driver driver;
FT_GlyphSlot slot;
+
if ( !face || !face->size || !face->glyph )
return FT_Err_Invalid_Face_Handle;
@@ -913,10 +942,11 @@
face->size,
glyph_index,
load_flags );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
/* compute the advance */
- if (load_flags & FT_LOAD_VERTICAL_LAYOUT)
+ if ( load_flags & FT_LOAD_VERTICAL_LAYOUT )
{
slot->advance.x = 0;
slot->advance.y = slot->metrics.vertAdvance;
@@ -928,12 +958,13 @@
}
/* now, transform the glyph image when needed */
- if (face->transform_flags)
+ if ( face->transform_flags )
{
/* get renderer */
FT_Renderer renderer = ft_lookup_glyph_renderer( slot );
- if (renderer)
+
+ if ( renderer )
error = renderer->clazz->transform_glyph( renderer, slot,
&face->transform_matrix,
&face->transform_delta );
@@ -953,7 +984,7 @@
/* */
/* <Description> */
/* A function used to load a single glyph within a given glyph slot, */
- /* for a given size, according to its character code ! */
+ /* for a given size, according to its character code. */
/* */
/* <Input> */
/* face :: A handle to a target face object where the glyph */
@@ -967,6 +998,7 @@
/* glyph loading process (e.g., whether the outline */
/* should be scaled, whether to load bitmaps or not, */
/* whether to hint the outline, etc). */
+ /* */
/* <Return> */
/* FreeType error code. 0 means success. */
/* */
@@ -973,15 +1005,15 @@
/* <Note> */
/* If the face has no current charmap, or if the character code */
/* is not defined in the charmap, this function will return an */
- /* error.. */
+ /* error. */
/* */
/* If the glyph image is not a bitmap, and if the bit flag */
/* FT_LOAD_IGNORE_TRANSFORM is unset, the glyph image will be */
/* transformed with the information passed to a previous call to */
- /* FT_Set_Transform. */
+ /* FT_Set_Transform(). */
/* */
- /* Note that this also transforms the "face.glyph.advance" field, */
- /* but **NOT** the values in "face.glyph.metrics".. */
+ /* Note that this also transforms the `face.glyph.advance' field, but */
+ /* *not* the values in `face.glyph.metrics'. */
/* */
FT_EXPORT_FUNC( FT_Error ) FT_Load_Char( FT_Face face,
FT_ULong char_code,
@@ -989,11 +1021,12 @@
{
FT_UInt glyph_index;
+
if ( !face )
return FT_Err_Invalid_Face_Handle;
glyph_index = (FT_UInt)char_code;
- if (face->charmap)
+ if ( face->charmap )
glyph_index = FT_Get_Char_Index( face, char_code );
return glyph_index ? FT_Load_Glyph( face, glyph_index, load_flags )
@@ -1001,8 +1034,6 @@
}
-
-
/* destructor for sizes list */
static
void destroy_size( FT_Memory memory,
@@ -1010,11 +1041,11 @@
FT_Driver driver )
{
/* finalize client-specific data */
- if (size->generic.finalizer)
+ if ( size->generic.finalizer )
size->generic.finalizer( size );
/* finalize format-specific stuff */
- if (driver->clazz->done_size)
+ if ( driver->clazz->done_size )
driver->clazz->done_size( size );
FREE( size );
@@ -1029,6 +1060,7 @@
{
FT_Driver_Class* clazz = driver->clazz;
+
/* Discard glyph slots for this face */
/* Beware! FT_Done_GlyphSlot() changes the field `face->slot' */
while ( face->glyph )
@@ -1046,11 +1078,11 @@
face->generic.finalizer( face );
/* finalize format-specific stuff */
- if (clazz->done_face)
- clazz->done_face(face);
+ if ( clazz->done_face )
+ clazz->done_face( face );
/* close the stream for this face if needed */
- if ( (face->face_flags & FT_FACE_FLAG_EXTERNAL_STREAM) == 0 )
+ if ( ( face->face_flags & FT_FACE_FLAG_EXTERNAL_STREAM ) == 0 )
ft_done_stream( &face->stream );
/* get rid of it */
@@ -1066,14 +1098,11 @@
driver );
/* see if we need to drop the driver's glyph loader */
- if (FT_DRIVER_USES_OUTLINES(driver))
+ if ( FT_DRIVER_USES_OUTLINES( driver ) )
FT_GlyphLoader_Done( driver->glyph_loader );
-
-
}
-
/*************************************************************************/
/* */
/* <Function> */
@@ -1095,6 +1124,7 @@
FT_Face face = 0;
FT_Error error;
+
clazz = driver->clazz;
memory = driver->root.memory;
@@ -1173,6 +1203,7 @@
{
FT_Open_Args args;
+
/* test for valid `library' and `aface' delayed to FT_Open_Face() */
if ( !pathname )
return FT_Err_Invalid_Argument;
@@ -1232,6 +1263,7 @@
{
FT_Open_Args args;
+
/* test for valid `library' and `face' delayed to FT_Open_Face() */
if ( !file_base )
return FT_Err_Invalid_Argument;
@@ -1315,14 +1347,15 @@
/* it. Otherwise, we'll scan the list of registered drivers. */
if ( args->flags & ft_open_driver && args->driver )
{
- driver = FT_DRIVER(args->driver);
+ driver = FT_DRIVER( args->driver );
/* not all modules are drivers, so check... */
- if ( FT_MODULE_IS_DRIVER(driver) )
+ if ( FT_MODULE_IS_DRIVER( driver ) )
{
FT_Int num_params = 0;
FT_Parameter* params = 0;
+
if ( args->flags & ft_open_params )
{
num_params = args->num_params;
@@ -1346,16 +1379,18 @@
FT_Module* cur = library->modules;
FT_Module* limit = cur + library->num_modules;
+
for ( ; cur < limit; cur++ )
{
/* not all modules are font drivers, so check... */
- if ( FT_MODULE_IS_DRIVER(cur[0]) )
+ if ( FT_MODULE_IS_DRIVER( cur[0] ) )
{
FT_Int num_params = 0;
FT_Parameter* params = 0;
- driver = FT_DRIVER(cur[0]);
+ driver = FT_DRIVER( cur[0] );
+
if ( args->flags & ft_open_params )
{
num_params = args->num_params;
@@ -1525,6 +1560,7 @@
FT_Driver_Class* clazz;
+
/* test for valid `parameters' delayed to ft_new_input_stream() */
if ( !face )
@@ -1543,11 +1579,11 @@
error = FT_Err_Unimplemented_Feature;
clazz = driver->clazz;
- if (clazz->attach_file)
+ if ( clazz->attach_file )
error = clazz->attach_file( face, stream );
/* close the attached stream */
- if ( !parameters->stream || (parameters->flags & ft_open_stream) )
+ if ( !parameters->stream || ( parameters->flags & ft_open_stream ) )
ft_done_stream( &stream );
Exit:
@@ -1572,11 +1608,12 @@
/* */
FT_EXPORT_FUNC( FT_Error ) FT_Done_Face( FT_Face face )
{
- FT_Error error;
- FT_Driver driver;
- FT_Memory memory;
- FT_ListNode node;
+ FT_Error error;
+ FT_Driver driver;
+ FT_Memory memory;
+ FT_ListNode node;
+
error = FT_Err_Invalid_Face_Handle;
if ( face && face->driver )
{
@@ -1628,6 +1665,7 @@
FT_Size size = 0;
FT_ListNode node = 0;
+
*asize = 0;
if ( !face || !asize || !face->driver )
@@ -1644,7 +1682,7 @@
size->face = face;
- if (clazz->init_size)
+ if ( clazz->init_size )
error = clazz->init_size( size );
/* in case of success, add to the face's list */
@@ -1725,6 +1763,24 @@
}
+ static void ft_recompute_scaled_metrics( FT_Face face,
+ FT_Size_Metrics* metrics )
+ {
+ /* Compute root ascender, descender, test height, and max_advance */
+ metrics->ascender = ( FT_MulFix( face->ascender,
+ metrics->y_scale ) + 32 ) & -64;
+
+ metrics->descender = ( FT_MulFix( face->descender,
+ metrics->y_scale ) + 32 ) & -64;
+
+ metrics->height = ( FT_MulFix( face->height,
+ metrics->y_scale ) + 32 ) & -64;
+
+ metrics->max_advance = ( FT_MulFix( face->max_advance_width,
+ metrics->x_scale ) + 32 ) & -64;
+ }
+
+
/*************************************************************************/
/* */
/* <Function> */
@@ -1759,27 +1815,6 @@
/* When dealing with fixed-size faces (i.e., non-scalable formats), */
/* use the function FT_Set_Pixel_Sizes(). */
/* */
-
- static void ft_recompute_scaled_metrics( FT_Face face,
- FT_Size_Metrics* metrics )
- {
- /* Compute root ascender, descender, test height, and max_advance */
- metrics->ascender = ( FT_MulFix( face->ascender,
- metrics->y_scale ) + 32 ) & -64;
-
- metrics->descender = ( FT_MulFix( face->descender,
- metrics->y_scale ) + 32 ) & -64;
-
- metrics->height = ( FT_MulFix( face->height,
- metrics->y_scale ) + 32 ) & -64;
-
- metrics->max_advance = ( FT_MulFix( face->max_advance_width,
- metrics->x_scale ) + 32 ) & -64;
- }
-
-
-
-
FT_EXPORT_FUNC( FT_Error ) FT_Set_Char_Size( FT_Face face,
FT_F26Dot6 char_width,
FT_F26Dot6 char_height,
@@ -1838,7 +1873,7 @@
ft_recompute_scaled_metrics( face, metrics );
- if (clazz->set_char_sizes)
+ if ( clazz->set_char_sizes )
error = clazz->set_char_sizes( face->size,
char_width,
char_height,
@@ -1913,7 +1948,7 @@
ft_recompute_scaled_metrics( face, metrics );
- if (clazz->set_pixel_sizes)
+ if ( clazz->set_pixel_sizes )
error = clazz->set_pixel_sizes( face->size,
pixel_width,
pixel_height );
@@ -1972,9 +2007,9 @@
if ( driver->clazz->get_kerning )
{
error = driver->clazz->get_kerning( face,
- left_glyph,
- right_glyph,
- kerning );
+ left_glyph,
+ right_glyph,
+ kerning );
}
else
{
@@ -2156,7 +2191,7 @@
driver = face->driver;
func = (FT_Get_Sfnt_Table_Func)driver->root.clazz->get_interface(
- FT_MODULE(driver), "get_sfnt" );
+ FT_MODULE( driver ), "get_sfnt" );
if ( func )
table = func( face, tag );
@@ -2180,28 +2215,30 @@
/* lookup a renderer by glyph format in the library's list */
static FT_Renderer ft_lookup_renderer( FT_Library library,
FT_Glyph_Format format,
- FT_ListNode *node )
+ FT_ListNode* node )
{
FT_ListNode cur = library->renderers.head;
FT_Renderer result = 0;
+
- if (node)
+ if ( node )
*node = 0;
- while (cur)
+ while ( cur )
{
- FT_Renderer renderer = FT_RENDERER(cur->data);
+ FT_Renderer renderer = FT_RENDERER( cur->data );
- if (renderer->glyph_format == format)
+
+ if ( renderer->glyph_format == format )
{
- if (node)
+ if ( node )
*node = cur;
result = renderer;
break;
}
-
}
+
return result;
}
@@ -2209,10 +2246,11 @@
static FT_Renderer ft_lookup_glyph_renderer( FT_GlyphSlot slot )
{
FT_Face face = slot->face;
- FT_Library library = FT_FACE_LIBRARY(face);
+ FT_Library library = FT_FACE_LIBRARY( face );
FT_Renderer result = library->cur_renderer;
+
- if (!result || result->glyph_format != slot->format)
+ if ( !result || result->glyph_format != slot->format )
result = ft_lookup_renderer( library, slot->format, 0 );
return result;
@@ -2235,13 +2273,14 @@
FT_Error error;
FT_ListNode node;
- if (ALLOC(node,sizeof(*node)))
+ if ( ALLOC( node, sizeof ( *node ) ) )
goto Exit;
{
- FT_Renderer render = FT_RENDERER(module);
+ FT_Renderer render = FT_RENDERER( module );
FT_Renderer_Class* clazz = (FT_Renderer_Class*)module->clazz;
+
render->clazz = clazz;
render->glyph_format = clazz->glyph_format;
@@ -2250,7 +2289,8 @@
clazz->raster_class->raster_new )
{
error = clazz->raster_class->raster_new( memory, &render->raster );
- if (error) goto Fail;
+ if ( error )
+ goto Fail;
render->raster_render = clazz->raster_class->raster_render;
render->render = clazz->render_glyph;
@@ -2264,8 +2304,8 @@
}
Fail:
- if (error)
- FREE(node);
+ if ( error )
+ FREE( node );
Exit:
return error;
@@ -2278,13 +2318,15 @@
FT_Memory memory = library->memory;
FT_ListNode node;
+
node = FT_List_Find( &library->renderers, module );
- if (node)
+ if ( node )
{
- FT_Renderer render = FT_RENDERER(module);
+ FT_Renderer render = FT_RENDERER( module );
+
/* release raster object, if any */
- if (render->raster)
+ if ( render->raster )
render->clazz->raster_class->raster_done( render->raster );
/* remove from list */
@@ -2296,74 +2338,73 @@
}
-
- /*************************************************************************
- *
- * <Function>
- * FT_Get_Renderer
- *
- * <Description>
- * retrieves the current renderer for a given glyph format.
- *
- * <Input>
- * library :: handle to library object
- * format :: glyph format
- *
- * <Return>
- * renderer handle. 0 if none found.
- *
- * <Note>
- * An error will be returned if a module already exists by that
- * name, or if the module requires a version of freetype that is
- * too great
- *
- * To add a new renderer, simply use FT_Add_Module. To retrieve
- * a renderer by its name, use FT_Get_Module
- *
- *************************************************************************/
-
- FT_EXPORT_FUNC(FT_Renderer) FT_Get_Renderer( FT_Library library,
- FT_Glyph_Format format )
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Get_Renderer */
+ /* */
+ /* <Description> */
+ /* Retrieves the current renderer for a given glyph format. */
+ /* */
+ /* <Input> */
+ /* library :: A handle to the library object. */
+ /* */
+ /* format :: The glyph format. */
+ /* */
+ /* <Return> */
+ /* A renderer handle. 0 if none found. */
+ /* */
+ /* <Note> */
+ /* An error will be returned if a module already exists by that name, */
+ /* or if the module requires a version of FreeType that is too great. */
+ /* */
+ /* To add a new renderer, simply use FT_Add_Module(). To retrieve a */
+ /* renderer by its name, use FT_Get_Module(). */
+ /*
+ FT_EXPORT_FUNC( FT_Renderer ) FT_Get_Renderer( FT_Library library,
+ FT_Glyph_Format format )
{
return ft_lookup_renderer( library, format, 0 );
}
- /*************************************************************************
- *
- * <Function>
- * FT_Set_Renderer
- *
- * <Description>
- * Sets the current renderer to use, and set additional mode
- *
- * <Input>
- * library :: handle to library object
- * renderer :: handle to renderer object
- * num_params :: number of additional parameters
- * params :: additional parameters
- *
- * <Return>
- * Error code. 0 means success.
- *
- * <Note>
- * in case of success, the renderer will be used to convert glyph
- * images in the renderer's known format into bitmaps.
- *
- * This doesn't change the current renderer for other formats..
- *
- *************************************************************************/
-
- FT_EXPORT_DEF(FT_Error) FT_Set_Renderer( FT_Library library,
- FT_Renderer renderer,
- FT_UInt num_params,
- FT_Parameter* parameters )
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Set_Renderer */
+ /* */
+ /* <Description> */
+ /* Sets the current renderer to use, and set additional mode. */
+ /* */
+ /* <Input> */
+ /* library :: A handle to the library object. */
+ /* */
+ /* renderer :: A handle to the renderer object. */
+ /* */
+ /* num_params :: The number of additional parameters. */
+ /* */
+ /* params :: Additional parameters. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
+ /* <Note> */
+ /* In case of success, the renderer will be used to convert glyph */
+ /* images in the renderer's known format into bitmaps. */
+ /* */
+ /* This doesn't change the current renderer for other formats. */
+ /* */
+ FT_EXPORT_DEF( FT_Error ) FT_Set_Renderer( FT_Library library,
+ FT_Renderer renderer,
+ FT_UInt num_params,
+ FT_Parameter* parameters )
{
FT_ListNode node;
FT_Error error = FT_Err_Ok;
+
node = FT_List_Find( &library->renderers, renderer );
- if (!node)
+ if ( !node )
{
error = FT_Err_Invalid_Argument;
goto Exit;
@@ -2371,17 +2412,18 @@
FT_List_Up( &library->renderers, node );
- if (renderer->glyph_format == ft_glyph_format_outline )
+ if ( renderer->glyph_format == ft_glyph_format_outline )
library->cur_renderer = renderer;
- if (num_params > 0)
+ if ( num_params > 0 )
{
FTRenderer_setMode set_mode = renderer->clazz->set_mode;
+
for ( ; num_params > 0; num_params-- )
{
error = set_mode( renderer, parameters->tag, parameters->data );
- if (error)
+ if ( error )
break;
}
}
@@ -2391,68 +2433,67 @@
}
-
- /*************************************************************************
- *
- * <Function>
- * FT_Render_Glyph
- *
- * <Description>
- * Converts a given glyph image to a bitmap. It does so by inspecting
- * the glyph image format, find the relevant renderer, and invoke it
- *
- * <Input>
- * slot :: handle to the glyph slot containing the image to
- * convert
- *
- * render_mode :: a set of bit flags indicating which kind of bitmap
- * to render. For now, only 'ft_render_mode_anti_alias'
- * is supported by the available renderers, but others
- * could appear later (e.g. LCD or TV optimised)
- *
- * <Return>
- * Error code. 0 means success.
- *
- * <Note>
- * in case of success, the renderer will be used to convert glyph
- * images in the renderer's known format into bitmaps.
- *
- * This doesn't change the current renderer for other formats..
- *
- * The slot's native image should be considered lost after the
- * conversion..
- *
- *************************************************************************/
-
- FT_EXPORT_FUNC(FT_Error) FT_Render_Glyph( FT_GlyphSlot slot,
- FT_UInt render_mode )
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Render_Glyph */
+ /* */
+ /* <Description> */
+ /* Converts a given glyph image to a bitmap. It does so by */
+ /* inspecting the glyph image format, find the relevant renderer, and */
+ /* invoke it. */
+ /* */
+ /* <Input> */
+ /* slot :: A handle to the glyph slot containing the image to */
+ /* convert. */
+ /* */
+ /* render_mode :: A set of bit flags indicating which kind of bitmap */
+ /* to render. For now, only */
+ /* `ft_render_mode_anti_alias' is supported by the */
+ /* available renderers, but others could appear later */
+ /* (e.g. optimized for TV or LCD). */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
+ /* <Note> */
+ /* In case of success, the renderer will be used to convert glyph */
+ /* images in the renderer's known format into bitmaps. */
+ /* */
+ /* This doesn't change the current renderer for other formats. */
+ /* */
+ /* The slot's native image should be considered lost after the */
+ /* conversion. */
+ /* */
+ FT_EXPORT_FUNC( FT_Error ) FT_Render_Glyph( FT_GlyphSlot slot,
+ FT_UInt render_mode )
{
FT_Error error = FT_Err_Ok;
FT_Renderer renderer;
+
- if (slot)
+ if ( slot )
{
FT_Face face = slot->face;
- FT_Library library = FT_FACE_LIBRARY(face);
+ FT_Library library = FT_FACE_LIBRARY( face );
- /* if it's already a bitmap, no need to do anything */
- switch (slot->format)
+
+ /* if it is already a bitmap, no need to do anything */
+ switch ( slot->format )
{
- case ft_glyph_format_bitmap: /* already a bitmap, don't do anything */
- break;
+ case ft_glyph_format_bitmap: /* already a bitmap, don't do anything */
+ break;
- default:
- {
- /* small shortcut for the very common case */
- if (slot->format == ft_glyph_format_outline)
- renderer = library->cur_renderer;
- else
- renderer = ft_lookup_renderer( library, slot->format, 0 );
+ default:
+ /* small shortcut for the very common case */
+ if ( slot->format == ft_glyph_format_outline )
+ renderer = library->cur_renderer;
+ else
+ renderer = ft_lookup_renderer( library, slot->format, 0 );
- error = FT_Err_Unimplemented_Feature;
- if (renderer)
- error = renderer->render( renderer, slot, render_mode );
- }
+ error = FT_Err_Unimplemented_Feature;
+ if ( renderer )
+ error = renderer->render( renderer, slot, render_mode );
}
}
else
@@ -2460,6 +2501,7 @@
return error;
}
+
/*************************************************************************/
/*************************************************************************/
@@ -2473,6 +2515,7 @@
/*************************************************************************/
/*************************************************************************/
+
/*************************************************************************/
/* */
/* <Function> */
@@ -2480,7 +2523,7 @@
/* */
/* <Description> */
/* Destroys a given module object. For drivers, this also destroys */
- /* all child faces.. */
+ /* all child faces. */
/* */
/* <InOut> */
/* module :: A handle to the target driver object. */
@@ -2494,50 +2537,49 @@
FT_Memory memory = module->memory;
FT_Module_Class* clazz = module->clazz;
+
/* finalize client-data - before anything else */
if ( module->generic.finalizer )
module->generic.finalizer( module );
/* if the module is a renderer */
- if (FT_MODULE_IS_RENDERER(module))
- ft_remove_renderer(module);
+ if ( FT_MODULE_IS_RENDERER( module ) )
+ ft_remove_renderer( module );
/* if the module is a font driver, add some steps */
- if (FT_MODULE_IS_DRIVER(module))
- Destroy_Driver( FT_DRIVER(module) );
+ if ( FT_MODULE_IS_DRIVER( module ) )
+ Destroy_Driver( FT_DRIVER( module ) );
/* finalize the module object */
- if (clazz->module_done)
- clazz->module_done(module);
+ if ( clazz->module_done )
+ clazz->module_done( module );
/* discard it */
FREE( module );
}
- /*************************************************************************
- *
- * <Function>
- * FT_Add_Module
- *
- * <Description>
- * Add a new module to a given library instance.
- *
- * <Input>
- * library :: handle to library object
- * clazz :: pointer to class descriptor for the module
- *
- * <Return>
- * Error code. 0 means success
- *
- * <Note>
- * An error will be returned if a module already exists by that
- * name, or if the module requires a version of freetype that is
- * too great
- *
- *************************************************************************/
- FT_EXPORT_FUNC(FT_Error) FT_Add_Module( FT_Library library,
- const FT_Module_Class* clazz )
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Add_Module */
+ /* */
+ /* <Description> */
+ /* Adds a new module to a given library instance. */
+ /* */
+ /* <Input> */
+ /* library :: A handle to the library object. */
+ /* clazz :: A pointer to class descriptor for the module. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
+ /* <Note> */
+ /* An error will be returned if a module already exists by that name, */
+ /* or if the module requires a version of FreeType that is too great. */
+ /* */
+ FT_EXPORT_FUNC( FT_Error ) FT_Add_Module( FT_Library library,
+ const FT_Module_Class* clazz )
{
FT_Error error;
FT_Memory memory;
@@ -2544,9 +2586,11 @@
FT_Module module;
FT_UInt nn;
- #define FREETYPE_VER_FIXED (((FT_Long)FREETYPE_MAJOR << 16) | FREETYPE_MINOR)
- if (!library || !clazz)
+#define FREETYPE_VER_FIXED ( ( (FT_Long)FREETYPE_MAJOR << 16 ) |
+ FREETYPE_MINOR )
+
+ if ( !library || !clazz )
return FT_Err_Invalid_Argument;
/* check freetype version */
@@ -2580,7 +2624,7 @@
}
/* allocate module object */
- if (ALLOC(module,clazz->module_size))
+ if ( ALLOC( module,clazz->module_size ) )
goto Exit;
/* base initialisation */
@@ -2589,88 +2633,96 @@
module->clazz = (FT_Module_Class*)clazz;
/* if the module is a renderer - this must be performed before */
- /* the normal module initialisation.. */
- if (FT_MODULE_IS_RENDERER(module))
+ /* the normal module initialization. */
+ if ( FT_MODULE_IS_RENDERER( module ) )
{
/* add to the renderers list */
- error = ft_add_renderer(module);
- if (error) goto Fail;
+ error = ft_add_renderer( module );
+ if ( error )
+ goto Fail;
}
/* if the module is a font driver */
- if (FT_MODULE_IS_DRIVER(module))
+ if ( FT_MODULE_IS_DRIVER( module ) )
{
/* allocate glyph loader if needed */
- FT_Driver driver = FT_DRIVER(module);
+ FT_Driver driver = FT_DRIVER( module );
+
driver->clazz = (FT_Driver_Class*)module->clazz;
- if (FT_DRIVER_USES_OUTLINES(driver))
+ if ( FT_DRIVER_USES_OUTLINES( driver ) )
{
error = FT_GlyphLoader_New( memory, &driver->glyph_loader );
- if (error) goto Fail;
+ if ( error )
+ goto Fail;
}
}
- if (clazz->module_init)
+ if ( clazz->module_init )
{
- error = clazz->module_init(module);
- if (error) goto Fail;
+ error = clazz->module_init( module );
+ if ( error )
+ goto Fail;
}
/* add module to the library's table */
- library->modules[ library->num_modules++ ] = module;
+ library->modules[library->num_modules++] = module;
-
Exit:
return error;
Fail:
- if (FT_MODULE_IS_DRIVER(module))
+ if ( FT_MODULE_IS_DRIVER( module ) )
{
- FT_Driver driver = FT_DRIVER(module);
+ FT_Driver driver = FT_DRIVER( module );
- if (FT_DRIVER_USES_OUTLINES(driver))
+
+ if ( FT_DRIVER_USES_OUTLINES( driver ) )
FT_GlyphLoader_Done( driver->glyph_loader );
}
- if (FT_MODULE_IS_RENDERER(module))
+ if ( FT_MODULE_IS_RENDERER( module ) )
{
- FT_Renderer renderer = FT_RENDERER(module);
- if (renderer->raster)
+ FT_Renderer renderer = FT_RENDERER( module );
+
+
+ if ( renderer->raster )
renderer->clazz->raster_class->raster_done( renderer->raster );
}
- FREE(module);
+
+ FREE( module );
goto Exit;
}
- /*************************************************************************
- *
- * <Function>
- * FT_Get_Module
- *
- * <Description>
- * Find a module by its name.
- *
- * <Input>
- * library :: handle to library object
- * module_name :: the module's ASCII name.
- *
- * <Return>
- * Module handle, 0 if none was found.
- *
- * <Note>
- * You'd better be familiar with FreeType internals to know which
- * module to look for :-)
- *
- *************************************************************************/
- FT_EXPORT_FUNC(FT_Module) FT_Get_Module( FT_Library library,
- const char* module_name )
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Get_Module */
+ /* */
+ /* <Description> */
+ /* Finds a module by its name. */
+ /* */
+ /* <Input> */
+ /* library :: A handle to the library object. */
+ /* */
+ /* module_name :: The module's name (as an ASCII string). */
+ /* */
+ /* <Return> */
+ /* A module handle. 0 if none was found. */
+ /* */
+ /* <Note> */
+ /* You should better be familiar with FreeType internals to know */
+ /* which module to look for :-) */
+ /* */
+ FT_EXPORT_FUNC( FT_Module ) FT_Get_Module( FT_Library library,
+ const char* module_name )
{
FT_Module result = 0;
FT_Module* cur = library->modules;
FT_Module* limit = cur + library->num_modules;
+
for ( ; cur < limit; cur++ )
if ( strcmp( cur[0]->clazz->module_name, module_name ) == 0 )
{
@@ -2681,66 +2733,70 @@
return result;
}
- /*************************************************************************
- *
- * <Function>
- * FT_Get_Module_Interface
- *
- * <Description>
- * Find a module and returns it's specific interface as a void*
- *
- * <Input>
- * library :: handle to library object
- * module_name :: the module's ASCII name.
- *
- * <Return>
- * Module specific interface, if any
- *
- * <Note>
- * You'd better be familiar with FreeType internals to know which
- * module to look for, and what it's interface is :-)
- *
- *************************************************************************/
-
- FT_EXPORT_FUNC(const void*) FT_Get_Module_Interface( FT_Library library,
- const char* mod_name )
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Get_Module_Interface */
+ /* */
+ /* <Description> */
+ /* Finds a module and returns its specific interface as a typeless */
+ /* pointer. */
+ /* */
+ /* <Input> */
+ /* library :: A handle to the library object. */
+ /* */
+ /* module_name :: The module's name (as an ASCII string). */
+ /* */
+ /* <Return> */
+ /* A module-specific interface if available, 0 otherwise. */
+ /* */
+ /* <Note> */
+ /* You should better be familiar with FreeType internals to know */
+ /* which module to look for, and what its interface is :-) */
+ /* */
+ FT_EXPORT_FUNC(const void*) FT_Get_Module_Interface(
+ FT_Library library,
+ const char* mod_name )
{
FT_Module module;
+
module = FT_Get_Module( library, mod_name );
+
return module ? module->clazz->module_interface : 0;
}
- /*************************************************************************
- *
- * <Function>
- * FT_Remove_Module
- *
- * <Description>
- * Removes a given module from a library instance.
- *
- * <Input>
- * library :: handle to library object
- * module :: handle to module object
- *
- * <Return>
- * Error code (module not listed)
- *
- * <Note>
- * The module object is destroyed by the function in case of success
- *
- *************************************************************************/
-
- FT_EXPORT_FUNC(FT_Error) FT_Remove_Module( FT_Library library,
- FT_Module module )
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* FT_Remove_Module */
+ /* */
+ /* <Description> */
+ /* Removes a given module from a library instance. */
+ /* */
+ /* <Input> */
+ /* library :: A handle to a library object. */
+ /* */
+ /* module :: A handle to a module object. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
+ /* <Note> */
+ /* The module object is destroyed by the function in case of success. */
+ /*
+ FT_EXPORT_FUNC( FT_Error ) FT_Remove_Module( FT_Library library,
+ FT_Module module )
{
/* try to find the module from the table, then remove it from there */
- if (library && module)
+ if ( library && module )
{
FT_Module* cur = library->modules;
FT_Module* limit = cur + library->num_modules;
+
for ( ; cur < limit; cur++ )
{
if (cur[0] == module)
@@ -2748,7 +2804,7 @@
/* remove it from the table */
library->num_modules--;
limit--;
- while (cur < limit)
+ while ( cur < limit )
{
cur[0] = cur[1];
cur++;
@@ -2756,7 +2812,7 @@
limit[0] = 0;
/* destroy the module */
- Destroy_Module(module);
+ Destroy_Module( module );
return FT_Err_Ok;
}
@@ -2766,13 +2822,6 @@
}
-
-
-
-
-
-
-
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
@@ -2785,6 +2834,7 @@
/*************************************************************************/
/*************************************************************************/
+
/*************************************************************************/
/* */
/* <Function> */
@@ -2871,6 +2921,7 @@
{
FT_Module module = library->modules[n];
+
if ( module )
{
Destroy_Module( module );
@@ -2893,8 +2944,8 @@
/* FT_Set_Debug_Hook */
/* */
/* <Description> */
- /* Sets a debug hook function for debugging the interpreter of a */
- /* font format. */
+ /* Sets a debug hook function for debugging the interpreter of a font */
+ /* format. */
/* */
/* <Input> */
/* library :: A handle to the library object. */
@@ -2918,9 +2969,6 @@
( sizeof ( library->debug_hooks ) / sizeof ( void* ) ) )
library->debug_hooks[hook_index] = debug_hook;
}
-
-
-
/*************************************************************************/
--- a/src/base/ftoutln.c
+++ b/src/base/ftoutln.c
@@ -573,8 +573,9 @@
/* */
/* <Description> */
/* Renders an outline within a bitmap using the current scan-convert. */
- /* This functions uses a FT_Raster_Params as argument, allowing */
- /* advanced features like direct composition/translucency, etc. */
+ /* This functions uses an FT_Raster_Params structure as an argument, */
+ /* allowing advanced features like direct composition, translucency, */
+ /* etc. */
/* */
/* <Input> */
/* library :: A handle to a FreeType library object. */
@@ -581,8 +582,8 @@
/* */
/* outline :: A pointer to the source outline descriptor. */
/* */
- /* params :: A pointer to a FT_Raster_Params used to describe */
- /* the rendering operation. */
+ /* params :: A pointer to a FT_Raster_Params structure used to */
+ /* describe the rendering operation. */
/* */
/* <Return> */
/* FreeType error code. 0 means success. */
@@ -592,7 +593,7 @@
/* scan-line converter will be serialized. */
/* */
/* <Note> */
- /* You should know what you're doing and the role of FT_Raster_Params */
+ /* You should know what you are doing and how FT_Raster_Params works */
/* to use this function. */
/* */
/* The field `params.source' will be set to `outline' before the scan */
@@ -606,6 +607,7 @@
FT_Error error;
FT_Renderer renderer;
+
if ( !library )
{
error = FT_Err_Invalid_Library_Handle;
@@ -620,7 +622,7 @@
/* retrieve the current outline renderer */
renderer = library->cur_renderer;
- if (!renderer)
+ if ( !renderer )
{
/* XXXX: should use another error code */
error = FT_Err_Invalid_Argument;
@@ -671,7 +673,8 @@
{
FT_Raster_Params params;
- if (!bitmap)
+
+ if ( !bitmap )
return FT_Err_Invalid_Argument;
/* other checks are delayed to FT_Outline_Render */
@@ -686,8 +689,6 @@
}
-
-
/*************************************************************************/
/* */
/* <Function> */
@@ -713,6 +714,7 @@
{
FT_Pos xz, yz;
+
xz = FT_MulFix( vector->x, matrix->xx ) +
FT_MulFix( vector->y, matrix->xy );
@@ -724,8 +726,6 @@
}
-
-
/*************************************************************************/
/* */
/* <Function> */
@@ -753,6 +753,7 @@
FT_Vector* vec = outline->points;
FT_Vector* limit = vec + outline->n_points;
+
for ( ; vec < limit; vec++ )
FT_Vector_Transform( vec, matrix );
}
--- a/src/cff/t2driver.c
+++ b/src/cff/t2driver.c
@@ -78,7 +78,7 @@
/* formats. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* Only horizontal layouts (left-to-right & right-to-left) are */
@@ -169,7 +169,7 @@
/* whether to hint the outline, etc). */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
static
FT_Error Load_Glyph( T2_GlyphSlot slot,
@@ -282,8 +282,10 @@
{
FT_Module sfnt;
- /* we simply pass our request to the "sfnt" module */
+
+ /* we simply pass our request to the `sfnt' module */
sfnt = FT_Get_Module( driver->root.root.library, "sfnt" );
+
return sfnt ? sfnt->clazz->get_interface( sfnt, interface ) : 0;
}
@@ -297,14 +299,14 @@
ft_module_font_driver | ft_module_driver_scalable,
sizeof( T2_DriverRec ),
"cff",
- 0x10000,
- 0x20000,
+ 0x10000L,
+ 0x20000L,
0, /* module-specific interface */
- (FT_Module_Constructor) T2_Init_Driver,
- (FT_Module_Destructor) T2_Done_Driver,
- (FT_Module_Requester) t2_get_interface,
+ (FT_Module_Constructor)T2_Init_Driver,
+ (FT_Module_Destructor) T2_Done_Driver,
+ (FT_Module_Requester) t2_get_interface,
},
/* now the specific driver fields */
@@ -312,22 +314,22 @@
sizeof( FT_SizeRec ),
sizeof( T2_GlyphSlotRec ),
- (FTDriver_initFace) T2_Init_Face,
- (FTDriver_doneFace) T2_Done_Face,
- (FTDriver_initSize) 0,
- (FTDriver_doneSize) 0,
- (FTDriver_initGlyphSlot) 0,
- (FTDriver_doneGlyphSlot) 0,
+ (FTDriver_initFace) T2_Init_Face,
+ (FTDriver_doneFace) T2_Done_Face,
+ (FTDriver_initSize) 0,
+ (FTDriver_doneSize) 0,
+ (FTDriver_initGlyphSlot)0,
+ (FTDriver_doneGlyphSlot)0,
- (FTDriver_setCharSizes) 0,
- (FTDriver_setPixelSizes) 0,
+ (FTDriver_setCharSizes) 0,
+ (FTDriver_setPixelSizes)0,
- (FTDriver_loadGlyph) Load_Glyph,
- (FTDriver_getCharIndex) Get_Char_Index,
+ (FTDriver_loadGlyph) Load_Glyph,
+ (FTDriver_getCharIndex) Get_Char_Index,
- (FTDriver_getKerning) Get_Kerning,
- (FTDriver_attachFile) 0,
- (FTDriver_getAdvances) 0
+ (FTDriver_getKerning) Get_Kerning,
+ (FTDriver_attachFile) 0,
+ (FTDriver_getAdvances) 0
};
--- a/src/cff/t2gload.c
+++ b/src/cff/t2gload.c
@@ -232,6 +232,7 @@
if ( glyph )
{
FT_GlyphLoader* loader = glyph->root.loader;
+
builder->loader = loader;
builder->base = &loader->base.outline;
@@ -273,6 +274,7 @@
{
T2_GlyphSlot glyph = builder->glyph;
+
if ( glyph )
glyph->root.outline = *builder->base;
}
@@ -360,8 +362,7 @@
FT_Error check_points( T2_Builder* builder,
FT_Int count )
{
- return FT_GlyphLoader_Check_Points( builder->loader,
- count, 0 );
+ return FT_GlyphLoader_Check_Points( builder->loader, count, 0 );
}
@@ -374,11 +375,13 @@
{
FT_Outline* outline = builder->current;
+
if ( builder->load_points )
{
FT_Vector* point = outline->points + outline->n_points;
FT_Byte* control = (FT_Byte*)outline->tags + outline->n_points;
+
point->x = x >> 16;
point->y = y >> 16;
*control = flag ? FT_Curve_Tag_On : FT_Curve_Tag_Cubic;
@@ -397,6 +400,7 @@
{
FT_Error error;
+
error = check_points( builder, 1 );
if ( !error )
add_point( builder, x, y, 1 );
@@ -412,6 +416,7 @@
FT_Outline* outline = builder->current;
FT_Error error;
+
if ( !builder->load_points )
{
outline->n_contours++;
@@ -419,7 +424,7 @@
}
error = FT_GlyphLoader_Check_Points( builder->loader, 0, 1 );
- if (!error)
+ if ( !error )
{
if ( outline->n_contours > 0 )
outline->contours[outline->n_contours - 1] = outline->n_points - 1;
@@ -426,6 +431,7 @@
outline->n_contours++;
}
+
return error;
}
@@ -441,6 +447,7 @@
{
FT_Error error;
+
builder->path_begun = 1;
error = add_contour( builder );
if ( error )
@@ -457,6 +464,7 @@
{
FT_Outline* outline = builder->current;
+
if ( outline->n_contours > 0 )
outline->contours[outline->n_contours - 1] = outline->n_points - 1;
}
@@ -484,7 +492,7 @@
/* charstring_len :: The length in bytes of the charstring stream. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error T2_Parse_CharStrings( T2_Decoder* decoder,
--- a/src/cff/t2objs.c
+++ b/src/cff/t2objs.c
@@ -68,7 +68,7 @@
/* face :: The newly built face object. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
LOCAL_DEF
FT_Error T2_Init_Face( FT_Stream stream,
@@ -80,9 +80,10 @@
FT_Error error;
SFNT_Interface* sfnt;
- sfnt = (SFNT_Interface*)
- FT_Get_Module_Interface( face->root.driver->root.library,"sfnt" );
- if ( !sfnt ) goto Bad_Format;
+ sfnt = (SFNT_Interface*)FT_Get_Module_Interface(
+ face->root.driver->root.library, "sfnt" );
+ if ( !sfnt )
+ goto Bad_Format;
/* create input stream from resource */
if ( FILE_Seek( 0 ) )
@@ -188,7 +189,7 @@
/* driver :: A handle to the target driver object. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error T2_Init_Driver( T2_Driver driver )
--- a/src/cid/cidgload.c
+++ b/src/cid/cidgload.c
@@ -158,12 +158,13 @@
if ( glyph )
{
FT_GlyphLoader* loader = glyph->root.loader;
+
builder->loader = loader;
builder->base = &loader->base.outline;
builder->current = &loader->current.outline;
- FT_GlyphLoader_Rewind(loader);
+ FT_GlyphLoader_Rewind( loader );
}
if ( size )
@@ -245,6 +246,7 @@
{
FT_Outline* outline = builder->current;
+
if ( builder->load_points )
{
FT_Vector* point = outline->points + outline->n_points;
@@ -285,6 +287,7 @@
FT_Outline* outline = builder->current;
FT_Error error;
+
if ( !builder->load_points )
{
outline->n_contours++;
@@ -292,7 +295,7 @@
}
error = FT_GlyphLoader_Check_Points( builder->loader, 0, 1 );
- if (!error)
+ if ( !error )
{
if ( outline->n_contours > 0 )
outline->contours[outline->n_contours - 1] = outline->n_points - 1;
@@ -314,6 +317,7 @@
{
FT_Error error;
+
builder->path_begun = 1;
error = add_contour( builder );
if ( error )
@@ -330,6 +334,7 @@
{
FT_Outline* outline = builder->current;
+
if ( outline->n_contours > 0 )
outline->contours[outline->n_contours - 1] = outline->n_points - 1;
}
@@ -410,7 +415,7 @@
/* achar :: The accent character's StandardEncoding charcode. */
/* */
/* <Return> */
- /* Type 1 error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
static
FT_Error t1operator_seac( CID_Decoder* decoder,
@@ -426,6 +431,7 @@
FT_Outline* base = decoder->builder.base;
FT_Vector left_bearing, advance;
+
bchar_index = bchar;
achar_index = achar;
@@ -435,19 +441,19 @@
return T1_Err_Syntax_Error;
}
-
/* if we are trying to load a composite glyph, do not load the */
/* accent character and return the array of subglyphs. */
if ( decoder->builder.no_recurse )
{
-
FT_GlyphSlot glyph = (FT_GlyphSlot)decoder->builder.glyph;
FT_GlyphLoader* loader = glyph->loader;
FT_SubGlyph* subg;
+
/* reallocate subglyph array if necessary */
error = FT_GlyphLoader_Check_Subglyphs( loader, 2 );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
subg = loader->current.subglyphs;
@@ -474,11 +480,12 @@
/* First load `bchar' in builder */
/* now load the unscaled outline */
- if (decoder->builder.loader)
- FT_GlyphLoader_Prepare( decoder->builder.loader ); /* prepare loader */
+ if ( decoder->builder.loader )
+ FT_GlyphLoader_Prepare( decoder->builder.loader );
error = cid_load_glyph( decoder, bchar_index ); /* load one glyph */
- if ( error ) goto Exit;
+ if ( error )
+ goto Exit;
n_base_points = cur->n_points;
@@ -508,6 +515,7 @@
if ( decoder->builder.load_points )
{
FT_Outline dummy;
+
dummy.n_points = base->n_points - n_base_points;
dummy.points = base->points + n_base_points;
@@ -541,7 +549,7 @@
/* charstring_len :: The length in bytes of the charstring stream. */
/* */
/* <Return> */
- /* Type1 error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error CID_Parse_CharStrings( CID_Decoder* decoder,
--- a/src/cid/cidobjs.c
+++ b/src/cid/cidobjs.c
@@ -110,7 +110,7 @@
/* face :: The newly built face object. */
/* */
/* <Return> */
- /* Type1 error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error CID_Init_Face( FT_Stream stream,
@@ -133,8 +133,8 @@
psnames = (PSNames_Interface*)face->psnames;
if ( !psnames )
{
- psnames = (PSNames_Interface*)
- FT_Get_Module_Interface( FT_FACE_LIBRARY(face), "psnames" );
+ psnames = (PSNames_Interface*)FT_Get_Module_Interface(
+ FT_FACE_LIBRARY( face ), "psnames" );
face->psnames = psnames;
}
@@ -337,7 +337,7 @@
/* driver :: A handle to the target driver object. */
/* */
/* <Return> */
- /* Type1 error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error CID_Init_Driver( T1_Driver driver )
@@ -344,7 +344,7 @@
{
UNUSED( driver );
- return FT_Err_Ok;
+ return T1_Err_Ok;
}
--- a/src/cid/cidparse.c
+++ b/src/cid/cidparse.c
@@ -67,7 +67,7 @@
/* reallocations. */
/* */
/* <Return> */
- /* Type1 error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error T1_New_Table( T1_Table* table,
@@ -157,7 +157,7 @@
/* length :: The length in bytes of the source object. */
/* */
/* <Return> */
- /* Type1 error code. 0 means success. An error is returned if */
+ /* FreeType error code. 0 means success. An error is returned if */
/* reallocation fails. */
/* */
LOCAL_FUNC
--- a/src/cid/cidriver.c
+++ b/src/cid/cidriver.c
@@ -38,8 +38,8 @@
static
- FT_Module_Interface CID_Get_Interface( FT_Driver driver,
- const FT_String* interface )
+ FT_Module_Interface CID_Get_Interface( FT_Driver driver,
+ const FT_String* interface )
{
UNUSED( driver );
UNUSED( interface );
@@ -48,7 +48,7 @@
}
-#ifdef xxxT1_CONFIG_OPTION_NO_AFM
+#ifndef T1_CONFIG_OPTION_NO_AFM
static
@@ -71,14 +71,13 @@
}
-#endif /* xxxT1_CONFIG_OPTION_NO_AFM */
+#endif /* !T1_CONFIG_OPTION_NO_AFM */
-
/*************************************************************************/
/* */
/* <Function> */
- /* cid_get_char_index */
+ /* Cid_Get_Char_Index */
/* */
/* <Description> */
/* Uses a charmap to return a given character code's glyph index. */
@@ -85,6 +84,7 @@
/* */
/* <Input> */
/* charmap :: A handle to the source charmap object. */
+ /* */
/* charcode :: The character code. */
/* */
/* <Return> */
@@ -98,6 +98,7 @@
FT_UInt result = 0;
PSNames_Interface* psnames;
+
face = (T1_Face)charmap->face;
psnames = (PSNames_Interface*)face->psnames;
if ( psnames )
@@ -173,7 +174,6 @@
}
-
const FT_Driver_Class t1cid_driver_class =
{
/* firs of all, the FT_Module_Class fields */
@@ -181,14 +181,14 @@
ft_module_font_driver | ft_module_driver_scalable,
sizeof( FT_DriverRec ),
"t1cid", /* module name */
- 0x10000, /* version 1.0 of driver */
- 0x20000, /* requires FreeType 2.0 */
+ 0x10000L, /* version 1.0 of driver */
+ 0x20000L, /* requires FreeType 2.0 */
0,
- (FT_Module_Constructor) CID_Init_Driver,
- (FT_Module_Destructor) CID_Done_Driver,
- (FT_Module_Requester) CID_Get_Interface
+ (FT_Module_Constructor)CID_Init_Driver,
+ (FT_Module_Destructor) CID_Done_Driver,
+ (FT_Module_Requester) CID_Get_Interface
},
/* then the other font drivers fields */
@@ -196,32 +196,30 @@
sizeof( T1_SizeRec ),
sizeof( T1_GlyphSlotRec ),
- (FTDriver_initFace) CID_Init_Face,
- (FTDriver_doneFace) CID_Done_Face,
+ (FTDriver_initFace) CID_Init_Face,
+ (FTDriver_doneFace) CID_Done_Face,
- (FTDriver_initSize) 0,
- (FTDriver_doneSize) 0,
- (FTDriver_initGlyphSlot) 0,
- (FTDriver_doneGlyphSlot) 0,
+ (FTDriver_initSize) 0,
+ (FTDriver_doneSize) 0,
+ (FTDriver_initGlyphSlot)0,
+ (FTDriver_doneGlyphSlot)0,
- (FTDriver_setCharSizes) 0,
- (FTDriver_setPixelSizes) 0,
+ (FTDriver_setCharSizes) 0,
+ (FTDriver_setPixelSizes)0,
- (FTDriver_loadGlyph) CID_Load_Glyph,
- (FTDriver_getCharIndex) CID_Get_Char_Index,
+ (FTDriver_loadGlyph) CID_Load_Glyph,
+ (FTDriver_getCharIndex) CID_Get_Char_Index,
-#ifndef xxxxT1_CONFIG_OPTION_NO_AFM
- (FTDriver_getKerning) 0,
- (FTDriver_attachFile) 0,
+#ifdef T1_CONFIG_OPTION_NO_AFM
+ (FTDriver_getKerning) 0,
+ (FTDriver_attachFile) 0,
#else
- (FTDriver_getKerning) cid_Get_Kerning,
- (FTDriver_attachFile) CID_Read_AFM,
+ (FTDriver_getKerning) cid_Get_Kerning,
+ (FTDriver_attachFile) CID_Read_AFM,
#endif
(FTDriver_getAdvances) 0
};
-
-
/* END */
--- a/src/psnames/psdriver.h
+++ b/src/psnames/psdriver.h
@@ -1,10 +1,10 @@
/***************************************************************************/
/* */
-/* psmodule.h */
+/* psdriver.h */
/* */
-/* High-level PSNames module interface (specification). */
+/* High-level PSNames driver interface (specification). */
/* */
-/* Copyright 1996-1999 by */
+/* Copyright 1996-2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -21,9 +21,9 @@
#include <freetype/ftmodule.h>
- FT_EXPORT_VAR(const FT_Module_Class) psnames_module_class;
+ FT_EXPORT_VAR( const FT_Module_Class ) psnames_module_class;
-#endif /* PSMODULE_H */
+#endif /* PSDRIVER_H */
/* END */
--- a/src/psnames/psmodule.c
+++ b/src/psnames/psmodule.c
@@ -1,44 +1,72 @@
+/***************************************************************************/
+/* */
+/* psmodule.c */
+/* */
+/* PSNames module implementation (body). */
+/* */
+/* Copyright 1996-2000 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+
#include <freetype/internal/psnames.h>
#include <freetype/internal/ftobjs.h>
#include <psmodule.h>
+
#include <stdlib.h>
+#include <string.h> /* for strcmp(), strncpy() */
+
#ifndef FT_CONFIG_OPTION_NO_POSTSCRIPT_NAMES
-/* see the python script "freetype2/docs/glnames.py" which is used */
-/* to generate the following tables... */
+
+ /* see the python script `freetype2/docs/glnames.py' which is used */
+ /* to generate the following tables... */
#include <pstables.h>
+
#ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST
- /* return the Unicode value corresponding to a given glyph. Note that */
- /* we do deal with glyph variants by detecting a non-initial dot */
- /* in the name, as in "A.swash" or "e.final", etc.. */
- /* */
+
+
+ /* return the Unicode value corresponding to a given glyph. Note that */
+ /* we do deal with glyph variants by detecting a non-initial dot in */
+ /* the name, as in `A.swash' or `e.final', etc. */
+ /* */
static
- FT_ULong PS_Unicode_Value( const char* glyph_name )
+ FT_ULong PS_Unicode_Value( const char* glyph_name )
{
FT_Int n;
char first = glyph_name[0];
char temp[64];
- /* if the name begins with "uni", then the glyph name may be a */
- /* hard-coded unicode character code.. */
+
+ /* if the name begins with `uni', then the glyph name may be a */
+ /* hard-coded unicode character code. */
if ( glyph_name[0] == 'u' &&
glyph_name[1] == 'n' &&
glyph_name[2] == 'i' )
{
/* determine wether the following characters are hexadecimal */
- FT_Int count;
- FT_ULong value = 0;
- const char* p = glyph_name + 4;
+ FT_Int count;
+ FT_ULong value = 0;
+ const char* p = glyph_name + 4;
- for ( count = 4;count > 0; count--, p++ )
+
+ for ( count = 4; count > 0; count--, p++ )
{
char c = *p;
unsigned char d;
- d = (unsigned char)c-'0';
- if (d >= 10)
+
+ d = (unsigned char)c - '0';
+ if ( d >= 10 )
{
d = (unsigned char)c - 'A';
if ( d >= 6 )
@@ -46,25 +74,27 @@
else
d += 10;
}
- /* exit if one non-uppercase-hexadecimal character was found */
- if (d >= 16)
+ /* exit if a non-uppercase-hexadecimal character was found */
+ if ( d >= 16 )
break;
- value = (value << 4) + d;
- if (count == 0)
+ value = ( value << 4 ) + d;
+ if ( count == 0 )
return value;
}
}
/* look for a non-initial dot in the glyph name in order to */
- /* sort-out variants like "A.swash", "e.final", etc.. */
+ /* sort-out variants like `A.swash', `e.final', etc. */
{
const char* p;
int len;
+
p = glyph_name;
- while ( *p && *p != '.' ) p++;
- len = p-glyph_name;
+ while ( *p && *p != '.' )
+ p++;
+ len = p - glyph_name;
if ( *p && len < 64 )
{
@@ -79,35 +109,40 @@
{
const char* name = t1_standard_glyphs[n];
+
if ( first == name[0] && strcmp( glyph_name, name ) == 0 )
return names_to_unicode[n];
}
+
/* not found, there is probably no Unicode value for this glyph name */
return 0;
}
- /* qsort callback to sort the unicode map */
+ /* qsort callback to sort the unicode map */
static
- int compare_uni_maps( const void* a, const void* b )
+ int compare_uni_maps( const void* a,
+ const void* b )
{
PS_UniMap* map1 = (PS_UniMap*)a;
PS_UniMap* map2 = (PS_UniMap*)b;
+
return ( map1->unicode < map2->unicode ? -1 :
map1->unicode > map2->unicode ? 1 : 0 );
}
- /* Builds a table that maps Unicode values to glyph indices */
+ /* Builds a table that maps Unicode values to glyph indices */
static
FT_Error PS_Build_Unicode_Table( FT_Memory memory,
FT_UInt num_glyphs,
const char** glyph_names,
- PS_Unicodes *table )
+ PS_Unicodes* table )
{
FT_Error error;
+
/* we first allocate the table */
table->num_maps = 0;
table->maps = 0;
@@ -119,14 +154,17 @@
PS_UniMap* map;
FT_ULong uni_char;
+
map = table->maps;
for ( n = 0; n < num_glyphs; n++ )
{
const char* gname = glyph_names[n];
- if (gname)
+
+
+ if ( gname )
{
- uni_char = PS_Unicode_Value(gname);
- if (uni_char && uni_char != 0xFFFF)
+ uni_char = PS_Unicode_Value( gname );
+ if ( uni_char && uni_char != 0xFFFF )
{
map->unicode = uni_char;
map->glyph_index = n;
@@ -138,102 +176,108 @@
/* now, compress the table a bit */
count = map - table->maps;
if ( count > 0 && REALLOC( table->maps,
- num_glyphs*sizeof(PS_UniMap),
- count*sizeof(PS_UniMap) ) )
- {
+ num_glyphs * sizeof ( PS_UniMap ),
+ count * sizeof ( PS_UniMap ) ) )
count = 0;
- }
- if (count == 0)
+ if ( count == 0 )
{
FREE( table->maps );
- if (!error)
- error = FT_Err_Invalid_Argument; /* no unicode chars here !! */
+ if ( !error )
+ error = FT_Err_Invalid_Argument; /* no unicode chars here! */
}
else
/* sort the table in increasing order of unicode values */
- qsort( table->maps, count, sizeof(PS_UniMap), compare_uni_maps );
+ qsort( table->maps, count, sizeof ( PS_UniMap ), compare_uni_maps );
table->num_maps = count;
}
+
return error;
}
+
static
FT_UInt PS_Lookup_Unicode( PS_Unicodes* table,
FT_ULong unicode )
{
PS_UniMap *min, *max, *mid;
+
+
/* perform a binary search on the table */
min = table->maps;
max = min + table->num_maps - 1;
- while (min <= max)
+ while ( min <= max )
{
- mid = min + (max-min)/2;
+ mid = min + ( max - min ) / 2;
if ( mid->unicode == unicode )
return mid->glyph_index;
- if (min == max)
+ if ( min == max )
break;
- if ( mid->unicode < unicode ) min = mid+1;
- else max = mid-1;
+ if ( mid->unicode < unicode )
+ min = mid + 1;
+ else
+ max = mid - 1;
}
return 0xFFFF;
}
-#endif
+#endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */
static
const char* PS_Macintosh_Name( FT_UInt name_index )
{
- if (name_index >= 258)
+ if ( name_index >= 258 )
name_index = 0;
- return standard_glyph_names[ mac_standard_names[name_index] ];
+ return standard_glyph_names[mac_standard_names[name_index]];
}
-
static
const char* PS_Standard_Strings( FT_UInt sid )
{
- return (sid < NUM_STD_GLYPHS ? t1_standard_glyphs[sid] : 0);
+ return ( sid < NUM_STD_GLYPHS ? t1_standard_glyphs[sid] : 0 );
}
-
- static const PSNames_Interface psnames_interface =
+ static const PSNames_Interface psnames_interface =
{
#ifdef FT_CONFIG_OPTION_ADOBE_GLYPH_LIST
- (PS_Unicode_Value_Func) PS_Unicode_Value,
- (PS_Build_Unicodes_Func) PS_Build_Unicode_Table,
- (PS_Lookup_Unicode_Func) PS_Lookup_Unicode,
+
+ (PS_Unicode_Value_Func) PS_Unicode_Value,
+ (PS_Build_Unicodes_Func) PS_Build_Unicode_Table,
+ (PS_Lookup_Unicode_Func) PS_Lookup_Unicode,
+
#else
+
0,
0,
0,
-#endif
- (PS_Macintosh_Name_Func) PS_Macintosh_Name,
- (PS_Adobe_Std_Strings_Func) PS_Standard_Strings,
+#endif /* FT_CONFIG_OPTION_ADOBE_GLYPH_LIST */
+ (PS_Macintosh_Name_Func) PS_Macintosh_Name,
+ (PS_Adobe_Std_Strings_Func)PS_Standard_Strings,
+
t1_standard_encoding,
t1_expert_encoding
};
+
#endif /* !FT_CONFIG_OPTION_NO_POSTSCRIPT_NAMES */
-
const FT_Module_Class psnames_module_class =
{
0, /* this is not a font driver, nor a renderer */
- sizeof(FT_ModuleRec),
+ sizeof( FT_ModuleRec ),
"psnames", /* driver name */
100, /* driver version */
@@ -245,8 +289,10 @@
(void*)&psnames_interface, /* module specific interface */
#endif
- (FT_Module_Constructor) 0,
- (FT_Module_Destructor) 0,
- (FT_Module_Requester) 0
+ (FT_Module_Constructor)0,
+ (FT_Module_Destructor) 0,
+ (FT_Module_Requester) 0
};
+
+/* END */
--- a/src/psnames/psmodule.h
+++ b/src/psnames/psmodule.h
@@ -4,7 +4,7 @@
/* */
/* High-level PSNames module interface (specification). */
/* */
-/* Copyright 1996-1999 by */
+/* Copyright 1996-2000 by */
/* David Turner, Robert Wilhelm, and Werner Lemberg. */
/* */
/* This file is part of the FreeType project, and may only be used, */
@@ -21,9 +21,9 @@
#include <freetype/ftmodule.h>
- FT_EXPORT_VAR(const FT_Module_Class) psnames_module_class;
+ FT_EXPORT_VAR( const FT_Module_Class ) psnames_module_class;
-#endif /* PSMODULE_H */
+#endif /* PSDRIVER_H */
/* END */
--- a/src/sfnt/sfdriver.c
+++ b/src/sfnt/sfdriver.c
@@ -25,6 +25,7 @@
#include <ttcmap.h>
#include <sfobjs.h>
+
static
void* get_sfnt_table( TT_Face face,
FT_Sfnt_Tag tag )
@@ -145,16 +146,15 @@
sizeof( FT_ModuleRec ),
"sfnt", /* driver name */
- 0x10000, /* driver version 1.0 */
- 0x20000, /* driver requires FreeType 2.0 or higher */
+ 0x10000L, /* driver version 1.0 */
+ 0x20000L, /* driver requires FreeType 2.0 or higher */
(const void*)&sfnt_interface, /* module specific interface */
- (FT_Module_Constructor) 0,
- (FT_Module_Destructor) 0,
- (FT_Module_Requester) SFNT_Get_Interface
+ (FT_Module_Constructor)0,
+ (FT_Module_Destructor) 0,
+ (FT_Module_Requester) SFNT_Get_Interface
};
-
/* END */
--- a/src/sfnt/sfdriver.h
+++ b/src/sfnt/sfdriver.h
@@ -21,7 +21,7 @@
#include <freetype/ftmodule.h>
- FT_EXPORT_VAR(const FT_Module_Class) sfnt_module_class;
+ FT_EXPORT_VAR( const FT_Module_Class ) sfnt_module_class;
#endif /* SFDRIVER_H */
--- a/src/sfnt/ttcmap.c
+++ b/src/sfnt/ttcmap.c
@@ -59,7 +59,7 @@
/* table :: A pointer to a cmap object. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* The function assumes that the stream is already in use (i.e., */
@@ -281,7 +281,7 @@
/* cmap :: A handle to a cmap object. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error TT_CharMap_Free( TT_Face face,
--- a/src/sfnt/ttload.c
+++ b/src/sfnt/ttload.c
@@ -96,7 +96,7 @@
/* length :: The length of the table if found, undefined otherwise. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error TT_Goto_Table( TT_Face face,
@@ -141,7 +141,7 @@
/* sfnt :: The SFNT header. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* The stream cursor must be at the font file's origin. */
@@ -275,7 +275,7 @@
/* sfnt :: The SFNT directory header. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* The stream cursor must be at the font file's origin. */
@@ -373,7 +373,7 @@
/* buffer :: The address of target buffer. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error TT_Load_Any( TT_Face face,
@@ -436,7 +436,7 @@
/* stream :: The input stream. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error TT_Load_Header( TT_Face face,
@@ -507,7 +507,7 @@
/* stream :: The input stream. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error TT_Load_MaxProfile( TT_Face face,
@@ -597,7 +597,7 @@
/* vertical :: A boolean flag. If set, load vertical metrics. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
static
FT_Error TT_Load_Metrics( TT_Face face,
@@ -733,7 +733,7 @@
/* vertical :: A boolean flag. If set, load vertical metrics. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error TT_Load_Metrics_Header( TT_Face face,
@@ -829,7 +829,7 @@
/* stream :: The input stream. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error TT_Load_Names( TT_Face face,
@@ -1020,7 +1020,7 @@
/* stream :: A handle to the input stream. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error TT_Load_CMap( TT_Face face,
@@ -1129,7 +1129,7 @@
/* stream :: A handle to the input stream. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error TT_Load_OS2( TT_Face face,
@@ -1263,7 +1263,7 @@
/* stream :: A handle to the input stream. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error TT_Load_PostScript( TT_Face face,
@@ -1318,7 +1318,7 @@
/* stream :: A handle to the input stream. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error TT_Load_PCLT( TT_Face face,
@@ -1389,7 +1389,7 @@
/* stream :: The input stream. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error TT_Load_Gasp( TT_Face face,
@@ -1461,7 +1461,7 @@
/* stream :: The input stream. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error TT_Load_Kern( TT_Face face,
@@ -1566,7 +1566,7 @@
/* stream :: A handle to the input stream. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error TT_Load_Hdmx( TT_Face face,
--- a/src/sfnt/ttpost.c
+++ b/src/sfnt/ttpost.c
@@ -427,7 +427,7 @@
/* You must not modify the returned string! */
/* */
/* <Output> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error TT_Get_PS_Name( TT_Face face,
--- a/src/sfnt/ttsbit.c
+++ b/src/sfnt/ttsbit.c
@@ -211,7 +211,7 @@
/* stream :: The input stream. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
static
FT_Error Load_SBit_Const_Metrics( TT_SBit_Range* range,
@@ -243,7 +243,7 @@
/* load_offsets :: A flag whether to load the glyph offset table. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
static
FT_Error Load_SBit_Range_Codes( TT_SBit_Range* range,
@@ -306,7 +306,7 @@
/* stream :: The input stream. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
static
FT_Error Load_SBit_Range( TT_SBit_Range* range,
@@ -381,7 +381,7 @@
/* stream :: The input stream. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error TT_Load_SBit_Strikes( TT_Face face,
@@ -631,7 +631,7 @@
/* aglyph_offset :: The offset of the glyph data in `EBDT' table. */
/* */
/* <Return> */
- /* TrueType error code. 0 means the glyph index was found. */
+ /* FreeType error code. 0 means the glyph index was found. */
/* */
static
FT_Error Find_SBit_Range( FT_UInt glyph_index,
@@ -735,7 +735,7 @@
/* aglyph_offset :: The offset of the glyph data in `EBDT' table. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. Returns */
+ /* FreeType error code. 0 means success. Returns */
/* TT_Err_Invalid_Argument if no sbit exists for the requested glyph. */
/* */
static
@@ -800,7 +800,7 @@
/* big_metrics :: A big SBit metrics structure for the glyph. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* The stream cursor must be positioned at the glyph's offset within */
@@ -1349,7 +1349,7 @@
/* metrics :: A big sbit metrics structure for the glyph image. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. Returns an error if no */
+ /* FreeType error code. 0 means success. Returns an error if no */
/* glyph sbit exists for the index. */
/* */
/* <Note> */
--- a/src/truetype/ttdriver.c
+++ b/src/truetype/ttdriver.c
@@ -75,7 +75,7 @@
/* formats. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* Only horizontal layouts (left-to-right & right-to-left) are */
@@ -178,7 +178,7 @@
/* size :: A handle to the target size object. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
static
FT_Error Set_Char_Sizes( TT_Size size,
@@ -238,7 +238,7 @@
/* size :: A handle to the target size object. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
static
FT_Error Set_Pixel_Sizes( TT_Size size,
@@ -280,7 +280,7 @@
/* whether to hint the outline, etc). */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
static
FT_Error Load_Glyph( TT_GlyphSlot slot,
@@ -398,18 +398,20 @@
static
- FT_Module_Interface tt_get_interface( TT_Driver driver,
- const char* interface )
+ FT_Module_Interface tt_get_interface( TT_Driver driver,
+ const char* interface )
{
- FT_Module sfntd = FT_Get_Module( driver->root.root.library, "sfnt" );
+ FT_Module sfntd = FT_Get_Module( driver->root.root.library,
+ "sfnt" );
SFNT_Interface* sfnt;
+
/* only return the default interface from the SFNT module */
if ( sfntd )
{
- sfnt = (SFNT_Interface*)(sfntd->clazz->module_interface);
+ sfnt = (SFNT_Interface*)( sfntd->clazz->module_interface );
if ( sfnt )
- return sfnt->get_interface( FT_MODULE(driver), interface );
+ return sfnt->get_interface( FT_MODULE( driver ), interface );
}
return 0;
@@ -425,14 +427,14 @@
sizeof ( TT_DriverRec ),
"truetype", /* driver name */
- 0x10000, /* driver version == 1.0 */
- 0x20000, /* driver requires FreeType 2.0 or above */
+ 0x10000L, /* driver version == 1.0 */
+ 0x20000L, /* driver requires FreeType 2.0 or above */
(void*)0, /* driver specific interface */
- (FT_Module_Constructor) TT_Init_Driver,
- (FT_Module_Destructor) TT_Done_Driver,
- (FT_Module_Requester) tt_get_interface,
+ (FT_Module_Constructor)TT_Init_Driver,
+ (FT_Module_Destructor) TT_Done_Driver,
+ (FT_Module_Requester) tt_get_interface,
},
sizeof ( TT_FaceRec ),
@@ -440,23 +442,21 @@
sizeof ( FT_GlyphSlotRec ),
- (FTDriver_initFace) TT_Init_Face,
- (FTDriver_doneFace) TT_Done_Face,
- (FTDriver_initSize) TT_Init_Size,
- (FTDriver_doneSize) TT_Done_Size,
- (FTDriver_initGlyphSlot) 0,
- (FTDriver_doneGlyphSlot) 0,
+ (FTDriver_initFace) TT_Init_Face,
+ (FTDriver_doneFace) TT_Done_Face,
+ (FTDriver_initSize) TT_Init_Size,
+ (FTDriver_doneSize) TT_Done_Size,
+ (FTDriver_initGlyphSlot)0,
+ (FTDriver_doneGlyphSlot)0,
- (FTDriver_setCharSizes) Set_Char_Sizes,
- (FTDriver_setPixelSizes) Set_Pixel_Sizes,
- (FTDriver_loadGlyph) Load_Glyph,
- (FTDriver_getCharIndex) Get_Char_Index,
+ (FTDriver_setCharSizes) Set_Char_Sizes,
+ (FTDriver_setPixelSizes)Set_Pixel_Sizes,
+ (FTDriver_loadGlyph) Load_Glyph,
+ (FTDriver_getCharIndex) Get_Char_Index,
- (FTDriver_getKerning) Get_Kerning,
- (FTDriver_attachFile) 0,
- (FTDriver_getAdvances) 0
-
-
+ (FTDriver_getKerning) Get_Kerning,
+ (FTDriver_attachFile) 0,
+ (FTDriver_getAdvances) 0
};
--- a/src/truetype/ttgload.c
+++ b/src/truetype/ttgload.c
@@ -196,8 +196,9 @@
/* */
/* The following functions are used by default with TrueType fonts. */
/* However, they can be replaced by alternatives if we need to support */
- /* TrueType-compressed formats (like MicroType) in the future.. */
+ /* TrueType-compressed formats (like MicroType) in the future. */
/* */
+ /*************************************************************************/
static
FT_Error TT_Access_Glyph_Frame( TT_Loader* loader,
@@ -208,7 +209,8 @@
FT_Error error;
FT_Stream stream = loader->stream;
- /* the following line sets the 'error' variable through macros !! */
+
+ /* the following line sets the `error' variable through macros! */
(void)( FILE_Seek( offset ) || ACCESS_Frame( byte_count ) );
FT_TRACE5(( "Glyph %ld\n", glyph_index ));
@@ -216,21 +218,22 @@
}
-
static
- void TT_Forget_Glyph_Frame( TT_Loader* loader )
+ void TT_Forget_Glyph_Frame( TT_Loader* loader )
{
FT_Stream stream = loader->stream;
+
+
FORGET_Frame();
}
-
static
FT_Error TT_Load_Glyph_Header( TT_Loader* loader )
{
FT_Stream stream = loader->stream;
+
loader->n_contours = GET_Short();
loader->bbox.xMin = GET_Short();
@@ -248,7 +251,6 @@
}
-
static
FT_Error TT_Load_Simple_Glyph( TT_Loader* load )
{
@@ -268,15 +270,17 @@
short* cur = gloader->current.outline.contours;
short* limit = cur + n_contours;
+
for ( ; cur < limit; cur++ )
cur[0] = GET_UShort();
n_points = 0;
- if (n_contours > 0)
- n_points = cur[-1]+1;
+ if ( n_contours > 0 )
+ n_points = cur[-1] + 1;
- error = FT_GlyphLoader_Check_Points( gloader, n_points+2, 0 );
- if (error) goto Fail;
+ error = FT_GlyphLoader_Check_Points( gloader, n_points + 2, 0 );
+ if ( error )
+ goto Fail;
outline = &gloader->current.outline;
}
@@ -305,7 +309,8 @@
}
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
- if ( ( load->load_flags &
+
+ if ( ( load->load_flags &
( FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING ) ) == 0 &&
load->instructions )
{
@@ -314,6 +319,7 @@
MEM_Copy( load->instructions, stream->cursor, n_ins );
}
+
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
stream->cursor += n_ins;
@@ -325,6 +331,7 @@
FT_Byte* limit = flag + n_points;
FT_Byte c, count;
+
for ( ; flag < limit; flag++ )
{
*flag = c = GET_Byte();
@@ -413,14 +420,18 @@
FT_SubGlyph* subglyph;
FT_UInt num_subglyphs;
+
num_subglyphs = 0;
+
do
{
FT_Fixed xx, xy, yy, yx;
+
/* check that we can load a new subglyph */
error = FT_GlyphLoader_Check_Subglyphs( gloader, num_subglyphs+1 );
- if (error) goto Fail;
+ if ( error )
+ goto Fail;
subglyph = gloader->current.subglyphs + num_subglyphs;
@@ -508,11 +519,11 @@
/* <Description> */
/* Once a simple glyph has been loaded, it needs to be processed. */
/* Usually, this means scaling and hinting through bytecode */
- /* interpretation.. */
+ /* interpretation. */
/* */
static
- FT_Error TT_Process_Simple_Glyph( TT_Loader* load,
- FT_Bool debug )
+ FT_Error TT_Process_Simple_Glyph( TT_Loader* load,
+ FT_Bool debug )
{
FT_GlyphLoader* gloader = load->gloader;
FT_Outline* outline = &gloader->current.outline;
@@ -521,6 +532,7 @@
TT_GlyphZone* zone = &load->zone;
FT_Error error = FT_Err_Ok;
+
n_ins = load->glyph->control_len;
/* add shadow points */
@@ -532,6 +544,7 @@
FT_Vector* pp1;
FT_Vector* pp2;
+
/* pp1 = xMin - lsb */
pp1 = outline->points + n_points;
pp1->x = load->bbox.xMin - load->left_bearing;
@@ -555,7 +568,7 @@
tt_prepare_zone( zone, &gloader->current, 0, 0 );
/* eventually scale the glyph */
- if (!(load->load_flags & FT_LOAD_NO_SCALE))
+ if ( !( load->load_flags & FT_LOAD_NO_SCALE ) )
{
FT_Vector* vec = zone->cur;
FT_Vector* limit = vec + n_points;
@@ -573,10 +586,11 @@
cur_to_org( n_points, zone );
/* eventually hint the glyph */
- if ( IS_HINTED(load->load_flags) )
+ if ( IS_HINTED( load->load_flags ) )
{
FT_Pos x = zone->org[n_points-2].x;
+
x = ( ( x + 32 ) & -64 ) - x;
translate_array( n_points, zone->org, x, 0 );
@@ -585,16 +599,18 @@
zone->cur[n_points - 1].x = ( zone->cur[n_points - 1].x + 32 ) & -64;
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
+
/* now consider hinting */
if ( n_ins > 0 )
{
error = TT_Set_CodeRange( load->exec, tt_coderange_glyph,
load->exec->glyphIns, n_ins );
- if ( error ) goto Exit;
+ if ( error )
+ goto Exit;
load->exec->is_composite = FALSE;
- load->exec->pedantic_hinting = (FT_Bool)(load->load_flags &
- FT_LOAD_PEDANTIC);
+ load->exec->pedantic_hinting = (FT_Bool)( load->load_flags &
+ FT_LOAD_PEDANTIC );
load->exec->pts = *zone;
load->exec->pts.n_points += 2;
@@ -604,7 +620,9 @@
error = FT_Err_Ok; /* ignore bytecode errors in non-pedantic mode */
}
+
#endif /* TT_CONFIG_OPTION_BYTECODE_INTERPRETER */
+
}
/* save glyph phantom points */
@@ -619,10 +637,6 @@
}
-
-
-
-
/*************************************************************************/
/* */
/* <Function> */
@@ -718,13 +732,15 @@
/* access glyph frame */
error = face->access_glyph_frame( loader, glyph_index, offset, count );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
opened_frame = 1;
/* read first glyph header */
error = face->read_glyph_header( loader );
- if (error) goto Fail;
+ if ( error )
+ goto Fail;
contours_count = loader->n_contours;
@@ -751,10 +767,12 @@
{
/* check that we can add the contours to the glyph */
error = FT_GlyphLoader_Check_Points( gloader, 0, contours_count );
- if (error) goto Fail;
+ if ( error )
+ goto Fail;
error = face->read_simple_glyph( loader );
- if (error) goto Fail;
+ if ( error )
+ goto Fail;
#ifdef TT_CONFIG_OPTION_BYTECODE_INTERPRETER
{
@@ -783,13 +801,14 @@
TT_GlyphSlot glyph = (TT_GlyphSlot)loader->glyph;
FT_UInt start_point, start_contour;
+
/* for each subglyph, read composite header */
start_point = gloader->base.outline.n_points;
start_contour = gloader->base.outline.n_contours;
-
error = face->read_composite_glyph( loader );
- if (error) goto Fail;
+ if ( error )
+ goto Fail;
face->forget_glyph_frame( loader );
opened_frame = 0;
@@ -832,10 +851,10 @@
FT_Vector pp1, pp2;
FT_Pos x, y;
- /* each time we call load_truetype_glyph in this loop, the */
- /* value of 'gloader.base.subglyphs' can change due to table */
- /* reallocations. We thus need to recompute the subglyph */
- /* pointer on each iteration.. */
+ /* Each time we call load_truetype_glyph in this loop, the */
+ /* value of `gloader.base.subglyphs' can change due to table */
+ /* reallocations. We thus need to recompute the subglyph */
+ /* pointer on each iteration. */
subglyph = gloader->base.subglyphs + num_base_subgs + n;
pp1 = loader->pp1;
@@ -870,8 +889,10 @@
WE_HAVE_AN_XY_SCALE |
WE_HAVE_A_2X2 ) )
{
- FT_Vector* cur = gloader->base.outline.points + num_base_points;
- FT_Vector* org = gloader->base.extra_points + num_base_points;
+ FT_Vector* cur = gloader->base.outline.points +
+ num_base_points;
+ FT_Vector* org = gloader->base.extra_points +
+ num_base_points;
FT_Vector* limit = cur + num_new_points;
for ( ; cur < limit; cur++, org++ )
@@ -890,6 +911,7 @@
FT_Vector* p1;
FT_Vector* p2;
+
if ( start_point + k >= num_base_points ||
l >= (FT_UInt)num_new_points )
{
@@ -950,12 +972,12 @@
/* read size of instructions */
if ( FILE_Seek( loader->ins_pos ) ||
- READ_UShort(n_ins) )
+ READ_UShort( n_ins ) )
goto Fail;
FT_TRACE5(( " Instructions size = %d\n", n_ins ));
/* in some fonts ?? */
- if (n_ins == 0xFFFF)
+ if ( n_ins == 0xFFFF )
n_ins = 0;
/* check it */
@@ -981,7 +1003,8 @@
goto Fail;
/* prepare the execution context */
- tt_prepare_zone( &exec->pts, &gloader->base, start_point, start_contour );
+ tt_prepare_zone( &exec->pts, &gloader->base,
+ start_point, start_contour );
pts = &exec->pts;
pts->n_points = num_points + 2;
@@ -1039,7 +1062,7 @@
/***********************************************************************/
Fail:
- if (opened_frame)
+ if ( opened_frame )
face->forget_glyph_frame( loader );
Exit:
@@ -1090,11 +1113,12 @@
else
bbox = loader->bbox;
- /* get the device-independent horizontal advance. It is scaled later */
- /* by the base layer.. */
+ /* get the device-independent horizontal advance. It is scaled later */
+ /* by the base layer. */
{
FT_Pos advance = loader->advance;
+
/* the flag FT_LOAD_NO_ADVANCE_CHECK was introduced to */
/* correctly support DynaLab fonts, which have an incorrect */
/* `advance_Width_Max' field! It is used, to my knowledge, */
@@ -1105,7 +1129,7 @@
advance = face->horizontal.advance_Width_Max;
/* we need to return the advance in font units in linearHoriAdvance, */
- /* it will be scaled later by the base layer.. */
+ /* it will be scaled later by the base layer. */
glyph->linearHoriAdvance = advance;
}
@@ -1188,13 +1212,13 @@
advance = advance_height;
}
- /* set the advance height in design units. It is scaled later by the */
- /* base layer.. */
+ /* set the advance height in design units. It is scaled later by */
+ /* the base layer. */
glyph->linearVertAdvance = advance_height;
- /* XXX: for now, we have no better algorithm for the lsb, but it */
- /* should work fine. */
- /* */
+ /* XXX: for now, we have no better algorithm for the lsb, but it */
+ /* should work fine. */
+ /* */
left = ( bbox.xMin - bbox.xMax ) / 2;
/* grid-fit them if necessary */
@@ -1252,7 +1276,7 @@
/* whether to hint the outline, etc). */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error TT_Load_Glyph( TT_Size size,
@@ -1352,6 +1376,7 @@
/* update the glyph zone bounds */
{
FT_GlyphLoader* gloader = FT_FACE_DRIVER(face)->glyph_loader;
+
loader.gloader = gloader;
--- a/src/truetype/ttinterp.c
+++ b/src/truetype/ttinterp.c
@@ -257,7 +257,7 @@
/* exec :: The target execution context. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error TT_Goto_CodeRange( TT_ExecContext exec,
@@ -307,7 +307,7 @@
/* exec :: The target execution context. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error TT_Set_CodeRange( TT_ExecContext exec,
@@ -339,7 +339,7 @@
/* exec :: The target execution context. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* Does not set the Error variable. */
@@ -378,7 +378,7 @@
/* memory :: A handle to the parent memory object. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* Only the glyph loader and debugger should call this function. */
@@ -433,7 +433,7 @@
/* exec :: A handle to the target execution context. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
static
FT_Error Init_Context( TT_ExecContext exec,
@@ -504,7 +504,7 @@
/* buff :: The address of the buffer base pointer. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
static
FT_Error Update_Max( FT_Memory memory,
@@ -546,7 +546,7 @@
/* exec :: A handle to the target execution context. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* Only the glyph loader and debugger should call this function. */
@@ -649,7 +649,7 @@
/* size :: A handle to the target size object. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* Only the glyph loader and debugger should call this function. */
@@ -834,7 +834,7 @@
/* exec :: A handle to the target execution context. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* Only the glyph loader and debugger should call this function. */
@@ -6781,7 +6781,7 @@
/* exec :: A handle to the target execution context. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
/* <Note> */
/* Only the object manager and debugger should call this function. */
--- a/src/truetype/ttobjs.c
+++ b/src/truetype/ttobjs.c
@@ -143,7 +143,7 @@
/* face :: The newly built face object. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
LOCAL_DEF
FT_Error TT_Init_Face( FT_Stream stream,
@@ -158,7 +158,8 @@
library = face->root.driver->root.library;
sfnt = (SFNT_Interface*)FT_Get_Module_Interface( library, "sfnt" );
- if (!sfnt) goto Bad_Format;
+ if ( !sfnt )
+ goto Bad_Format;
/* create input stream from resource */
if ( FILE_Seek( 0 ) )
@@ -190,7 +191,7 @@
TT_Load_CVT ( face, stream ) ||
TT_Load_Programs ( face, stream );
- /* initialise standard glyph loading routines */
+ /* initialize standard glyph loading routines */
TT_Init_Glyph_Loading( face );
Exit:
@@ -221,8 +222,8 @@
SFNT_Interface* sfnt = face->sfnt;
- /* for "extended TrueType formats" (i.e. compressed versions) */
- if (face->extra.finalizer)
+ /* for `extended TrueType formats' (i.e. compressed versions) */
+ if ( face->extra.finalizer )
face->extra.finalizer( face->extra.data );
if ( sfnt )
@@ -263,7 +264,7 @@
/* size :: A handle to the size object. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
LOCAL_DEF
FT_Error TT_Init_Size( TT_Size size )
@@ -341,6 +342,7 @@
{
FT_Library library = face->root.driver->root.library;
+
face->interpreter = (TT_Interpreter)
library->debug_hooks[FT_DEBUG_HOOK_TRUETYPE];
if ( !face->interpreter )
@@ -652,7 +654,7 @@
/* driver :: A handle to the target driver object. */
/* */
/* <Return> */
- /* TrueType error code. 0 means success. */
+ /* FreeType error code. 0 means success. */
/* */
LOCAL_FUNC
FT_Error TT_Init_Driver( TT_Driver driver )
@@ -659,13 +661,14 @@
{
FT_Error error;
- /* set 'extra' in glyph loader */
- error = FT_GlyphLoader_Create_Extra( FT_DRIVER(driver)->glyph_loader );
+
+ /* set `extra' in glyph loader */
+ error = FT_GlyphLoader_Create_Extra( FT_DRIVER( driver )->glyph_loader );
/* init extension registry if needed */
#ifdef TT_CONFIG_OPTION_EXTEND_ENGINE
- if (!error)
+ if ( !error )
return TT_Init_Extensions( driver );
#endif
--- a/src/type1/t1afm.h
+++ b/src/type1/t1afm.h
@@ -1,47 +1,59 @@
-/***************************************************************************
- *
- * t1afm.h - support for reading Type 1 AFM files
- *
- *
- ***************************************************************************/
+/***************************************************************************/
+/* */
+/* t1afm.h */
+/* */
+/* AFM support for Type 1 fonts (specification). */
+/* */
+/* Copyright 1996-2000 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
#ifndef T1AFM_H
#define T1AFM_H
#include <freetype/internal/ftobjs.h>
-/* In this version, we only read the kerning table from the */
-/* AFM file. We may add support for ligatures a bit later.. */
-typedef struct T1_Kern_Pair_
-{
- FT_UInt glyph1;
- FT_UInt glyph2;
- FT_Vector kerning;
+ typedef struct T1_Kern_Pair_
+ {
+ FT_UInt glyph1;
+ FT_UInt glyph2;
+ FT_Vector kerning;
-} T1_Kern_Pair;
+ } T1_Kern_Pair;
+ typedef struct T1_AFM_
+ {
+ FT_Int num_pairs;
+ T1_Kern_Pair* kern_pairs;
-typedef struct T1_AFM_
-{
- FT_Int num_pairs;
- T1_Kern_Pair* kern_pairs;
+ } T1_AFM;
-} T1_AFM;
+ LOCAL_DEF
+ FT_Error T1_Read_AFM( FT_Face face,
+ FT_Stream stream );
-LOCAL_DEF
-FT_Error T1_Read_AFM( FT_Face face,
- FT_Stream stream );
+ LOCAL_DEF
+ void T1_Done_AFM( FT_Memory memory,
+ T1_AFM* afm );
-LOCAL_DEF
-void T1_Done_AFM( FT_Memory memory,
- T1_AFM* afm );
+ LOCAL_DEF
+ void T1_Get_Kerning( T1_AFM* afm,
+ FT_UInt glyph1,
+ FT_UInt glyph2,
+ FT_Vector* kerning );
-LOCAL_DEF
-void T1_Get_Kerning( T1_AFM* afm,
- FT_UInt glyph1,
- FT_UInt glyph2,
- FT_Vector* kerning );
#endif /* T1AFM_H */
+
+
+/* END */
--- a/src/type1/t1driver.c
+++ b/src/type1/t1driver.c
@@ -1,20 +1,21 @@
-/*******************************************************************
- *
- * t1driver.c
- *
- * High-level Type1 driver interface for FreeType 2.0
- *
- * Copyright 1996-1998 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- ******************************************************************/
+/***************************************************************************/
+/* */
+/* t1driver.c */
+/* */
+/* Type 1 driver interface (body). */
+/* */
+/* Copyright 1996-2000 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
#include <t1driver.h>
#include <t1gload.h>
#include <t1afm.h>
@@ -23,11 +24,22 @@
#include <freetype/internal/ftstream.h>
#include <freetype/internal/psnames.h>
+#include <string.h> /* for strcmp() */
+
+
+ /*************************************************************************/
+ /* */
+ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
+ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
+ /* messages during execution. */
+ /* */
#undef FT_COMPONENT
#define FT_COMPONENT trace_t1driver
+
#ifndef T1_CONFIG_OPTION_NO_AFM
+
/*************************************************************************/
/* */
/* <Function> */
@@ -68,85 +80,96 @@
{
T1_AFM* afm;
+
kerning->x = 0;
kerning->y = 0;
afm = (T1_AFM*)face->afm_data;
- if (afm)
+ if ( afm )
T1_Get_Kerning( afm, left_glyph, right_glyph, kerning );
return T1_Err_Ok;
}
-#endif
- /******************************************************************/
- /* */
- /* <Function> Set_Char_Sizes */
- /* */
- /* <Description> */
- /* A driver method used to reset a size's character sizes */
- /* (horizontal and vertical) expressed in fractional points. */
- /* */
- /* <Input> */
- /* size :: handle to target size object */
- /* char_width :: character width expressed in 26.6 points */
- /* char_height :: character height expressed in 26.6 points */
- /* */
- /* <Return> */
- /* FreeType error code. 0 means success */
- /* */
+
+#endif /* T1_CONFIG_OPTION_NO_AFM */
+
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* Set_Char_Sizes */
+ /* */
+ /* <Description> */
+ /* A driver method used to reset a size's character sizes (horizontal */
+ /* and vertical) expressed in fractional points. */
+ /* */
+ /* <Input> */
+ /* char_width :: The character width expressed in 26.6 */
+ /* fractional points. */
+ /* */
+ /* char_height :: The character height expressed in 26.6 */
+ /* fractional points. */
+ /* */
+ /* horz_resolution :: The horizontal resolution of the output device. */
+ /* */
+ /* vert_resolution :: The vertical resolution of the output device. */
+ /* */
+ /* <InOut> */
+ /* size :: A handle to the target size object. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
static
- FT_Error Set_Char_Sizes( T1_Size size,
- FT_F26Dot6 char_width,
- FT_F26Dot6 char_height,
- FT_UInt horz_resolution,
- FT_UInt vert_resolution )
+ FT_Error Set_Char_Sizes( T1_Size size,
+ FT_F26Dot6 char_width,
+ FT_F26Dot6 char_height,
+ FT_UInt horz_resolution,
+ FT_UInt vert_resolution )
{
- UNUSED(char_width);
- UNUSED(char_height);
- UNUSED(horz_resolution);
- UNUSED(vert_resolution);
+ UNUSED( char_width );
+ UNUSED( char_height );
+ UNUSED( horz_resolution );
+ UNUSED( vert_resolution );
size->valid = FALSE;
+
return T1_Reset_Size( size );
}
- /******************************************************************/
- /* */
- /* <Function> Set_Pixel_Sizes */
- /* */
- /* <Description> */
- /* A driver method used to reset a size's character sizes */
- /* (horizontal and vertical) expressed in integer pixels. */
- /* */
- /* <Input> */
- /* size :: handle to target size object */
- /* */
- /* pixel_width :: character width expressed in 26.6 points */
- /* */
- /* pixel_height :: character height expressed in 26.6 points */
- /* */
- /* char_size :: the corresponding character size in points */
- /* This value is only sent to the TrueType */
- /* bytecode interpreter, even though 99% of */
- /* glyph programs will simply ignore it. A */
- /* safe value there is the maximum of the */
- /* pixel width and height (multiplied by */
- /* 64 to make it a 26.6 fixed float !) */
- /* <Return> */
- /* FreeType error code. 0 means success */
- /* */
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* Set_Pixel_Sizes */
+ /* */
+ /* <Description> */
+ /* A driver method used to reset a size's character sizes (horizontal */
+ /* and vertical) expressed in integer pixels. */
+ /* */
+ /* <Input> */
+ /* pixel_width :: The character width expressed in integer pixels. */
+ /* */
+ /* pixel_height :: The character height expressed in integer pixels. */
+ /* */
+ /* <InOut> */
+ /* size :: A handle to the target size object. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
static
- FT_Error Set_Pixel_Sizes( T1_Size size,
- FT_Int pixel_width,
- FT_Int pixel_height )
+ FT_Error Set_Pixel_Sizes( T1_Size size,
+ FT_Int pixel_width,
+ FT_Int pixel_height )
{
- UNUSED(pixel_width);
- UNUSED(pixel_height);
+ UNUSED( pixel_width );
+ UNUSED( pixel_height );
size->valid = FALSE;
- return T1_Reset_Size(size);
+
+ return T1_Reset_Size( size );
}
/*************************************************************************/
@@ -174,71 +197,72 @@
face = (T1_Face)charmap->face;
psnames = (PSNames_Interface*)face->psnames;
- if (psnames)
- switch (charmap->encoding)
+ if ( psnames )
+ switch ( charmap->encoding )
{
- /********************************************************************/
- /* */
- /* Unicode encoding support */
- /* */
- case ft_encoding_unicode:
- {
- /* use the "psnames" module to synthetize the Unicode charmap */
- result = psnames->lookup_unicode( &face->unicode_map,
- (FT_ULong)charcode );
+ /*******************************************************************/
+ /* */
+ /* Unicode encoding support */
+ /* */
+ case ft_encoding_unicode:
+ /* use the `psnames' module to synthetize the Unicode charmap */
+ result = psnames->lookup_unicode( &face->unicode_map,
+ (FT_ULong)charcode );
- /* the function returns 0xFFFF when the Unicode charcode has */
- /* no corresponding glyph.. */
- if (result == 0xFFFF)
- result = 0;
- goto Exit;
- }
+ /* the function returns 0xFFFF when the Unicode charcode has */
+ /* no corresponding glyph. */
+ if ( result == 0xFFFF )
+ result = 0;
+ goto Exit;
- /********************************************************************/
- /* */
- /* Custom Type 1 encoding */
- /* */
- case ft_encoding_adobe_custom:
- {
- T1_Encoding* encoding = &face->type1.encoding;
- if (charcode >= encoding->code_first &&
- charcode <= encoding->code_last)
- {
- result = encoding->char_index[charcode];
- }
- goto Exit;
- }
+ /*******************************************************************/
+ /* */
+ /* Custom Type 1 encoding */
+ /* */
+ case ft_encoding_adobe_custom:
+ {
+ T1_Encoding* encoding = &face->type1.encoding;
- /********************************************************************/
- /* */
- /* Adobe Standard & Expert encoding support */
- /* */
- default:
- if (charcode < 256)
- {
- FT_UInt code;
- FT_Int n;
- const char* glyph_name;
- code = psnames->adobe_std_encoding[charcode];
- if (charmap->encoding == ft_encoding_adobe_expert)
- code = psnames->adobe_expert_encoding[charcode];
+ if ( charcode >= encoding->code_first &&
+ charcode <= encoding->code_last )
+ result = encoding->char_index[charcode];
+ goto Exit;
+ }
- glyph_name = psnames->adobe_std_strings(code);
- if (!glyph_name) break;
+ /*******************************************************************/
+ /* */
+ /* Adobe Standard & Expert encoding support */
+ /* */
+ default:
+ if ( charcode < 256 )
+ {
+ FT_UInt code;
+ FT_Int n;
+ const char* glyph_name;
- for ( n = 0; n < face->type1.num_glyphs; n++ )
- {
- const char* gname = face->type1.glyph_names[n];
- if ( gname && gname[0] == glyph_name[0] &&
- strcmp( gname, glyph_name ) == 0 )
- {
- result = n;
- break;
- }
- }
- }
+ code = psnames->adobe_std_encoding[charcode];
+ if ( charmap->encoding == ft_encoding_adobe_expert )
+ code = psnames->adobe_expert_encoding[charcode];
+
+ glyph_name = psnames->adobe_std_strings( code );
+ if ( !glyph_name )
+ break;
+
+ for ( n = 0; n < face->type1.num_glyphs; n++ )
+ {
+ const char* gname = face->type1.glyph_names[n];
+
+
+ if ( gname && gname[0] == glyph_name[0] &&
+ strcmp( gname, glyph_name ) == 0 )
+ {
+ result = n;
+ break;
+ }
+ }
+ }
}
Exit:
return result;
@@ -245,9 +269,7 @@
}
-
-
- const FT_Driver_Class t1_driver_class =
+ const FT_Driver_Class t1_driver_class =
{
{
ft_module_font_driver | ft_module_driver_scalable,
@@ -254,17 +276,17 @@
sizeof( FT_DriverRec ),
"type1", /* driver name */
- 0x10000, /* driver version 1.0 */
- 0x20000, /* driver requires FreeType 2.0 or above */
+ 0x10000L, /* driver version 1.0 */
+ 0x20000L, /* driver requires FreeType 2.0 or above */
0, /* module specific interface */
- (FT_Module_Constructor) 0,
- (FT_Module_Destructor) 0,
+ (FT_Module_Constructor)0,
+ (FT_Module_Destructor) 0,
#ifdef T1_CONFIG_OPTION_NO_AFM
- (FT_Module_Requester) Get_Interface
+ (FT_Module_Requester) Get_Interface
#else
- (FT_Module_Requester) 0
+ (FT_Module_Requester) 0
#endif
},
@@ -272,51 +294,31 @@
sizeof( T1_SizeRec ),
sizeof( T1_GlyphSlotRec ),
- (FTDriver_initFace) T1_Init_Face,
- (FTDriver_doneFace) T1_Done_Face,
- (FTDriver_initSize) T1_Init_Size,
- (FTDriver_doneSize) T1_Done_Size,
- (FTDriver_initGlyphSlot) T1_Init_GlyphSlot,
- (FTDriver_doneGlyphSlot) T1_Done_GlyphSlot,
+ (FTDriver_initFace) T1_Init_Face,
+ (FTDriver_doneFace) T1_Done_Face,
+ (FTDriver_initSize) T1_Init_Size,
+ (FTDriver_doneSize) T1_Done_Size,
+ (FTDriver_initGlyphSlot)T1_Init_GlyphSlot,
+ (FTDriver_doneGlyphSlot)T1_Done_GlyphSlot,
- (FTDriver_setCharSizes) Set_Char_Sizes,
- (FTDriver_setPixelSizes) Set_Pixel_Sizes,
- (FTDriver_loadGlyph) T1_Load_Glyph,
- (FTDriver_getCharIndex) Get_Char_Index,
+ (FTDriver_setCharSizes) Set_Char_Sizes,
+ (FTDriver_setPixelSizes)Set_Pixel_Sizes,
+ (FTDriver_loadGlyph) T1_Load_Glyph,
+ (FTDriver_getCharIndex) Get_Char_Index,
#ifdef T1_CONFIG_OPTION_NO_AFM
- (FTDriver_getKerning) 0,
- (FTDriver_getAdvances) 0
+ (FTDriver_getKerning) 0,
+ (FTDriver_getAdvances) 0
#else
- (FTDriver_getKerning) Get_Kerning,
- (FTDriver_attachFile) T1_Read_AFM
+ (FTDriver_getKerning) Get_Kerning,
+ (FTDriver_attachFile) T1_Read_AFM
#endif
};
- /******************************************************************/
- /* */
- /* <Function> Get_FreeType_Driver_Interface */
- /* */
- /* <Description> */
- /* This function is used when compiling the TrueType driver */
- /* as a shared library (.DLL or .so). It will be used by the */
- /* high-level library of FreeType to retrieve the address of */
- /* the driver's generic interface. */
- /* */
- /* It shouldn't be implemented in a static build, as each */
- /* driver must have the same function as an exported entry */
- /* point. */
- /* */
- /* <Return> */
- /* address of TrueType's driver generic interface. The */
- /* forma-specific interface can then be retrieved through */
- /* the method interface->get_format_interface.. */
- /* */
-
#ifdef FT_CONFIG_OPTION_DYNAMIC_DRIVERS
- EXPORT_FUNC(const FT_Driver_Class*) getDriverClass( void )
+ EXPORT_FUNC( const FT_Driver_Class* ) getDriverClass( void )
{
return &t1_driver_class;
}
@@ -324,3 +326,4 @@
#endif /* FT_CONFIG_OPTION_DYNAMIC_DRIVERS */
+/* END */
--- a/src/type1/t1driver.h
+++ b/src/type1/t1driver.h
@@ -1,26 +1,30 @@
-/*******************************************************************
- *
- * t1driver.h
- *
- * High-level Type1 driver interface for FreeType 2.0
- *
- * Copyright 1996-1998 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used,
- * modified, and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- ******************************************************************/
+/***************************************************************************/
+/* */
+/* t1driver.h */
+/* */
+/* High-level Type 1 driver interface (specification). */
+/* */
+/* Copyright 1996-2000 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
#ifndef T1DRIVER_H
#define T1DRIVER_H
#include <freetype/internal/ftdriver.h>
- FT_EXPORT_VAR(const FT_Driver_Class) t1_driver_class;
+ FT_EXPORT_VAR( const FT_Driver_Class ) t1_driver_class;
+
#endif /* T1DRIVER_H */
+
+/* END */
--- a/src/type1/t1gload.c
+++ b/src/type1/t1gload.c
@@ -1,20 +1,21 @@
-/*******************************************************************
- *
- * t1gload.c 1.0
- *
- * Type1 Glyph Loader.
- *
- * Copyright 1996-1999 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used
- * modified and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- ******************************************************************/
+/***************************************************************************/
+/* */
+/* t1gload.c */
+/* */
+/* Type 1 Glyph Loader (body). */
+/* */
+/* Copyright 1996-2000 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
#include <t1gload.h>
#include <freetype/internal/ftdebug.h>
#include <freetype/internal/ftstream.h>
@@ -23,37 +24,35 @@
#include <t1hinter.h>
#endif
- /**********************************************************************/
- /**********************************************************************/
- /**********************************************************************/
- /********** *********/
- /********** *********/
- /********** GENERIC CHARSTRINGS PARSING *********/
- /********** *********/
- /********** *********/
- /**********************************************************************/
- /**********************************************************************/
- /**********************************************************************/
+#include <string.h> /* for strcmp() */
-/*********************************************************************
- *
- * <Function>
- * T1_Init_Builder
- *
- * <Description>
- * Initialise a given glyph builder.
- *
- * <Input>
- * builder :: glyph builder to initialise
- * face :: current face object
- * size :: current size object
- * glyph :: current glyph object
- * funcs :: glyph builder functions (or "methods").
- *
- *********************************************************************/
+ /*************************************************************************/
+ /* */
+ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
+ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
+ /* messages during execution. */
+ /* */
+#undef FT_COMPONENT
+#define FT_COMPONENT trace_t1gload
+
+
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /********** *********/
+ /********** *********/
+ /********** GENERIC CHARSTRING PARSING *********/
+ /********** *********/
+ /********** *********/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+
+
static
- void T1_Reset_Builder( T1_Builder* builder, FT_Bool reset_base )
+ void T1_Reset_Builder( T1_Builder* builder,
+ FT_Bool reset_base )
{
builder->pos_x = 0;
builder->pos_y = 0;
@@ -66,9 +65,9 @@
builder->pass = 0;
builder->hint_point = 0;
- if (builder->loader)
+ if ( builder->loader )
{
- if (reset_base)
+ if ( reset_base )
FT_GlyphLoader_Rewind( builder->loader );
FT_GlyphLoader_Prepare( builder->loader );
@@ -76,12 +75,32 @@
}
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* T1_Init_Builder */
+ /* */
+ /* <Description> */
+ /* Initializes a given glyph builder. */
+ /* */
+ /* <InOut> */
+ /* builder :: A pointer to the glyph builder to initialize. */
+ /* */
+ /* <Input> */
+ /* face :: The current face object. */
+ /* */
+ /* size :: The current size object. */
+ /* */
+ /* glyph :: The current glyph object. */
+ /* */
+ /* funcs :: Glyph builder functions (or `methods'). */
+ /* */
LOCAL_FUNC
- void T1_Init_Builder( T1_Builder* builder,
- T1_Face face,
- T1_Size size,
- T1_GlyphSlot glyph,
- const T1_Builder_Funcs* funcs )
+ void T1_Init_Builder( T1_Builder* builder,
+ T1_Face face,
+ T1_Size size,
+ T1_GlyphSlot glyph,
+ const T1_Builder_Funcs* funcs )
{
builder->funcs = *funcs;
builder->path_begun = 0;
@@ -92,9 +111,10 @@
builder->glyph = glyph;
builder->memory = face->root.memory;
- if (glyph)
+ if ( glyph )
{
- FT_GlyphLoader* loader = FT_SLOT(glyph)->loader;
+ FT_GlyphLoader* loader = FT_SLOT( glyph )->loader;
+
builder->loader = loader;
builder->base = &loader->base.outline;
@@ -101,7 +121,7 @@
builder->current = &loader->current.outline;
}
- if (size)
+ if ( size )
{
builder->scale_x = size->root.metrics.x_scale;
builder->scale_y = size->root.metrics.y_scale;
@@ -111,47 +131,43 @@
}
-/*********************************************************************
- *
- * <Function>
- * T1_Done_Builder
- *
- * <Description>
- * Finalise a given glyph builder. Its content can still be
- * used after the call, but the function saves important information
- * within the corresponding glyph slot.
- *
- * <Input>
- * builder :: glyph builder to initialise
- *
- *********************************************************************/
-
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* T1_Done_Builder */
+ /* */
+ /* <Description> */
+ /* Finalizes a given glyph builder. Its contents can still be used */
+ /* after the call, but the function saves important information */
+ /* within the corresponding glyph slot. */
+ /* */
+ /* <Input> */
+ /* builder :: A pointer to the glyph builder to finalize. */
+ /* */
LOCAL_FUNC
- void T1_Done_Builder( T1_Builder* builder )
+ void T1_Done_Builder( T1_Builder* builder )
{
T1_GlyphSlot glyph = builder->glyph;
- if (glyph)
+
+ if ( glyph )
glyph->root.outline = *builder->base;
}
-
-/*********************************************************************
- *
- * <Function>
- * T1_Init_Decoder
- *
- * <Description>
- * Initialise a given Type 1 decoder for parsing
- *
- * <Input>
- * decoder :: Type 1 decoder to initialise
- * funcs :: hinter functions interface
- *
- *********************************************************************/
-
-
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* T1_Init_Decoder */
+ /* */
+ /* <Description> */
+ /* Initializes a given glyph decoder. */
+ /* */
+ /* <InOut> */
+ /* decoder :: A pointer to the glyph builder to initialize. */
+ /* */
+ /* <Input> */
+ /* funcs :: The hinting functions interface. */
LOCAL_FUNC
void T1_Init_Decoder( T1_Decoder* decoder,
const T1_Hinter_Funcs* funcs )
@@ -164,49 +180,50 @@
decoder->num_flex_vectors = 0;
/* Clear loader */
- MEM_Set( &decoder->builder, 0, sizeof(decoder->builder) );
+ MEM_Set( &decoder->builder, 0, sizeof ( decoder->builder ) );
}
-/*********************************************************************
- *
- * <Function>
- * lookup_glyph_by_stdcharcode
- *
- * <Description>
- * Lookup a given glyph by its StandardEncoding charcode. Used
- * to implement the SEAC Type 1 operator.
- *
- * <Input>
- * face :: current face object
- * charcode :: charcode to look for
- *
- * <Return>
- * glyph index in font face. Returns -1 if the corresponding
- * glyph wasn't found.
- *
- *********************************************************************/
-
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* lookup_glyph_by_stdcharcode */
+ /* */
+ /* <Description> */
+ /* Looks up a given glyph by its StandardEncoding charcode. Used */
+ /* to implement the SEAC Type 1 operator. */
+ /* */
+ /* <Input> */
+ /* face :: The current face object. */
+ /* */
+ /* charcode :: The character code to look for. */
+ /* */
+ /* <Return> */
+ /* A glyph index in the font face. Returns -1 if the corresponding */
+ /* glyph wasn't found. */
+ /* */
static
- FT_Int lookup_glyph_by_stdcharcode( T1_Face face,
- FT_Int charcode )
+ FT_Int lookup_glyph_by_stdcharcode( T1_Face face,
+ FT_Int charcode )
{
FT_Int n;
const FT_String* glyph_name;
PSNames_Interface* psnames = (PSNames_Interface*)face->psnames;
+
/* check range of standard char code */
- if (charcode < 0 || charcode > 255)
+ if ( charcode < 0 || charcode > 255 )
return -1;
glyph_name = psnames->adobe_std_strings(
- psnames->adobe_std_encoding[charcode]);
+ psnames->adobe_std_encoding[charcode] );
for ( n = 0; n < face->type1.num_glyphs; n++ )
{
FT_String* name = (FT_String*)face->type1.glyph_names[n];
- if ( name && strcmp(name,glyph_name) == 0 )
+
+ if ( name && strcmp( name, glyph_name ) == 0 )
return n;
}
@@ -214,27 +231,30 @@
}
-/*********************************************************************
- *
- * <Function>
- * t1operator_seac
- *
- * <Description>
- * Implements the "seac" Type 1 operator for a Type 1 decoder
- *
- * <Input>
- * decoder :: current Type 1 decoder
- * asb :: accent's side bearing
- * adx :: horizontal position of accent
- * ady :: vertical position of accent
- * bchar :: base character's StandardEncoding charcode
- * achar :: accent character's StandardEncoding charcode
- *
- * <Return>
- * Error code. 0 means success.
- *
- *********************************************************************/
-
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* t1operator_seac */
+ /* */
+ /* <Description> */
+ /* Implements the `seac' Type 1 operator for a Type 1 decoder. */
+ /* */
+ /* <Input> */
+ /* decoder :: The current CID decoder. */
+ /* */
+ /* asb :: The accent's side bearing. */
+ /* */
+ /* adx :: The horizontal offset of the accent. */
+ /* */
+ /* ady :: The vertical offset of the accent. */
+ /* */
+ /* bchar :: The base character's StandardEncoding charcode. */
+ /* */
+ /* achar :: The accent character's StandardEncoding charcode. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
static
FT_Error t1operator_seac( T1_Decoder* decoder,
FT_Pos asb,
@@ -251,6 +271,7 @@
T1_Face face = decoder->builder.face;
T1_Font* type1 = &face->type1;
+
bchar_index = lookup_glyph_by_stdcharcode( face, bchar );
achar_index = lookup_glyph_by_stdcharcode( face, achar );
@@ -264,14 +285,15 @@
/* accent character and return the array of subglyphs. */
if ( decoder->builder.no_recurse )
{
-
FT_GlyphSlot glyph = (FT_GlyphSlot)decoder->builder.glyph;
FT_GlyphLoader* loader = glyph->loader;
FT_SubGlyph* subg;
+
/* reallocate subglyph array if necessary */
error = FT_GlyphLoader_Check_Subglyphs( loader, 2 );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
subg = loader->current.subglyphs;
@@ -300,7 +322,7 @@
/* First load `bchar' in builder */
/* now load the unscaled outline */
- if (decoder->builder.loader)
+ if ( decoder->builder.loader )
FT_GlyphLoader_Prepare( decoder->builder.loader ); /* prepare loader */
error = T1_Parse_CharStrings( decoder,
@@ -309,69 +331,69 @@
type1->num_subrs,
type1->subrs,
type1->subrs_len );
- if ( error ) goto Exit;
+ if ( error )
+ goto Exit;
n_base_points = cur->n_points;
- {
- /* save the left bearing and width of the base character */
- /* as they will be erased by the next load. */
+ /* save the left bearing and width of the base character */
+ /* as they will be erased by the next load. */
- left_bearing = decoder->builder.left_bearing;
- advance = decoder->builder.advance;
+ left_bearing = decoder->builder.left_bearing;
+ advance = decoder->builder.advance;
- decoder->builder.left_bearing.x = 0;
- decoder->builder.left_bearing.y = 0;
+ decoder->builder.left_bearing.x = 0;
+ decoder->builder.left_bearing.y = 0;
- /* Now load `achar' on top of */
- /* the base outline */
- error = T1_Parse_CharStrings( decoder,
- type1->charstrings [achar_index],
- type1->charstrings_len[achar_index],
- type1->num_subrs,
- type1->subrs,
- type1->subrs_len );
- if ( error ) return error;
+ /* Now load `achar' on top of the base outline */
+ error = T1_Parse_CharStrings( decoder,
+ type1->charstrings [achar_index],
+ type1->charstrings_len[achar_index],
+ type1->num_subrs,
+ type1->subrs,
+ type1->subrs_len );
+ if ( error )
+ return error;
- /* restore the left side bearing and */
- /* advance width of the base character */
+ /* restore the left side bearing and */
+ /* advance width of the base character */
- decoder->builder.left_bearing = left_bearing;
- decoder->builder.advance = advance;
+ decoder->builder.left_bearing = left_bearing;
+ decoder->builder.advance = advance;
- /* Finally, move the accent */
- if ( decoder->builder.load_points )
- {
- FT_Outline dummy;
+ /* Finally, move the accent */
+ if ( decoder->builder.load_points )
+ {
+ FT_Outline dummy;
+
- dummy.n_points = base->n_points - n_base_points;
- dummy.points = base->points + n_base_points;
- FT_Outline_Translate( &dummy, adx - asb, ady );
- }
+ dummy.n_points = base->n_points - n_base_points;
+ dummy.points = base->points + n_base_points;
+ FT_Outline_Translate( &dummy, adx - asb, ady );
}
+
Exit:
return error;
}
-/*********************************************************************
- *
- * <Function>
- * t1operator_flex
- *
- * <Description>
- * Implements the "flex" Type 1 operator for a Type 1 decoder
- *
- * <Input>
- * decoder :: current Type 1 decoder
- * threshold :: threshold
- * end_x :: position of final flex point
- * end_y :: position of final flex point
- *
- * <Return>
- * Error code. 0 means success.
- *
- *********************************************************************/
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* t1operator_flex */
+ /* */
+ /* <Description> */
+ /* Implements the `flex' Type 1 operator for a Type 1 decoder. */
+ /* */
+ /* <Input> */
+ /* decoder :: The current Type 1 decoder. */
+ /* threshold :: The threshold. */
+ /* end_x :: The horizontal position of the final flex point. */
+ /* end_y :: The vertical position of the final flex point. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
static
FT_Error t1operator_flex( T1_Decoder* decoder,
FT_Pos threshold,
@@ -382,10 +404,15 @@
FT_Vector* flex = decoder->flex_vectors;
FT_Int n;
- /* we don't even try to test the threshold in the non-hinting */
+ UNUSED( threshold );
+ UNUSED( end_x );
+ UNUSED( end_y );
+
+
+ /* we don't even try to test the threshold in the non-hinting */
/* builder, even if the flex operator is said to be a path */
- /* construction statement in the specification. This is better */
- /* left to the hinter.. */
+ /* construction statement in the specification. This is better */
+ /* left to the hinter. */
flex = decoder->flex_vectors;
vec = *flex++;
@@ -398,11 +425,6 @@
vec = *flex++;
}
-
- UNUSED(threshold);
- UNUSED(end_x);
- UNUSED(end_y);
-
flex = decoder->flex_vectors;
return decoder->builder.funcs.rcurve_to( &decoder->builder,
@@ -417,44 +439,47 @@
}
-/*********************************************************************
- *
- * <Function>
- * T1_Parse_CharStrings
- *
- * <Description>
- * Parses a given Type 1 charstrings program
- *
- * <Input>
- * decoder :: current Type 1 decoder
- * charstring_base :: base of the charstring stream
- * charstring_len :: length in bytes of the charstring stream
- * num_subrs :: number of sub-routines
- * subrs_base :: array of sub-routines addresses
- * subrs_len :: array of sub-routines lengths
- *
- * <Return>
- * Error code. 0 means success.
- *
- *********************************************************************/
-
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* T1_Parse_CharStrings */
+ /* */
+ /* <Description> */
+ /* Parses a given Type 1 charstrings program. */
+ /* */
+ /* <Input> */
+ /* decoder :: The current Type 1 decoder. */
+ /* */
+ /* charstring_base :: The base address of the charstring stream. */
+ /* */
+ /* charstring_len :: The length in bytes of the charstring stream. */
+ /* */
+ /* num_subrs :: The number of sub-routines. */
+ /* */
+ /* subrs_base :: An array of sub-routines addresses. */
+ /* */
+ /* subrs_len :: An array of sub-routines lengths. */
+ /* */
+ /* <Return> */
+ /* Free error code. 0 means success. */
+ /* */
LOCAL_FUNC
- FT_Error T1_Parse_CharStrings( T1_Decoder* decoder,
- FT_Byte* charstring_base,
- FT_Int charstring_len,
- FT_Int num_subrs,
- FT_Byte** subrs_base,
- FT_Int* subrs_len )
+ FT_Error T1_Parse_CharStrings( T1_Decoder* decoder,
+ FT_Byte* charstring_base,
+ FT_Int charstring_len,
+ FT_Int num_subrs,
+ FT_Byte** subrs_base,
+ FT_Int* subrs_len )
{
- FT_Error error;
- T1_Decoder_Zone* zone;
- FT_Byte* ip;
- FT_Byte* limit;
- T1_Builder* builder = &decoder->builder;
- T1_Builder_Funcs* builds = &builder->funcs;
- T1_Hinter_Funcs* hints = &decoder->hinter;
+ FT_Error error;
+ T1_Decoder_Zone* zone;
+ FT_Byte* ip;
+ FT_Byte* limit;
+ T1_Builder* builder = &decoder->builder;
+ T1_Builder_Funcs* builds = &builder->funcs;
+ T1_Hinter_Funcs* hints = &decoder->hinter;
- static const FT_Int args_count[ op_max ] =
+ static const FT_Int args_count[op_max] =
{
0, /* none */
0, /* endchar */
@@ -484,7 +509,8 @@
2 /* setcurrentpoint */
};
- /* First of all, initialise the decoder */
+
+ /* First of all, initialize the decoder */
decoder->top = decoder->stack;
decoder->zone = decoder->zones;
zone = decoder->zones;
@@ -504,99 +530,146 @@
T1_Operator op = op_none;
FT_Long value = 0;
- /* First of all, decompress operator or value */
- switch (*ip++)
+
+ /* Start with the decompression of operator or value */
+ switch ( *ip++ )
{
- case 1: op = op_hstem; break;
+ case 1:
+ op = op_hstem;
+ break;
- case 3: op = op_vstem; break;
- case 4: op = op_vmoveto; break;
- case 5: op = op_rlineto; break;
- case 6: op = op_hlineto; break;
- case 7: op = op_vlineto; break;
- case 8: op = op_rrcurveto; break;
- case 9: op = op_closepath; break;
- case 10: op = op_callsubr; break;
- case 11: op = op_return; break;
+ case 3:
+ op = op_vstem;
+ break;
+ case 4:
+ op = op_vmoveto;
+ break;
+ case 5:
+ op = op_rlineto;
+ break;
+ case 6:
+ op = op_hlineto;
+ break;
+ case 7:
+ op = op_vlineto;
+ break;
+ case 8:
+ op = op_rrcurveto;
+ break;
+ case 9:
+ op = op_closepath;
+ break;
+ case 10:
+ op = op_callsubr;
+ break;
+ case 11:
+ op = op_return;
+ break;
- case 13: op = op_hsbw; break;
- case 14: op = op_endchar; break;
+ case 13:
+ op = op_hsbw;
+ break;
+ case 14:
+ op = op_endchar;
+ break;
- case 21: op = op_rmoveto; break;
- case 22: op = op_hmoveto; break;
+ case 21:
+ op = op_rmoveto;
+ break;
+ case 22:
+ op = op_hmoveto;
+ break;
- case 30: op = op_vhcurveto; break;
- case 31: op = op_hvcurveto; break;
+ case 30:
+ op = op_vhcurveto;
+ break;
+ case 31:
+ op = op_hvcurveto;
+ break;
+ case 12:
+ if ( ip > limit )
+ {
+ FT_ERROR(( "T1_Parse_CharStrings: invalid escape (12+EOF)\n" ));
+ goto Syntax_Error;
+ }
+
+ switch ( *ip++ )
+ {
+ case 0:
+ op = op_dotsection;
+ break;
+ case 1:
+ op = op_vstem3;
+ break;
+ case 2:
+ op = op_hstem3;
+ break;
+ case 6:
+ op = op_seac;
+ break;
+ case 7:
+ op = op_sbw;
+ break;
case 12:
- {
- if (ip > limit)
- {
- FT_ERROR(( "T1.Parse_CharStrings : invalid escape (12+EOF)\n" ));
- goto Syntax_Error;
- }
+ op = op_div;
+ break;
+ case 16:
+ op = op_callothersubr;
+ break;
+ case 17:
+ op = op_pop;
+ break;
+ case 33:
+ op = op_setcurrentpoint;
+ break;
- switch (*ip++)
- {
- case 0: op = op_dotsection; break;
- case 1: op = op_vstem3; break;
- case 2: op = op_hstem3; break;
- case 6: op = op_seac; break;
- case 7: op = op_sbw; break;
- case 12: op = op_div; break;
- case 16: op = op_callothersubr; break;
- case 17: op = op_pop; break;
- case 33: op = op_setcurrentpoint; break;
+ default:
+ FT_ERROR(( "T1_Parse_CharStrings: invalid escape (12+%d)\n",
+ ip[-1] ));
+ goto Syntax_Error;
+ }
+ break;
- default:
- FT_ERROR(( "T1.Parse_CharStrings : invalid escape (12+%d)\n",
- ip[-1] ));
- goto Syntax_Error;
- }
- }
- break;
+ case 255: /* four bytes integer */
+ if ( ip + 4 > limit )
+ {
+ FT_ERROR(( "T1_Parse_CharStrings: unexpected EOF in integer\n" ));
+ goto Syntax_Error;
+ }
- case 255: /* four bytes integer */
+ value = ( (FT_Long)ip[0] << 24 ) |
+ ( (FT_Long)ip[1] << 16 ) |
+ ( (FT_Long)ip[2] << 8 ) |
+ ip[3];
+ ip += 4;
+ break;
+
+ default:
+ if ( ip[-1] >= 32 )
+ {
+ if ( ip[-1] < 247 )
+ value = (FT_Long)ip[-1] - 139;
+ else
{
- if (ip+4 > limit)
+ if ( ++ip > limit )
{
- FT_ERROR(( "T1.Parse_CharStrings : unexpected EOF in integer\n" ));
+ FT_ERROR(( "T1_Parse_CharStrings: unexpected EOF in integer\n" ));
goto Syntax_Error;
}
- value = ((long)ip[0] << 24) |
- ((long)ip[1] << 16) |
- ((long)ip[2] << 8) |
- ip[3];
- ip += 4;
- }
- break;
-
- default:
- if (ip[-1] >= 32)
- {
- if (ip[-1] < 247)
- value = (long)ip[-1] - 139;
+ if ( ip[-2] < 251 )
+ value = ((FT_Long)( ip[-2] - 247 ) << 8 ) + ip[-1] + 108;
else
- {
- if (++ip > limit)
- {
- FT_ERROR(( "T1.Parse_CharStrings : unexpected EOF in integer\n" ));
- goto Syntax_Error;
- }
-
- if (ip[-2] < 251)
- value = ((long)(ip[-2]-247) << 8) + ip[-1] + 108;
- else
- value = -((((long)ip[-2]-251) << 8) + ip[-1] + 108 );
- }
+ value = -( ( ( (FT_Long)ip[-2] - 251 ) << 8 ) + ip[-1] + 108 );
}
- else
- {
- FT_ERROR(( "T1.Parse_CharStrings : invalid byte (%d)\n",
+ }
+ else
+ {
+ FT_ERROR(( "T1_Parse_CharStrings: invalid byte (%d)\n",
ip[-1] ));
- goto Syntax_Error;
- }
+ goto Syntax_Error;
+ }
}
/* push value if needed */
@@ -604,7 +677,7 @@
{
if ( top - decoder->stack >= T1_MAX_CHARSTRINGS_OPERANDS )
{
- FT_ERROR(( "T1.Parse_CharStrings : Stack overflow !!\n" ));
+ FT_ERROR(( "T1_Parse_CharStrings: stack overflow!\n" ));
goto Syntax_Error;
}
@@ -614,113 +687,110 @@
else if ( op == op_callothersubr ) /* check arguments differently */
{
- if ( top - decoder->stack < 2)
+ if ( top - decoder->stack < 2 )
goto Stack_Underflow;
top -= 2;
- switch (top[1])
+ switch ( top[1] )
{
- case 1: /* start flex feature ----------------------------- */
- {
- if (top[0] != 0) goto Unexpected_OtherSubr;
+ case 1: /* start flex feature */
+ if ( top[0] != 0 )
+ goto Unexpected_OtherSubr;
- decoder->flex_state = 1;
- decoder->num_flex_vectors = 0;
- decoder->flex_vectors[0].x = 0;
- decoder->flex_vectors[0].y = 0;
- }
- break;
+ decoder->flex_state = 1;
+ decoder->num_flex_vectors = 0;
+ decoder->flex_vectors[0].x = 0;
+ decoder->flex_vectors[0].y = 0;
+ break;
+ case 2: /* add flex vector */
+ {
+ FT_Int index;
+ FT_Vector* flex;
- case 2: /* add flex vector ------------------------------- */
- {
- FT_Int index;
- FT_Vector* flex;
- if (top[0] != 0) goto Unexpected_OtherSubr;
+ if ( top[0] != 0 )
+ goto Unexpected_OtherSubr;
- top -= 2;
- if (top < decoder->stack) goto Stack_Underflow;
+ top -= 2;
+ if ( top < decoder->stack )
+ goto Stack_Underflow;
- index = decoder->num_flex_vectors++;
- if (index >= 7)
- {
- FT_ERROR(( "T1.Parse_CharStrings: too many flex vectors !\n" ));
- goto Syntax_Error;
- }
-
- flex = decoder->flex_vectors + index;
- flex->x += top[0];
- flex->y += top[1];
-
+ index = decoder->num_flex_vectors++;
+ if ( index >= 7 )
+ {
+ FT_ERROR(( "T1_Parse_CharStrings: too many flex vectors!\n" ));
+ goto Syntax_Error;
}
- break;
+ flex = decoder->flex_vectors + index;
+ flex->x += top[0];
+ flex->y += top[1];
+ }
+ break;
- case 0: /* end flex feature ------------------------------ */
- {
- if ( decoder->flex_state == 0 ||
- decoder->num_flex_vectors != 7 )
- {
- FT_ERROR(( "T1.Parse_CharStrings: unexpected flex end\n" ));
- goto Syntax_Error;
- }
+ case 0: /* end flex feature */
+ if ( decoder->flex_state == 0 ||
+ decoder->num_flex_vectors != 7 )
+ {
+ FT_ERROR(( "T1_Parse_CharStrings: unexpected flex end\n" ));
+ goto Syntax_Error;
+ }
- if (top[0] != 3) goto Unexpected_OtherSubr;
+ if ( top[0] != 3 )
+ goto Unexpected_OtherSubr;
- top -= 3;
- if (top < decoder->stack) goto Stack_Underflow;
+ top -= 3;
+ if ( top < decoder->stack )
+ goto Stack_Underflow;
- /* now consume the remaining "pop pop setcurrentpoint" */
- if ( ip+6 > limit ||
- ip[0] != 12 || ip[1] != 17 || /* pop */
- ip[2] != 12 || ip[3] != 17 || /* pop */
- ip[4] != 12 || ip[5] != 33 ) /* setcurrentpoint */
- {
- FT_ERROR(( "T1.Parse_CharStrings: invalid flex charstring\n" ));
- goto Syntax_Error;
- }
+ /* now consume the remaining `pop pop setcurrentpoint' */
+ if ( ip + 6 > limit ||
+ ip[0] != 12 || ip[1] != 17 || /* pop */
+ ip[2] != 12 || ip[3] != 17 || /* pop */
+ ip[4] != 12 || ip[5] != 33 ) /* setcurrentpoint */
+ {
+ FT_ERROR(( "T1_Parse_CharStrings: invalid flex charstring\n" ));
+ goto Syntax_Error;
+ }
- decoder->flex_state = 0;
- decoder->top = top;
+ decoder->flex_state = 0;
+ decoder->top = top;
- error = t1operator_flex( decoder, top[0], top[1], top[2] );
- }
- break;
+ error = t1operator_flex( decoder, top[0], top[1], top[2] );
+ break;
+ case 3: /* change hints */
+ if ( top[0] != 1 )
+ goto Unexpected_OtherSubr;
- case 3: /* change hints ------------------------------------ */
- {
- if (top[0] != 1) goto Unexpected_OtherSubr;
+ /* eat the following `pop' */
+ if ( ip + 2 > limit )
+ {
+ FT_ERROR(( "T1_Parse_CharStrings: invalid escape (12+%d)\n",
+ ip[-1] ));
+ goto Syntax_Error;
+ }
- /* eat the following "pop" */
- if (ip+2 > limit)
- {
- FT_ERROR(( "T1.Parse_CharStrings: invalid escape (12+%d)\n",
- ip[-1] ));
- goto Syntax_Error;
- }
+ if (ip[0] != 12 || ip[1] != 17)
+ {
+ FT_ERROR(( "T1_Parse_CharStrings: `pop' expected, found (%d %d)\n",
+ ip[0], ip[1] ));
+ goto Syntax_Error;
+ }
- if (ip[0] != 12 || ip[1] != 17)
- {
- FT_ERROR(( "T1.Parse_CharStrings: 'pop' expected, found (%d %d)\n",
- ip[0], ip[1] ));
- goto Syntax_Error;
- }
+ ip += 2;
- ip += 2;
- error = hints->change_hints(builder);
- }
- break;
+ error = hints->change_hints( builder );
+ break;
-
- default:
- /* invalid OtherSubrs call */
- Unexpected_OtherSubr:
- FT_ERROR(( "T1.Parse_CharStrings: unexpected OtherSubrs [%d %d]\n",
+ default:
+ /* invalid OtherSubrs call */
+ Unexpected_OtherSubr:
+ FT_ERROR(( "T1_Parse_CharStrings: unexpected OtherSubrs [%d %d]\n",
top[0], top[1] ));
- goto Syntax_Error;
+ goto Syntax_Error;
}
decoder->top = top;
}
@@ -728,180 +798,179 @@
{
FT_Int num_args = args_count[op];
+
if ( top - decoder->stack < num_args )
goto Stack_Underflow;
top -= num_args;
- switch (op)
+ switch ( op )
{
- case op_endchar:
- error = builds->end_char( builder );
- break;
+ case op_endchar:
+ error = builds->end_char( builder );
+ break;
- case op_hsbw:
- error = builds->set_bearing_point( builder, top[0], 0,
- top[1], 0 );
- break;
+ case op_hsbw:
+ error = builds->set_bearing_point( builder, top[0], 0,
+ top[1], 0 );
+ break;
- case op_seac:
- /* return immediately after the processing */
- return t1operator_seac( decoder, top[0], top[1],
- top[2], top[3], top[4] );
+ case op_seac:
+ /* return immediately after the processing */
+ return t1operator_seac( decoder, top[0], top[1],
+ top[2], top[3], top[4] );
- case op_sbw:
- error = builds->set_bearing_point( builder, top[0], top[1],
- top[2], top[3] );
- break;
+ case op_sbw:
+ error = builds->set_bearing_point( builder, top[0], top[1],
+ top[2], top[3] );
+ break;
- case op_closepath:
- error = builds->close_path( builder );
- break;
+ case op_closepath:
+ error = builds->close_path( builder );
+ break;
- case op_hlineto:
- error = builds->rline_to( builder, top[0], 0 );
- break;
+ case op_hlineto:
+ error = builds->rline_to( builder, top[0], 0 );
+ break;
- case op_hmoveto:
- error = builds->rmove_to( builder, top[0], 0 );
- break;
+ case op_hmoveto:
+ error = builds->rmove_to( builder, top[0], 0 );
+ break;
- case op_hvcurveto:
- error = builds->rcurve_to( builder, top[0], 0,
- top[1], top[2],
- 0, top[3] );
- break;
+ case op_hvcurveto:
+ error = builds->rcurve_to( builder, top[0], 0,
+ top[1], top[2],
+ 0, top[3] );
+ break;
- case op_rlineto:
- error = builds->rline_to( builder, top[0], top[1] );
- break;
+ case op_rlineto:
+ error = builds->rline_to( builder, top[0], top[1] );
+ break;
- case op_rmoveto:
- /* ignore operator when in flex mode */
- if (decoder->flex_state == 0)
- error = builds->rmove_to( builder, top[0], top[1] );
- else
- top += 2;
- break;
+ case op_rmoveto:
+ /* ignore operator when in flex mode */
+ if ( decoder->flex_state == 0 )
+ error = builds->rmove_to( builder, top[0], top[1] );
+ else
+ top += 2;
+ break;
- case op_rrcurveto:
- {
- error = builds->rcurve_to( builder, top[0], top[1],
- top[2], top[3],
- top[4], top[5] );
- }
- break;
+ case op_rrcurveto:
+ error = builds->rcurve_to( builder, top[0], top[1],
+ top[2], top[3],
+ top[4], top[5] );
+ break;
- case op_vhcurveto:
- error = builds->rcurve_to( builder, 0, top[0],
- top[1], top[2],
- top[3], 0 );
- break;
+ case op_vhcurveto:
+ error = builds->rcurve_to( builder, 0, top[0],
+ top[1], top[2],
+ top[3], 0 );
+ break;
- case op_vlineto:
- error = builds->rline_to( builder, 0, top[0] );
- break;
+ case op_vlineto:
+ error = builds->rline_to( builder, 0, top[0] );
+ break;
- case op_vmoveto:
- error = builds->rmove_to( builder, 0, top[0] );
- break;
+ case op_vmoveto:
+ error = builds->rmove_to( builder, 0, top[0] );
+ break;
- case op_dotsection:
- error = hints->dot_section( builder );
- break;
+ case op_dotsection:
+ error = hints->dot_section( builder );
+ break;
- case op_hstem:
- error = hints->stem( builder, top[0], top[1], 0 );
- break;
+ case op_hstem:
+ error = hints->stem( builder, top[0], top[1], 0 );
+ break;
- case op_hstem3:
- error = hints->stem3( builder, top[0], top[1], top[2],
- top[3], top[4], top[5], 0 );
- break;
+ case op_hstem3:
+ error = hints->stem3( builder, top[0], top[1], top[2],
+ top[3], top[4], top[5], 0 );
+ break;
- case op_vstem:
- error = hints->stem( builder, top[0], top[1], 1 );
- break;
+ case op_vstem:
+ error = hints->stem( builder, top[0], top[1], 1 );
+ break;
- case op_vstem3:
- error = hints->stem3( builder, top[0], top[1], top[2],
- top[3], top[4], top[5], 1 );
- break;
+ case op_vstem3:
+ error = hints->stem3( builder, top[0], top[1], top[2],
+ top[3], top[4], top[5], 1 );
+ break;
- case op_div:
- if (top[1])
+ case op_div:
+ if ( top[1] )
+ {
+ *top = top[0] / top[1];
+ ++top;
+ }
+ else
+ {
+ FT_ERROR(( "T1_Parse_CHarStrings: division by 0\n" ));
+ goto Syntax_Error;
+ }
+ break;
+
+ case op_callsubr:
+ {
+ FT_Int index = top[0];
+
+
+ if ( index < 0 || index >= num_subrs )
{
- *top = top[0] / top[1];
- ++top;
- }
- else
- {
- FT_ERROR(( "T1.Parse_CHarStrings : division by 0\n" ));
+ FT_ERROR(( "T1_Parse_CharStrings: invalid subrs index\n" ));
goto Syntax_Error;
}
- break;
- case op_callsubr:
+ if ( zone - decoder->zones >= T1_MAX_SUBRS_CALLS )
{
- FT_Int index = top[0];
-
- if ( index < 0 || index >= num_subrs )
- {
- FT_ERROR(( "T1.Parse_CharStrings : invalid subrs index\n" ));
- goto Syntax_Error;
- }
-
- if ( zone - decoder->zones >= T1_MAX_SUBRS_CALLS )
- {
- FT_ERROR(( "T1.Parse_CharStrings : too many nested subrs\n" ));
- goto Syntax_Error;
- }
-
- zone->cursor = ip; /* save current instruction pointer */
-
- zone++;
- zone->base = subrs_base[index];
- zone->limit = zone->base + subrs_len[index];
- zone->cursor = zone->base;
-
- if (!zone->base)
- {
- FT_ERROR(( "T1.Parse_CharStrings : invoking empty subrs !!\n" ));
- goto Syntax_Error;
- }
-
- decoder->zone = zone;
- ip = zone->base;
- limit = zone->limit;
+ FT_ERROR(( "T1_Parse_CharStrings: too many nested subrs\n" ));
+ goto Syntax_Error;
}
- break;
- case op_pop:
- FT_ERROR(( "T1.Parse_CharStrings : unexpected POP\n" ));
- goto Syntax_Error;
+ zone->cursor = ip; /* save current instruction pointer */
+ zone++;
+ zone->base = subrs_base[index];
+ zone->limit = zone->base + subrs_len[index];
+ zone->cursor = zone->base;
- case op_return:
- if ( zone <= decoder->zones )
+ if ( !zone->base )
{
- FT_ERROR(( "T1.Parse_CharStrings : unexpected return\n" ));
+ FT_ERROR(( "T1_Parse_CharStrings: invoking empty subrs!\n" ));
goto Syntax_Error;
}
- zone--;
- ip = zone->cursor;
- limit = zone->limit;
decoder->zone = zone;
- break;
+ ip = zone->base;
+ limit = zone->limit;
+ }
+ break;
- case op_setcurrentpoint:
- FT_ERROR(( "T1.Parse_CharStrings : unexpected SETCURRENTPOINT\n" ));
- goto Syntax_Error;
- break;
+ case op_pop:
+ FT_ERROR(( "T1_Parse_CharStrings: unexpected POP\n" ));
+ goto Syntax_Error;
- default:
- FT_ERROR(( "T1.Parse_CharStrings : unhandled opcode %d\n", op ));
+ case op_return:
+ if ( zone <= decoder->zones )
+ {
+ FT_ERROR(( "T1_Parse_CharStrings: unexpected return\n" ));
goto Syntax_Error;
+ }
+
+ zone--;
+ ip = zone->cursor;
+ limit = zone->limit;
+ decoder->zone = zone;
+ break;
+
+ case op_setcurrentpoint:
+ FT_ERROR(( "T1_Parse_CharStrings: unexpected `setcurrentpoint'\n" ));
+ goto Syntax_Error;
+ break;
+
+ default:
+ FT_ERROR(( "T1_Parse_CharStrings: unhandled opcode %d\n", op ));
+ goto Syntax_Error;
}
decoder->top = top;
@@ -918,28 +987,29 @@
}
-
-/*************************************************************************/
-/* */
-/* <Function> T1_Add_Points */
-/* */
-/* <Description> */
-/* Checks that there is enough room in the current load glyph outline */
-/* to accept "num_points" additional outline points. If not, this */
-/* function grows the load outline's arrays accordingly.. */
-/* */
-/* <Input> */
-/* builder :: pointer to glyph builder object */
-/* num_points :: number of points that will be added later */
-/* */
-/* <Return> */
-/* Type1 error code. 0 means success */
-/* */
-/* <Note> */
-/* This function does NOT update the points count in the glyph builder*/
-/* This must be done by the caller itself, after this function is */
-/* invoked.. */
-/* */
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* T1_Add_Points */
+ /* */
+ /* <Description> */
+ /* Checks that there is enough room in the current load glyph outline */
+ /* to accept `num_points' additional outline points. If not, this */
+ /* function grows the load outline's arrays accordingly. */
+ /* */
+ /* <Input> */
+ /* builder :: A pointer to the glyph builder object. */
+ /* */
+ /* num_points :: The number of points that will be added later. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
+ /* <Note> */
+ /* This function does NOT update the points count in the glyph */
+ /* builder. This must be done by the caller itself, after this */
+ /* function has been invoked. */
+ /* */
LOCAL_FUNC
FT_Error T1_Add_Points( T1_Builder* builder,
FT_Int num_points )
@@ -947,27 +1017,30 @@
return FT_GlyphLoader_Check_Points( builder->loader, num_points, 0 );
}
-/*************************************************************************/
-/* */
-/* <Function> T1_Add_Contours */
-/* */
-/* <Description> */
-/* Checks that there is enough room in the current load glyph outline */
-/* to accept "num_contours" additional contours. If not, this func */
-/* the load outline's arrays accordingly.. */
-/* */
-/* <Input> */
-/* builder :: pointer to glyph builder object */
-/* num_contours :: number of contours that will be added later */
-/* */
-/* <Return> */
-/* Type1 error code. 0 means success */
-/* */
-/* <Note> */
-/* This function does NOT update the contours count in the load glyph */
-/* This must be done by the caller itself, after this function is */
-/* invoked.. */
-/* */
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* T1_Add_Contours */
+ /* */
+ /* <Description> */
+ /* Checks that there is enough room in the current load glyph outline */
+ /* to accept `num_contours' additional contours. If not, this */
+ /* function grows the load outline's arrays accordingly. */
+ /* */
+ /* <Input> */
+ /* builder :: A pointer to the glyph builder object. */
+ /* */
+ /* num_contours :: The number of contours that will be added later. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
+ /* <Note> */
+ /* This function does NOT update the contours count in the load glyph */
+ /* This must be done by the caller itself, after this function is */
+ /* invoked. */
+ /* */
LOCAL_FUNC
FT_Error T1_Add_Contours( T1_Builder* builder,
FT_Int num_contours )
@@ -976,25 +1049,23 @@
}
- /**********************************************************************/
- /**********************************************************************/
- /**********************************************************************/
- /********** *********/
- /********** *********/
- /********** COMPUTE THE MAXIMUM ADVANCE WIDTH *********/
- /********** *********/
- /********** The following code is in charge of computing *********/
- /********** the maximum advance width of the font. It *********/
- /********** quickly process each glyph charstring to *********/
- /********** extract the value from either a "sbw" or "seac" *********/
- /********** operator. *********/
- /********** *********/
- /**********************************************************************/
- /**********************************************************************/
- /**********************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /********** *********/
+ /********** COMPUTE THE MAXIMUM ADVANCE WIDTH *********/
+ /********** *********/
+ /********** The following code is in charge of computing *********/
+ /********** the maximum advance width of the font. It *********/
+ /********** quickly processes each glyph charstring to *********/
+ /********** extract the value from either a `sbw' or `seac' *********/
+ /********** operator. *********/
+ /********** *********/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
-
static
FT_Error maxadv_sbw( T1_Decoder* decoder,
FT_Pos sbx,
@@ -1002,12 +1073,13 @@
FT_Pos wx,
FT_Pos wy )
{
- if (wx > decoder->builder.advance.x)
+ UNUSED( sbx );
+ UNUSED( sby );
+ UNUSED( wy );
+
+ if ( wx > decoder->builder.advance.x )
decoder->builder.advance.x = wx;
- UNUSED(sbx);
- UNUSED(sby);
- UNUSED(wy);
return -1; /* return an error code to exit the Type 1 parser */
/* immediately. */
}
@@ -1020,40 +1092,38 @@
return -2;
}
+
/* the maxadv_gbuilder_interface is used when computing the maximum */
- /* advance width of all glyphs in a given font. We only process the */
- /* 'sbw' operator here, and return an error for all others.. */
+ /* advance width of all glyphs in a given font. We only process the */
+ /* `sbw' operator here, and return an error for all others. */
- /* Note that "seac" is processed by the T1_Decoder */
+ /* Note that `seac' is processed by the T1_Decoder. */
static
const T1_Builder_Funcs maxadv_builder_interface =
{
- (T1_Builder_EndChar) maxadv_error,
- (T1_Builder_Sbw) maxadv_sbw,
- (T1_Builder_ClosePath) maxadv_error,
- (T1_Builder_RLineTo) maxadv_error,
- (T1_Builder_RMoveTo) maxadv_error,
- (T1_Builder_RCurveTo) maxadv_error
+ (T1_Builder_EndChar) maxadv_error,
+ (T1_Builder_Sbw) maxadv_sbw,
+ (T1_Builder_ClosePath)maxadv_error,
+ (T1_Builder_RLineTo) maxadv_error,
+ (T1_Builder_RMoveTo) maxadv_error,
+ (T1_Builder_RCurveTo) maxadv_error
};
- /* the maxadv_interface is used when computing the maximum advance */
- /* with of the set of glyphs in a given font file. We only process */
- /* the "seac" operator and return immediately.. */
+ /* the maxadv_hinter_interface always return an error. */
static
const T1_Hinter_Funcs maxadv_hinter_interface =
{
- (T1_Hinter_DotSection) maxadv_error,
- (T1_Hinter_ChangeHints) maxadv_error,
- (T1_Hinter_Stem) maxadv_error,
- (T1_Hinter_Stem3) maxadv_error,
+ (T1_Hinter_DotSection) maxadv_error,
+ (T1_Hinter_ChangeHints)maxadv_error,
+ (T1_Hinter_Stem) maxadv_error,
+ (T1_Hinter_Stem3) maxadv_error,
};
-
LOCAL_FUNC
FT_Error T1_Compute_Max_Advance( T1_Face face,
- FT_Int *max_advance )
+ FT_Int* max_advance )
{
FT_Error error;
T1_Decoder decoder;
@@ -1060,9 +1130,10 @@
FT_Int glyph_index;
T1_Font* type1 = &face->type1;
+
*max_advance = 0;
- /* Initialise load decoder */
+ /* Initialize load decoder */
T1_Init_Decoder( &decoder, &maxadv_hinter_interface );
T1_Init_Builder( &decoder.builder, face, 0, 0,
@@ -1069,7 +1140,7 @@
&maxadv_builder_interface );
/* For each glyph, parse the glyph charstring and extract */
- /* the advance width.. */
+ /* the advance width. */
for ( glyph_index = 0; glyph_index < type1->num_glyphs; glyph_index++ )
{
/* now get load the unscaled outline */
@@ -1087,25 +1158,23 @@
}
- /**********************************************************************/
- /**********************************************************************/
- /**********************************************************************/
- /********** *********/
- /********** *********/
- /********** UNHINTED GLYPH LOADER *********/
- /********** *********/
- /********** The following code is in charge of loading a *********/
- /********** single outline. It completely ignores hinting *********/
- /********** and is used when FT_LOAD_NO_HINTING is set. *********/
- /********** *********/
- /********** The Type 1 hinter is located in "t1hint.c" *********/
- /********** *********/
- /**********************************************************************/
- /**********************************************************************/
- /**********************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /********** *********/
+ /********** UNHINTED GLYPH LOADER *********/
+ /********** *********/
+ /********** The following code is in charge of loading a *********/
+ /********** single outline. It completely ignores hinting *********/
+ /********** and is used when FT_LOAD_NO_HINTING is set. *********/
+ /********** *********/
+ /********** The Type 1 hinter is located in `t1hint.c' *********/
+ /********** *********/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
-
static
FT_Error close_open_path( T1_Builder* builder )
{
@@ -1114,14 +1183,15 @@
FT_Int num_points;
FT_Int first_point;
- /* Some fonts, like Hershey, are made of "open paths" which are */
- /* now managed directly by FreeType. In this case, it is necessary */
- /* to close the path by duplicating its points in reverse order, */
- /* which is precisely the purpose of this function */
- /* first compute the number of points to duplicate.. */
- if (cur->n_contours > 1)
- first_point = cur->contours[ cur->n_contours-2 ]+1;
+ /* Some fonts, like Hershey, are made of `open paths' which are */
+ /* now managed directly by FreeType. In this case, it is necessary */
+ /* to close the path by duplicating its points in reverse order, */
+ /* which is precisely the purpose of this function. */
+
+ /* first compute the number of points to duplicate */
+ if ( cur->n_contours > 1 )
+ first_point = cur->contours[cur->n_contours - 2] + 1;
else
first_point = 0;
@@ -1133,14 +1203,16 @@
FT_Vector* point;
char* tags;
+
error = T1_Add_Points( builder, num_points );
- if (error) return error;
+ if ( error )
+ return error;
point = cur->points + cur->n_points;
- tags = cur->tags + cur->n_points;
+ tags = cur->tags + cur->n_points;
- source_point = point - 2;
- source_tags = tags - 2;
+ source_point = point - 2;
+ source_tags = tags - 2;
cur->n_points += num_points;
@@ -1148,10 +1220,9 @@
do
{
*point++ = *source_point--;
- *tags++ = *source_tags--;
+ *tags++ = *source_tags--;
num_points--;
- }
- while (num_points > 0);
+ } while ( num_points > 0 );
}
builder->path_begun = 0;
@@ -1164,9 +1235,10 @@
{
FT_Outline* cur = builder->current;
+
/* save current contour, if any */
if ( cur->n_contours > 0 )
- cur->contours[cur->n_contours-1] = cur->n_points-1;
+ cur->contours[cur->n_contours - 1] = cur->n_points - 1;
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
/* hint latest points if needed - this is not strictly required */
@@ -1180,17 +1252,18 @@
}
-
static
FT_Error gload_endchar( T1_Builder* builder )
{
FT_Error error;
+
/* close path if needed */
- if (builder->path_begun)
+ if ( builder->path_begun )
{
error = close_open_path( builder );
- if (error) return error;
+ if ( error )
+ return error;
}
error = gload_closepath( builder );
@@ -1201,7 +1274,6 @@
}
-
static
FT_Error gload_sbw( T1_Builder* builder,
FT_Pos sbx,
@@ -1216,12 +1288,11 @@
builder->last.x = sbx;
builder->last.y = sby;
+
return 0;
}
-
-
static
FT_Error gload_rlineto( T1_Builder* builder,
FT_Pos dx,
@@ -1231,9 +1302,11 @@
FT_Outline* cur = builder->current;
FT_Vector vec;
+
/* grow buffer if necessary */
- error = T1_Add_Points ( builder, 1 );
- if (error) return error;
+ error = T1_Add_Points( builder, 1 );
+ if ( error )
+ return error;
if ( builder->load_points )
{
@@ -1242,13 +1315,14 @@
vec.y = builder->last.y + dy;
cur->points[cur->n_points] = vec;
- cur->tags [cur->n_points] = FT_Curve_Tag_On;
+ cur->tags [cur->n_points] = FT_Curve_Tag_On;
builder->last = vec;
}
cur->n_points++;
- builder->path_begun = 1;
+ builder->path_begun = 1;
+
return T1_Err_Ok;
}
@@ -1262,17 +1336,20 @@
FT_Outline* cur = builder->current;
FT_Vector vec;
- /* in the case where "path_begun" is set, we have a rmoveto */
- /* after some normal path definition. When the face's paint */
- /* type is set to 1, this means that we have an "open path", */
- /* also called a 'stroke'. The FreeType raster doesn't support */
- /* opened path, so we'll close it explicitely there.. */
+
+ /* in the case where `path_begun' is set, we have an `rmoveto' */
+ /* after some normal path definition. If the face's paint type */
+ /* is set to 1, this means that we have an `open path', also */
+ /* called a `stroke'. The FreeType raster doesn't support */
+ /* opened paths, so we'll close it explicitely there. */
+
if ( builder->path_begun && builder->face->type1.paint_type == 1 )
{
if ( builder->face->type1.paint_type == 1 )
{
error = close_open_path( builder );
- if (error) return error;
+ if ( error )
+ return error;
}
}
@@ -1279,11 +1356,12 @@
/* grow buffer if necessary */
error = T1_Add_Contours( builder, 1 ) ||
T1_Add_Points ( builder, 1 );
- if (error) return error;
+ if ( error )
+ return error;
/* save current contour, if any */
if ( cur->n_contours > 0 )
- cur->contours[cur->n_contours-1] = cur->n_points-1;
+ cur->contours[cur->n_contours - 1] = cur->n_points - 1;
if ( builder->load_points )
{
@@ -1291,7 +1369,7 @@
vec.x = builder->last.x + dx;
vec.y = builder->last.y + dy;
cur->points[cur->n_points] = vec;
- cur->tags [cur->n_points] = FT_Curve_Tag_On;
+ cur->tags [cur->n_points] = FT_Curve_Tag_On;
builder->last = vec;
}
@@ -1318,27 +1396,32 @@
FT_Vector* points;
char* tags;
+
/* grow buffer if necessary */
- error = T1_Add_Points ( builder, 3 );
- if (error) return error;
+ error = T1_Add_Points( builder, 3 );
+ if ( error )
+ return error;
if ( builder->load_points )
{
/* save point */
points = cur->points + cur->n_points;
- tags = cur->tags + cur->n_points;
+ tags = cur->tags + cur->n_points;
vec.x = builder->last.x + dx1;
vec.y = builder->last.y + dy1;
- points[0] = vec; tags[0] = FT_Curve_Tag_Cubic;
+ points[0] = vec;
+ tags[0] = FT_Curve_Tag_Cubic;
vec.x += dx2;
vec.y += dy2;
- points[1] = vec; tags[1] = FT_Curve_Tag_Cubic;
+ points[1] = vec;
+ tags[1] = FT_Curve_Tag_Cubic;
vec.x += dx3;
vec.y += dy3;
- points[2] = vec; tags[2] = FT_Curve_Tag_On;
+ points[2] = vec;
+ tags[2] = FT_Curve_Tag_On;
builder->last = vec;
}
@@ -1345,12 +1428,11 @@
cur->n_points += 3;
builder->path_begun = 1;
+
return T1_Err_Ok;
}
-
-
static
FT_Error gload_ignore( void )
{
@@ -1373,12 +1455,12 @@
static
const T1_Builder_Funcs gload_builder_interface_null =
{
- (T1_Builder_EndChar) gload_ignore,
- (T1_Builder_Sbw) gload_sbw, /* record left bearing */
- (T1_Builder_ClosePath) gload_ignore,
- (T1_Builder_RLineTo) gload_ignore,
- (T1_Builder_RMoveTo) gload_ignore,
- (T1_Builder_RCurveTo) gload_ignore
+ (T1_Builder_EndChar) gload_ignore,
+ (T1_Builder_Sbw) gload_sbw, /* record left bearing */
+ (T1_Builder_ClosePath)gload_ignore,
+ (T1_Builder_RLineTo) gload_ignore,
+ (T1_Builder_RMoveTo) gload_ignore,
+ (T1_Builder_RCurveTo) gload_ignore
};
@@ -1385,31 +1467,32 @@
static
const T1_Hinter_Funcs gload_hinter_interface =
{
- (T1_Hinter_DotSection) gload_ignore, /* dotsection */
- (T1_Hinter_ChangeHints) gload_ignore, /* changehints */
- (T1_Hinter_Stem) gload_ignore, /* hstem & vstem */
- (T1_Hinter_Stem3) gload_ignore, /* hstem3 & vestem3 */
+ (T1_Hinter_DotSection) gload_ignore, /* dotsection */
+ (T1_Hinter_ChangeHints)gload_ignore, /* changehints */
+ (T1_Hinter_Stem) gload_ignore, /* hstem & vstem */
+ (T1_Hinter_Stem3) gload_ignore, /* hstem3 & vestem3 */
};
+#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
- /*****************************************************************/
- /* */
- /* Hinter overview : */
- /* */
- /* This is a two-pass hinter. On the first pass, the hints */
- /* are all recorded by the hinter, and no point is loaded */
- /* in the outline. */
- /* */
- /* When the first pass is finished, all stems hints are */
- /* grid-fitted at once. */
- /* */
- /* Then, a second pass is performed to load the outline */
- /* points as well as hint/scale them correctly. */
- /* */
-#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
+ /*************************************************************************/
+ /* */
+ /* Hinter overview: */
+ /* */
+ /* This is a two-pass hinter. On the first pass, the hints are all */
+ /* recorded by the hinter, and no point is loaded in the outline. */
+ /* */
+ /* When the first pass is finished, all stems hints are grid-fitted */
+ /* at once. */
+ /* */
+ /* Then, a second pass is performed to load the outline points as */
+ /* well as hint/scale them correctly. */
+ /* */
+ /*************************************************************************/
+
static
FT_Error t1_load_hinted_glyph( T1_Decoder* decoder,
FT_UInt glyph_index,
@@ -1422,6 +1505,7 @@
FT_GlyphLoader* loader = decoder->builder.loader;
FT_Error error;
+
/* Pass 1 - try to load first glyph, simply recording points */
old_points = loader->base.outline.n_points;
old_contours = loader->base.outline.n_contours;
@@ -1441,49 +1525,55 @@
type1->num_subrs,
type1->subrs,
type1->subrs_len );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
- /* check for composite (i.e. "seac" operator) */
+ /* check for composite (i.e. `seac' operator) */
if ( glyph->root.format == ft_glyph_format_composite )
{
/* this is a composite glyph, we must then load the first one, */
/* then load the second one on top of it and translate it by a */
- /* fixed amount.. */
- FT_UInt n_base_points;
- FT_SubGlyph* subglyph = loader->base.subglyphs;
- T1_Size size = builder->size;
- FT_Pos dx, dy;
- FT_Vector left_bearing, advance;
+ /* fixed amount. */
+ FT_UInt n_base_points;
+ FT_SubGlyph* subglyph = loader->base.subglyphs;
+ T1_Size size = builder->size;
+ FT_Pos dx, dy;
+ FT_Vector left_bearing, advance;
+
/* clean glyph format */
glyph->root.format = ft_glyph_format_none;
- /* First load "bchar" in builder */
+ /* First load `bchar' in builder */
builder->no_recurse = 0;
error = t1_load_hinted_glyph( decoder, subglyph->index, 0 );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
/* save the left bearing and width of the base character */
- /* as they will be erased by the next load.. */
+ /* as they will be erased by the next load */
left_bearing = builder->left_bearing;
advance = builder->advance;
- /* Then load "achar" in builder */
+ /* Then load `achar' in builder */
n_base_points = builder->base->n_points;
subglyph++;
error = t1_load_hinted_glyph( decoder, subglyph->index, 0 );
- if (error) goto Exit;
+ if ( error )
+ goto Exit;
/* Finally, move the accent */
dx = FT_MulFix( subglyph->arg1, size->root.metrics.x_scale );
dy = FT_MulFix( subglyph->arg2, size->root.metrics.y_scale );
- dx = (dx+32) & -64;
- dy = (dy+32) & -64;
+ dx = ( dx + 32 ) & -64;
+ dy = ( dy + 32 ) & -64;
{
FT_Outline dummy;
+
dummy.n_points = loader->base.outline.n_points - n_base_points;
dummy.points = loader->base.outline.points + n_base_points;
+
FT_Outline_Translate( &dummy, dx, dy );
}
@@ -1516,16 +1606,17 @@
}
/* save new glyph tables */
- if (recurse)
+ if ( recurse )
T1_Done_Builder( builder );
Exit:
return error;
}
-#endif
-
+#endif /* T1_CONFIG_OPTION_DISABLE_HINTER */
+
+
LOCAL_FUNC
FT_Error T1_Load_Glyph( T1_GlyphSlot glyph,
T1_Size size,
@@ -1532,13 +1623,14 @@
FT_Int glyph_index,
FT_Int load_flags )
{
- FT_Error error;
- T1_Decoder decoder;
- T1_Face face = (T1_Face)glyph->root.face;
- FT_Bool hinting;
- T1_Font* type1 = &face->type1;
+ FT_Error error;
+ T1_Decoder decoder;
+ T1_Face face = (T1_Face)glyph->root.face;
+ FT_Bool hinting;
+ T1_Font* type1 = &face->type1;
- if (load_flags & FT_LOAD_NO_RECURSE)
+
+ if ( load_flags & FT_LOAD_NO_RECURSE )
load_flags |= FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING;
glyph->x_scale = size->root.metrics.x_scale;
@@ -1553,7 +1645,7 @@
#ifndef T1_CONFIG_OPTION_DISABLE_HINTER
- hinting = (load_flags & (FT_LOAD_NO_SCALE|FT_LOAD_NO_HINTING)) == 0;
+ hinting = ( load_flags & ( FT_LOAD_NO_SCALE | FT_LOAD_NO_HINTING ) ) == 0;
if ( hinting )
{
@@ -1564,8 +1656,9 @@
error = t1_load_hinted_glyph( &decoder, glyph_index, 1 );
}
else
-#endif
+#endif /* T1_CONFIG_OPTION_DISABLE_HINTER */
+
{
T1_Init_Decoder( &decoder, &gload_hinter_interface );
@@ -1572,7 +1665,7 @@
T1_Init_Builder( &decoder.builder, face, size, glyph,
&gload_builder_interface );
- decoder.builder.no_recurse = !!(load_flags & FT_LOAD_NO_RECURSE);
+ decoder.builder.no_recurse = ( load_flags & FT_LOAD_NO_RECURSE ) != 0;
/* now load the unscaled outline */
error = T1_Parse_CharStrings( &decoder,
@@ -1586,14 +1679,13 @@
T1_Done_Builder( &decoder.builder );
}
-
- /* Now, set the metrics.. - this is rather simple, as : */
- /* the left side bearing is the xMin, and the top side */
- /* bearing the yMax.. */
- if (!error)
+ /* Now, set the metrics -- this is rather simple, as */
+ /* the left side bearing is the xMin, and the top side */
+ /* bearing the yMax */
+ if ( !error )
{
/* for composite glyphs, return only the left side bearing and the */
- /* advance width.. */
+ /* advance width */
if ( load_flags & FT_LOAD_NO_RECURSE )
{
glyph->root.metrics.horiBearingX = decoder.builder.left_bearing.x;
@@ -1604,18 +1696,20 @@
FT_BBox cbox;
FT_Glyph_Metrics* metrics = &glyph->root.metrics;
+
/* apply the font matrix */
- FT_Outline_Transform( &glyph->root.outline, &face->type1.font_matrix );
+ FT_Outline_Transform( &glyph->root.outline,
+ &face->type1.font_matrix );
FT_Outline_Get_CBox( &glyph->root.outline, &cbox );
/* grid fit the bounding box if necessary */
- if (hinting)
+ if ( hinting )
{
cbox.xMin &= -64;
cbox.yMin &= -64;
- cbox.xMax = ( cbox.xMax+63 ) & -64;
- cbox.yMax = ( cbox.yMax+63 ) & -64;
+ cbox.xMax = ( cbox.xMax + 63 ) & -64;
+ cbox.yMax = ( cbox.yMax + 63 ) & -64;
}
metrics->width = cbox.xMax - cbox.xMin;
@@ -1625,7 +1719,7 @@
metrics->horiBearingY = cbox.yMax;
/* copy the _unscaled_ advance width */
- metrics->horiAdvance = decoder.builder.advance.x;
+ metrics->horiAdvance = decoder.builder.advance.x;
/* make up vertical metrics */
metrics->vertBearingX = 0;
@@ -1641,20 +1735,20 @@
glyph->root.outline.flags |= ft_outline_reverse_fill;
- /*
+#if 0
glyph->root.outline.second_pass = TRUE;
- glyph->root.outline.high_precision = ( size->root.metrics.y_ppem < 24 );
+ glyph->root.outline.high_precision = size->root.metrics.y_ppem < 24;
glyph->root.outline.dropout_mode = 2;
- */
+#endif
if ( hinting )
{
- /* adjust the advance width */
- /* XXX : TODO : consider stem hints grid-fit */
+ /* adjust the advance width */
+ /* XXX TODO: consider stem hints grid-fit */
metrics->horiAdvance = FT_MulFix( metrics->horiAdvance,
glyph->x_scale );
}
- else if ( (load_flags & FT_LOAD_NO_SCALE) == 0 )
+ else if ( ( load_flags & FT_LOAD_NO_SCALE ) == 0 )
{
/* scale the outline and the metrics */
FT_Int n;
@@ -1681,7 +1775,6 @@
metrics->vertBearingX = FT_MulFix( metrics->vertBearingX, x_scale );
metrics->vertBearingY = FT_MulFix( metrics->vertBearingY, y_scale );
metrics->vertAdvance = FT_MulFix( metrics->vertAdvance, x_scale );
-
}
}
}
@@ -1689,3 +1782,5 @@
return error;
}
+
+/* END */
--- a/src/type1/t1gload.h
+++ b/src/type1/t1gload.h
@@ -1,37 +1,21 @@
-/*******************************************************************
- *
- * t1gload.h 1.0
- *
- * Type1 Glyph Loader.
- *
- * Copyright 1996-1998 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used
- * modified and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- *
- * The Type 1 glyph loader uses three distinct objects to build
- * scaled and hinted outlines from a charstrings program. These are :
- *
- * - a glyph builder, T1_Builder, used to store the built outline
- *
- * - a glyph hinter, T1_Hinter, used to record and apply the stem
- * hints
- *
- * - a charstrings interpreter, T1_Decoder, used to parse the
- * Type 1 charstrings stream, manage a stack and call the builder
- * and/or hinter depending on the opcodes.
- *
- * Ideally, a Type 2 glyph loader would only need to have its own
- * T2_Decoder object (assuming the hinter is able to manage all
- * kinds of hints).
- *
- ******************************************************************/
+/***************************************************************************/
+/* */
+/* t1gload.h */
+/* */
+/* Type 1 Glyph Loader (specification). */
+/* */
+/* Copyright 1996-2000 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
#ifndef T1GLOAD_H
#define T1GLOAD_H
@@ -42,25 +26,15 @@
#endif
-/*************************************************************************/
-/* */
-/* <Structure> T1_Builder_Funcs */
-/* */
-/* <Description> */
-/* a structure used to store the address of various functions */
-/* used by a glyph builder to implement the outline's "path */
-/* construction". */
-/* */
-/* */
typedef struct T1_Builder_ T1_Builder;
typedef FT_Error (*T1_Builder_EndChar)( T1_Builder* loader );
- typedef FT_Error (*T1_Builder_Sbw) ( T1_Builder* loader,
- FT_Pos sbx,
- FT_Pos sby,
- FT_Pos wx,
- FT_Pos wy );
+ typedef FT_Error (*T1_Builder_Sbw)( T1_Builder* loader,
+ FT_Pos sbx,
+ FT_Pos sby,
+ FT_Pos wx,
+ FT_Pos wy );
typedef FT_Error (*T1_Builder_ClosePath)( T1_Builder* loader );
@@ -80,7 +54,17 @@
FT_Pos dx3,
FT_Pos dy3 );
- typedef struct T1_Builder_Funcs_
+
+ /*************************************************************************/
+ /* */
+ /* <Structure> */
+ /* T1_Builder_Funcs */
+ /* */
+ /* <Description> */
+ /* A structure to store the address of various functions used by a */
+ /* glyph builder to implement the outline's `path construction'. */
+ /* */
+ typedef struct T1_Builder_Funcs_
{
T1_Builder_EndChar end_char;
T1_Builder_Sbw set_bearing_point;
@@ -93,50 +77,60 @@
-/*************************************************************************/
-/* */
-/* <Structure> T1_Builder */
-/* */
-/* <Description> */
-/* a structure used during glyph loading to store its outline. */
-/* */
-/* <Fields> */
-/* system :: current system object */
-/* face :: current face object */
-/* size :: current size object */
-/* glyph :: current glyph slot */
-/* */
-/* current :: current glyph outline */
-/* base :: base glyph outline */
-/* */
-/* max_points :: maximum points in builder outline */
-/* max_contours :: maximum contours in builder outline */
-/* */
-/* last :: last point position */
-/* */
-/* scale_x :: horizontal scale ( FUnits to sub-pixels ) */
-/* scale_y :: vertical scale ( FUnits to sub-pixels ) */
-/* pos_x :: horizontal translation (composite glyphs) */
-/* pos_y :: vertical translation (composite glyph) */
-/* */
-/* left_bearing :: left side bearing point */
-/* advance :: horizontal advance vector */
-/* */
-/* path_begun :: flag, indicates that a new path has begun */
-/* load_points :: flag, if not set, no points are loaded */
-/* */
-/* pass :: pass number for multi-pass hinters */
-/* */
-/* funcs :: table of builder functions used to perform */
-/* the outline's path construction */
-/* */
-/* hint_point :: index of next point to hint.. */
-/* */
-/* */
-/* */
-/* */
-
- struct T1_Builder_
+ /*************************************************************************/
+ /* */
+ /* <Structure> */
+ /* T1_Builder */
+ /* */
+ /* <Description> */
+ /* A structure used during glyph loading to store its outline. */
+ /* */
+ /* <Fields> */
+ /* memory :: The current memory object. */
+ /* */
+ /* face :: The current face object. */
+ /* */
+ /* size :: The current size object. */
+ /* */
+ /* glyph :: The current glyph slot. */
+ /* */
+ /* loader :: The current glyph loader. */
+ /* */
+ /* current :: The current glyph outline. */
+ /* */
+ /* base :: The base glyph outline. */
+ /* */
+ /* last :: The last point position. */
+ /* */
+ /* scale_x :: The horizontal scale (FUnits to sub-pixels). */
+ /* */
+ /* scale_y :: The vertical scale (FUnits to sub-pixels). */
+ /* */
+ /* pos_x :: The horizontal translation (for composite glyphs). */
+ /* */
+ /* pos_y :: The vertical translation (for composite glyphs). */
+ /* */
+ /* left_bearing :: The left side bearing point. */
+ /* */
+ /* advance :: The horizontal advance vector. */
+ /* */
+ /* no_recurse :: */
+ /* */
+ /* bbox :: The glyph's bounding box. */
+ /* */
+ /* path_begun :: A flag which indicates that a new path has begun. */
+ /* */
+ /* load_points :: A flag which indicates, if not set, that no points */
+ /* are loaded. */
+ /* */
+ /* pass :: The pass number for multi-pass hinters. */
+ /* */
+ /* hint_point :: The index of the next point to hint. */
+ /* */
+ /* funcs :: A table of builder functions used to perform the */
+ /* outline's path construction. */
+ /* */
+ struct T1_Builder_
{
FT_Memory memory;
T1_Face face;
@@ -171,15 +165,6 @@
};
-/*************************************************************************/
-/* */
-/* <Structure> T1_Hinter_Funcs */
-/* */
-/* <Description> */
-/* a structure used to store the address of various functions */
-/* used by a Type 1 hinter to perform outline hinting. */
-/* */
-
typedef FT_Error (*T1_Hinter_ChangeHints)( T1_Builder* builder );
typedef FT_Error (*T1_Hinter_DotSection)( T1_Builder* builder );
@@ -189,7 +174,6 @@
FT_Pos width,
FT_Bool vertical );
-
typedef FT_Error (*T1_Hinter_Stem3)( T1_Builder* builder,
FT_Pos pos0,
FT_Pos width0,
@@ -199,18 +183,28 @@
FT_Pos width2,
FT_Bool vertical );
- typedef struct T1_Hinter_Func_
+
+ /*************************************************************************/
+ /* */
+ /* <Structure> */
+ /* T1_Hinter_Funcs */
+ /* */
+ /* <Description> */
+ /* A structure to store the address of various functions used by a */
+ /* Type 1 hinter to perform outline hinting. */
+ /* */
+ typedef struct T1_Hinter_Func_
{
- T1_Hinter_ChangeHints change_hints;
- T1_Hinter_DotSection dot_section;
- T1_Hinter_Stem stem;
- T1_Hinter_Stem3 stem3;
+ T1_Hinter_ChangeHints change_hints;
+ T1_Hinter_DotSection dot_section;
+ T1_Hinter_Stem stem;
+ T1_Hinter_Stem3 stem3;
} T1_Hinter_Funcs;
- typedef enum T1_Operator_
+ typedef enum T1_Operator_
{
op_none = 0,
op_endchar,
@@ -244,10 +238,8 @@
} T1_Operator;
-
-
/* execution context charstring zone */
- typedef struct T1_Decoder_Zone_
+ typedef struct T1_Decoder_Zone_
{
FT_Byte* base;
FT_Byte* limit;
@@ -256,171 +248,58 @@
} T1_Decoder_Zone;
- typedef struct T1_Decoder_
+ typedef struct T1_Decoder_
{
- T1_Builder builder;
- T1_Hinter_Funcs hinter;
+ T1_Builder builder;
+ T1_Hinter_Funcs hinter;
- FT_Int stack[ T1_MAX_CHARSTRINGS_OPERANDS ];
- FT_Int* top;
+ FT_Int stack[T1_MAX_CHARSTRINGS_OPERANDS];
+ FT_Int* top;
- T1_Decoder_Zone zones[ T1_MAX_SUBRS_CALLS+1 ];
- T1_Decoder_Zone* zone;
+ T1_Decoder_Zone zones[T1_MAX_SUBRS_CALLS + 1];
+ T1_Decoder_Zone* zone;
- FT_Int flex_state;
- FT_Int num_flex_vectors;
- FT_Vector flex_vectors[7];
+ FT_Int flex_state;
+ FT_Int num_flex_vectors;
+ FT_Vector flex_vectors[7];
} T1_Decoder;
-
-/*********************************************************************
- *
- * <Function>
- * T1_Init_Builder
- *
- * <Description>
- * Initialise a given glyph builder.
- *
- * <Input>
- * builder :: glyph builder to initialise
- * face :: current face object
- * size :: current size object
- * glyph :: current glyph object
- * funcs :: glyph builder functions (or "methods").
- *
- * <Note>
- * This function is exported for now because it is used by the
- * "t1dump" utility. Later, it will be accessed through a
- * format-specific extension
- *
- *********************************************************************/
-
LOCAL_DEF
- void T1_Init_Builder( T1_Builder* builder,
- T1_Face face,
- T1_Size size,
- T1_GlyphSlot glyph,
- const T1_Builder_Funcs* funcs );
+ void T1_Init_Builder( T1_Builder* builder,
+ T1_Face face,
+ T1_Size size,
+ T1_GlyphSlot glyph,
+ const T1_Builder_Funcs* funcs );
-/*********************************************************************
- *
- * <Function>
- * T1_Done_Builder
- *
- * <Description>
- * Finalise a given glyph builder. Its content can still be
- * used after the call, but the function saves important information
- * within the corresponding glyph slot.
- *
- * <Input>
- * builder :: glyph builder to initialise
- *
- * <Note>
- * This function is exported for now because it is used by the
- * "t1dump" utility. Later, it will be accessed through a
- * format-specific extension
- *
- *********************************************************************/
-
LOCAL_DEF
void T1_Done_Builder( T1_Builder* builder );
-
-/*********************************************************************
- *
- * <Function>
- * T1_Init_Decoder
- *
- * <Description>
- * Initialise a given Type 1 decoder for parsing
- *
- * <Input>
- * decoder :: Type 1 decoder to initialise
- * funcs :: hinter functions interface
- *
- * <Note>
- * This function is exported for now because it is used by the
- * "t1dump" utility. Later, it will be accessed through a
- * format-specific extension
- *
- *********************************************************************/
-
LOCAL_DEF
void T1_Init_Decoder( T1_Decoder* decoder,
const T1_Hinter_Funcs* funcs );
-
-
- /* Compute the maximum advance width of a font through quick parsing */
LOCAL_DEF
FT_Error T1_Compute_Max_Advance( T1_Face face,
- FT_Int *max_advance );
+ FT_Int* max_advance );
-
- /* This function is exported, because it is used by the T1Dump utility */
LOCAL_DEF
- FT_Error T1_Parse_CharStrings( T1_Decoder* decoder,
- FT_Byte* charstring_base,
- FT_Int charstring_len,
- FT_Int num_subrs,
- FT_Byte** subrs_base,
- FT_Int* subrs_len );
+ FT_Error T1_Parse_CharStrings( T1_Decoder* decoder,
+ FT_Byte* charstring_base,
+ FT_Int charstring_len,
+ FT_Int num_subrs,
+ FT_Byte** subrs_base,
+ FT_Int* subrs_len );
-
-
-/*************************************************************************/
-/* */
-/* <Function> T1_Add_Points */
-/* */
-/* <Description> */
-/* Checks that there is enough room in the current load glyph outline */
-/* to accept "num_points" additional outline points. If not, this */
-/* function grows the load outline's arrays accordingly.. */
-/* */
-/* <Input> */
-/* builder :: pointer to glyph builder object */
-/* num_points :: number of points that will be added later */
-/* */
-/* <Return> */
-/* Type1 error code. 0 means success */
-/* */
-/* <Note> */
-/* This function does NOT update the points count in the glyph loader */
-/* This must be done by the caller itself, after this function is */
-/* invoked.. */
-/* */
LOCAL_DEF
FT_Error T1_Add_Points( T1_Builder* builder,
FT_Int num_points );
-/*************************************************************************/
-/* */
-/* <Function> T1_Add_Contours */
-/* */
-/* <Description> */
-/* Checks that there is enough room in the current load glyph outline */
-/* to accept "num_contours" additional contours. If not, this func */
-/* the load outline's arrays accordingly.. */
-/* */
-/* <Input> */
-/* builder :: pointer to glyph builder object */
-/* num_contours :: number of contours that will be added later */
-/* */
-/* <Return> */
-/* Type1 error code. 0 means success */
-/* */
-/* <Note> */
-/* This function does NOT update the contours count in the load glyph */
-/* This must be done by the caller itself, after this function is */
-/* invoked.. */
-/* */
LOCAL_DEF
FT_Error T1_Add_Contours( T1_Builder* builder,
FT_Int num_contours );
-
LOCAL_DEF
FT_Error T1_Load_Glyph( T1_GlyphSlot glyph,
T1_Size size,
@@ -432,4 +311,8 @@
}
#endif
+
#endif /* T1GLOAD_H */
+
+
+/* END */
--- a/src/type1/t1hinter.c
+++ b/src/type1/t1hinter.c
@@ -1,31 +1,43 @@
-/*******************************************************************
- *
- * t1hinter.c 1.2
- *
- * Type1 hinter.
- *
- * Copyright 1996-1999 by
- * David Turner, Robert Wilhelm, and Werner Lemberg.
- *
- * This file is part of the FreeType project, and may only be used
- * modified and distributed under the terms of the FreeType project
- * license, LICENSE.TXT. By continuing to use, modify, or distribute
- * this file you indicate that you have read the license and
- * understand and accept it fully.
- *
- *
- * The Hinter is in charge of fitting th scaled outline to the
- * pixel grid in order to considerably improve the quality of
- * the Type 1 font driver's output..
- *
- ******************************************************************/
+/***************************************************************************/
+/* */
+/* t1hinter.c */
+/* */
+/* Type 1 hinter (body). */
+/* */
+/* Copyright 1996-2000 by */
+/* David Turner, Robert Wilhelm, and Werner Lemberg. */
+/* */
+/* This file is part of the FreeType project, and may only be used, */
+/* modified, and distributed under the terms of the FreeType project */
+/* license, LICENSE.TXT. By continuing to use, modify, or distribute */
+/* this file you indicate that you have read the license and */
+/* understand and accept it fully. */
+/* */
+/***************************************************************************/
+
+ /*************************************************************************/
+ /* */
+ /* The Hinter is in charge of fitting th scaled outline to the pixel */
+ /* grid in order to considerably improve the quality of the Type 1 font */
+ /* driver's output. */
+ /* */
+ /*************************************************************************/
+
+
#include <freetype/internal/ftdebug.h>
#include <t1objs.h>
#include <t1hinter.h>
+
+ /*************************************************************************/
+ /* */
+ /* The macro FT_COMPONENT is used in trace mode. It is an implicit */
+ /* parameter of the FT_TRACE() and FT_ERROR() macros, used to print/log */
+ /* messages during execution. */
+ /* */
#undef FT_COMPONENT
-#define FT_COMPONENT trace_t1hint /* for debugging/tracing */
+#define FT_COMPONENT trace_t1hint
#undef ONE_PIXEL
@@ -32,13 +44,14 @@
#define ONE_PIXEL 64
#undef ROUND
-#define ROUND(x) (( x + ONE_PIXEL/2 ) & -ONE_PIXEL)
+#define ROUND( x ) ( ( x + ONE_PIXEL / 2 ) & -ONE_PIXEL )
#undef SCALE
-#define SCALE(val) FT_MulFix( val, scale )
+#define SCALE( val ) FT_MulFix( val, scale )
/* various constants used to describe the alignment of a horizontal */
/* stem with regards to the blue zones */
+
#define T1_ALIGN_NONE 0
#define T1_ALIGN_BOTTOM 1
#define T1_ALIGN_TOP 2
@@ -45,107 +58,104 @@
#define T1_ALIGN_BOTH 3
-/************************************************************************
- *
- * <Function>
- * t1_set_blue_zones
- *
- * <Description>
- * Set a size object's blue zones during reset. This will compute
- * the "snap" zone corresponding to each blue zone.
- *
- * <Input>
- * size :: handle to target size object
- *
- * <Return>
- * Error code. 0 means success
- *
- * <Note>
- * This functions does the following :
- *
- * 1. It extracts the bottom and top blue zones from the
- * face object.
- *
- * 2. Each zone is then grown by BlueFuzz, overlapping
- * is eliminated by adjusting the zone edges appropriately
- *
- * 3. For each zone, we keep its original font units position, its
- * original scaled position, as well as its grown/adjusted
- * edges.
- *
- ************************************************************************/
+ /* very simple bubble sort (not a lot of elements, mostly */
+ /* pre-sorted, no need for quicksort) */
- /* ultra simple bubble sort (not a lot of elements, mostly */
- /* pre-sorted, no need for quicksort) */
- static
- void t1_sort_blues( FT_Int* blues,
- FT_Int count )
- {
- FT_Int i, swap;
- FT_Int* cur;
+ static
+ void t1_sort_blues( FT_Int* blues,
+ FT_Int count )
+ {
+ FT_Int i, swap;
+ FT_Int* cur;
- for ( i = 2; i < count; i += 2 )
- {
- cur = blues + i;
- do
- {
- if ( cur[-1] < cur[0] )
- break;
- swap = cur[-2]; cur[-2] = cur[0]; cur[0] = swap;
- swap = cur[-1]; cur[-1] = cur[1]; cur[1] = swap;
- cur -= 2;
- }
- while ( cur > blues );
- }
- }
+ for ( i = 2; i < count; i += 2 )
+ {
+ cur = blues + i;
+ do
+ {
+ if ( cur[-1] < cur[0] )
+ break;
+ swap = cur[-2]; cur[-2] = cur[0]; cur[0] = swap;
+ swap = cur[-1]; cur[-1] = cur[1]; cur[1] = swap;
+ cur -= 2;
+ } while ( cur > blues );
+ }
+ }
+
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* t1_set_blue_zones */
+ /* */
+ /* <Description> */
+ /* Sets a size object's blue zones during reset. This will compute */
+ /* the `snap' zone corresponding to each blue zone. */
+ /* */
+ /* <InOut> */
+ /* size :: A handle to target size object. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
+ /* <Note> */
+ /* This functions does the following: */
+ /* */
+ /* 1. It extracts the bottom and top blue zones from the face object. */
+ /* */
+ /* 2. Each zone is then grown by `BlueFuzz', overlapping is */
+ /* eliminated by adjusting the zone edges appropriately. */
+ /* */
+ /* 3. For each zone, we keep its original font units position, its */
+ /* original scaled position, as well as its grown/adjusted edges. */
+ /* */
static
FT_Error t1_set_blue_zones( T1_Size size )
{
- T1_Face face = (T1_Face)size->root.face;
- T1_Private* priv = &face->type1.private_dict;
- FT_Int n;
- FT_Int blues[24];
- FT_Int num_bottom;
- FT_Int num_top;
- FT_Int num_blues;
- T1_Size_Hints* hints = size->hints;
- T1_Snap_Zone* zone;
- FT_Pos pix, orus;
- FT_Pos min, max, threshold;
- FT_Fixed scale;
- FT_Bool is_bottom;
+ T1_Face face = (T1_Face)size->root.face;
+ T1_Private* priv = &face->type1.private_dict;
+ FT_Int n;
+ FT_Int blues[24];
+ FT_Int num_bottom;
+ FT_Int num_top;
+ FT_Int num_blues;
+ T1_Size_Hints* hints = size->hints;
+ T1_Snap_Zone* zone;
+ FT_Pos pix, orus;
+ FT_Pos min, max, threshold;
+ FT_Fixed scale;
+ FT_Bool is_bottom;
- /**********************************************************************/
- /* */
- /* COPY BOTTOM AND TOP BLUE ZONES IN LOCAL ARRAYS */
- /* */
- /* */
+ /***********************************************************************/
+ /* */
+ /* copy bottom and top blue zones in local arrays */
+ /* */
+
/* First of all, check the sizes of the /BlueValues and /OtherBlues */
- /* tables. They all must contain an even number of arguments */
+ /* tables. They all must contain an even number of arguments. */
if ( priv->num_other_blues & 1 ||
priv->num_blue_values & 1 )
{
- FT_ERROR(( "T1.Copy_Blues : odd number of blue values\n" ));
+ FT_ERROR(( "t1_set_blue_zones: odd number of blue values\n" ));
return T1_Err_Syntax_Error;
}
- /* copy the bottom blue zones from /OtherBlues */
+ /* copy the bottom blue zones from /OtherBlues */
num_top = 0;
num_bottom = priv->num_other_blues;
- for ( n = 0; n < num_bottom; n ++ )
+ for ( n = 0; n < num_bottom; n++ )
blues[n] = priv->other_blues[n];
- /* Add the first blue zone in /BlueValues to the table */
+ /* add the first blue zone in /BlueValues to the table */
num_top = priv->num_blue_values - 2;
if ( num_top >= 0 )
{
- blues[ num_bottom ] = priv->blue_values[0];
- blues[num_bottom+1] = priv->blue_values[1];
+ blues[num_bottom ] = priv->blue_values[0];
+ blues[num_bottom + 1] = priv->blue_values[1];
num_bottom += 2;
}
@@ -159,7 +169,7 @@
if ( num_top > 0 )
{
for ( n = 0; n < num_top; n++ )
- blues[ num_bottom+n ] = priv->blue_values[n+2];
+ blues[num_bottom + n] = priv->blue_values[n + 2];
/* sort the top blue zones */
t1_sort_blues( blues + num_bottom, num_top );
@@ -170,28 +180,29 @@
num_blues = num_top + num_bottom;
hints->num_blue_zones = ( num_blues ) >> 1;
- /**********************************************************************/
- /* */
- /* BUILD BLUE SNAP ZONES FROM THE LOCAL BLUES ARRAYS */
- /* */
- /* */
+ /***********************************************************************/
+ /* */
+ /* build blue snap zones from the local blues arrays */
+ /* */
scale = size->root.metrics.y_scale;
zone = hints->blue_zones;
- threshold = ONE_PIXEL/4; /* 0.25 pixels */
+ threshold = ONE_PIXEL / 4; /* 0.25 pixels */
- for ( n = 0; n < num_blues; n += 2, zone ++ )
+ for ( n = 0; n < num_blues; n += 2, zone++ )
{
- is_bottom = ( n < num_bottom ? 1 : 0 );
+ is_bottom = n < num_bottom ? 1 : 0;
- orus = blues[n+is_bottom]; /* get alignement coordinate */
- pix = SCALE( orus ); /* scale it */
+ orus = blues[n + is_bottom]; /* get alignement coordinate */
+ pix = SCALE( orus ); /* scale it */
- min = SCALE( blues[ n ] - priv->blue_fuzz );
- max = SCALE( blues[n+1] + priv->blue_fuzz );
+ min = SCALE( blues[n ] - priv->blue_fuzz );
+ max = SCALE( blues[n + 1] + priv->blue_fuzz );
- if ( min > pix - threshold ) min = pix - threshold;
- if ( max < pix + threshold ) max = pix + threshold;
+ if ( min > pix - threshold )
+ min = pix - threshold;
+ if ( max < pix + threshold )
+ max = pix + threshold;
zone->orus = orus;
zone->pix = pix;
@@ -201,26 +212,24 @@
/* adjust edges in case of overlap */
zone = hints->blue_zones;
- for ( n = 0; n < num_blues-2; n += 2, zone ++ )
+ for ( n = 0; n < num_blues - 2; n += 2, zone++ )
{
- if ( n != num_bottom-2 &&
+ if ( n != num_bottom - 2 &&
zone[0].max > zone[1].min )
- {
- zone[0].max = zone[1].min = (zone[0].pix+zone[1].pix)/2;
- }
+ zone[0].max = zone[1].min = ( zone[0].pix + zone[1].pix ) / 2;
}
+ /* compare the current pixel size with the BlueScale value */
+ /* to know whether to supress overshoots */
- /* Compare the current pixel size with the BlueScale value */
- /* to know wether to supress overshoots.. */
-
hints->supress_overshoots =
- ( size->root.metrics.y_ppem < FT_MulFix(1000,priv->blue_scale) );
+ size->root.metrics.y_ppem < FT_MulFix( 1000, priv->blue_scale );
- /* Now print the new blue values in tracing mode */
#ifdef FT_DEBUG_LEVEL_TRACE
- FT_TRACE2(( "Blue Zones for size object at $%08lx :\n", (long)size ));
+ /* now print the new blue values in tracing mode */
+
+ FT_TRACE2(( "Blue Zones for size object at $%08lx:\n", (long)size ));
FT_TRACE2(( " orus pix min max\n" ));
FT_TRACE2(( "-------------------------------\n" ));
@@ -228,14 +237,14 @@
for ( n = 0; n < hints->num_blue_zones; n++ )
{
FT_TRACE2(( " %3d %.2f %.2f %.2f\n",
- zone->orus,
- zone->pix/64.0,
- zone->min/64.0,
- zone->max/64.0 ));
+ zone->orus,
+ zone->pix / 64.0,
+ zone->min / 64.0,
+ zone->max / 64.0 ));
zone++;
}
- FT_TRACE2(( "\nOver shoots are %s\n\n",
- hints->supress_overshoots ? "supressed" : "active" ));
+ FT_TRACE2(( "\nOvershoots are %s\n\n",
+ hints->supress_overshoots ? "supressed" : "active" ));
#endif /* DEBUG_LEVEL_TRACE */
@@ -243,52 +252,50 @@
}
-
-/************************************************************************
- *
- * <Function>
- * t1_set_snap_zones
- *
- * <Description>
- * This function set a size object's stem snap zones.
- *
- * <Input>
- * size :: handle to target size object
- *
- * <Return>
- * Error code. 0 means success
- *
- * <Note>
- * This function performs the following :
- *
- * 1. It reads and scales the stem snap widths from the parent face
- *
- * 2. A "snap zone" is computed for each snap width, by "growing"
- * it with a threshold of a 1/2 pixel. Overlapping is avoided
- * through proper edge adjustment.
- *
- * 3. Each width whose zone contain the scaled standard set width
- * is removed from the table
- *
- * 4. Finally, the standard set width is scaled, and its correponding
- * "snap zone" is inserted into the sorted snap zones table
- *
- ************************************************************************/
-
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* t1_set_snap_zones */
+ /* */
+ /* <Description> */
+ /* This function set a size object's stem snap zones. */
+ /* */
+ /* <InOut> */
+ /* size :: A handle to the target size object. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
+ /* <Note> */
+ /* This function performs the following: */
+ /* */
+ /* 1. It reads and scales the stem snap widths from the parent face. */
+ /* */
+ /* 2. A `snap zone' is computed for each snap width, by `growing' it */
+ /* with a threshold of 1/2 pixel. Overlapping is avoided through */
+ /* proper edge adjustment. */
+ /* */
+ /* 3. Each width whose zone contain the scaled standard set width is */
+ /* removed from the table. */
+ /* */
+ /* 4. Finally, the standard set width is scaled, and its correponding */
+ /* `snap zone' is inserted into the sorted snap zones table. */
+ /* */
static
FT_Error t1_set_snap_zones( T1_Size size )
{
- FT_Int n, direction, n_zones, num_zones;
- T1_Snap_Zone* zone;
- T1_Snap_Zone* base_zone;
- FT_Short* orgs;
- FT_Pos standard_width;
- FT_Fixed scale;
+ FT_Int n, direction, n_zones, num_zones;
+ T1_Snap_Zone* zone;
+ T1_Snap_Zone* base_zone;
+ FT_Short* orgs;
+ FT_Pos standard_width;
+ FT_Fixed scale;
- T1_Face face = (T1_Face)size->root.face;
- T1_Private* priv = &face->type1.private_dict;
+ T1_Face face = (T1_Face)size->root.face;
+ T1_Private* priv = &face->type1.private_dict;
T1_Size_Hints* hints = size->hints;
+
/* start with horizontal snap zones */
direction = 0;
standard_width = priv->standard_width[0];
@@ -297,16 +304,18 @@
orgs = priv->snap_widths;
scale = size->root.metrics.x_scale;
- while (direction < 2)
+ while ( direction < 2 )
{
- /*****************************************************************/
- /* */
- /* Read and scale stem snap widths table from the physical */
- /* font record. */
- /* */
+ /*********************************************************************/
+ /* */
+ /* Read and scale stem snap widths table from the physical font */
+ /* record. */
+ /* */
+
FT_Pos prev, orus, pix, min, max, threshold;
- threshold = ONE_PIXEL/4;
+
+ threshold = ONE_PIXEL / 4;
zone = base_zone;
if ( n_zones > 0 )
@@ -313,8 +322,8 @@
{
orus = *orgs++;
pix = SCALE( orus );
- min = pix-threshold;
- max = pix+threshold;
+ min = pix - threshold;
+ max = pix + threshold;
zone->orus = orus;
zone->pix = pix;
@@ -326,12 +335,12 @@
orus = *orgs++;
pix = SCALE( orus );
- if ( pix-prev < 2*threshold )
+ if ( pix - prev < 2 * threshold )
{
- min = max = (pix+prev)/2;
+ min = max = ( pix + prev ) / 2;
}
else
- min = pix-threshold;
+ min = pix - threshold;
zone->max = max;
zone++;
@@ -339,19 +348,20 @@
zone->pix = pix;
zone->min = min;
- max = pix+threshold;
+ max = pix + threshold;
prev = pix;
}
zone->max = max;
}
- /* print the scaled stem snap values in tracing modes */
#ifdef FT_DEBUG_LEVEL_TRACE
- FT_TRACE2(( "Set_Snap_Zones : first %s pass\n",
- direction ? "vertical" : "horizontal" ));
+ /* print the scaled stem snap values in tracing mode */
- FT_TRACE2(( "Scaled original stem snap zones :\n" ));
+ FT_TRACE2(( "Set_Snap_Zones: first %s pass\n",
+ direction ? "vertical" : "horizontal" ));
+
+ FT_TRACE2(( "Scaled original stem snap zones:\n" ));
FT_TRACE2(( " orus pix min max\n" ));
FT_TRACE2(( "-----------------------------\n" ));
@@ -358,30 +368,32 @@
zone = base_zone;
for ( n = 0; n < n_zones; n++, zone++ )
FT_TRACE2(( " %3d %.2f %.2f %.2f\n",
- zone->orus,
- zone->pix/64.0,
- zone->min/64.0,
- zone->max/64.0 ));
+ zone->orus,
+ zone->pix / 64.0,
+ zone->min / 64.0,
+ zone->max / 64.0 ));
FT_TRACE2(( "\n" ));
FT_TRACE2(( "Standard width = %d\n", standard_width ));
-#endif
- /*****************************************************************/
- /* */
- /* Now, each snap width which is in the range of the standard */
- /* set width will be removed from the list.. */
- /* */
+#endif /* FT_DEBUG_LEVEL_TRACE */
+ /*********************************************************************/
+ /* */
+ /* Now, each snap width which is in the range of the standard set */
+ /* width will be removed from the list. */
+ /* */
+
if ( standard_width > 0 )
{
T1_Snap_Zone* parent;
FT_Pos std_pix, std_min, std_max;
+
std_pix = SCALE( standard_width );
- std_min = std_pix-threshold;
- std_max = std_pix+threshold;
+ std_min = std_pix - threshold;
+ std_max = std_pix + threshold;
num_zones = 0;
zone = base_zone;
@@ -392,8 +404,10 @@
if ( zone->pix >= std_min && zone->pix <= std_max )
{
/* this zone must be removed from the list */
- if ( std_min > zone->min ) std_min = zone->min;
- if ( std_max < zone->max ) std_max = zone->max;
+ if ( std_min > zone->min )
+ std_min = zone->min;
+ if ( std_max < zone->max )
+ std_max = zone->max;
}
else
{
@@ -403,14 +417,16 @@
zone++;
}
- /**********************************************/
- /* Now, insert the standard width zone */
+ /*******************************************************************/
+ /* */
+ /* Now, insert the standard width zone */
+ /* */
- zone = base_zone+num_zones;
+ zone = base_zone + num_zones;
while ( zone > base_zone && zone[-1].pix > std_max )
{
zone[0] = zone[-1];
- zone --;
+ zone--;
}
/* check border zones */
@@ -417,7 +433,7 @@
if ( zone > base_zone && zone[-1].max > std_min )
zone[-1].max = std_min;
- if ( zone < base_zone+num_zones && zone[1].min < std_max )
+ if ( zone < base_zone + num_zones && zone[1].min < std_max )
zone[1].min = std_max;
zone->orus = standard_width;
@@ -431,16 +447,19 @@
num_zones = n_zones;
/* save total number of stem snaps now */
- if (direction) hints->num_snap_heights = num_zones;
- else hints->num_snap_widths = num_zones;
+ if ( direction )
+ hints->num_snap_heights = num_zones;
+ else
+ hints->num_snap_widths = num_zones;
- /* print the scaled stem snap values in tracing modes */
#ifdef FT_DEBUG_LEVEL_TRACE
- FT_TRACE2(( "Set_Snap_Zones : second %s pass\n",
- direction ? "vertical" : "horizontal" ));
+ /* print the scaled stem snap values in tracing mode */
- FT_TRACE2(( "Scaled clipped stem snap zones :\n" ));
+ FT_TRACE2(( "Set_Snap_Zones: second %s pass\n",
+ direction ? "vertical" : "horizontal" ));
+
+ FT_TRACE2(( "Scaled clipped stem snap zones:\n" ));
FT_TRACE2(( " orus pix min max\n" ));
FT_TRACE2(( "-----------------------------\n" ));
@@ -447,15 +466,16 @@
zone = base_zone;
for ( n = 0; n < num_zones; n++, zone++ )
FT_TRACE2(( " %3d %.2f %.2f %.2f\n",
- zone->orus,
- zone->pix/64.0,
- zone->min/64.0,
- zone->max/64.0 ));
+ zone->orus,
+ zone->pix / 64.0,
+ zone->min / 64.0,
+ zone->max / 64.0 ));
FT_TRACE2(( "\n" ));
FT_TRACE2(( "Standard width = %d\n", standard_width ));
-#endif
+#endif /* FT_DEBUG_LEVEL_TRACE */
+
/* continue with vertical snap zone */
direction++;
standard_width = priv->standard_height[0];
@@ -469,153 +489,145 @@
}
-/************************************************************************
- *
- * <Function>
- * T1_New_Size_Hinter
- *
- * <Description>
- * Allocates a new hinter structure for a given size object
- *
- * <Input>
- * size :: handle to target size object
- *
- * <Return>
- * Error code. 0 means success
- *
- ************************************************************************/
-
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* T1_New_Size_Hinter */
+ /* */
+ /* <Description> */
+ /* Allocates a new hinter structure for a given size object. */
+ /* */
+ /* <InOut> */
+ /* size :: A handle to the target size object. */
+ /* */
+ /* <Return> */
+ /* FreeType Error code. 0 means success. */
+ /* */
LOCAL_FUNC
FT_Error T1_New_Size_Hinter( T1_Size size )
{
FT_Memory memory = size->root.face->memory;
- return MEM_Alloc( size->hints, sizeof(*size->hints) );
+
+ return MEM_Alloc( size->hints, sizeof ( *size->hints ) );
}
-/************************************************************************
- *
- * <Function>
- * T1_Done_Size_Hinter
- *
- * <Description>
- * Releases a given size object's hinter structure
- *
- * <Input>
- * size :: handle to target size object
- *
- ************************************************************************/
-
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* T1_Done_Size_Hinter */
+ /* */
+ /* <Description> */
+ /* Releases a given size object's hinter structure. */
+ /* */
+ /* <Input> */
+ /* size :: A handle to the target size object. */
+ /* */
LOCAL_FUNC
- void T1_Done_Size_Hinter( T1_Size size )
+ void T1_Done_Size_Hinter( T1_Size size )
{
FT_Memory memory = size->root.face->memory;
+
FREE( size->hints );
}
-
-/************************************************************************
- *
- * <Function>
- * T1_Reset_Size_Hinter
- *
- * <Description>
- * Recomputes hinting information when a given size object has
- * changed its resolutions/char sizes/pixel sizes
- *
- * <Input>
- * size :: handle to size object
- *
- * <Return>
- * Error code. 0 means success
- *
- ************************************************************************/
-
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* T1_Reset_Size_Hinter */
+ /* */
+ /* <Description> */
+ /* Recomputes hinting information when a given size object has */
+ /* changed its resolutions/char sizes/pixel sizes. */
+ /* */
+ /* <InOut> */
+ /* size :: A handle to the size object. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
LOCAL_FUNC
FT_Error T1_Reset_Size_Hinter( T1_Size size )
{
- return t1_set_blue_zones(size) || t1_set_snap_zones(size);
+ return t1_set_blue_zones( size ) || t1_set_snap_zones( size );
}
-
-/************************************************************************
- *
- * <Function>
- * T1_New_Glyph_Hinter
- *
- * <Description>
- * Allocates a new hinter structure for a given glyph slot
- *
- * <Input>
- * glyph :: handle to target glyph slot
- *
- * <Return>
- * Error code. 0 means success
- *
- ************************************************************************/
-
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* T1_New_Glyph_Hinter */
+ /* */
+ /* <Description> */
+ /* Allocates a new hinter structure for a given glyph slot. */
+ /* */
+ /* <InOut> */
+ /* glyph :: A handle to the target glyph slot. */
+ /* */
+ /* <Return> */
+ /* FreeType error code. 0 means success. */
+ /* */
LOCAL_FUNC
FT_Error T1_New_Glyph_Hinter( T1_GlyphSlot glyph )
{
FT_Memory memory = glyph->root.face->memory;
- return MEM_Alloc( glyph->hints, sizeof(*glyph->hints) );
+
+ return MEM_Alloc( glyph->hints, sizeof ( *glyph->hints ) );
}
-/************************************************************************
- *
- * <Function>
- * T1_Done_Glyph_Hinter
- *
- * <Description>
- * Releases a given glyph slot's hinter structure
- *
- * <Input>
- * glyph :: handle to glyph slot
- *
- ************************************************************************/
-
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* T1_Done_Glyph_Hinter */
+ /* */
+ /* <Description> */
+ /* Releases a given glyph slot's hinter structure. */
+ /* */
+ /* <Input> */
+ /* glyph :: A handle to the glyph slot. */
+ /* */
LOCAL_FUNC
void T1_Done_Glyph_Hinter( T1_GlyphSlot glyph )
{
FT_Memory memory = glyph->root.face->memory;
+
FREE( glyph->hints );
}
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /********** **********/
+ /********** HINTED GLYPH LOADER **********/
+ /********** **********/
+ /********** The following code is in charge of the first **********/
+ /********** and second pass when loading a single outline **********/
+ /********** **********/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
- /**********************************************************************/
- /**********************************************************************/
- /**********************************************************************/
- /********** *********/
- /********** *********/
- /********** HINTED GLYPH LOADER *********/
- /********** *********/
- /********** The following code is in charge of the first *********/
- /********** and second pass when loading a single outline *********/
- /********** *********/
- /**********************************************************************/
- /**********************************************************************/
- /**********************************************************************/
static
- FT_Error t1_hinter_ignore( void )
+ FT_Error t1_hinter_ignore( void )
{
- /* do nothing, used for "dotsection" which is unsupported for now */
+ /* do nothing, used for `dotsection' which is unsupported for now */
return 0;
}
+
static
- FT_Error t1_hinter_stem( T1_Builder* builder,
- FT_Pos pos,
- FT_Int width,
- FT_Bool vertical )
+ FT_Error t1_hinter_stem( T1_Builder* builder,
+ FT_Pos pos,
+ FT_Int width,
+ FT_Bool vertical )
{
T1_Stem_Table* stem_table;
T1_Stem_Hint* stems;
@@ -624,6 +636,7 @@
FT_Bool new_stem;
T1_Glyph_Hints* hinter = builder->glyph->hints;
+
/* select the appropriate stem array */
stem_table = vertical ? &hinter->vert_stems : &hinter->hori_stems;
stems = stem_table->stems;
@@ -638,7 +651,7 @@
max = min + width;
else
{
- /* a negative width indicates a "ghost" stem */
+ /* a negative width indicates a `ghost' stem */
if ( width == -21 )
min += width;
@@ -645,8 +658,8 @@
max = min;
}
- /* now scan the array. If we find a stem with the same borders */
- /* simply activate it.. */
+ /* now scan the array. If we find a stem with the same borders */
+ /* simply activate it. */
cur_stem = stems;
new_stem = 1;
@@ -656,10 +669,10 @@
cur_stem->max_edge.orus == max )
{
/* This stem is already in the table, simply activate it */
- if ( (cur_stem->hint_flags & T1_HINT_FLAG_ACTIVE) == 0)
+ if ( ( cur_stem->hint_flags & T1_HINT_FLAG_ACTIVE ) == 0 )
{
- cur_stem->hint_flags |= T1_HINT_FLAG_ACTIVE;
- stem_table->num_active ++;
+ cur_stem->hint_flags |= T1_HINT_FLAG_ACTIVE;
+ stem_table->num_active++;
}
new_stem = 0;
break;
@@ -667,16 +680,16 @@
}
/* add a new stem to the array when necessary */
- if (new_stem)
+ if ( new_stem )
{
- if (cur_stem >= stems + T1_HINTER_MAX_EDGES)
+ if ( cur_stem >= stems + T1_HINTER_MAX_EDGES )
{
- FT_ERROR(( "T1.Hinter : too many stems in glyph charstring\n" ));
+ FT_ERROR(( "t1_hinter_stem: too many stems in glyph charstring\n" ));
return T1_Err_Syntax_Error;
}
/* on the first pass, we record the stem, otherwise, this is */
- /* a bug in the glyph loader !! */
+ /* a bug in the glyph loader! */
if ( builder->pass == 0 )
{
cur_stem->min_edge.orus = min;
@@ -688,7 +701,7 @@
}
else
{
- FT_ERROR(( "T1.Hinter : fatal glyph loader bug - pass2-stem\n" ));
+ FT_ERROR(( "t1_hinter_stem: fatal glyph loader bug - pass2-stem\n" ));
return T1_Err_Syntax_Error;
}
}
@@ -698,16 +711,16 @@
static
- FT_Error t1_hinter_stem3( T1_Builder* builder,
- FT_Pos pos0,
- FT_Int width0,
- FT_Pos pos1,
- FT_Int width1,
- FT_Pos pos2,
- FT_Int width2,
- FT_Bool vertical )
+ FT_Error t1_hinter_stem3( T1_Builder* builder,
+ FT_Pos pos0,
+ FT_Int width0,
+ FT_Pos pos1,
+ FT_Int width1,
+ FT_Pos pos2,
+ FT_Int width2,
+ FT_Bool vertical )
{
- /* For now, don't be elitist and simply call "stem" 3 times */
+ /* For now, simply call `stem' 3 times */
return t1_hinter_stem( builder, pos0, width0, vertical ) ||
t1_hinter_stem( builder, pos1, width1, vertical ) ||
t1_hinter_stem( builder, pos2, width2, vertical );
@@ -721,9 +734,10 @@
T1_Stem_Table* stem_table;
T1_Glyph_Hints* hinter = builder->glyph->hints;
- /* if we're in the second pass of glyph hinting, we must */
- /* call the function T1_Hint_Points on the builder in order */
- /* to force the fit the latest points to the pixel grid */
+
+ /* If we are in the second pass of glyph hinting, we must */
+ /* call the function T1_Hint_Points() on the builder in order */
+ /* to force the fit the latest points to the pixel grid. */
if ( builder->pass == 1 )
T1_Hint_Points( builder );
@@ -735,6 +749,7 @@
T1_Stem_Hint* cur = stem_table->stems;
T1_Stem_Hint* limit = cur + stem_table->num_stems;
+
for ( ; cur < limit; cur++ )
cur->hint_flags &= ~T1_HINT_FLAG_ACTIVE;
@@ -749,41 +764,40 @@
LOCAL_FUNC
const T1_Hinter_Funcs t1_hinter_funcs =
{
- (T1_Hinter_ChangeHints) t1_hinter_changehints,
- (T1_Hinter_DotSection) t1_hinter_ignore,
- (T1_Hinter_Stem) t1_hinter_stem,
- (T1_Hinter_Stem3) t1_hinter_stem3
+ (T1_Hinter_ChangeHints)t1_hinter_changehints,
+ (T1_Hinter_DotSection) t1_hinter_ignore,
+ (T1_Hinter_Stem) t1_hinter_stem,
+ (T1_Hinter_Stem3) t1_hinter_stem3
};
- /**********************************************************************/
- /**********************************************************************/
- /**********************************************************************/
- /********** *********/
- /********** *********/
- /********** STEM HINTS MANAGEMENT *********/
- /********** *********/
- /********** The following code is in charge of computing *********/
- /********** the placement of each scaled stem hint.. *********/
- /********** *********/
- /**********************************************************************/
- /**********************************************************************/
- /**********************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
+ /********** *********/
+ /********** *********/
+ /********** STEM HINTS MANAGEMENT *********/
+ /********** *********/
+ /********** The following code is in charge of computing *********/
+ /********** the placement of each scaled stem hint. *********/
+ /********** *********/
+ /*************************************************************************/
+ /*************************************************************************/
+ /*************************************************************************/
-/************************************************************************
- *
- * <Function>
- * t1_sort_hints
- *
- * <Description>
- * Sort the list of active stems in increasing order, through
- * the "sort" indexing table
- *
- * <Input>
- * table :: a stem hints table
- *
- ************************************************************************/
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* t1_sort_hints */
+ /* */
+ /* <Description> */
+ /* Sorta the list of active stems in increasing order, through the */
+ /* `sort' indexing table. */
+ /* */
+ /* <InOut> */
+ /* table :: A stem hints table. */
+ /* */
static
void t1_sort_hints( T1_Stem_Table* table )
{
@@ -793,6 +807,7 @@
T1_Stem_Hint* stems = table->stems;
FT_Int n;
+
/* record active stems in sort table */
for ( n = 0; n < num_stems; n++ )
{
@@ -800,32 +815,33 @@
sort[num_active++] = n;
}
- /* now sort the indices. There are usually very few stems, */
- /* and they are pre-sorted in 90% cases, so we choose a */
- /* simple bubble sort (quicksort would be slower).. */
+ /* now sort the indices. There are usually very few stems, */
+ /* and they are pre-sorted in 90% cases, so we choose a */
+ /* simple bubble sort (quicksort would be slower). */
for ( n = 1; n < num_active; n++ )
{
- FT_Int p = n-1;
- T1_Stem_Hint* cur = stems + sort[n];
+ FT_Int p = n - 1;
+ T1_Stem_Hint* cur = stems + sort[n];
+
do
{
FT_Int swap;
T1_Stem_Hint* prev = stems + sort[p];
- /* note that by definition, the active stems cannot overlap */
- /* so we simply compare their "min" to sort them.. */
- /* (we could compare their max, this wouldn't change anything) */
+
+ /* note that by definition, the active stems cannot overlap */
+ /* so we simply compare their `min' to sort them (we could compare */
+ /* their max values also; this wouldn't change anything). */
if ( prev->min_edge.orus <= cur->min_edge.orus )
break;
/* swap elements */
- swap = sort[ p ];
- sort[ p ] = sort[p+1];
- sort[p+1] = swap;
+ swap = sort[p ];
+ sort[p ] = sort[p + 1];
+ sort[p + 1] = swap;
p--;
- }
- while ( p >= 0 );
+ } while ( p >= 0 );
}
table->num_active = num_active;
@@ -832,32 +848,32 @@
}
-/************************************************************************
- *
- * <Function>
- * t1_hint_horizontal_stems
- *
- * <Description>
- * Compute the location of each scaled horizontal stem hint.
- * This takes care of the blue zones and the horizontal stem
- * snap table
- *
- * <Input>
- * table :: the horizontal stem hints table
- * hints :: the current size's hint structure
- * blueShift :: the value of the /BlueShift as taken from the
- * face object.
- * scale :: the 16.16 scale used to convert outline
- * units to 26.6 pixels
- *
- * <Note>
- * For now, all stems are hinted independently from each other.
- * It might be necessary, for better performance, to introduce
- * the notion of "controlled" hints describing things like
- * counter-stems, stem3 as well as overlapping stems control.
- *
- ************************************************************************/
-
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* t1_hint_horizontal_stems */
+ /* */
+ /* <Description> */
+ /* Computes the location of each scaled horizontal stem hint. This */
+ /* takes care of the blue zones and the horizontal stem snap table. */
+ /* */
+ /* <Input> */
+ /* table :: The horizontal stem hints table. */
+ /* */
+ /* hints :: The current size's hint structure. */
+ /* */
+ /* blueShift :: The value of the /BlueShift as taken from the face */
+ /* object. */
+ /* */
+ /* scale :: The 16.16 scale used to convert outline units to */
+ /* 26.6 pixels. */
+ /* */
+ /* <Note> */
+ /* For now, all stems are hinted independently from each other. It */
+ /* might be necessary, for better performance, to introduce the */
+ /* notion of `controlled' hints describing things like counter-stems, */
+ /* stem3, as well as overlapping stems control. */
+ /* */
static
void t1_hint_horizontal_stems( T1_Stem_Table* table,
T1_Size_Hints* hints,
@@ -867,8 +883,9 @@
T1_Stem_Hint* stem = table->stems;
T1_Stem_Hint* limit = stem + table->num_stems;
+
/* first of all, scale the blueShift */
- blueShift = SCALE(blueShift);
+ blueShift = SCALE( blueShift );
/* then scan the horizontal stem table */
for ( ; stem < limit; stem++ )
@@ -884,20 +901,28 @@
FT_Pos top = top_pix;
FT_Int align = T1_ALIGN_NONE;
- /******************************************************************/
- /* Snap pixel width if in stem snap range */
+
+ /*********************************************************************/
+ /* */
+ /* Snap pixel width if in stem snap range */
+ /* */
+
{
T1_Snap_Zone* zone = hints->snap_heights;
T1_Snap_Zone* zone_limit = zone + hints->num_snap_heights;
- FT_Pos best_dist = 32000;
- T1_Snap_Zone* best_zone = 0;
+ FT_Pos best_dist = 32000;
+ T1_Snap_Zone* best_zone = 0;
+
for ( ; zone < zone_limit; zone++ )
{
FT_Pos dist;
- dist = width_pix - zone->min; if (dist < 0) dist = -dist;
- if (dist < best_dist)
+
+ dist = width_pix - zone->min;
+ if ( dist < 0 )
+ dist = -dist;
+ if ( dist < best_dist )
{
best_zone = zone;
best_dist = dist;
@@ -904,36 +929,43 @@
}
}
- if (best_zone)
+ if ( best_zone )
{
- if (width_pix > best_zone->pix)
+ if ( width_pix > best_zone->pix )
{
width_pix -= 0x20;
- if (width_pix < best_zone->pix)
+ if ( width_pix < best_zone->pix )
width_pix = best_zone->pix;
}
else
{
width_pix += 0x20;
- if (width_pix > best_zone->pix)
+ if ( width_pix > best_zone->pix )
width_pix = best_zone->pix;
}
}
}
- /******************************************************************/
- /* round width - minimum 1 pixel if this isn't a ghost stem */
+ /*********************************************************************/
+ /* */
+ /* round width - minimum 1 pixel if this isn't a ghost stem */
+ /* */
+
if ( width_pix > 0 )
- width_pix = ( width_pix < ONE_PIXEL ? ONE_PIXEL : ROUND(width_pix) );
+ width_pix = width_pix < ONE_PIXEL ? ONE_PIXEL : ROUND( width_pix );
- /******************************************************************/
- /* Now check for bottom blue zones alignement */
+ /*********************************************************************/
+ /* */
+ /* Now check for bottom blue zones alignement */
+ /* */
+
{
FT_Int num_blues = hints->num_bottom_zones;
T1_Snap_Zone* blue = hints->blue_zones;
T1_Snap_Zone* blue_limit = blue + num_blues;
+
for ( ; blue < blue_limit; blue++ )
{
if ( bottom_pix < blue->min )
@@ -944,12 +976,13 @@
align = T1_ALIGN_BOTTOM;
bottom = ROUND( blue->pix );
- /* implements blue shift */
- if (!hints->supress_overshoots)
+ /* implement blue shift */
+ if ( !hints->supress_overshoots )
{
FT_Pos delta = blue->pix - bottom_pix;
- delta = ( delta < blueShift ? 0 : ROUND( delta ) );
+
+ delta = delta < blueShift ? 0 : ROUND( delta );
bottom -= delta;
}
}
@@ -956,9 +989,11 @@
}
}
+ /*********************************************************************/
+ /* */
+ /* check for top blue zones alignement */
+ /* */
- /******************************************************************/
- /* Check for top blue zones alignement */
{
FT_Int num_blues = hints->num_blue_zones -
hints->num_bottom_zones;
@@ -968,6 +1003,7 @@
T1_Snap_Zone* blue_limit = blue + num_blues;
+
for ( ; blue < blue_limit; blue++ )
{
if ( top_pix < blue->min )
@@ -975,15 +1011,16 @@
if ( top_pix <= blue->max )
{
- align |= T1_ALIGN_TOP;
- top = ROUND( blue->pix );
+ align |= T1_ALIGN_TOP;
+ top = ROUND( blue->pix );
- /* implements blue shift */
- if (!hints->supress_overshoots)
+ /* implement blue shift */
+ if ( !hints->supress_overshoots )
{
FT_Pos delta = top - blue->pix;
- delta = ( delta < blueShift ? 0 : ROUND( delta ) );
+
+ delta = delta < blueShift ? 0 : ROUND( delta );
top += delta;
}
}
@@ -990,34 +1027,35 @@
}
}
+ /*********************************************************************/
+ /* */
+ /* compute the hinted stem position, according to its alignment */
+ /* */
- /******************************************************************/
- /* compute the hinted stem position, according to its alignment */
- switch (align)
+ switch ( align )
{
- case T1_ALIGN_BOTTOM: /* bottom zone alignement */
- bottom_pix = bottom;
- top_pix = bottom + width_pix;
- break;
+ case T1_ALIGN_BOTTOM: /* bottom zone alignment */
+ bottom_pix = bottom;
+ top_pix = bottom + width_pix;
+ break;
- case T1_ALIGN_TOP: /* top zone alignement */
- top_pix = top;
- bottom_pix = top - width_pix;
+ case T1_ALIGN_TOP: /* top zone alignment */
+ top_pix = top;
+ bottom_pix = top - width_pix;
+ break;
- break;
+ case T1_ALIGN_BOTH: /* bottom+top zone alignment */
+ bottom_pix = bottom;
+ top_pix = top;
+ break;
- case T1_ALIGN_BOTH: /* bottom+top zone alignement */
- bottom_pix = bottom;
- top_pix = top;
- break;
+ default: /* no alignment */
- default: /* no alignement */
+ /* XXXX TODO: Add management of controlled stems */
+ bottom = ( SCALE( bottom_orus + top_orus ) - width_pix ) / 2;
- /* XXXX : TODO : Add management of controlled stems */
- bottom = ( SCALE(bottom_orus+top_orus) - width_pix )/2;
-
- bottom_pix = ROUND(bottom);
- top_pix = bottom_pix + width_pix;
+ bottom_pix = ROUND( bottom );
+ top_pix = bottom_pix + width_pix;
}
stem->min_edge.pix = bottom_pix;
@@ -1026,33 +1064,27 @@
}
-
-
-/************************************************************************
- *
- * <Function>
- * t1_hint_vertical_stems
- *
- * <Description>
- * Compute the location of each scaled vertical stem hint.
- * This takes care of the vertical stem snap table
- *
- * <Input>
- * table :: the vertical stem hints table
- * hints :: the current size's hint structure
- * scale :: the 16.16 scale used to convert outline
- * units to 26.6 pixels
- *
- * <Note>
- * For now, all stems are hinted independently from each other.
- * It might be necessary, for better performance, to introduce
- * the notion of "controlled" hints describing things like
- * counter-stems, stem3 as well as overlapping stems control.
- *
- ************************************************************************/
-
- /* compute the location of each scaled vertical stem hint. */
- /* Take care of blue zones and stem snap table */
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* t1_hint_vertical_stems */
+ /* */
+ /* <Description> */
+ /* Computes the location of each scaled vertical stem hint. This */
+ /* takes care of the vertical stem snap table. */
+ /* */
+ /* <Input> */
+ /* table :: The vertical stem hints table. */
+ /* hints :: The current size's hint structure. */
+ /* scale :: The 16.16 scale used to convert outline units to */
+ /* 26.6 pixels. */
+ /* */
+ /* <Note> */
+ /* For now, all stems are hinted independently from each other. It */
+ /* might be necessary, for better performance, to introduce the */
+ /* notion of `controlled' hints describing things like counter-stems, */
+ /* stem3 as well as overlapping stems control. */
+ /* */
static
void t1_hint_vertical_stems( T1_Stem_Table* table,
T1_Size_Hints* hints,
@@ -1061,6 +1093,7 @@
T1_Stem_Hint* stem = table->stems;
T1_Stem_Hint* limit = stem + table->num_stems;
+
for ( ; stem < limit; stem++ )
{
FT_Pos stem_left = stem->min_edge.orus;
@@ -1067,6 +1100,7 @@
FT_Pos stem_right = stem->max_edge.orus;
FT_Pos width_pix, left;
+
width_pix = SCALE( stem_right - stem_left );
/* Snap pixel width if in stem snap range */
@@ -1073,15 +1107,19 @@
{
T1_Snap_Zone* zone = hints->snap_heights;
T1_Snap_Zone* zone_limit = zone + hints->num_snap_heights;
- FT_Pos best_dist = 32000;
- T1_Snap_Zone* best_zone = 0;
+ FT_Pos best_dist = 32000;
+ T1_Snap_Zone* best_zone = 0;
+
for ( ; zone < zone_limit; zone++ )
{
FT_Pos dist;
- dist = width_pix - zone->min; if (dist < 0) dist = -dist;
- if (dist < best_dist)
+
+ dist = width_pix - zone->min;
+ if ( dist < 0 )
+ dist = -dist;
+ if ( dist < best_dist )
{
best_zone = zone;
best_dist = dist;
@@ -1088,18 +1126,18 @@
}
}
- if (best_zone)
+ if ( best_zone )
{
- if (width_pix > best_zone->pix)
+ if ( width_pix > best_zone->pix )
{
width_pix -= 0x20;
- if (width_pix < best_zone->pix)
+ if ( width_pix < best_zone->pix )
width_pix = best_zone->pix;
}
else
{
width_pix += 0x20;
- if (width_pix > best_zone->pix)
+ if ( width_pix > best_zone->pix )
width_pix = best_zone->pix;
}
}
@@ -1107,49 +1145,45 @@
/* round width - minimum 1 pixel if this isn't a ghost stem */
if ( width_pix > 0 )
- width_pix = ( width_pix < ONE_PIXEL ? ONE_PIXEL :
- ROUND( width_pix ) );
+ width_pix = width_pix < ONE_PIXEL ? ONE_PIXEL
+ : ROUND( width_pix );
/* now place the snapped and rounded stem */
- /* XXXX : TODO : implement controlled stems for the overlapping */
- /* cases.. */
+ /* XXXX TODO: implement controlled stems for the overlapping */
+ /* cases */
- left = ( SCALE(stem_left+stem_right) - width_pix )/2;
+ left = ( SCALE( stem_left + stem_right ) - width_pix ) / 2;
- stem->min_edge.pix = ROUND(left);
+ stem->min_edge.pix = ROUND( left );
stem->max_edge.pix = stem->min_edge.pix + width_pix;
}
}
-
-
-/************************************************************************
- *
- * <Function>
- * t1_hint_point
- *
- * <Description>
- * Grid-fit a coordinate with regards to a given stem hints table
- *
- * <Input>
- * table :: the source stem hints table
- * coord :: original coordinate, expressed in font units
- * scale :: the 16.16 scale used to convert font units into
- * 26.6 pixels
- *
- * <Return>
- * the hinted/scaled value in 26.6 pixels
- *
- * <Note>
- * For now, all stems are hinted independently from each other.
- * It might be necessary, for better performance, to introduce
- * the notion of "controlled" hints describing things like
- * counter-stems, stem3 as well as overlapping stems control.
- *
- ************************************************************************/
-
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* t1_hint_point */
+ /* */
+ /* <Description> */
+ /* Grid-fit a coordinate with regards to a given stem hints table. */
+ /* */
+ /* <Input> */
+ /* table :: The source stem hints table. */
+ /* coord :: The original coordinate, expressed in font units. */
+ /* scale :: The 16.16 scale used to convert font units into */
+ /* 26.6 pixels. */
+ /* */
+ /* <Return> */
+ /* The hinted/scaled value in 26.6 pixels. */
+ /* */
+ /* <Note> */
+ /* For now, all stems are hinted independently from each other. It */
+ /* might be necessary, for better performance, to introduce the */
+ /* notion of `controlled' hints describing things like counter-stems, */
+ /* stem3 as well as overlapping stems control. */
+ /* */
static
FT_Pos t1_hint_point( T1_Stem_Table* table,
FT_Pos coord,
@@ -1163,9 +1197,10 @@
T1_Edge* max;
FT_Pos delta;
+
/* only hint when there is at least one stem defined */
- if (num_active <= 0)
- return SCALE(coord);
+ if ( num_active <= 0 )
+ return SCALE( coord );
/* scan the stem table to determine placement of coordinate */
/* relative to the list of sorted and stems */
@@ -1173,31 +1208,36 @@
{
cur = table->stems + table->sort[n];
- /* is it on the left of the current edge ? */
+ /* is it on the left of the current edge? */
delta = cur->min_edge.orus - coord;
- if ( delta == 0 ) return cur->min_edge.pix;
+ if ( delta == 0 )
+ return cur->min_edge.pix;
- if (delta > 0)
+ if ( delta > 0 )
{
/* if this is the left of the first edge, simply shift */
- if (!prev) return cur->min_edge.pix - SCALE(delta);
+ if ( !prev )
+ return cur->min_edge.pix - SCALE( delta );
/* otherwise, interpolate between the maximum of the */
/* previous stem, and the minimum of the current one */
min = &prev->max_edge;
max = &cur->min_edge;
+
goto Interpolate;
}
- /* is it within the current edge ? */
+ /* is it within the current edge? */
delta = cur->max_edge.orus - coord;
- if ( delta == 0 ) return cur->max_edge.pix;
+ if ( delta == 0 )
+ return cur->max_edge.pix;
- if (delta > 0)
+ if ( delta > 0 )
{
/* interpolate within the stem */
min = &cur->min_edge;
max = &cur->max_edge;
+
goto Interpolate;
}
}
@@ -1204,43 +1244,34 @@
/* apparently, this coordinate is on the right of the last stem */
delta = coord - cur->max_edge.orus;
- return cur->max_edge.pix + SCALE(delta);
+ return cur->max_edge.pix + SCALE( delta );
Interpolate:
- return min->pix +
- FT_MulDiv( coord - min->orus,
- max->pix - min->pix,
- max->orus - min->orus );
+ return min->pix + FT_MulDiv( coord - min->orus,
+ max->pix - min->pix,
+ max->orus - min->orus );
}
-
-
-
-
#if 1
-/************************************************************************
- *
- * <Function>
- * T1_Hint_Points
- *
- * <Description>
- * this function grid-fits several points in a given Type 1 builder
- * at once.
- *
- * <Input>
- * builder :: handle to target Type 1 builder
- * first :: first point to hint in builder's current outline
- * last :: last point to hint in builder's current outline
- *
- ************************************************************************/
-
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* T1_Hint_Points */
+ /* */
+ /* <Description> */
+ /* This function grid-fits several points in a given Type 1 builder */
+ /* at once. */
+ /* */
+ /* <Input> */
+ /* builder :: A handle to target Type 1 builder. */
+ /* */
LOCAL_FUNC
void T1_Hint_Points( T1_Builder* builder )
{
FT_Int first = builder->hint_point;
- FT_Int last = builder->current->n_points-1;
+ FT_Int last = builder->current->n_points - 1;
T1_Size size = builder->size;
FT_Fixed scale_x = size->root.metrics.x_scale;
@@ -1253,6 +1284,7 @@
FT_Vector* cur = builder->current->points + first;
FT_Vector* limit = cur + last - first + 1;
+
/* first of all, sort the active stem hints */
t1_sort_hints( hori_stems );
t1_sort_hints( vert_stems );
@@ -1267,21 +1299,19 @@
}
-/************************************************************************
- *
- * <Function>
- * T1_Hint_Stems
- *
- * <Description>
- * This function is used to compute the location of each stem hint
- * between the first and second passes of the glyph loader on the
- * charstring.
- *
- * <Input>
- * builder :: handle to target builder
- *
- ************************************************************************/
-
+ /*************************************************************************/
+ /* */
+ /* <Function> */
+ /* T1_Hint_Stems */
+ /* */
+ /* <Description> */
+ /* This function is used to compute the location of each stem hint */
+ /* between the first and second passes of the glyph loader on the */
+ /* charstring. */
+ /* */
+ /* <Input> */
+ /* builder :: A handle to the target builder. */
+ /* */
LOCAL_FUNC
void T1_Hint_Stems( T1_Builder* builder )
{
@@ -1292,6 +1322,7 @@
FT_Fixed scale_x = size->root.metrics.x_scale;
FT_Fixed scale_y = size->root.metrics.y_scale;
+
t1_hint_horizontal_stems( &hints->hori_stems,
builder->size->hints,
priv->blue_shift,
@@ -1302,4 +1333,7 @@
scale_x );
}
-#endif
+#endif /* 1 */
+
+
+/* END */