diff --git a/c/autohint/autohintlib/build/linux/gcc/debug/Makefile b/c/autohint/autohintlib/build/linux/gcc/debug/Makefile deleted file mode 100644 index a61a9ee2e..000000000 --- a/c/autohint/autohintlib/build/linux/gcc/debug/Makefile +++ /dev/null @@ -1,213 +0,0 @@ -######################################################################### -# # -# Copyright 2014 Adobe Systems Incorporated. # -# All rights reserved. # -# # -######################################################################### - -# Configuration -CONFIG = debug - -# Library -ROOT_DIR = ../../../.. -SRC_DIR = $(ROOT_DIR)/source -OBJECT_DIR = . -LIB_TARGET = $(LIB_DIR)/autohintlib.a - -CFLAGS = $(STD_OPTS) -I$(ROOT_DIR)/source/public/ac \ - -I$(ROOT_DIR)/source/public/extras \ - -I$(ROOT_DIR)/source/ac \ - -I$(ROOT_DIR)/source/bf \ - -DAC_C_LIB=1 \ - -DACLIB_EXPORTS \ - -DIS_LIB \ - -g - -LIB_SRCS = \ - $(SRC_DIR)/ac/ac.c \ - $(SRC_DIR)/ac/ac_C_lib.c \ - $(SRC_DIR)/ac/acfixed.c \ - $(SRC_DIR)/ac/auto.c \ - $(SRC_DIR)/ac/bbox.c \ - $(SRC_DIR)/ac/bfstub.c \ - $(SRC_DIR)/ac/charprop.c \ - $(SRC_DIR)/ac/check.c \ - $(SRC_DIR)/ac/control.c \ - $(SRC_DIR)/ac/cswrite.c \ - $(SRC_DIR)/ac/enum.c \ - $(SRC_DIR)/ac/eval.c \ - $(SRC_DIR)/ac/fix.c \ - $(SRC_DIR)/ac/flat.c \ - $(SRC_DIR)/ac/fontinfo.c \ - $(SRC_DIR)/ac/gen.c \ - $(SRC_DIR)/ac/head.c \ - $(SRC_DIR)/ac/merge.c \ - $(SRC_DIR)/ac/misc.c \ - $(SRC_DIR)/ac/path.c \ - $(SRC_DIR)/ac/pick.c \ - $(SRC_DIR)/ac/read.c \ - $(SRC_DIR)/ac/report.c \ - $(SRC_DIR)/ac/shuffle.c \ - $(SRC_DIR)/ac/stub.c \ - $(SRC_DIR)/ac/write.c \ - $(SRC_DIR)/bf/charlistpriv.c \ - $(SRC_DIR)/bf/charpath.c \ - $(SRC_DIR)/bf/charpathpriv.c \ - $(SRC_DIR)/bf/cryptprocs.c \ - $(SRC_DIR)/bf/fileops.c \ - $(SRC_DIR)/bf/filookup.c \ - $(SRC_DIR)/bf/illtobez.c \ - $(SRC_DIR)/bf/machinedep.c \ - $(SRC_DIR)/bf/rawPStobez.c -LIB_OBJS = \ - ac.o \ - ac_C_lib.o \ - acfixed.o \ - auto.o \ - bbox.o \ - bfstub.o \ - charprop.o \ - check.o \ - control.o \ - cswrite.o \ - enum.o \ - eval.o \ - fix.o \ - flat.o \ - fontinfo.o \ - gen.o \ - head.o \ - merge.o \ - misc.o \ - path.o \ - pick.o \ - read.o \ - report.o \ - shuffle.o \ - stub.o \ - write.o \ - charlistpriv.o \ - charpath.o \ - charpathpriv.o \ - cryptprocs.o \ - fileops.o \ - filookup.o \ - illtobez.o \ - machinedep.o \ - rawPStobez.o - -# Standard definitions -include $(ROOT_DIR)/config/linux/gcc/gcc.mak - - -# Lib Object rules -absfont.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/absfont.c -o $@ - -ac.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/ac.c -o $@ - -ac_C_lib.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/ac_C_lib.c -o $@ - -acfixed.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/acfixed.c -o $@ - -auto.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/auto.c -o $@ - -bbox.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/bbox.c -o $@ - -bfstub.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/bfstub.c -o $@ - -charprop.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/charprop.c -o $@ - -check.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/check.c -o $@ - -control.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/control.c -o $@ - -cswrite.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/cswrite.c -o $@ - -enum.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/enum.c -o $@ - -eval.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/eval.c -o $@ - -fix.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/fix.c -o $@ - -flat.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/flat.c -o $@ - -fontinfo.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/fontinfo.c -o $@ - -gen.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/gen.c -o $@ - -head.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/head.c -o $@ - -merge.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/merge.c -o $@ - -misc.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/misc.c -o $@ - -path.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/path.c -o $@ - -pick.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/pick.c -o $@ - -read.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/read.c -o $@ - -report.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/report.c -o $@ - -shuffle.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/shuffle.c -o $@ - -stub.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/stub.c -o $@ - -write.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/write.c -o $@ - -charlistpriv.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/bf/charlistpriv.c -o $@ - -charpath.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/bf/charpath.c -o $@ - -charpathpriv.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/bf/charpathpriv.c -o $@ - -cryptprocs.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/bf/cryptprocs.c -o $@ - -fileops.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/bf/fileops.c -o $@ - -filookup.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/bf/filookup.c -o $@ - -illtobez.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/bf/illtobez.c -o $@ - -machinedep.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/bf/machinedep.c -o $@ - -rawPStobez.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/bf/rawPStobez.c -o $@ - - - diff --git a/c/autohint/autohintlib/build/linux/gcc/release/Makefile b/c/autohint/autohintlib/build/linux/gcc/release/Makefile deleted file mode 100644 index b021dc221..000000000 --- a/c/autohint/autohintlib/build/linux/gcc/release/Makefile +++ /dev/null @@ -1,212 +0,0 @@ -######################################################################### -# # -# Copyright 2014 Adobe Systems Incorporated. # -# All rights reserved. # -# # -######################################################################### - -# Configuration -CONFIG = release - -# Library -ROOT_DIR = ../../../.. -SRC_DIR = $(ROOT_DIR)/source -OBJECT_DIR = . -LIB_TARGET = $(LIB_DIR)/autohintlib.a - -CFLAGS = $(STD_OPTS) -I$(ROOT_DIR)/source/public/ac \ - -I$(ROOT_DIR)/source/public/extras \ - -I$(ROOT_DIR)/source/ac \ - -I$(ROOT_DIR)/source/bf \ - -DAC_C_LIB=1 \ - -DACLIB_EXPORTS \ - -DIS_LIB - -LIB_SRCS = \ - $(SRC_DIR)/ac/ac.c \ - $(SRC_DIR)/ac/ac_C_lib.c \ - $(SRC_DIR)/ac/acfixed.c \ - $(SRC_DIR)/ac/auto.c \ - $(SRC_DIR)/ac/bbox.c \ - $(SRC_DIR)/ac/bfstub.c \ - $(SRC_DIR)/ac/charprop.c \ - $(SRC_DIR)/ac/check.c \ - $(SRC_DIR)/ac/control.c \ - $(SRC_DIR)/ac/cswrite.c \ - $(SRC_DIR)/ac/enum.c \ - $(SRC_DIR)/ac/eval.c \ - $(SRC_DIR)/ac/fix.c \ - $(SRC_DIR)/ac/flat.c \ - $(SRC_DIR)/ac/fontinfo.c \ - $(SRC_DIR)/ac/gen.c \ - $(SRC_DIR)/ac/head.c \ - $(SRC_DIR)/ac/merge.c \ - $(SRC_DIR)/ac/misc.c \ - $(SRC_DIR)/ac/path.c \ - $(SRC_DIR)/ac/pick.c \ - $(SRC_DIR)/ac/read.c \ - $(SRC_DIR)/ac/report.c \ - $(SRC_DIR)/ac/shuffle.c \ - $(SRC_DIR)/ac/stub.c \ - $(SRC_DIR)/ac/write.c \ - $(SRC_DIR)/bf/charlistpriv.c \ - $(SRC_DIR)/bf/charpath.c \ - $(SRC_DIR)/bf/charpathpriv.c \ - $(SRC_DIR)/bf/cryptprocs.c \ - $(SRC_DIR)/bf/fileops.c \ - $(SRC_DIR)/bf/filookup.c \ - $(SRC_DIR)/bf/illtobez.c \ - $(SRC_DIR)/bf/machinedep.c \ - $(SRC_DIR)/bf/rawPStobez.c -LIB_OBJS = \ - ac.o \ - ac_C_lib.o \ - acfixed.o \ - auto.o \ - bbox.o \ - bfstub.o \ - charprop.o \ - check.o \ - control.o \ - cswrite.o \ - enum.o \ - eval.o \ - fix.o \ - flat.o \ - fontinfo.o \ - gen.o \ - head.o \ - merge.o \ - misc.o \ - path.o \ - pick.o \ - read.o \ - report.o \ - shuffle.o \ - stub.o \ - write.o \ - charlistpriv.o \ - charpath.o \ - charpathpriv.o \ - cryptprocs.o \ - fileops.o \ - filookup.o \ - illtobez.o \ - machinedep.o \ - rawPStobez.o - -# Standard definitions -include $(ROOT_DIR)/config/linux/gcc/gcc.mak - - -# Lib Object rules -absfont.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/absfont.c -o $@ - -ac.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/ac.c -o $@ - -ac_C_lib.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/ac_C_lib.c -o $@ - -acfixed.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/acfixed.c -o $@ - -auto.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/auto.c -o $@ - -bbox.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/bbox.c -o $@ - -bfstub.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/bfstub.c -o $@ - -charprop.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/charprop.c -o $@ - -check.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/check.c -o $@ - -control.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/control.c -o $@ - -cswrite.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/cswrite.c -o $@ - -enum.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/enum.c -o $@ - -eval.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/eval.c -o $@ - -fix.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/fix.c -o $@ - -flat.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/flat.c -o $@ - -fontinfo.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/fontinfo.c -o $@ - -gen.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/gen.c -o $@ - -head.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/head.c -o $@ - -merge.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/merge.c -o $@ - -misc.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/misc.c -o $@ - -path.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/path.c -o $@ - -pick.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/pick.c -o $@ - -read.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/read.c -o $@ - -report.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/report.c -o $@ - -shuffle.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/shuffle.c -o $@ - -stub.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/stub.c -o $@ - -write.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/ac/write.c -o $@ - -charlistpriv.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/bf/charlistpriv.c -o $@ - -charpath.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/bf/charpath.c -o $@ - -charpathpriv.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/bf/charpathpriv.c -o $@ - -cryptprocs.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/bf/cryptprocs.c -o $@ - -fileops.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/bf/fileops.c -o $@ - -filookup.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/bf/filookup.c -o $@ - -illtobez.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/bf/illtobez.c -o $@ - -machinedep.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/bf/machinedep.c -o $@ - -rawPStobez.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/bf/rawPStobez.c -o $@ - - - diff --git a/c/autohint/autohintlib/build/osx/xcode4/autohintlib.xcodeproj/project.pbxproj b/c/autohint/autohintlib/build/osx/xcode4/autohintlib.xcodeproj/project.pbxproj deleted file mode 100644 index 0b063a6cf..000000000 --- a/c/autohint/autohintlib/build/osx/xcode4/autohintlib.xcodeproj/project.pbxproj +++ /dev/null @@ -1,509 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - BD5BF3610D9AC7FB0015F645 /* ac.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF3410D9AC7FB0015F645 /* ac.c */; }; - BD5BF3620D9AC7FB0015F645 /* ac.h in Headers */ = {isa = PBXBuildFile; fileRef = BD5BF3420D9AC7FB0015F645 /* ac.h */; }; - BD5BF3630D9AC7FB0015F645 /* ac_C_lib.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF3430D9AC7FB0015F645 /* ac_C_lib.c */; }; - BD5BF3640D9AC7FB0015F645 /* acfixed.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF3440D9AC7FB0015F645 /* acfixed.c */; }; - BD5BF3670D9AC7FB0015F645 /* auto.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF3470D9AC7FB0015F645 /* auto.c */; }; - BD5BF3680D9AC7FB0015F645 /* bbox.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF3480D9AC7FB0015F645 /* bbox.c */; }; - BD5BF3690D9AC7FB0015F645 /* bfstub.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF3490D9AC7FB0015F645 /* bfstub.c */; }; - BD5BF36A0D9AC7FB0015F645 /* charprop.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF34A0D9AC7FB0015F645 /* charprop.c */; }; - BD5BF36B0D9AC7FB0015F645 /* check.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF34B0D9AC7FB0015F645 /* check.c */; }; - BD5BF36C0D9AC7FB0015F645 /* control.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF34C0D9AC7FB0015F645 /* control.c */; }; - BD5BF36D0D9AC7FB0015F645 /* cswrite.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF34D0D9AC7FB0015F645 /* cswrite.c */; }; - BD5BF36E0D9AC7FB0015F645 /* enum.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF34E0D9AC7FB0015F645 /* enum.c */; }; - BD5BF36F0D9AC7FB0015F645 /* eval.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF34F0D9AC7FB0015F645 /* eval.c */; }; - BD5BF3700D9AC7FB0015F645 /* fix.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF3500D9AC7FB0015F645 /* fix.c */; }; - BD5BF3710D9AC7FB0015F645 /* flat.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF3510D9AC7FB0015F645 /* flat.c */; }; - BD5BF3720D9AC7FB0015F645 /* fontinfo.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF3520D9AC7FB0015F645 /* fontinfo.c */; }; - BD5BF3730D9AC7FB0015F645 /* gen.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF3530D9AC7FB0015F645 /* gen.c */; }; - BD5BF3740D9AC7FB0015F645 /* head.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF3540D9AC7FB0015F645 /* head.c */; }; - BD5BF3760D9AC7FB0015F645 /* memcheck.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF3560D9AC7FB0015F645 /* memcheck.c */; }; - BD5BF3770D9AC7FB0015F645 /* merge.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF3570D9AC7FB0015F645 /* merge.c */; }; - BD5BF3780D9AC7FB0015F645 /* misc.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF3580D9AC7FB0015F645 /* misc.c */; }; - BD5BF3790D9AC7FB0015F645 /* path.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF3590D9AC7FB0015F645 /* path.c */; }; - BD5BF37A0D9AC7FB0015F645 /* pick.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF35A0D9AC7FB0015F645 /* pick.c */; }; - BD5BF37B0D9AC7FB0015F645 /* read.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF35B0D9AC7FB0015F645 /* read.c */; }; - BD5BF37C0D9AC7FB0015F645 /* report.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF35C0D9AC7FB0015F645 /* report.c */; }; - BD5BF37D0D9AC7FB0015F645 /* shuffle.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF35D0D9AC7FB0015F645 /* shuffle.c */; }; - BD5BF37E0D9AC7FB0015F645 /* stub.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF35E0D9AC7FB0015F645 /* stub.c */; }; - BD5BF3800D9AC7FB0015F645 /* write.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF3600D9AC7FB0015F645 /* write.c */; }; - BD5BF3A20D9AC8350015F645 /* afmcharsetdefs.h in Headers */ = {isa = PBXBuildFile; fileRef = BD5BF3830D9AC8350015F645 /* afmcharsetdefs.h */; }; - BD5BF3A30D9AC8350015F645 /* basic.h in Headers */ = {isa = PBXBuildFile; fileRef = BD5BF3840D9AC8350015F645 /* basic.h */; }; - BD5BF3A40D9AC8350015F645 /* bftoac.h in Headers */ = {isa = PBXBuildFile; fileRef = BD5BF3850D9AC8350015F645 /* bftoac.h */; }; - BD5BF3A50D9AC8350015F645 /* buildfont.h in Headers */ = {isa = PBXBuildFile; fileRef = BD5BF3860D9AC8350015F645 /* buildfont.h */; }; - BD5BF3A60D9AC8350015F645 /* charlist.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF3870D9AC8350015F645 /* charlist.c */; }; - BD5BF3A70D9AC8350015F645 /* charlist.h in Headers */ = {isa = PBXBuildFile; fileRef = BD5BF3880D9AC8350015F645 /* charlist.h */; }; - BD5BF3A80D9AC8350015F645 /* charlistpriv.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF3890D9AC8350015F645 /* charlistpriv.c */; }; - BD5BF3A90D9AC8350015F645 /* charlistpriv.h in Headers */ = {isa = PBXBuildFile; fileRef = BD5BF38A0D9AC8350015F645 /* charlistpriv.h */; }; - BD5BF3AA0D9AC8350015F645 /* charpath.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF38B0D9AC8350015F645 /* charpath.c */; }; - BD5BF3AB0D9AC8350015F645 /* charpath.h in Headers */ = {isa = PBXBuildFile; fileRef = BD5BF38C0D9AC8350015F645 /* charpath.h */; }; - BD5BF3AC0D9AC8350015F645 /* charpathpriv.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF38D0D9AC8350015F645 /* charpathpriv.c */; }; - BD5BF3AD0D9AC8350015F645 /* chartable.h in Headers */ = {isa = PBXBuildFile; fileRef = BD5BF38E0D9AC8350015F645 /* chartable.h */; }; - BD5BF3AE0D9AC8350015F645 /* cryptdefs.h in Headers */ = {isa = PBXBuildFile; fileRef = BD5BF38F0D9AC8350015F645 /* cryptdefs.h */; }; - BD5BF3AF0D9AC8350015F645 /* cryptprocs.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF3900D9AC8350015F645 /* cryptprocs.c */; }; - BD5BF3B00D9AC8350015F645 /* derivedchars.h in Headers */ = {isa = PBXBuildFile; fileRef = BD5BF3910D9AC8350015F645 /* derivedchars.h */; }; - BD5BF3B10D9AC8350015F645 /* fileops.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF3920D9AC8350015F645 /* fileops.c */; }; - BD5BF3B20D9AC8350015F645 /* filookup.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF3930D9AC8350015F645 /* filookup.c */; }; - BD5BF3B30D9AC8350015F645 /* filookup.h in Headers */ = {isa = PBXBuildFile; fileRef = BD5BF3940D9AC8350015F645 /* filookup.h */; }; - BD5BF3B40D9AC8350015F645 /* fipriv.h in Headers */ = {isa = PBXBuildFile; fileRef = BD5BF3950D9AC8350015F645 /* fipriv.h */; }; - BD5BF3B50D9AC8350015F645 /* fipublic.h in Headers */ = {isa = PBXBuildFile; fileRef = BD5BF3960D9AC8350015F645 /* fipublic.h */; }; - BD5BF3B60D9AC8350015F645 /* hintfile.h in Headers */ = {isa = PBXBuildFile; fileRef = BD5BF3970D9AC8350015F645 /* hintfile.h */; }; - BD5BF3B70D9AC8350015F645 /* illtobez.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF3980D9AC8350015F645 /* illtobez.c */; }; - BD5BF3B80D9AC8350015F645 /* machinedep.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF3990D9AC8350015F645 /* machinedep.c */; }; - BD5BF3B90D9AC8350015F645 /* machinedep.h in Headers */ = {isa = PBXBuildFile; fileRef = BD5BF39A0D9AC8350015F645 /* machinedep.h */; }; - BD5BF3BA0D9AC8350015F645 /* masterfont.h in Headers */ = {isa = PBXBuildFile; fileRef = BD5BF39B0D9AC8350015F645 /* masterfont.h */; }; - BD5BF3BB0D9AC8350015F645 /* masterfontpriv.h in Headers */ = {isa = PBXBuildFile; fileRef = BD5BF39C0D9AC8350015F645 /* masterfontpriv.h */; }; - BD5BF3BC0D9AC8350015F645 /* opcodes.h in Headers */ = {isa = PBXBuildFile; fileRef = BD5BF39D0D9AC8350015F645 /* opcodes.h */; }; - BD5BF3BD0D9AC8350015F645 /* optable.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF39E0D9AC8350015F645 /* optable.c */; }; - BD5BF3BE0D9AC8350015F645 /* optable.h in Headers */ = {isa = PBXBuildFile; fileRef = BD5BF39F0D9AC8350015F645 /* optable.h */; }; - BD5BF3BF0D9AC8350015F645 /* rawPStobez.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF3A00D9AC8350015F645 /* rawPStobez.c */; }; - BD5BF3C00D9AC8350015F645 /* transitionalchars.h in Headers */ = {isa = PBXBuildFile; fileRef = BD5BF3A10D9AC8350015F645 /* transitionalchars.h */; }; - BD5BF3D20D9ACD300015F645 /* ac_C_lib.h in Headers */ = {isa = PBXBuildFile; fileRef = BD5BF3CD0D9ACD300015F645 /* ac_C_lib.h */; }; - BD5BF3D30D9ACD300015F645 /* memcheck.h in Headers */ = {isa = PBXBuildFile; fileRef = BD5BF3CE0D9ACD300015F645 /* memcheck.h */; }; - BD5BF3D40D9ACD300015F645 /* numtypes.h in Headers */ = {isa = PBXBuildFile; fileRef = BD5BF3D00D9ACD300015F645 /* numtypes.h */; }; - BD5BF3D50D9ACD300015F645 /* pubtypes.h in Headers */ = {isa = PBXBuildFile; fileRef = BD5BF3D10D9ACD300015F645 /* pubtypes.h */; }; -/* End PBXBuildFile section */ - -/* Begin PBXFileReference section */ - BD5BF3410D9AC7FB0015F645 /* ac.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ac.c; sourceTree = ""; }; - BD5BF3420D9AC7FB0015F645 /* ac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ac.h; path = ../../../source/ac/ac.h; sourceTree = ""; }; - BD5BF3430D9AC7FB0015F645 /* ac_C_lib.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = ac_C_lib.c; sourceTree = ""; }; - BD5BF3440D9AC7FB0015F645 /* acfixed.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = acfixed.c; sourceTree = ""; }; - BD5BF3470D9AC7FB0015F645 /* auto.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = auto.c; sourceTree = ""; }; - BD5BF3480D9AC7FB0015F645 /* bbox.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bbox.c; sourceTree = ""; }; - BD5BF3490D9AC7FB0015F645 /* bfstub.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = bfstub.c; sourceTree = ""; }; - BD5BF34A0D9AC7FB0015F645 /* charprop.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = charprop.c; sourceTree = ""; }; - BD5BF34B0D9AC7FB0015F645 /* check.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = check.c; sourceTree = ""; }; - BD5BF34C0D9AC7FB0015F645 /* control.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = control.c; sourceTree = ""; }; - BD5BF34D0D9AC7FB0015F645 /* cswrite.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cswrite.c; sourceTree = ""; }; - BD5BF34E0D9AC7FB0015F645 /* enum.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = enum.c; sourceTree = ""; }; - BD5BF34F0D9AC7FB0015F645 /* eval.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = eval.c; sourceTree = ""; }; - BD5BF3500D9AC7FB0015F645 /* fix.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fix.c; sourceTree = ""; }; - BD5BF3510D9AC7FB0015F645 /* flat.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = flat.c; sourceTree = ""; }; - BD5BF3520D9AC7FB0015F645 /* fontinfo.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fontinfo.c; sourceTree = ""; }; - BD5BF3530D9AC7FB0015F645 /* gen.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = gen.c; sourceTree = ""; }; - BD5BF3540D9AC7FB0015F645 /* head.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = head.c; sourceTree = ""; }; - BD5BF3560D9AC7FB0015F645 /* memcheck.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = memcheck.c; sourceTree = ""; }; - BD5BF3570D9AC7FB0015F645 /* merge.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = merge.c; sourceTree = ""; }; - BD5BF3580D9AC7FB0015F645 /* misc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = misc.c; sourceTree = ""; }; - BD5BF3590D9AC7FB0015F645 /* path.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = path.c; sourceTree = ""; }; - BD5BF35A0D9AC7FB0015F645 /* pick.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = pick.c; sourceTree = ""; }; - BD5BF35B0D9AC7FB0015F645 /* read.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = read.c; sourceTree = ""; }; - BD5BF35C0D9AC7FB0015F645 /* report.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = report.c; sourceTree = ""; }; - BD5BF35D0D9AC7FB0015F645 /* shuffle.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = shuffle.c; sourceTree = ""; }; - BD5BF35E0D9AC7FB0015F645 /* stub.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = stub.c; sourceTree = ""; }; - BD5BF3600D9AC7FB0015F645 /* write.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = write.c; sourceTree = ""; }; - BD5BF3830D9AC8350015F645 /* afmcharsetdefs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = afmcharsetdefs.h; path = ../../../source/bf/afmcharsetdefs.h; sourceTree = ""; }; - BD5BF3840D9AC8350015F645 /* basic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = basic.h; path = ../../../source/bf/basic.h; sourceTree = ""; }; - BD5BF3850D9AC8350015F645 /* bftoac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = bftoac.h; path = ../../../source/bf/bftoac.h; sourceTree = ""; }; - BD5BF3860D9AC8350015F645 /* buildfont.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = buildfont.h; path = ../../../source/bf/buildfont.h; sourceTree = ""; }; - BD5BF3870D9AC8350015F645 /* charlist.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = charlist.c; sourceTree = ""; }; - BD5BF3880D9AC8350015F645 /* charlist.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = charlist.h; path = ../../../source/bf/charlist.h; sourceTree = ""; }; - BD5BF3890D9AC8350015F645 /* charlistpriv.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = charlistpriv.c; sourceTree = ""; }; - BD5BF38A0D9AC8350015F645 /* charlistpriv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = charlistpriv.h; path = ../../../source/bf/charlistpriv.h; sourceTree = ""; }; - BD5BF38B0D9AC8350015F645 /* charpath.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = charpath.c; sourceTree = ""; }; - BD5BF38C0D9AC8350015F645 /* charpath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = charpath.h; path = ../../../source/bf/charpath.h; sourceTree = ""; }; - BD5BF38D0D9AC8350015F645 /* charpathpriv.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = charpathpriv.c; sourceTree = ""; }; - BD5BF38E0D9AC8350015F645 /* chartable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = chartable.h; path = ../../../source/bf/chartable.h; sourceTree = ""; }; - BD5BF38F0D9AC8350015F645 /* cryptdefs.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = cryptdefs.h; path = ../../../source/bf/cryptdefs.h; sourceTree = ""; }; - BD5BF3900D9AC8350015F645 /* cryptprocs.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = cryptprocs.c; sourceTree = ""; }; - BD5BF3910D9AC8350015F645 /* derivedchars.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = derivedchars.h; path = ../../../source/bf/derivedchars.h; sourceTree = ""; }; - BD5BF3920D9AC8350015F645 /* fileops.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = fileops.c; sourceTree = ""; }; - BD5BF3930D9AC8350015F645 /* filookup.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = filookup.c; sourceTree = ""; }; - BD5BF3940D9AC8350015F645 /* filookup.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = filookup.h; path = ../../../source/bf/filookup.h; sourceTree = ""; }; - BD5BF3950D9AC8350015F645 /* fipriv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = fipriv.h; path = ../../../source/bf/fipriv.h; sourceTree = ""; }; - BD5BF3960D9AC8350015F645 /* fipublic.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = fipublic.h; path = ../../../source/bf/fipublic.h; sourceTree = ""; }; - BD5BF3970D9AC8350015F645 /* hintfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = hintfile.h; sourceTree = ""; }; - BD5BF3980D9AC8350015F645 /* illtobez.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = illtobez.c; sourceTree = ""; }; - BD5BF3990D9AC8350015F645 /* machinedep.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = machinedep.c; sourceTree = ""; }; - BD5BF39A0D9AC8350015F645 /* machinedep.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = machinedep.h; path = ../../../source/bf/machinedep.h; sourceTree = ""; }; - BD5BF39B0D9AC8350015F645 /* masterfont.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = masterfont.h; path = ../../../source/bf/masterfont.h; sourceTree = ""; }; - BD5BF39C0D9AC8350015F645 /* masterfontpriv.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = masterfontpriv.h; path = ../../../source/bf/masterfontpriv.h; sourceTree = ""; }; - BD5BF39D0D9AC8350015F645 /* opcodes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = opcodes.h; path = ../../../source/bf/opcodes.h; sourceTree = ""; }; - BD5BF39E0D9AC8350015F645 /* optable.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = optable.c; sourceTree = ""; }; - BD5BF39F0D9AC8350015F645 /* optable.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = optable.h; path = ../../../source/bf/optable.h; sourceTree = ""; }; - BD5BF3A00D9AC8350015F645 /* rawPStobez.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = rawPStobez.c; sourceTree = ""; }; - BD5BF3A10D9AC8350015F645 /* transitionalchars.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = transitionalchars.h; path = ../../../source/bf/transitionalchars.h; sourceTree = ""; }; - BD5BF3C20D9AC9890015F645 /* debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = debug.xcconfig; path = ../../../config/xcconfig/debug.xcconfig; sourceTree = SOURCE_ROOT; }; - BD5BF3C30D9AC9900015F645 /* release.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = release.xcconfig; path = ../../../config/xcconfig/release.xcconfig; sourceTree = SOURCE_ROOT; }; - BD5BF3CD0D9ACD300015F645 /* ac_C_lib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ac_C_lib.h; sourceTree = ""; }; - BD5BF3CE0D9ACD300015F645 /* memcheck.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = memcheck.h; sourceTree = ""; }; - BD5BF3D00D9ACD300015F645 /* numtypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = numtypes.h; sourceTree = ""; }; - BD5BF3D10D9ACD300015F645 /* pubtypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pubtypes.h; sourceTree = ""; }; - D2AAC046055464E500DB518D /* libautohintlib.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libautohintlib.a; sourceTree = BUILT_PRODUCTS_DIR; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - D289987405E68DCB004EDB86 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 08FB7794FE84155DC02AAC07 /* autohintlib */ = { - isa = PBXGroup; - children = ( - BD5BF3C10D9AC9550015F645 /* xcconfig */, - BD5BF3810D9AC8130015F645 /* Headers */, - 08FB7795FE84155DC02AAC07 /* Source */, - C6A0FF2B0290797F04C91782 /* Documentation */, - 1AB674ADFE9D54B511CA2CBB /* Products */, - ); - name = autohintlib; - sourceTree = ""; - }; - 08FB7795FE84155DC02AAC07 /* Source */ = { - isa = PBXGroup; - children = ( - BD5BF3820D9AC8350015F645 /* bf */, - BD5BF3400D9AC7FB0015F645 /* ac */, - ); - name = Source; - sourceTree = ""; - }; - 1AB674ADFE9D54B511CA2CBB /* Products */ = { - isa = PBXGroup; - children = ( - D2AAC046055464E500DB518D /* libautohintlib.a */, - ); - name = Products; - sourceTree = ""; - }; - BD5BF3400D9AC7FB0015F645 /* ac */ = { - isa = PBXGroup; - children = ( - BD5BF3410D9AC7FB0015F645 /* ac.c */, - BD5BF3430D9AC7FB0015F645 /* ac_C_lib.c */, - BD5BF3440D9AC7FB0015F645 /* acfixed.c */, - BD5BF3470D9AC7FB0015F645 /* auto.c */, - BD5BF3480D9AC7FB0015F645 /* bbox.c */, - BD5BF3490D9AC7FB0015F645 /* bfstub.c */, - BD5BF34A0D9AC7FB0015F645 /* charprop.c */, - BD5BF34B0D9AC7FB0015F645 /* check.c */, - BD5BF34C0D9AC7FB0015F645 /* control.c */, - BD5BF34D0D9AC7FB0015F645 /* cswrite.c */, - BD5BF34E0D9AC7FB0015F645 /* enum.c */, - BD5BF34F0D9AC7FB0015F645 /* eval.c */, - BD5BF3500D9AC7FB0015F645 /* fix.c */, - BD5BF3510D9AC7FB0015F645 /* flat.c */, - BD5BF3520D9AC7FB0015F645 /* fontinfo.c */, - BD5BF3530D9AC7FB0015F645 /* gen.c */, - BD5BF3540D9AC7FB0015F645 /* head.c */, - BD5BF3560D9AC7FB0015F645 /* memcheck.c */, - BD5BF3570D9AC7FB0015F645 /* merge.c */, - BD5BF3580D9AC7FB0015F645 /* misc.c */, - BD5BF3590D9AC7FB0015F645 /* path.c */, - BD5BF35A0D9AC7FB0015F645 /* pick.c */, - BD5BF35B0D9AC7FB0015F645 /* read.c */, - BD5BF35C0D9AC7FB0015F645 /* report.c */, - BD5BF35D0D9AC7FB0015F645 /* shuffle.c */, - BD5BF35E0D9AC7FB0015F645 /* stub.c */, - BD5BF3600D9AC7FB0015F645 /* write.c */, - ); - name = ac; - path = ../../../source/ac; - sourceTree = SOURCE_ROOT; - }; - BD5BF3810D9AC8130015F645 /* Headers */ = { - isa = PBXGroup; - children = ( - BD5BF3CC0D9ACD300015F645 /* ac */, - BD5BF3CF0D9ACD300015F645 /* extras */, - BD5BF3420D9AC7FB0015F645 /* ac.h */, - BD5BF3830D9AC8350015F645 /* afmcharsetdefs.h */, - BD5BF3840D9AC8350015F645 /* basic.h */, - BD5BF3850D9AC8350015F645 /* bftoac.h */, - BD5BF3860D9AC8350015F645 /* buildfont.h */, - BD5BF3880D9AC8350015F645 /* charlist.h */, - BD5BF38A0D9AC8350015F645 /* charlistpriv.h */, - BD5BF38C0D9AC8350015F645 /* charpath.h */, - BD5BF38E0D9AC8350015F645 /* chartable.h */, - BD5BF38F0D9AC8350015F645 /* cryptdefs.h */, - BD5BF3910D9AC8350015F645 /* derivedchars.h */, - BD5BF3940D9AC8350015F645 /* filookup.h */, - BD5BF3950D9AC8350015F645 /* fipriv.h */, - BD5BF3960D9AC8350015F645 /* fipublic.h */, - BD5BF39A0D9AC8350015F645 /* machinedep.h */, - BD5BF39C0D9AC8350015F645 /* masterfontpriv.h */, - BD5BF39B0D9AC8350015F645 /* masterfont.h */, - BD5BF39D0D9AC8350015F645 /* opcodes.h */, - BD5BF39F0D9AC8350015F645 /* optable.h */, - BD5BF3A10D9AC8350015F645 /* transitionalchars.h */, - ); - name = Headers; - sourceTree = ""; - }; - BD5BF3820D9AC8350015F645 /* bf */ = { - isa = PBXGroup; - children = ( - BD5BF3870D9AC8350015F645 /* charlist.c */, - BD5BF3890D9AC8350015F645 /* charlistpriv.c */, - BD5BF38B0D9AC8350015F645 /* charpath.c */, - BD5BF38D0D9AC8350015F645 /* charpathpriv.c */, - BD5BF3900D9AC8350015F645 /* cryptprocs.c */, - BD5BF3920D9AC8350015F645 /* fileops.c */, - BD5BF3930D9AC8350015F645 /* filookup.c */, - BD5BF3970D9AC8350015F645 /* hintfile.h */, - BD5BF3980D9AC8350015F645 /* illtobez.c */, - BD5BF3990D9AC8350015F645 /* machinedep.c */, - BD5BF39E0D9AC8350015F645 /* optable.c */, - BD5BF3A00D9AC8350015F645 /* rawPStobez.c */, - ); - name = bf; - path = ../../../source/bf; - sourceTree = SOURCE_ROOT; - }; - BD5BF3C10D9AC9550015F645 /* xcconfig */ = { - isa = PBXGroup; - children = ( - BD5BF3C20D9AC9890015F645 /* debug.xcconfig */, - BD5BF3C30D9AC9900015F645 /* release.xcconfig */, - ); - name = xcconfig; - sourceTree = ""; - }; - BD5BF3CC0D9ACD300015F645 /* ac */ = { - isa = PBXGroup; - children = ( - BD5BF3CD0D9ACD300015F645 /* ac_C_lib.h */, - BD5BF3CE0D9ACD300015F645 /* memcheck.h */, - ); - name = ac; - path = ../../../source/public/ac; - sourceTree = SOURCE_ROOT; - }; - BD5BF3CF0D9ACD300015F645 /* extras */ = { - isa = PBXGroup; - children = ( - BD5BF3D00D9ACD300015F645 /* numtypes.h */, - BD5BF3D10D9ACD300015F645 /* pubtypes.h */, - ); - name = extras; - path = ../../../source/public/extras; - sourceTree = SOURCE_ROOT; - }; - C6A0FF2B0290797F04C91782 /* Documentation */ = { - isa = PBXGroup; - children = ( - ); - name = Documentation; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXHeadersBuildPhase section */ - D2AAC043055464E500DB518D /* Headers */ = { - isa = PBXHeadersBuildPhase; - buildActionMask = 2147483647; - files = ( - BD5BF3620D9AC7FB0015F645 /* ac.h in Headers */, - BD5BF3A20D9AC8350015F645 /* afmcharsetdefs.h in Headers */, - BD5BF3A30D9AC8350015F645 /* basic.h in Headers */, - BD5BF3A40D9AC8350015F645 /* bftoac.h in Headers */, - BD5BF3A50D9AC8350015F645 /* buildfont.h in Headers */, - BD5BF3A70D9AC8350015F645 /* charlist.h in Headers */, - BD5BF3A90D9AC8350015F645 /* charlistpriv.h in Headers */, - BD5BF3AB0D9AC8350015F645 /* charpath.h in Headers */, - BD5BF3AD0D9AC8350015F645 /* chartable.h in Headers */, - BD5BF3AE0D9AC8350015F645 /* cryptdefs.h in Headers */, - BD5BF3B00D9AC8350015F645 /* derivedchars.h in Headers */, - BD5BF3B30D9AC8350015F645 /* filookup.h in Headers */, - BD5BF3B40D9AC8350015F645 /* fipriv.h in Headers */, - BD5BF3B50D9AC8350015F645 /* fipublic.h in Headers */, - BD5BF3B60D9AC8350015F645 /* hintfile.h in Headers */, - BD5BF3B90D9AC8350015F645 /* machinedep.h in Headers */, - BD5BF3BA0D9AC8350015F645 /* masterfont.h in Headers */, - BD5BF3BB0D9AC8350015F645 /* masterfontpriv.h in Headers */, - BD5BF3BC0D9AC8350015F645 /* opcodes.h in Headers */, - BD5BF3BE0D9AC8350015F645 /* optable.h in Headers */, - BD5BF3C00D9AC8350015F645 /* transitionalchars.h in Headers */, - BD5BF3D20D9ACD300015F645 /* ac_C_lib.h in Headers */, - BD5BF3D30D9ACD300015F645 /* memcheck.h in Headers */, - BD5BF3D40D9ACD300015F645 /* numtypes.h in Headers */, - BD5BF3D50D9ACD300015F645 /* pubtypes.h in Headers */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXHeadersBuildPhase section */ - -/* Begin PBXNativeTarget section */ - D2AAC045055464E500DB518D /* autohintlib */ = { - isa = PBXNativeTarget; - buildConfigurationList = 1DEB91EB08733DB70010E9CD /* Build configuration list for PBXNativeTarget "autohintlib" */; - buildPhases = ( - D2AAC043055464E500DB518D /* Headers */, - D2AAC044055464E500DB518D /* Sources */, - D289987405E68DCB004EDB86 /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = autohintlib; - productName = autohintlib; - productReference = D2AAC046055464E500DB518D /* libautohintlib.a */; - productType = "com.apple.product-type.library.static"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 08FB7793FE84155DC02AAC07 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0460; - }; - buildConfigurationList = 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "autohintlib" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 1; - knownRegions = ( - English, - Japanese, - French, - German, - ); - mainGroup = 08FB7794FE84155DC02AAC07 /* autohintlib */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - D2AAC045055464E500DB518D /* autohintlib */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXSourcesBuildPhase section */ - D2AAC044055464E500DB518D /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - BD5BF3610D9AC7FB0015F645 /* ac.c in Sources */, - BD5BF3630D9AC7FB0015F645 /* ac_C_lib.c in Sources */, - BD5BF3640D9AC7FB0015F645 /* acfixed.c in Sources */, - BD5BF3670D9AC7FB0015F645 /* auto.c in Sources */, - BD5BF3680D9AC7FB0015F645 /* bbox.c in Sources */, - BD5BF3690D9AC7FB0015F645 /* bfstub.c in Sources */, - BD5BF36A0D9AC7FB0015F645 /* charprop.c in Sources */, - BD5BF36B0D9AC7FB0015F645 /* check.c in Sources */, - BD5BF36C0D9AC7FB0015F645 /* control.c in Sources */, - BD5BF36D0D9AC7FB0015F645 /* cswrite.c in Sources */, - BD5BF36E0D9AC7FB0015F645 /* enum.c in Sources */, - BD5BF36F0D9AC7FB0015F645 /* eval.c in Sources */, - BD5BF3700D9AC7FB0015F645 /* fix.c in Sources */, - BD5BF3710D9AC7FB0015F645 /* flat.c in Sources */, - BD5BF3720D9AC7FB0015F645 /* fontinfo.c in Sources */, - BD5BF3730D9AC7FB0015F645 /* gen.c in Sources */, - BD5BF3740D9AC7FB0015F645 /* head.c in Sources */, - BD5BF3760D9AC7FB0015F645 /* memcheck.c in Sources */, - BD5BF3770D9AC7FB0015F645 /* merge.c in Sources */, - BD5BF3780D9AC7FB0015F645 /* misc.c in Sources */, - BD5BF3790D9AC7FB0015F645 /* path.c in Sources */, - BD5BF37A0D9AC7FB0015F645 /* pick.c in Sources */, - BD5BF37B0D9AC7FB0015F645 /* read.c in Sources */, - BD5BF37C0D9AC7FB0015F645 /* report.c in Sources */, - BD5BF37D0D9AC7FB0015F645 /* shuffle.c in Sources */, - BD5BF37E0D9AC7FB0015F645 /* stub.c in Sources */, - BD5BF3800D9AC7FB0015F645 /* write.c in Sources */, - BD5BF3A60D9AC8350015F645 /* charlist.c in Sources */, - BD5BF3A80D9AC8350015F645 /* charlistpriv.c in Sources */, - BD5BF3AA0D9AC8350015F645 /* charpath.c in Sources */, - BD5BF3AC0D9AC8350015F645 /* charpathpriv.c in Sources */, - BD5BF3AF0D9AC8350015F645 /* cryptprocs.c in Sources */, - BD5BF3B10D9AC8350015F645 /* fileops.c in Sources */, - BD5BF3B20D9AC8350015F645 /* filookup.c in Sources */, - BD5BF3B70D9AC8350015F645 /* illtobez.c in Sources */, - BD5BF3B80D9AC8350015F645 /* machinedep.c in Sources */, - BD5BF3BD0D9AC8350015F645 /* optable.c in Sources */, - BD5BF3BF0D9AC8350015F645 /* rawPStobez.c in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 1DEB91EC08733DB70010E9CD /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = BD5BF3C20D9AC9890015F645 /* debug.xcconfig */; - buildSettings = { - GCC_PREPROCESSOR_DEFINITIONS = ( - "ACLIB_EXPORTS=1", - "IS_LIB=1", - "$(inherited)", - ); - }; - name = Debug; - }; - 1DEB91ED08733DB70010E9CD /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = BD5BF3C30D9AC9900015F645 /* release.xcconfig */; - buildSettings = { - GCC_PREPROCESSOR_DEFINITIONS = ( - "ACLIB_EXPORTS=1", - "IS_LIB=1", - "$(inherited)", - ); - }; - name = Release; - }; - 1DEB91F008733DB70010E9CD /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = BD5BF3C20D9AC9890015F645 /* debug.xcconfig */; - buildSettings = { - GCC_PREPROCESSOR_DEFINITIONS = ( - "ACLIB_EXPORTS=1", - "IS_LIB=1", - "OSX=1", - ); - PRODUCT_NAME = autohintlib; - }; - name = Debug; - }; - 1DEB91F108733DB70010E9CD /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = BD5BF3C30D9AC9900015F645 /* release.xcconfig */; - buildSettings = { - GCC_PREPROCESSOR_DEFINITIONS = ( - "ACLIB_EXPORTS=1", - "IS_LIB=1", - "OSX=1", - ); - PRODUCT_NAME = autohintlib; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 1DEB91EB08733DB70010E9CD /* Build configuration list for PBXNativeTarget "autohintlib" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 1DEB91EC08733DB70010E9CD /* Debug */, - 1DEB91ED08733DB70010E9CD /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 1DEB91EF08733DB70010E9CD /* Build configuration list for PBXProject "autohintlib" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 1DEB91F008733DB70010E9CD /* Debug */, - 1DEB91F108733DB70010E9CD /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 08FB7793FE84155DC02AAC07 /* Project object */; -} diff --git a/c/autohint/autohintlib/build/win/visualstudio/autohintlib.vcxproj b/c/autohint/autohintlib/build/win/visualstudio/autohintlib.vcxproj deleted file mode 100755 index e0e5a559d..000000000 --- a/c/autohint/autohintlib/build/win/visualstudio/autohintlib.vcxproj +++ /dev/null @@ -1,131 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {FDCEB06E-D2E3-4916-9208-3C70703BFB27} - autohintlib - 10.0.17134.0 - - - - StaticLibrary - MultiByte - $(DefaultPlatformToolset) - - - StaticLibrary - MultiByte - $(DefaultPlatformToolset) - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - ..\..\..\lib\win\debug\ - $(Configuration)\ - ..\..\..\lib\win\release\ - $(Configuration)\ - autohintlib - autohintlib - - - - Disabled - ..\..\..\source\ac;..\..\..\source\public\ac;..\..\..\source\public\extras;..\..\..\source\public\winextras;..\..\..\source\bf\;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_LIB;ACLIB_EXPORTS;IS_LIB;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) - MultiThreadedDebug - - - Level3 - EditAndContinue - - - AutoColorString;AC_getVersion;AC_SetMemManager;%(ExportNamedFunctions) - - - - - MaxSpeed - ..\..\..\source\ac;..\..\..\source\public\ac;..\..\..\source\public\extras;..\..\..\source\public\winextras;..\..\..\source\bf\;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_LIB;ACLIB_EXPORTS;IS_LIB;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) - MultiThreaded - - - Level3 - ProgramDatabase - - - AutoColorString;AC_getVersion;AC_SetMemManager;%(ExportNamedFunctions) - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/c/autohint/autohintlib/config/linux/gcc/gcc.mak b/c/autohint/autohintlib/config/linux/gcc/gcc.mak deleted file mode 100755 index 028c58139..000000000 --- a/c/autohint/autohintlib/config/linux/gcc/gcc.mak +++ /dev/null @@ -1,41 +0,0 @@ -######################################################################### -# # -# Copyright 2014 Adobe Systems Incorporated. # -# All rights reserved. # -# # -######################################################################### - -# Make definitions for Linux platform (i86) - -# Configuration -PLATFORM = linux -HARDWARE = i86 -COMPILER = gcc -XFLAGS = -m32 - -# Directories (relative to build directory) -LIB_DIR = $(ROOT_DIR)/lib/$(PLATFORM)/$(CONFIG) - -STD_OPTS = $(XFLAGS) \ -$(SYS_INCLUDES) - -ifneq ($(strip $(OSX)),) # In order to test under Mac OSX, define OSX in the user environment. - STD_OPTS += -DOSX=1 -endif - -default: $(LIB_TARGET) - -$(LIB_TARGET): $(LIB_OBJS) - mkdir -p $(LIB_DIR) - $(AR) -rvs $@ $? - -clean: - if [ "$(LIB_OBJS)" ]; then \ - rm -f $(LIB_OBJS); \ - fi - - if [ "$(LIB_TARGET)" ]; then \ - rm -f $(LIB_TARGET); \ - fi - - diff --git a/c/autohint/autohintlib/config/xcconfig/debug.xcconfig b/c/autohint/autohintlib/config/xcconfig/debug.xcconfig deleted file mode 100644 index a9d2b73e4..000000000 --- a/c/autohint/autohintlib/config/xcconfig/debug.xcconfig +++ /dev/null @@ -1,3 +0,0 @@ -#include "../../../config/xcconfig/debug.xcconfig" -HEADER_SEARCH_PATHS = $(SDKROOT)/usr/include ../../../../api/** ../../../../resource/** -CONFIGURATION_BUILD_DIR = ../../../../lib/osx/debug diff --git a/c/autohint/autohintlib/config/xcconfig/release.xcconfig b/c/autohint/autohintlib/config/xcconfig/release.xcconfig deleted file mode 100644 index 6d4662a91..000000000 --- a/c/autohint/autohintlib/config/xcconfig/release.xcconfig +++ /dev/null @@ -1,4 +0,0 @@ -#include "../../../config/xcconfig/release.xcconfig" -HEADER_SEARCH_PATHS = $(SDKROOT)/usr/include ../../../../api/** ../../../../resource/** -CONFIGURATION_BUILD_DIR = ../../../../lib/osx/release - diff --git a/c/autohint/autohintlib/source/ac/ac.c b/c/autohint/autohintlib/source/ac/ac.c deleted file mode 100644 index 2d2950435..000000000 --- a/c/autohint/autohintlib/source/ac/ac.c +++ /dev/null @@ -1,315 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* ac.c */ - -#include "ac.h" -#include "bftoac.h" -#include "machinedep.h" -#include "fipublic.h" - -#if !WIN32 -extern int unlink(const char *); -#endif - -#define MAXSTEMDIST 150 /* initial maximum stem width allowed for hints */ - -#if ALLOWCSOUTPUT && THISISACMAIN -extern boolean charstringoutput; -#endif - -public -PPathElt pathStart, pathEnd; -public -boolean YgoesUp; -public -boolean useV, useH, autoVFix, autoHFix, autoLinearCurveFix, editChar; -public -boolean AutoExtraDEBUG, debugColorPath, DEBUG, logging; -public -boolean showVs, showHs, listClrInfo; -public -boolean reportErrors, hasFlex, flexOK, flexStrict, showClrInfo, bandError; -public -Fixed hBigDist, vBigDist, initBigDist, minDist, minMidPt, ghostWidth, - ghostLength, bendLength, bandMargin, maxFlare, - maxBendMerge, maxMerge, minColorElementLength, flexCand, - pruneMargin; -public -Fixed pruneA, pruneB, pruneC, pruneD, pruneValue, bonus; -public -real theta, hBigDistR, vBigDistR, maxVal, minVal; -public -integer lenTopBands, lenBotBands, numSerifs, DMIN, DELTA, CPpercent; -public -integer bendTan, sCurveTan; -public -PClrVal Vcoloring, Hcoloring, Vprimary, Hprimary, valList; -public -char *fileName; -public -char outPrefix[MAXPATHLEN]; -public -char inPrefix[MAXPATHLEN]; -public -PClrSeg segLists[4]; -public -Fixed VStems[MAXSTEMS], HStems[MAXSTEMS]; -public -integer NumVStems, NumHStems; -public -Fixed topBands[MAXBLUES], botBands[MAXBLUES], serifs[MAXSERIFS]; -public -PClrPoint pointList, *ptLstArray; -public -integer ptLstIndex, numPtLsts, maxPtLsts; -public -boolean makehintslog = TRUE; -public -boolean writecoloredbez = TRUE; -public -Fixed bluefuzz; -public -boolean doAligns, doStems; -public -boolean idInFile; -public -boolean roundToInt; -private -int maxStemDist = MAXSTEMDIST; - -public -AC_REPORTFUNCPTR libReportCB = NULL; -public -AC_REPORTFUNCPTR libErrorReportCB = NULL; -unsigned int allstems; /* if false, then stems defined by curves are excluded from the reporting */ -public -AC_REPORTSTEMPTR addHStemCB = NULL; -public -AC_REPORTSTEMPTR addVStemCB = NULL; -public -AC_REPORTZONEPTR addCharExtremesCB = NULL; -public -AC_REPORTZONEPTR addStemExtremesCB = NULL; -public -AC_RETRYPTR reportRetryCB = NULL; -#define CHARSETVAR "CHARSETDIR" -#define BAKFILE "hints.log.BAK" - -private -void *defaultAC_memmanage(void *ctxptr, void *old, unsigned long size) { -#ifndef WIN32 -#pragma unused(ctxptr) -#endif - if (size > 0) { - if (NULL == old) { -#if DOMEMCHECK - return memck_malloc((size_t)size); -#else - return malloc((size_t)size); -#endif - } else { -#if DOMEMCHECK - return memck_realloc(old, (size_t)size); -#else - return realloc(old, (size_t)size); -#endif - } - } else { - if (NULL == old) - return NULL; - else { -#if DOMEMCHECK - memck_free(old); -#else - free(old); -#endif - return NULL; - } - } -} - -/* SEE MACROS in ac.h: - ACNEWMEM(size) - ACREALLOCMEM(oldptr, newsize) - ACFREEMEM(ptr) -*/ - -public -AC_MEMMANAGEFUNCPTR AC_memmanageFuncPtr = defaultAC_memmanage; -public -void *AC_memmanageCtxPtr = NULL; - -public -void setAC_memoryManager(void *ctxptr, AC_MEMMANAGEFUNCPTR func) { - AC_memmanageFuncPtr = func; - AC_memmanageCtxPtr = ctxptr; -} - -#define VMSIZE (1000000L) -private -unsigned char *vmfree, *vmlast, vm[VMSIZE]; - -/* sub allocator */ -public -unsigned char *Alloc(integer sz) { - unsigned char *s; - sz = (sz + 3) & ~3; /* make size a multiple of 4 */ - s = vmfree; - vmfree += sz; - if (vmfree > vmlast) /* Error! need to make VMSIZE bigger */ - { - FlushLogFiles(); - sprintf(globmsg, "Exceeded VM size for hints in file: %s.\n", - fileName); - LogMsg(globmsg, LOGERROR, FATALERROR, TRUE); - } - return s; -} - -public -procedure InitData(integer reason) { - register char *s; - real tmp, origEmSquare; - - switch (reason) { - case STARTUP: - DEBUG = FALSE; - DMIN = 50; - DELTA = 0; - YgoesUp = (dtfmy(FixOne) > 0) ? TRUE : FALSE; - initBigDist = PSDist(maxStemDist); - /* must be <= 168 for ITC Garamond Book Italic p, q, thorn */ - minDist = PSDist(7); - ghostWidth = PSDist(20); - ghostLength = PSDist(4); - bendLength = PSDist(2); - bendTan = 577; /* 30 sin 30 cos div abs == .57735 */ - theta = (float).38; /* must be <= .38 for Ryumin-Light-32 c49*/ - pruneA = FixInt(50); - pruneC = 100; - pruneD = FixOne; - tmp = (float)10.24; /* set to 1024 times the threshold value */ - pruneValue = pruneB = acpflttofix(&tmp); - /* pruneB must be <= .01 for Yakout/Light/heM */ - /* pruneValue must be <= .01 for Yakout/Light/heM */ - CPpercent = 40; - /* must be < 46 for Americana-Bold d bowl vs stem coloring */ - bandMargin = PSDist(30); - maxFlare = PSDist(10); - pruneMargin = PSDist(10); - maxBendMerge = PSDist(6); - maxMerge = PSDist(2); /* must be < 3 for Cushing-BookItalic z */ - minColorElementLength = PSDist(12); - flexCand = PSDist(4); - sCurveTan = 25; - maxVal = 8000000.0; - minVal = 1.0 / (real)(FixOne); - autoHFix = autoVFix = FALSE; - editChar = TRUE; - roundToInt = true; - /* Default is to change a curve with collinear points into a line. */ - autoLinearCurveFix = TRUE; - flexOK = FALSE; - flexStrict = TRUE; - AutoExtraDEBUG = DEBUG; - logging = DEBUG; - debugColorPath = FALSE; - showClrInfo = DEBUG; - showHs = showVs = DEBUG; - listClrInfo = DEBUG; - if (scalinghints) { - SetFntInfoFileName(SCALEDHINTSINFO); - s = GetFntInfo("OrigEmSqUnits", MANDATORY); - sscanf(s, "%g", &origEmSquare); -#if DOMEMCHECK - memck_free(s); -#else - ACFREEMEM(s); -#endif - bluefuzz = (Fixed)(origEmSquare / 2000.0); /* .5 pixel */ - } else { - ResetFntInfoFileName(); - bluefuzz = DEFAULTBLUEFUZZ; - } - /* fall through */ - case RESTART: - memset((void *)vm, 0x0, VMSIZE); - vmfree = vm; - vmlast = vm + VMSIZE; - - /* ?? Does this cause a leak ?? */ - pointList = NULL; - maxPtLsts = 5; - ptLstArray = (PClrPoint *)Alloc(maxPtLsts * sizeof(PClrPoint)); - ptLstIndex = 0; - ptLstArray[0] = NULL; - numPtLsts = 1; - - /* if (fileName != NULL && fileName[0] == 'g') - showClrInfo = showHs = showVs = listClrInfo = TRUE; */ - } -} - -private -procedure setOutputPrefix(prefix) char *prefix; -{ - get_filename(outPrefix, prefix, ""); -} - -public -procedure SetMaxStemDist(int dist) { - maxStemDist = dist; -} - -/* Returns whether coloring was successful. */ -public -boolean AutoColor( - boolean release, - boolean fixStems, - boolean debug, - boolean extracolor, - boolean changeChar, - short total_files, - char *fileNamePtr[], - boolean quiet, - boolean doAll, - boolean roundCoords, - boolean doLog) { - boolean result, renameLog = FALSE; - char *tempstring; - - makehintslog = doLog; - (void)InitAll(STARTUP); - -#if ALLOWCSOUTPUT && THISISACMAIN - if (charstringoutput) { - setOutputPrefix("CharString"); - DirExists("CharString", FALSE, TRUE, FALSE); - } -#endif - if (!ReadFontInfo()) return FALSE; - editChar = changeChar; - roundToInt = roundCoords; - if ((editChar) && fixStems) - autoVFix = autoHFix = fixStems; - autoLinearCurveFix = editChar; - if (debug) - DEBUG = showClrInfo = showHs = showVs = listClrInfo = TRUE; - if ((tempstring = getenv(CHARSETVAR)) != NULL) - set_charsetdir(tempstring); - else - set_charsetdir("\0"); - if (doLog) - OpenLogFiles(); - /* It is possible to do both DoArgs and DoAll when called from - BuildFont. The derived character names are hinted by calling - DoArgs since they should always be rehinted, even in release mode. */ - if (total_files > 0) /* user specified file names */ - { - if (fileNamePtr[0][0] == '\0') - result = DoArgsIgnoreTime(total_files, fileNamePtr, extracolor, &renameLog, release); - } - - return (result); -} diff --git a/c/autohint/autohintlib/source/ac/ac.h b/c/autohint/autohintlib/source/ac/ac.h deleted file mode 100644 index 75bd53a28..000000000 --- a/c/autohint/autohintlib/source/ac/ac.h +++ /dev/null @@ -1,480 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ - -/* See the discussion in the function definition for: - control.c:Blues() - private procedure Blues() - */ -#include "ac_C_lib.h" -#include "buildfont.h" - -#if DOMEMCHECK -#include "memcheck.h" -#endif - -/* widely used definitions */ - -#define procedure void -#define private static -#define public -#ifndef NULL -#define NULL 0L -#endif - -#if THISISACMAIN -#define ALLOWCSOUTPUT 1 -#else -#define ALLOWCSOUTPUT 0 -#endif - -#if defined(THINK_C) -#define L_cuserid 20 /*ASP: was defined stdio.h*/ -#endif - -/* number of default entries in counter color character list. */ -#define COUNTERDEFAULTENTRIES 4 -#define COUNTERLISTSIZE 64 - -/* values for ClrSeg.sType */ -#define sLINE (0L) -#define sBEND (1L) -#define sCURVE (2L) -#define sGHOST (3L) - -/* values for PathElt.type */ -#define MOVETO (0L) -#define LINETO (1L) -#define CURVETO (2L) -#define CLOSEPATH (3L) - -/* values for pathelt control points */ -#define cpStart (0L) -#define cpCurve1 (1L) -#define cpCurve2 (2L) -#define cpEnd (3L) - -/* widths of ghost bands */ -#define botGhst (-21L) -#define topGhst (-20L) - -/* structures */ - -typedef struct { - short int limit; - Fixed feps; - procedure (*report)(); - Cd ll, ur; - Fixed llx, lly; -} FltnRec, *PFltnRec; - -typedef struct _clrseg { - struct _clrseg *sNxt; - /* points to next ClrSeg in list */ - /* separate lists for top, bottom, left, and right segments */ - Fixed sLoc, sMax, sMin; - /* sLoc is X loc for vertical seg, Y loc for horizontal seg */ - /* sMax and sMin give Y extent for vertical seg, X extent for horizontal */ - /* i.e., sTop=sMax, sBot=sMin, sLft=sMin, sRght=sMax. */ - Fixed sBonus; - /* nonzero for segments in sol-eol subpaths */ - /* (probably a leftover that is no longer needed) */ - struct _clrval *sLnk; - /* points to the best ClrVal that uses this ClrSeg */ - /* set by FindBestValForSegs in pick.c */ - struct _pthelt *sElt; - /* points to the path element that generated this ClrSeg */ - /* set by AddSegment in gen.c */ - short int sType; - /* tells what type of segment this is: sLINE sBEND sCURVE or sGHOST */ -} ClrSeg, *PClrSeg; - -typedef struct _seglnk { - PClrSeg seg; -} SegLnk, *PSegLnk; - -typedef struct _seglnklst { - struct _seglnklst *next; - PSegLnk lnk; -} SegLnkLst; - -typedef SegLnkLst *PSegLnkLst; - -#if 0 -typedef struct _clrrep { - Fixed vVal, vSpc, vLoc1, vLoc2; - struct _clrval *vBst; -} ClrRep, *PClrRep; - -typedef struct _clrval { - struct _clrval *vNxt; - Fixed vVal, vSpc, initVal; - Fixed vLoc1, vLoc2; - /* vBot=vLoc1, vTop=vLoc2, vLft=vLoc1, vRght=vLoc2 */ - short int vGhst : 8; - short int pruned : 8; - PClrSeg vSeg1, vSeg2; - struct _clrval *vBst; - PClrRep vRep; -} ClrVal, *PClrVal; -#else -typedef struct _clrval { - struct _clrval *vNxt; - /* points to next ClrVal in list */ - Fixed vVal, vSpc, initVal; - /* vVal is value given in eval.c */ - /* vSpc is nonzero for "special" ClrVals */ - /* such as those with a segment in a blue zone */ - /* initVal is the initially assigned value */ - /* used by FndBstVal in pick.c */ - Fixed vLoc1, vLoc2; - /* vLoc1 is location corresponding to vSeg1 */ - /* vLoc2 is location corresponding to vSeg2 */ - /* for horizontal ClrVal, vBot=vLoc1 and vTop=vLoc2 */ - /* for vertical ClrVal, vLft=vLoc1 and vRght=vLoc2 */ - unsigned int vGhst : 1; /* true iff one of the ClrSegs is a sGHOST seg */ - unsigned int pruned : 1; - /* flag used by FindBestHVals and FindBestVVals */ - /* and by PruneVVals and PruneHVals */ - unsigned int merge : 1; - /* flag used by ReplaceVals in merge.c */ - unsigned int unused : 13; - PClrSeg vSeg1, vSeg2; - /* vSeg1 points to the left ClrSeg in a vertical, bottom in a horizontal */ - /* vSeg2 points to the right ClrSeg in a vertical, top in a horizontal */ - struct _clrval *vBst; - /* points to another ClrVal if this one has been merged or replaced */ -} ClrVal, *PClrVal; -#endif - -typedef struct _pthelt { - struct _pthelt *prev, *next, *conflict; - short int type; - PSegLnkLst Hs, Vs; - boolean Hcopy : 1, Vcopy : 1, isFlex : 1, yFlex : 1, newCP : 1, sol : 1, eol : 1; - int unused : 9; - short int count, newcolors; - Fixed x, y, x1, y1, x2, y2, x3, y3; -} PathElt, *PPathElt; - -typedef struct _clrpnt { - struct _clrpnt *next; - Fixed x0, y0, x1, y1; - /* for vstem, only interested in x0 and x1 */ - /* for hstem, only interested in y0 and y1 */ - PPathElt p0, p1; - /* p0 is source of x0,y0; p1 is source of x1,y1 */ - char c; - /* tells what kind of coloring: 'b' 'y' 'm' or 'v' */ - boolean done; -} ClrPoint, *PClrPoint; - -typedef struct { - char *key, *value; -} FFEntry; - -/* global data */ - -#ifdef IS_LIB -extern FFEntry *featurefiledata; -extern int featurefilesize; - -#elif defined(AC_C_LIB) -extern FFEntry *featurefiledata; -extern int featurefilesize; -#endif - -extern PPathElt pathStart, pathEnd; -extern boolean YgoesUp; -extern boolean useV, useH, autoVFix, autoHFix, autoLinearCurveFix; -extern boolean AutoExtraDEBUG, debugColorPath, DEBUG, logging; -extern boolean editChar; /* whether character can be modified when adding hints */ -extern boolean scalehints; -extern boolean showHs, showVs, bandError, listClrInfo; -extern boolean reportErrors, hasFlex, flexOK, flexStrict, showClrInfo; -extern Fixed hBigDist, vBigDist, initBigDist, minDist, minMidPt, ghostWidth, - ghostLength, bendLength, bandMargin, maxFlare, - maxBendMerge, maxMerge, minColorElementLength, flexCand, - pruneMargin; -extern Fixed pruneA, pruneB, pruneC, pruneD, pruneValue, bonus; -extern real theta, hBigDistR, vBigDistR, maxVal, minVal; -extern integer DMIN, DELTA, CPpercent, bendTan, sCurveTan; -extern PClrVal Vcoloring, Hcoloring, Vprimary, Hprimary, valList; -extern char *fileName; -extern char outPrefix[MAXPATHLEN], *outSuffix; -extern char inPrefix[MAXPATHLEN], *inSuffix; -extern PClrSeg segLists[4]; /* left, right, top, bot */ -extern PClrPoint pointList, *ptLstArray; -extern integer ptLstIndex, numPtLsts, maxPtLsts; -extern procedure AddStemExtremes(Fixed bot, Fixed top); - -#define leftList (segLists[0]) -#define rightList (segLists[1]) -#define topList (segLists[2]) -#define botList (segLists[3]) - -#define MAXFLEX (PSDist(20)) -#define MAXBLUES (20) -#define MAXSERIFS (5) -extern Fixed topBands[MAXBLUES], botBands[MAXBLUES], serifs[MAXSERIFS]; -extern integer lenTopBands, lenBotBands, numSerifs; -#define MAXSTEMS (20) -extern Fixed VStems[MAXSTEMS], HStems[MAXSTEMS]; -extern integer NumVStems, NumHStems; -extern char *HColorList[], *VColorList[]; -extern integer NumHColors, NumVColors; -extern boolean makehintslog; -extern boolean writecoloredbez; -extern Fixed bluefuzz; -extern boolean doAligns, doStems; -extern boolean idInFile; -extern boolean roundToInt; -extern char bezGlyphName[64]; /* defined in read.c; set from the glyph name at the start of the bex file. */ - -/* macros */ - -#define ac_abs(a) (((abstmp = (a)) < 0) ? -abstmp : abstmp) - -#define FixedPosInf MAXinteger -#define FixedNegInf MINinteger -#define FixShift (8) -#define FixInt(i) (((long int)(i)) << FixShift) -#define FixReal(i) ((long int)((i)*256.0)) -extern long int FRnd(long int x); -#define FHalfRnd(x) ((long int)(((x) + (1 << 7)) & ~0xFFL)) -#define FracPart(x) ((long int)(x)&0xFFL) -#define FTrunc(x) (((long int)(x)) >> FixShift) -#define FIXED2FLOAT(x) (x / 256.0) -#if SUN -#ifndef MAX -#define MAX(a, b) ((a) >= (b) ? (a) : (b)) -#endif -#ifndef MIN -#define MIN(a, b) ((a) <= (b) ? (a) : (b)) -#endif -#endif - -#define FixOne (0x100L) -#define FixTwo (0x200L) -#define FixHalf (0x80L) -#define FixQuarter (0x40L) -#define FixHalfMul(f) (2 * ((f) >> 2)) /* DEBUG 8 BIT. Revert this to ((f) >>1) once I am confident that there are not bugs from the update to 8 bits for the Fixed fraction. */ -#define FixTwoMul(f) ((f) << 1) -#define tfmx(x) ((x)) -#define tfmy(y) (-(y)) -#define itfmx(x) ((x)) -#define itfmy(y) (-(y)) -#define dtfmx(x) ((x)) -#define dtfmy(y) (-(y)) -#define idtfmx(x) ((x)) -#define idtfmy(y) (-(y)) -#define PSDist(d) ((FixInt(d))) -#define IsVertical(x1, y1, x2, y2) (VertQuo(x1, y1, x2, y2) > 0) -#define IsHorizontal(x1, y1, x2, y2) (HorzQuo(x1, y1, x2, y2) > 0) -#define SFACTOR (20L) -/* SFACTOR must be < 25 for Gothic-Medium-22 c08 */ -#define spcBonus (1000L) -#define ProdLt0(f0, f1) (((f0) < 0L && (f1) > 0L) || ((f0) > 0L && (f1) < 0L)) -#define ProdGe0(f0, f1) (!ProdLt0(f0, f1)) - -#define DEBUG_ROUND(val) \ - { val = (val >= 0) ? (2 * (val / 2)) : (2 * ((val - 1) / 2)); } -#define DEBUG_ROUND4(val) \ - { val = (val >= 0) ? (4 * (val / 4)) : (4 * ((val - 1) / 4)); } - -/* DEBUG_ROUND is used to force calculations to come out the same as the previous version, where coordinates used 7 bits for the Fixed fraction, rather than the current 8 bits. Once I am confident that there are no bugs in the update, I will remove all occurences of this macro, and accept the differences due to more exact division */ -/* procedures */ - -/* The fix to float and float to fixed procs are different for ac because it - uses 24 bit of integer and 8 bits of fraction. */ -extern procedure acfixtopflt(Fixed x, float *pf); -extern Fixed acpflttofix(float *pv); - -extern unsigned char *Alloc(integer sz); /* Sub-allocator */ - -extern AC_MEMMANAGEFUNCPTR AC_memmanageFuncPtr; -extern void *AC_memmanageCtxPtr; -extern void setAC_memoryManager(void *ctxptr, AC_MEMMANAGEFUNCPTR func); - -#define ACNEWMEM(size) AC_memmanageFuncPtr(AC_memmanageCtxPtr, NULL, (unsigned long)(size)) -#define ACREALLOCMEM(oldptr, newsize) AC_memmanageFuncPtr(AC_memmanageCtxPtr, (oldptr), (newsize)) -#define ACFREEMEM(ptr) AC_memmanageFuncPtr(AC_memmanageCtxPtr, (ptr), 0) - -extern int AddCounterColorChars(); -extern boolean FindNameInList(); -extern procedure ACGetVersion(); -extern procedure PruneElementColorSegs(); -extern int TestColorLst(/*lst, colorList, flg, Hflg, doLst*/); -extern PClrVal CopyClrs(/*lst*/); -extern procedure AutoExtraColors(/*movetoNewClrs, soleol, solWhere*/); -extern PPathElt FindSubpathBBox(/*e*/); -extern procedure ClrVBnds(); -extern procedure ReClrVBnds(); -extern procedure ClrHBnds(); -extern procedure ReClrHBnds(); -extern procedure AddBBoxHV(/*Hflg*/); -extern procedure ClrBBox(); -extern procedure SetMaxStemDist(/* int dist */); -extern procedure CheckPathBBox(); -extern integer SpecialCharType(); -extern boolean VColorChar(); -extern boolean HColorChar(); -extern boolean NoBlueChar(); -extern integer SolEolCharCode(/*s*/); -extern boolean SpecialSolEol(); -extern boolean MoveToNewClrs(); -extern procedure CheckSmooth(); -extern procedure CheckBBoxEdge(/*e, vrt, lc, pf, pl*/); -extern boolean CheckBBoxes(/*e1, e2*/); -extern boolean CheckSmoothness(/*x0, y0, x1, y1, x2, y2, pd*/); -extern procedure CheckForDups(); -extern boolean showClrInfo; -extern procedure AddColorPoint(Fixed x0, Fixed y0, Fixed x1, Fixed y1, char ch, PPathElt p0, PPathElt p1); -extern procedure AddHPair(PClrVal v, char ch); -extern procedure AddVPair(PClrVal v, char ch); -extern procedure XtraClrs(/*e*/); -extern boolean CreateTimesFile(); -extern boolean DoFile(char *fname, boolean extracolor); -extern procedure DoList(/*filenames*/); -extern procedure EvalV(); -extern procedure EvalH(); -extern procedure GenVPts(); -extern procedure CheckVal(/*val, vert*/); -extern procedure CheckTfmVal(/*b, t, vert*/); -extern procedure CheckVals(/*vlst, vert*/); -extern boolean DoFixes(); -extern boolean FindLineSeg(); -extern procedure FltnCurve(/*c0, c1, c2, c3, pfr*/); -extern boolean ReadFontInfo(); -extern boolean InBlueBand(/*loc,n,p*/); -extern procedure GenHPts(); -extern procedure PreGenPts(); -extern PPathElt GetDest(/*cldest*/); -extern PPathElt GetClosedBy(/*clsdby*/); -extern procedure GetEndPoint(/*e, x1p, y1p*/); -extern procedure GetEndPoints(/*p,px0,py0,px1,py1*/); -extern Fixed VertQuo(/*xk,yk,xl,yl*/); -extern Fixed HorzQuo(/*xk,yk,xl,yl*/); -extern boolean IsTiny(/*e*/); -extern boolean IsShort(/*e*/); -extern PPathElt NxtForBend(/*p,px2,py2,px3,py3*/); -extern PPathElt PrvForBend(/*p,px2,py2*/); -extern boolean IsLower(/*p*/); -extern boolean IsUpper(/*p*/); -extern boolean CloseSegs(/*s1,s2,vert*/); -extern boolean DoAllIgnoreTime(); -extern boolean DoArgsIgnoreTime(); -extern boolean DoArgs(int cnt, char *names[], boolean extraColor, boolean *renameLog, boolean release); -extern boolean DoAll(boolean extraColor, boolean release, boolean *renameLog, boolean quiet); - -extern procedure DoPrune(); -extern procedure PruneVVals(); -extern procedure PruneHVals(); -extern procedure MergeVals(/*vert*/); -extern procedure MergeFromMainColors(char ch); -extern procedure RoundPathCoords(); -extern procedure MoveSubpathToEnd(/*e*/); -extern procedure AddSolEol(); -extern int IncludeFile(); -extern procedure InitAuto(); -extern procedure InitData(integer reason); -extern procedure InitFix(); -extern procedure InitGen(); -extern boolean RotateSubpaths(/*flg*/); -extern procedure InitPick(); -extern procedure AutoAddFlex(); -extern integer PointListCheck(/*new,lst*/); -extern boolean SameColors(/*cn1, cn2*/); -extern boolean PreCheckForColoring(); -extern integer CountSubPaths(); -extern procedure PickVVals(/*valList*/); -extern procedure PickHVals(/*valList*/); -extern procedure FindBestHVals(); -extern procedure FindBestVVals(); -extern procedure LogYMinMax(); -extern procedure PrintMessage(/*s*/); -extern procedure ReportError(/*s*/); -extern procedure ReportSmoothError(/*x, y*/); -extern procedure ReportBadClosePathForAutoColoring(/*e*/); -extern procedure ReportAddFlex(); -extern procedure ReportClipSharpAngle(/*x, y*/); -extern procedure ReportSharpAngle(/*x, y*/); -extern procedure ReportLinearCurve(/*e, x0, y0, x1, y1*/); -extern procedure ReportNonHError(/*x0, y0, x1, y1*/); -extern procedure ReportNonVError(/*x0, y0, x1, y1*/); -extern procedure ExpectedMoveTo(/*e*/); -extern procedure ReportMissingClosePath(); -extern procedure ReportTryFlexNearMiss(/*x0, y0, x2, y2*/); -extern procedure ReportTryFlexError(/*CPflg, x, y*/); -extern procedure AskForSplit(/*e*/); -extern procedure ReportSplit(/*e*/); -extern procedure ReportConflictCheck(/*e, conflict, cp*/); -extern procedure ReportConflictCnt(/*e, cnt*/); -extern procedure ReportMoveSubpath(/*e*/); -extern procedure ReportRemFlare(/*e*/); -extern procedure ReportRemConflict(/*e*/); -extern procedure ReportRotateSubpath(/*e*/); -extern procedure ReportRemShortColors(/*ex, ey*/); -extern boolean ResolveConflictBySplit(/*e,Hflg,lnk1,lnk2*/); -extern procedure ReportPossibleLoop(/*e*/); -extern procedure ShowHVal(/*val*/); -extern procedure ShowHVals(/*lst*/); -extern procedure ReportAddHVal(/*val*/); -extern procedure ShowVVal(/*val*/); -extern procedure ShowVVals(/*lst*/); -extern procedure ReportAddVVal(/*val*/); -extern procedure ReportFndBstVal(/*seg,val,hFlg*/); -extern procedure ReportCarry(/*l0, l1, loc, clrs, vert*/); -extern procedure ReportBestCP(/*e, cp*/); -extern procedure LogColorInfo(/*pl*/); -extern procedure ReportAddVSeg(/*from, to, loc, i*/); -extern procedure ReportAddHSeg(/*from, to, loc, i*/); -#if 0 -extern procedure ReportBandError(/*str, loc, blu*/); -#else -extern procedure ReportBandNearMiss(/*str, loc, blu*/); -#endif -extern procedure ReportStemNearMiss(/*vert, w, minW, b, t*/); -extern procedure ReportColorConflict(/*x0, y0, x1, y1, ch*/); -extern procedure ReportDuplicates(/*x, y*/); -extern procedure ReportBBoxBogus(/*llx, lly, urx, ury*/); -extern procedure ReportMergeHVal(/*b0,t0,b1,t1,v0,s0,v1,s1*/); -extern procedure ReportMergeVVal(/*l0,r0,l1,r1,v0,s0,v1,s1*/); -extern procedure ReportPruneHVal(/*val*/); -extern procedure ReportPruneVVal(/*val*/); -extern Fixed ScaleAbs(); -extern Fixed UnScaleAbs(); -extern procedure InitShuffleSubpaths(); -extern procedure MarkLinks(/*vL,hFlg*/); -extern procedure DoShuffleSubpaths(); -extern procedure CopyMainH(); -extern procedure CopyMainV(); -extern procedure RMovePoint(); -extern procedure AddVSegment(); -extern procedure AddHSegment(); -extern procedure Delete(); -extern boolean StrEqual(); -extern boolean ReadCharFile(); -extern double FixToDbl(/*f*/); -extern boolean CompareValues(); -extern procedure SaveFile(); -extern procedure CheckForMultiMoveTo(); -extern double fabs(); -#define STARTUP (0) -#define RESTART (1) - -public -procedure ListClrInfo(/**/); -public -procedure Test(); - -extern procedure InitAll(/*reason*/); - -public -procedure AddVStem(); -public -procedure AddHStem(); - -public -procedure AddCharExtremes(); -public -procedure AddStemExtremes(); diff --git a/c/autohint/autohintlib/source/ac/ac_C_lib.c b/c/autohint/autohintlib/source/ac/ac_C_lib.c deleted file mode 100644 index 450ff64cc..000000000 --- a/c/autohint/autohintlib/source/ac/ac_C_lib.c +++ /dev/null @@ -1,326 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/* AC_C_lib.c */ - -#include "setjmp.h" - -#include "ac_C_lib.h" -#include "ac.h" -#include "bftoac.h" -#include "machinedep.h" - -const char *libversion = "1.5.12"; -const char *progname = "AC_C_lib"; -char editingResource = 0; - -FFEntry *featurefiledata; -int featurefilesize; - -char *FL_glyphname = 0; - -const char *bezstring = 0; -char *bezoutput = 0; -int bezoutputalloc = 0; -int bezoutputactual = 0; - -extern int compatiblemode; /*forces the definition of colors even before a color sub*/ - -jmp_buf aclibmark; /* to handle exit() calls in the library version*/ - -#define skipblanks() \ - while (*current == '\t' || *current == '\n' || *current == ' ' || *current == '\r') current++ -#define skipnonblanks() \ - while (*current != '\t' && *current != '\n' && *current != ' ' && *current != '\r' && *current != '\0') current++ -#define skipmatrix() \ - while (*current != '\0' && *current != ']') current++ - -static void skippsstring(const char **current) { - int parencount = 0; - - do { - if (**current == '(') - parencount++; - else if (**current == ')') - parencount--; - else if (**current == '\0') - return; - - (*current)++; - } while (parencount > 0); -} - -static void FreeFontInfoArray(void) { - int i; - - for (i = 0; i < featurefilesize; i++) { - if (featurefiledata[i].value[0]) { -#if DOMEMCHECK - memck_free(featurefiledata[i].value); -#else - ACFREEMEM(featurefiledata[i].value); -#endif - } - } -#if DOMEMCHECK - memck_free(featurefiledata); -#else - ACFREEMEM(featurefiledata); -#endif -} -static int ParseFontInfo(const char *fontinfo) { - const char *kwstart, *kwend, *tkstart, *current; - int i; - - featurefilesize = 34; -#if DOMEMCHECK - featurefiledata = (FFEntry *)memck_malloc(featurefilesize * sizeof(FFEntry)); -#else - featurefiledata = (FFEntry *)ACNEWMEM(featurefilesize * sizeof(FFEntry)); -#endif - featurefiledata[0].key = "OrigEmSqUnits"; - featurefiledata[1].key = "FontName"; - featurefiledata[2].key = "FlexOK"; - /* Blue Values */ - featurefiledata[3].key = "BaselineOvershoot"; - featurefiledata[4].key = "BaselineYCoord"; - featurefiledata[5].key = "CapHeight"; - featurefiledata[6].key = "CapOvershoot"; - featurefiledata[7].key = "LcHeight"; - featurefiledata[8].key = "LcOvershoot"; - featurefiledata[9].key = "AscenderHeight"; - featurefiledata[10].key = "AscenderOvershoot"; - featurefiledata[11].key = "FigHeight"; - featurefiledata[12].key = "FigOvershoot"; - featurefiledata[13].key = "Height5"; - featurefiledata[14].key = "Height5Overshoot"; - featurefiledata[15].key = "Height6"; - featurefiledata[16].key = "Height6Overshoot"; - /* Other Values */ - featurefiledata[17].key = "Baseline5Overshoot"; - featurefiledata[18].key = "Baseline5"; - featurefiledata[19].key = "Baseline6Overshoot"; - featurefiledata[20].key = "Baseline6"; - featurefiledata[21].key = "SuperiorOvershoot"; - featurefiledata[22].key = "SuperiorBaseline"; - featurefiledata[23].key = "OrdinalOvershoot"; - featurefiledata[24].key = "OrdinalBaseline"; - featurefiledata[25].key = "DescenderOvershoot"; - featurefiledata[26].key = "DescenderHeight"; - - featurefiledata[27].key = "DominantV"; - featurefiledata[28].key = "StemSnapV"; - featurefiledata[29].key = "DominantH"; - featurefiledata[30].key = "StemSnapH"; - featurefiledata[31].key = "VCounterChars"; - featurefiledata[32].key = "HCounterChars"; - /* later addenda */ - featurefiledata[33].key = "BlueFuzz"; - - for (i = 0; i < featurefilesize; i++) { - featurefiledata[i].value = ""; - } - - if (!fontinfo) - return AC_Success; - - current = fontinfo; - while (*current) { - size_t kwLen; - skipblanks(); - kwstart = current; - skipnonblanks(); - kwend = current; - skipblanks(); - tkstart = current; - if (*tkstart == '(') { - skippsstring(¤t); - if (*tkstart) current++; - } else if (*tkstart == '[') { - skipmatrix(); - if (*tkstart) current++; - } else - skipnonblanks(); - - kwLen = (int)(kwend - kwstart); - for (i = 0; i < featurefilesize; i++) { - size_t matchLen = MAX(kwLen, strlen(featurefiledata[i].key)); - if (!strncmp(featurefiledata[i].key, kwstart, matchLen)) { -#if DOMEMCHECK - featurefiledata[i].value = (char *)memck_malloc(current - tkstart + 1); -#else - featurefiledata[i].value = (char *)ACNEWMEM(current - tkstart + 1); -#endif - if (!featurefiledata[i].value) - return AC_MemoryError; - strncpy(featurefiledata[i].value, tkstart, current - tkstart); - featurefiledata[i].value[current - tkstart] = '\0'; - break; - } - } - if (i == featurefilesize) { - char *temp; -#if DOMEMCHECK - temp = (char *)memck_malloc(tkstart - kwstart + 1); -#else - temp = (char *)ACNEWMEM(tkstart - kwstart + 1); -#endif - if (!temp) - return AC_MemoryError; - strncpy(temp, kwstart, tkstart - kwstart); - temp[tkstart - kwstart] = '\0'; - /*fprintf(stderr, "Ignoring fileinfo %s...\n", temp);*/ -#if DOMEMCHECK - memck_free(temp); -#else - ACFREEMEM(temp); -#endif - } - skipblanks(); - } - - return AC_Success; -} -#if __MWERKS__ -#pragma export on -#endif -ACLIB_API void AC_SetMemManager(void *ctxptr, AC_MEMMANAGEFUNCPTR func) { - setAC_memoryManager(ctxptr, func); -} - -ACLIB_API void AC_SetReportCB(AC_REPORTFUNCPTR reportCB, int verbose) { - if (verbose) - libReportCB = reportCB; - else - libReportCB = NULL; - - libErrorReportCB = reportCB; -} - -ACLIB_API void AC_SetReportStemsCB(AC_REPORTSTEMPTR hstemCB, AC_REPORTSTEMPTR vstemCB, unsigned int allStems) { - allstems = allStems; - addHStemCB = hstemCB; - addVStemCB = vstemCB; - doStems = 1; - - addCharExtremesCB = NULL; - addStemExtremesCB = NULL; - doAligns = 0; -} - -ACLIB_API void AC_SetReportZonesCB(AC_REPORTZONEPTR charCB, AC_REPORTZONEPTR stemCB) { - addCharExtremesCB = charCB; - addStemExtremesCB = stemCB; - doAligns = 1; - - addHStemCB = NULL; - addVStemCB = NULL; - doStems = 0; -} - -int cleanup(short code) { - closefiles(); - - if (code == FATALERROR || code == NONFATALERROR) - longjmp(aclibmark, -1); - else - longjmp(aclibmark, 1); - - return 0; /* we dont actually ever get here */ -} - -ACLIB_API int AutoColorString(const char *srcbezdata, const char *fontinfo, char *dstbezdata, int *length, int allowEdit, int allowHintSub, int roundCoords, int debug) { - int value, result; - char *names[] = {""}; - - if (!srcbezdata) - return AC_InvalidParameterError; - - if (ParseFontInfo(fontinfo)) - return AC_FontinfoParseFail; - - set_errorproc(cleanup); - value = setjmp(aclibmark); - - if (value == -1) { - /* a fatal error occurred soemwhere. */ - FreeFontInfoArray(); - return AC_FatalError; - - } else if (value == 1) { - /* AutoColor was called succesfully */ - FreeFontInfoArray(); - if (bezoutputactual < *length) { - strncpy(dstbezdata, bezoutput, bezoutputactual + 1); - *length = bezoutputactual + 1; -#if DOMEMCHECK - memck_free(bezoutput); -#else - ACFREEMEM(bezoutput); -#endif - bezoutputalloc = 0; - return AC_Success; - } else { - *length = bezoutputactual + 1; -#if DOMEMCHECK - memck_free(bezoutput); -#else - ACFREEMEM(bezoutput); -#endif - bezoutputalloc = 0; - return AC_DestBuffOfloError; - } - } - - bezstring = srcbezdata; - - bezoutputalloc = *length; - bezoutputactual = 0; -#if DOMEMCHECK - bezoutput = (char *)memck_malloc(bezoutputalloc); -#else - bezoutput = (char *)ACNEWMEM(bezoutputalloc); -#endif - if (!bezoutput) { - FreeFontInfoArray(); - return AC_MemoryError; - } - *bezoutput = 0; - - result = AutoColor( - FALSE, /* whether any new coloring should cause error */ - FALSE, /*fixStems*/ - (boolean)debug, /*debug*/ - allowHintSub, /* extracolor*/ - allowEdit, /*editChars*/ - 1, - names, - FALSE, /*quiet*/ - FALSE, /* doAll*/ - roundCoords, /* doAll*/ - FALSE); /* do log */ - /* result == TRUE is good */ - /* The following call to cleanup() always returns control to just after the setjmp() function call above, - but with value set to 1 if success, or -1 if not */ - cleanup((result == TRUE) ? OK : NONFATALERROR); - - return AC_UnknownError; /*Shouldn't get here*/ -} - -ACLIB_API void AC_initCallGlobals(void) { - libReportCB = NULL; - libErrorReportCB = NULL; - addCharExtremesCB = NULL; - addStemExtremesCB = NULL; - doAligns = 0; - addHStemCB = NULL; - addVStemCB = NULL; - doStems = 0; -} - -ACLIB_API const char *AC_getVersion(void) { - return libversion; -} - -#if __MWERKS__ -#pragma export off -#endif diff --git a/c/autohint/autohintlib/source/ac/acfixed.c b/c/autohint/autohintlib/source/ac/acfixed.c deleted file mode 100644 index 29f025666..000000000 --- a/c/autohint/autohintlib/source/ac/acfixed.c +++ /dev/null @@ -1,25 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* fixed.c */ - -#include "ac.h" - -#define fixedScale ((real)(FixOne)) - -public -procedure acfixtopflt(x, pf) - Fixed x; -float *pf; -{ - *pf = (float)x / fixedScale; -} - -public -Fixed acpflttofix(pf) float *pf; -{ - float f = *pf; - if (f >= FixedPosInf / fixedScale) return FixedPosInf; - if (f <= FixedNegInf / fixedScale) return FixedNegInf; - return (Fixed)(f * fixedScale); -} diff --git a/c/autohint/autohintlib/source/ac/atan.c b/c/autohint/autohintlib/source/ac/atan.c deleted file mode 100644 index 665451a65..000000000 --- a/c/autohint/autohintlib/source/ac/atan.c +++ /dev/null @@ -1,115 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* - atan.c - -Original version: -Edit History: -Ed Taft: Sat Apr 30 14:54:30 1988 -Ivor Durham: Thu Aug 25 14:20:03 1988 -Bill Paxton: Mon Jan 30 14:23:13 1989 -End Edit History. -*/ - -/* - floating-point arctangent - - os_atan returns the value of the arctangent of its - argument in the range [-pi/2,pi/2]. - - os_atan2 returns the arctangent of arg1/arg2 - in the range [-pi,pi]. - - there are no error returns. - - coefficients are #5077 from Hart & Cheney. (19.56D) -*/ - -static double sq2p1 = 2.414213562373095048802e0; -static double sq2m1 = .414213562373095048802e0; -static double pio2 = 1.570796326794896619231e0; -static double pio4 = .785398163397448309615e0; -static double p4 = .161536412982230228262e2; -static double p3 = .26842548195503973794141e3; -static double p2 = .11530293515404850115428136e4; -static double p1 = .178040631643319697105464587e4; -static double p0 = .89678597403663861959987488e3; -static double q4 = .5895697050844462222791e2; -static double q3 = .536265374031215315104235e3; -static double q2 = .16667838148816337184521798e4; -static double q1 = .207933497444540981287275926e4; -static double q0 = .89678597403663861962481162e3; - -/* - xatan evaluates a series valid in the - range [-0.414...,+0.414...]. -*/ -static double - xatan(arg) double arg; -{ - double argsq; - double value; - - argsq = arg * arg; - value = ((((p4 * argsq + p3) * argsq + p2) * argsq + p1) * argsq + p0); - value = value / (((((argsq + q4) * argsq + q3) * argsq + q2) * argsq + q1) * argsq + q0); - return (value * arg); -} - -/* - satan reduces its argument (known to be positive) - to the range [0,0.414...] and calls xatan. -*/ - -static double - satan(arg) double arg; -{ - if (arg < sq2m1) - return (xatan(arg)); - else if (arg > sq2p1) - return (pio2 - xatan(1.0 / arg)); - else - return (pio4 + xatan((arg - 1.0) / (arg + 1.0))); -} - -#if false /* not needed */ -/* - os_atan makes its argument positive and - calls the inner routine satan. -*/ - -double - os_atan(arg) double arg; -{ - if (arg > 0) - return (satan(arg)); - else - return (-satan(-arg)); -} -#endif /*false*/ - -/* - os_atan2 discovers what quadrant the angle - is in and calls os_atan. -*/ - -#if defined(__MWERKS__) && (!IS_MACHO) -double -atan2(double arg1, double arg2) { - if ((arg1 + arg2) == arg1) - if (arg1 >= 0.) - return (pio2); - else - return (-pio2); - else if (arg2 < 0.) - if (arg1 >= 0.) - return (pio2 + pio2 - satan(-arg1 / arg2)); - else - return (-pio2 - pio2 + satan(arg1 / arg2)); - else if (arg1 > 0) - return (satan(arg1 / arg2)); - else - return (-satan(-arg1 / arg2)); -} -#endif /*false*/ diff --git a/c/autohint/autohintlib/source/ac/auto.c b/c/autohint/autohintlib/source/ac/auto.c deleted file mode 100644 index 9ba3c3f2a..000000000 --- a/c/autohint/autohintlib/source/ac/auto.c +++ /dev/null @@ -1,1165 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* auto.c */ - -#include "ac.h" -#include "machinedep.h" - -private -boolean clrBBox, clrHBounds, clrVBounds, haveHBnds, haveVBnds, - mergeMain; - -public -procedure InitAuto(reason) integer reason; -{ - switch (reason) { - case STARTUP: - case RESTART: - clrBBox = clrHBounds = clrVBounds = haveHBnds = haveVBnds = FALSE; - } -} - -private -PPathElt GetSubPathNxt(e) PPathElt e; -{ - if (e->type == CLOSEPATH) return GetDest(e); - return e->next; -} - -private -PPathElt GetSubPathPrv(e) PPathElt e; -{ - if (e->type == MOVETO) e = GetClosedBy(e); - return e->prev; -} - -private -PClrVal FindClosestVal(sLst, loc) PClrVal sLst; -Fixed loc; -{ - Fixed dist = FixInt(10000), bot, top, d; - PClrVal best = NULL; - while (sLst != NULL) { - bot = sLst->vLoc1; - top = sLst->vLoc2; - if (bot > top) { - Fixed tmp = bot; - bot = top; - top = tmp; - } - if (loc >= bot && loc <= top) { - best = sLst; - break; - } - if (loc < bot) - d = bot - loc; - else - d = loc - top; - if (d < dist) { - dist = d; - best = sLst; - } - sLst = sLst->vNxt; - } - return best; -} - -private -procedure CpyHClr(e) PPathElt e; -{ - Fixed x1, y1; - PClrVal best; - GetEndPoint(e, &x1, &y1); - best = FindClosestVal(Hprimary, y1); - if (best != NULL) - AddHPair(best, 'b'); -} - -private -procedure CpyVClr(e) PPathElt e; -{ - Fixed x1, y1; - PClrVal best; - GetEndPoint(e, &x1, &y1); - best = FindClosestVal(Vprimary, x1); - if (best != NULL) - AddVPair(best, 'y'); -} - -private -procedure PruneColorSegs(e, hFlg) PPathElt e; -boolean hFlg; -{ - PSegLnkLst lst, nxt, prv; - PSegLnk lnk; - PClrSeg seg; - PClrVal val; - lst = hFlg ? e->Hs : e->Vs; - prv = NULL; - while (lst != NULL) { - val = NULL; - lnk = lst->lnk; - if (lnk != NULL) { - seg = lnk->seg; - if (seg != NULL) val = seg->sLnk; - } - nxt = lst->next; - if (val == NULL) { /* prune this one */ - if (prv == NULL) { - if (hFlg) - e->Hs = nxt; - else - e->Vs = nxt; - } else - prv->next = nxt; - lst = nxt; - } else { - prv = lst; - lst = nxt; - } - } -} - -public -procedure PruneElementColorSegs() { - register PPathElt e; - e = pathStart; - while (e != NULL) { - PruneColorSegs(e, TRUE); - PruneColorSegs(e, FALSE); - e = e->next; - } -} - -#define ElmntClrSegLst(e, hFlg) (hFlg) ? (e)->Hs : (e)->Vs - -private -procedure RemLnk(e, hFlg, rm) - PPathElt e; -boolean hFlg; -PSegLnkLst rm; -{ - PSegLnkLst lst, prv, nxt; - lst = hFlg ? e->Hs : e->Vs; - prv = NULL; - while (lst != NULL) { - nxt = lst->next; - if (lst == rm) { - if (prv == NULL) { - if (hFlg) - e->Hs = nxt; - else - e->Vs = nxt; - } else - prv->next = nxt; - return; - } - prv = lst; - lst = nxt; - } - FlushLogFiles(); - sprintf(globmsg, "Badly formatted segment list in file: %s.\n", fileName); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); -} - -private -boolean AlreadyOnList(v, lst) register PClrVal v, lst; -{ - while (lst != NULL) { - if (v == lst) return TRUE; - lst = lst->vNxt; - } - return FALSE; -} - -private -procedure AutoVSeg(sLst) PClrVal sLst; -{ - AddVPair(sLst, 'y'); -} - -private -procedure AutoHSeg(sLst) PClrVal sLst; -{ - AddHPair(sLst, 'b'); -} - -private -procedure AddHColoring(h) PClrVal h; -{ - if (useH || AlreadyOnList(h, Hcoloring)) return; - h->vNxt = Hcoloring; - Hcoloring = h; - AutoHSeg(h); -} - -private -procedure AddVColoring(v) PClrVal v; -{ - if (useV || AlreadyOnList(v, Vcoloring)) return; - v->vNxt = Vcoloring; - Vcoloring = v; - AutoVSeg(v); -} - -private -integer TestColor(s, colorList, flg, doLst) - PClrSeg s; -PClrVal colorList; -boolean flg, doLst; -{ - /* -1 means already in colorList; 0 means conflicts; 1 means ok to add */ - PClrVal v, clst; - Fixed top, bot, cTop, cBot, vT, vB, loc, abstmp; - boolean loc1; - if (s == NULL) return -1L; - v = s->sLnk; - loc = s->sLoc; - if (v == NULL) return -1L; - vT = top = v->vLoc2; - vB = bot = v->vLoc1; - if (v->vGhst) { /* collapse width for conflict test */ - if (v->vSeg1->sType == sGHOST) - bot = top; - else - top = bot; - } - if (DEBUG) { - integer cnt = 0; - clst = colorList; - while (clst != NULL) { - if (++cnt > 100) { - LogMsg("Loop in hintlist for TestHint\n\007", WARNING, OK, TRUE); - return 0L; - } - clst = clst->vNxt; - } - } - if (v->vGhst) { - /* if best value for segment uses a ghost, and - segment loc is already in the colorList, then return -1 */ - clst = colorList; - if (ac_abs(loc - vT) < ac_abs(loc - vB)) { - loc1 = FALSE; - loc = vT; - } else { - loc1 = TRUE; - loc = vB; - } - while (clst != NULL) { - if ((loc1 ? clst->vLoc1 : clst->vLoc2) == loc) - return -1; - clst = clst->vNxt; - if (!doLst) break; - } - } - if (flg) { - top += bandMargin; - bot -= bandMargin; - } else { - top -= bandMargin; - bot += bandMargin; - } - while (colorList != NULL) { /* check for conflict */ - cTop = colorList->vLoc2; - cBot = colorList->vLoc1; - if (vB == cBot && vT == cTop) { - return -1L; - } - if (colorList->vGhst) { /* collapse width for conflict test */ - if (colorList->vSeg1->sType == sGHOST) - cBot = cTop; - else - cTop = cBot; - } - if ((flg && (cBot <= top) && (cTop >= bot)) || - (!flg && (cBot >= top) && (cTop <= bot))) { - return 0L; - } - colorList = colorList->vNxt; - if (!doLst) break; - } - return 1L; -} - -#define TestHColorLst(h) TestColorLst(h, Hcoloring, YgoesUp, TRUE) -#define TestVColorLst(v) TestColorLst(v, Vcoloring, TRUE, TRUE) - -public -int TestColorLst(lst, colorList, flg, doLst) - PSegLnkLst lst; -PClrVal colorList; -boolean flg, doLst; -{ - /* -1 means already in colorList; 0 means conflicts; 1 means ok to add */ - int result, i, cnt; - result = -1; - cnt = 0; - while (lst != NULL) { - i = TestColor(lst->lnk->seg, colorList, flg, doLst); - if (i == 0) { - result = 0; - break; - } - if (i == 1) result = 1L; - lst = lst->next; - if (++cnt > 100) { - LogMsg("Looping in TestHintLst\007\n", WARNING, OK, TRUE); - return 0L; - } - } - return result; -} - -#define FixedMidPoint(m, a, b) \ - (m).x = ((a).x + (b).x) >> 1; \ - (m).y = ((a).y + (b).y) >> 1 - -#define FixedBezDiv(a0, a1, a2, a3, b0, b1, b2, b3) \ - FixedMidPoint(b2, a2, a3); \ - FixedMidPoint(a3, a1, a2); \ - FixedMidPoint(a1, a0, a1); \ - FixedMidPoint(a2, a1, a3); \ - FixedMidPoint(b1, a3, b2); \ - FixedMidPoint(a3, a2, b1); - -public -boolean ResolveConflictBySplit(e, Hflg, lnk1, lnk2) register PPathElt e; -boolean Hflg; -PSegLnkLst lnk1, lnk2; -{ - /* insert new pathelt immediately following e */ - /* e gets first half of split; new gets second */ - /* e gets lnk1 in Hs or Vs; new gets lnk2 */ - register PPathElt new; - Cd d0, d1, d2, d3, d4, d5, d6, d7; - if (e->type != CURVETO || e->isFlex) return FALSE; - ReportSplit(e); - new = (PPathElt)Alloc(sizeof(PathElt)); - new->next = e->next; - e->next = new; - new->prev = e; - if (new->next == NULL) - pathEnd = new; - else - new->next->prev = new; - if (Hflg) { - e->Hs = lnk1; - new->Hs = lnk2; - } else { - e->Vs = lnk1; - new->Vs = lnk2; - } - if (lnk1 != NULL) lnk1->next = NULL; - if (lnk2 != NULL) lnk2->next = NULL; - new->type = CURVETO; - GetEndPoint(e->prev, &d0.x, &d0.y); - d1.x = e->x1; - d1.y = e->y1; - d2.x = e->x2; - d2.y = e->y2; - d3.x = e->x3; - d3.y = e->y3; - d4 = d0; - d5 = d1; - d6 = d2; - d7 = d3; - new->x3 = d3.x; - new->y3 = d3.y; - FixedBezDiv(d4, d5, d6, d7, d0, d1, d2, d3); - e->x1 = d5.x; - e->y1 = d5.y; - e->x2 = d6.x; - e->y2 = d6.y; - e->x3 = d7.x; - e->y3 = d7.y; - new->x1 = d1.x; - new->y1 = d1.y; - new->x2 = d2.x; - new->y2 = d2.y; - return TRUE; -} - -private -procedure RemDupLnks(e, Hflg) PPathElt e; -boolean Hflg; -{ - PSegLnkLst l1, l2, l2nxt; - l1 = Hflg ? e->Hs : e->Vs; - while (l1 != NULL) { - l2 = l1->next; - while (l2 != NULL) { - l2nxt = l2->next; - if (l1->lnk->seg == l2->lnk->seg) - RemLnk(e, Hflg, l2); - l2 = l2nxt; - } - l1 = l1->next; - } -} - -#define OkToRemLnk(loc, Hflg, spc) \ - (!(Hflg) || (spc) == 0 || \ - (!InBlueBand((loc), lenTopBands, topBands) && \ - !InBlueBand((loc), lenBotBands, botBands))) - -/* The changes made here were to fix a problem in MinisterLight/E. - The top left point was not getting colored. */ -private -boolean TryResolveConflict(e, Hflg) - PPathElt e; -boolean Hflg; -{ - integer typ; - PSegLnkLst lst, lnk1, lnk2; - PClrSeg seg, seg1, seg2; - PClrVal val1, val2; - Fixed lc1, lc2, loc0, loc1, loc2, loc3, x0, y0, x1, y1, abstmp; - RemDupLnks(e, Hflg); - typ = e->type; - if (typ == MOVETO) - GetEndPoints(GetClosedBy(e), &x0, &y0, &x1, &y1); - else if (typ == CURVETO) { - x0 = e->x1; - y0 = e->y1; - x1 = e->x3; - y1 = e->y3; - } else - GetEndPoints(e, &x0, &y0, &x1, &y1); - loc1 = Hflg ? y0 : x0; - loc2 = Hflg ? y1 : x1; - lst = Hflg ? e->Hs : e->Vs; - seg1 = lst->lnk->seg; - lc1 = seg1->sLoc; - lnk1 = lst; - lst = lst->next; - seg2 = lst->lnk->seg; - lc2 = seg2->sLoc; - lnk2 = lst; - if (lc1 == loc1 || lc2 == loc2) { - } else if (ac_abs(lc1 - loc1) > ac_abs(lc1 - loc2) || - ac_abs(lc2 - loc2) > ac_abs(lc2 - loc1)) { - seg = seg1; - seg1 = seg2; - seg2 = seg; - lst = lnk1; - lnk1 = lnk2; - lnk2 = lst; - } - val1 = seg1->sLnk; - val2 = seg2->sLnk; - if (val1->vVal < FixInt(50) && OkToRemLnk(loc1, Hflg, val1->vSpc)) { - RemLnk(e, Hflg, lnk1); - if (showClrInfo) ReportRemConflict(e); - return TRUE; - } - if (val2->vVal < FixInt(50) && val1->vVal > val2->vVal * 20L && - OkToRemLnk(loc2, Hflg, val2->vSpc)) { - RemLnk(e, Hflg, lnk2); - if (showClrInfo) ReportRemConflict(e); - return TRUE; - } - if (typ != CURVETO || - ((((Hflg && IsHorizontal(x0, y0, x1, y1)) || - (!Hflg && IsVertical(x0, y0, x1, y1)))) && - OkToRemLnk(loc1, Hflg, val1->vSpc))) { - RemLnk(e, Hflg, lnk1); - if (showClrInfo) ReportRemConflict(e); - return TRUE; - } - GetEndPoints(GetSubPathPrv(e), &x0, &y0, &x1, &y1); - loc0 = Hflg ? y0 : x0; - if (ProdLt0(loc2 - loc1, loc0 - loc1)) { - RemLnk(e, Hflg, lnk1); - if (showClrInfo) ReportRemConflict(e); - return TRUE; - } - GetEndPoint(GetSubPathNxt(e), &x1, &y1); - loc3 = Hflg ? y1 : x1; - if (ProdLt0(loc3 - loc2, loc1 - loc2)) { - RemLnk(e, Hflg, lnk2); - if (showClrInfo) ReportRemConflict(e); - return TRUE; - } - if ((loc2 == val2->vLoc1 || loc2 == val2->vLoc2) && - loc1 != val1->vLoc1 && loc1 != val1->vLoc2) { - RemLnk(e, Hflg, lnk1); - if (showClrInfo) ReportRemConflict(e); - return TRUE; - } - if ((loc1 == val1->vLoc1 || loc1 == val1->vLoc2) && - loc2 != val2->vLoc1 && loc2 != val2->vLoc2) { - RemLnk(e, Hflg, lnk2); - if (showClrInfo) ReportRemConflict(e); - return TRUE; - } - if (editChar && ResolveConflictBySplit(e, Hflg, lnk1, lnk2)) - return TRUE; - else - return FALSE; -} - -private -boolean CheckColorSegs(PPathElt e, boolean flg, boolean Hflg) { - PSegLnkLst lst; - PSegLnkLst lst2; - PClrSeg seg; - PClrVal val; - lst = Hflg ? e->Hs : e->Vs; - while (lst != NULL) { - lst2 = lst->next; - if (lst2 != NULL) { - seg = lst->lnk->seg; - val = seg->sLnk; - if (val != NULL && TestColorLst(lst2, val, flg, FALSE) == 0) { - if (TryResolveConflict(e, Hflg)) - return CheckColorSegs(e, flg, Hflg); - AskForSplit(e); - if (Hflg) - e->Hs = NULL; - else - e->Vs = NULL; - return TRUE; - } - } - lst = lst2; - } - return FALSE; -} - -private -procedure CheckElmntClrSegs() { - PPathElt e; - e = pathStart; - while (e != NULL) { - if (!CheckColorSegs(e, YgoesUp, TRUE)) - (void)CheckColorSegs(e, TRUE, FALSE); - e = e->next; - } -} -private -boolean ClrLstsClash(lst1, lst2, flg) - PSegLnkLst lst1, - lst2; -boolean flg; -{ - PClrSeg seg; - PClrVal val; - PSegLnkLst lst; - while (lst1 != NULL) { - seg = lst1->lnk->seg; - val = seg->sLnk; - if (val != NULL) { - lst = lst2; - while (lst != NULL) { - if (TestColorLst(lst, val, flg, FALSE) == 0) { - return TRUE; - } - lst = lst->next; - } - } - lst1 = lst1->next; - } - return FALSE; -} - -private -PSegLnkLst BestFromLsts(lst1, lst2) PSegLnkLst lst1, lst2; -{ - PSegLnkLst lst, bst; - PClrSeg seg; - PClrVal val; - Fixed bstval; - integer i; - bst = NULL; - bstval = 0; - for (i = 0; i < 2; i++) { - lst = i ? lst1 : lst2; - while (lst != NULL) { - seg = lst->lnk->seg; - val = seg->sLnk; - if (val != NULL && val->vVal > bstval) { - bst = lst; - bstval = val->vVal; - } - lst = lst->next; - } - } - return bst; -} - -private -boolean ClrsClash(e, p, hLst, vLst, phLst, pvLst) - PPathElt e, - p; -PSegLnkLst *hLst, *vLst, *phLst, *pvLst; -{ - boolean clash = FALSE; - PSegLnkLst bst, new; - if (ClrLstsClash(*hLst, *phLst, YgoesUp)) { - clash = TRUE; - bst = BestFromLsts(*hLst, *phLst); - if (bst) { - new = (PSegLnkLst)Alloc(sizeof(SegLnkLst)); - new->next = NULL; - new->lnk = bst->lnk; - } else - new = NULL; - e->Hs = p->Hs = *hLst = *phLst = new; - } - if (ClrLstsClash(*vLst, *pvLst, TRUE)) { - clash = TRUE; - bst = BestFromLsts(*vLst, *pvLst); - if (bst) { - new = (PSegLnkLst)Alloc(sizeof(SegLnkLst)); - new->next = NULL; - new->lnk = bst->lnk; - } else - new = NULL; - e->Vs = p->Vs = *vLst = *pvLst = new; - } - return clash; -} - -private -procedure GetColorLsts(e, phLst, pvLst, ph, pv) - PPathElt e; -PSegLnkLst *phLst, *pvLst; -integer *ph, *pv; -{ - PSegLnkLst hLst, vLst; - integer h, v; - if (useH) { - hLst = NULL; - h = -1; - } else { - hLst = e->Hs; - if (hLst == NULL) - h = -1; - else - h = TestHColorLst(hLst); - } - if (useV) { - vLst = NULL; - v = -1; - } else { - vLst = e->Vs; - if (vLst == NULL) - v = -1; - else - v = TestVColorLst(vLst); - } - *pvLst = vLst; - *phLst = hLst; - *ph = h; - *pv = v; -} - -private -procedure ReClrBounds(e) PPathElt e; -{ - if (!useH) { - if (clrHBounds && Hcoloring == NULL && !haveHBnds) - ReClrHBnds(); - else if (!clrBBox) { - if (Hcoloring == NULL) CpyHClr(e); - if (mergeMain) MergeFromMainColors('b'); - } - } - if (!useV) { - if (clrVBounds && Vcoloring == NULL && !haveVBnds) - ReClrVBnds(); - else if (!clrBBox) { - if (Vcoloring == NULL) CpyVClr(e); - if (mergeMain) MergeFromMainColors('y'); - } - } -} - -private -procedure AddColorLst(lst, vert) PSegLnkLst lst; -boolean vert; -{ - PClrVal val; - PClrSeg seg; - while (lst != NULL) { - seg = lst->lnk->seg; - val = seg->sLnk; - if (vert) - AddVColoring(val); - else - AddHColoring(val); - lst = lst->next; - } -} - -private -procedure StartNewColoring(e, hLst, vLst) - PPathElt e; -PSegLnkLst hLst, vLst; -{ - ReClrBounds(e); - if (e->newcolors != 0) { - FlushLogFiles(); - sprintf(globmsg, "Uninitialized extra hints list in file: %s.\n", fileName); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - XtraClrs(e); - clrBBox = FALSE; - if (useV) CopyMainV(); - if (useH) CopyMainH(); - Hcoloring = Vcoloring = NULL; - if (!useH) AddColorLst(hLst, FALSE); - if (!useV) AddColorLst(vLst, TRUE); -} - -private -boolean IsIn(h, v) integer h, v; -{ - return (h == -1 && v == -1); -} - -private -boolean IsOk(h, v) integer h, v; -{ - return (h != 0 && v != 0); -} - -#define AddIfNeedV(v, vLst) \ - if (!useV && v == 1) AddColorLst(vLst, TRUE) -#define AddIfNeedH(h, hLst) \ - if (!useH && h == 1) AddColorLst(hLst, FALSE) - -private -procedure SetHColors(lst) PClrVal lst; -{ - if (useH) return; - Hcoloring = lst; - while (lst != NULL) { - AutoHSeg(lst); - lst = lst->vNxt; - } -} - -private -procedure SetVColors(lst) PClrVal lst; -{ - if (useV) return; - Vcoloring = lst; - while (lst != NULL) { - AutoVSeg(lst); - lst = lst->vNxt; - } -} - -public -PClrVal CopyClrs(lst) PClrVal lst; -{ - PClrVal v, vlst; - int cnt; - vlst = NULL; - cnt = 0; - while (lst != NULL) { - v = (PClrVal)Alloc(sizeof(ClrVal)); - *v = *lst; - v->vNxt = vlst; - vlst = v; - if (++cnt > 100) { - LogMsg("Loop in CopyClrs\007\n", WARNING, OK, TRUE); - return vlst; - } - lst = lst->vNxt; - } - return vlst; -} - -private -PPathElt ColorBBox(e) PPathElt e; -{ - e = FindSubpathBBox(e); - ClrBBox(); - clrBBox = TRUE; - return e; -} - -private -boolean IsFlare(loc, e, n, Hflg) Fixed loc; -PPathElt e, n; -boolean Hflg; -{ - Fixed x, y, abstmp; - while (e != n) { - GetEndPoint(e, &x, &y); - if ((Hflg && ac_abs(y - loc) > maxFlare) || (!Hflg && ac_abs(x - loc) > maxFlare)) - return FALSE; - e = GetSubPathNxt(e); - } - return TRUE; -} - -private -boolean IsTopSegOfVal(loc, top, bot) Fixed loc, top, bot; -{ - Fixed d1, d2, abstmp; - d1 = top - loc; - d2 = bot - loc; - return (ac_abs(d1) <= ac_abs(d2)) ? TRUE : FALSE; -} - -private -procedure RemFlareLnk(e, hFlg, rm, e2, i) - PPathElt e, - e2; -boolean hFlg; -PSegLnkLst rm; -integer i; -{ - RemLnk(e, hFlg, rm); - if (showClrInfo) ReportRemFlare(e, e2, hFlg, i); -} - -public -boolean CompareValues(val1, val2, factor, ghstshift) register PClrVal val1, val2; -integer factor, ghstshift; -{ - register Fixed v1 = val1->vVal, v2 = val2->vVal, mx; - mx = v1 > v2 ? v1 : v2; - mx <<= 1; - while (mx > 0) { - mx <<= 1; - v1 <<= 1; - v2 <<= 1; - } - if (ghstshift > 0 && val1->vGhst != val2->vGhst) { - if (val1->vGhst) v1 >>= ghstshift; - if (val2->vGhst) v2 >>= ghstshift; - } - if ((val1->vSpc > 0 && val2->vSpc > 0) || - (val1->vSpc == 0 && val2->vSpc == 0)) - return v1 > v2; - if (val1->vSpc > 0L) - return (v1 < FixedPosInf / factor) ? (v1 * factor > v2) : (v1 > v2 / factor); - return (v2 < FixedPosInf / factor) ? (v1 > v2 * factor) : (v1 / factor > v2); -} - -private -procedure RemFlares(Hflg) boolean Hflg; -{ - PSegLnkLst lst1, lst2, nxt1, nxt2; - PPathElt e, n; - PClrSeg seg1, seg2; - PClrVal val1, val2; - Fixed diff, abstmp; - boolean nxtE; - boolean Nm1, Nm2; - if (Hflg) { - Nm1 = TRUE; - Nm2 = FALSE; - } else { - Nm1 = FALSE; - Nm2 = TRUE; - } - e = pathStart; - while (e != NULL) { - if (Nm1 ? e->Hs == NULL : e->Vs == NULL) { - e = e->next; - continue; - } - /* e now is an element with Nm1 prop */ - n = GetSubPathNxt(e); - nxtE = FALSE; - while (n != e && !nxtE) { - if (Nm1 ? n->Hs != NULL : n->Vs != NULL) { - lst1 = ElmntClrSegLst(e, Nm1); - while (lst1 != NULL) { - seg1 = lst1->lnk->seg; - nxt1 = lst1->next; - lst2 = ElmntClrSegLst(n, Nm1); - while (lst2 != NULL) { - seg2 = lst2->lnk->seg; - nxt2 = lst2->next; - if (seg1 != NULL && seg2 != NULL) { - diff = seg1->sLoc - seg2->sLoc; - if (ac_abs(diff) > maxFlare) { - nxtE = TRUE; - goto Nxt2; - } - if (!IsFlare(seg1->sLoc, e, n, Hflg)) { - nxtE = TRUE; - goto Nxt2; - } - val1 = seg1->sLnk; - val2 = seg2->sLnk; - if (diff != 0 && - IsTopSegOfVal(seg1->sLoc, val1->vLoc2, val1->vLoc1) == - IsTopSegOfVal(seg2->sLoc, val2->vLoc2, val2->vLoc1)) { - if (CompareValues(val1, val2, spcBonus, 0L)) { - /* This change was made to fix flares in Bodoni2. */ - if (val2->vSpc == 0 && val2->vVal < FixInt(1000)) - RemFlareLnk(n, Nm1, lst2, e, 1); - } else if (val1->vSpc == 0 && val1->vVal < FixInt(1000)) { - RemFlareLnk(e, Nm1, lst1, n, 2); - goto Nxt1; - } - } - } - Nxt2: - lst2 = nxt2; - } - Nxt1: - lst1 = nxt1; - } - } - if (Nm2 ? n->Hs != NULL : n->Vs != NULL) break; - n = GetSubPathNxt(n); - } - e = e->next; - } -} - -private -procedure CarryIfNeed(loc, vert, clrs) - PClrVal clrs; -Fixed loc; -boolean vert; -{ - PClrSeg seg; - PClrVal seglnk; - Fixed l0, l1, tmp, halfMargin; - if ((vert && useV) || (!vert && useH)) return; - halfMargin = FixHalfMul(bandMargin); - /* DEBUG 8 BIT. Needed to double test from 10 to 20 for change in coordinate system */ - if (halfMargin > FixInt(20)) halfMargin = FixInt(20); - while (clrs != NULL) { - seg = clrs->vSeg1; - if (clrs->vGhst && seg->sType == sGHOST) seg = clrs->vSeg2; - if (seg == NULL) goto Nxt; - l0 = clrs->vLoc2; - l1 = clrs->vLoc1; - if (l0 > l1) { - tmp = l1; - l1 = l0; - l0 = tmp; - } - l0 -= halfMargin; - l1 += halfMargin; - if (loc > l0 && loc < l1) { - seglnk = seg->sLnk; - seg->sLnk = clrs; - if (vert) { - if (TestColor(seg, Vcoloring, TRUE, TRUE) == 1) { - if (showClrInfo) - ReportCarry(l0, l1, loc, clrs, vert); - AddVColoring(clrs); - seg->sLnk = seglnk; - break; - } - } else if (TestColor(seg, Hcoloring, YgoesUp, TRUE) == 1) { - if (showClrInfo) - ReportCarry(l0, l1, loc, clrs, vert); - AddHColoring(clrs); - seg->sLnk = seglnk; - break; - } - seg->sLnk = seglnk; - } - Nxt: - clrs = clrs->vNxt; - } -} - -#define PRODIST (FixInt(100)) /* DEBUG 8 BIT. Needed to double test from 50 to 100 for change in coordinate system */ -private -procedure ProClrs(e, hFlg, loc) - PPathElt e; -Fixed loc; -boolean hFlg; -{ - PSegLnkLst lst, plst; - PPathElt prv; - Fixed cx, cy, dst, abstmp; - lst = ElmntClrSegLst(e, hFlg); - if (lst == NULL) return; - if (hFlg ? e->Hcopy : e->Vcopy) return; - prv = e; - while (TRUE) { - prv = GetSubPathPrv(prv); - plst = ElmntClrSegLst(prv, hFlg); - if (plst != NULL) return; - GetEndPoint(prv, &cx, &cy); - dst = (hFlg ? cy : cx) - loc; - if (ac_abs(dst) > PRODIST) return; - if (hFlg) { - prv->Hs = lst; - prv->Hcopy = TRUE; - } else { - prv->Vs = lst; - prv->Vcopy = TRUE; - } - } -} - -private -procedure PromoteColors() { - PPathElt e; - Fixed cx, cy; - e = pathStart; - while (e != NULL) { - GetEndPoint(e, &cx, &cy); - ProClrs(e, TRUE, cy); - ProClrs(e, FALSE, cx); - e = e->next; - } -} - -private -procedure RemPromotedClrs() { - PPathElt e; - e = pathStart; - while (e != NULL) { - if (e->Hcopy) { - e->Hs = NULL; - e->Hcopy = FALSE; - } - if (e->Vcopy) { - e->Vs = NULL; - e->Vcopy = FALSE; - } - e = e->next; - } -} - -private -procedure RemShortColors() { - /* Must not change colors at a short element. */ - PPathElt e; - Fixed cx, cy, ex, ey, abstmp; - e = pathStart; - cx = 0; - cy = 0; - while (e != NULL) { - GetEndPoint(e, &ex, &ey); - if (ac_abs(cx - ex) < minColorElementLength && - ac_abs(cy - ey) < minColorElementLength) { - if (showClrInfo) ReportRemShortColors(ex, ey); - e->Hs = NULL; - e->Vs = NULL; - } - e = e->next; - cx = ex; - cy = ey; - } -} - -public -procedure AutoExtraColors(movetoNewClrs, soleol, solWhere) - boolean movetoNewClrs, - soleol; -integer solWhere; -{ - integer h, v, ph, pv; - PPathElt e, cp, p; - integer etype; - PSegLnkLst hLst, vLst, phLst, pvLst; - PClrVal mtVclrs, mtHclrs, prvHclrs, prvVclrs; - - boolean (*Tst)(), newClrs = TRUE; - boolean isSpc; - Fixed x, y; - - isSpc = clrBBox = clrVBounds = clrHBounds = FALSE; - mergeMain = (CountSubPaths() <= 5); - e = pathStart; - if (AutoExtraDEBUG) PrintMessage("RemFlares"); - RemFlares(TRUE); - RemFlares(FALSE); - if (AutoExtraDEBUG) PrintMessage("CheckElmntClrSegs"); - CheckElmntClrSegs(); - if (AutoExtraDEBUG) PrintMessage("PromoteColors"); - PromoteColors(); - if (AutoExtraDEBUG) PrintMessage("RemShortColors"); - RemShortColors(); - haveVBnds = clrVBounds; - haveHBnds = clrHBounds; - p = NULL; - Tst = IsOk; /* it is ok to add to primary coloring */ - if (AutoExtraDEBUG) PrintMessage("color loop"); - mtVclrs = mtHclrs = NULL; - while (e != NULL) { - etype = e->type; - if (movetoNewClrs && etype == MOVETO) { - StartNewColoring(e, (PSegLnkLst)NULL, (PSegLnkLst)NULL); - Tst = IsOk; - } - if (soleol && etype == MOVETO) { /* start new coloring on soleol mt */ - if ((solWhere == 1 && IsUpper(e)) || - (solWhere == -1 && IsLower(e)) || - (solWhere == 0)) { /* color bbox of next subpath */ - StartNewColoring(e, (PSegLnkLst)NULL, (PSegLnkLst)NULL); - Tst = IsOk; - haveHBnds = haveVBnds = isSpc = TRUE; - e = ColorBBox(e); - continue; - } else if (isSpc) { /* new coloring after the special */ - StartNewColoring(e, (PSegLnkLst)NULL, (PSegLnkLst)NULL); - Tst = IsOk; - haveHBnds = haveVBnds = isSpc = FALSE; - } - } - if (newClrs && e == p) { - StartNewColoring(e, (PSegLnkLst)NULL, (PSegLnkLst)NULL); - SetHColors(mtHclrs); - SetVColors(mtVclrs); - Tst = IsIn; - } - GetColorLsts(e, &hLst, &vLst, &h, &v); - if (etype == MOVETO && IsShort(cp = GetClosedBy(e))) { - GetColorLsts(p = cp->prev, &phLst, &pvLst, &ph, &pv); - if (ClrsClash(e, p, &hLst, &vLst, &phLst, &pvLst)) { - GetColorLsts(e, &hLst, &vLst, &h, &v); - GetColorLsts(p, &phLst, &pvLst, &ph, &pv); - } - if (!(*Tst)(ph, pv) || !(*Tst)(h, v)) { - StartNewColoring(e, hLst, vLst); - Tst = IsOk; - ph = pv = 1; /* force add of colors for p also */ - } else { - AddIfNeedH(h, hLst); - AddIfNeedV(v, vLst); - } - AddIfNeedH(ph, phLst); - AddIfNeedV(pv, pvLst); - newClrs = FALSE; /* so can tell if added new colors in subpath */ - } else if (!(*Tst)(h, v)) { /* e needs new coloring */ - if (etype == CLOSEPATH) { /* do not attach extra colors to closepath */ - e = e->prev; - GetColorLsts(e, &hLst, &vLst, &h, &v); - } - prvHclrs = CopyClrs(Hcoloring); - prvVclrs = CopyClrs(Vcoloring); - if (!newClrs) { /* this is the first extra since mt */ - newClrs = TRUE; - mtVclrs = CopyClrs(prvVclrs); - mtHclrs = CopyClrs(prvHclrs); - } - StartNewColoring(e, hLst, vLst); - Tst = IsOk; - if (etype == CURVETO) { - x = e->x1; - y = e->y1; - } else - GetEndPoint(e, &x, &y); - CarryIfNeed(y, FALSE, prvHclrs); - CarryIfNeed(x, TRUE, prvVclrs); - } else { /* do not need to start new coloring */ - AddIfNeedH(h, hLst); - AddIfNeedV(v, vLst); - } - e = e->next; - } - ReClrBounds(pathEnd); - if (AutoExtraDEBUG) PrintMessage("RemPromotedClrs"); - RemPromotedClrs(); - if (AutoExtraDEBUG) PrintMessage("done autoextracolors"); -} diff --git a/c/autohint/autohintlib/source/ac/bbox.c b/c/autohint/autohintlib/source/ac/bbox.c deleted file mode 100644 index 2fac46584..000000000 --- a/c/autohint/autohintlib/source/ac/bbox.c +++ /dev/null @@ -1,445 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* bbox.c */ - -#include "ac.h" -#include "bftoac.h" -#include "machinedep.h" - -private -Fixed xmin, ymin, xmax, ymax, vMn, vMx, hMn, hMx; -private -PPathElt pxmn, pxmx, pymn, pymx, pe, pvMn, pvMx, phMn, phMx; - -private -procedure FPBBoxPt(c) Cd c; -{ - if (c.x < xmin) { - xmin = c.x; - pxmn = pe; - } - if (c.x > xmax) { - xmax = c.x; - pxmx = pe; - } - if (c.y < ymin) { - ymin = c.y; - pymn = pe; - } - if (c.y > ymax) { - ymax = c.y; - pymx = pe; - } -} - -private -procedure FindPathBBox() { - FltnRec fr; - register PPathElt e; - Cd c0, c1, c2, c3; - if (pathStart == NULL) { - xmin = ymin = xmax = ymax = 0; - pxmn = pxmx = pymn = pymx = NULL; - return; - } - fr.report = FPBBoxPt; - xmin = ymin = FixInt(10000); - xmax = ymax = -xmin; - e = pathStart; - while (e != NULL) { - switch (e->type) { - case MOVETO: - case LINETO: - c0.x = e->x; - c0.y = e->y; - pe = e; - FPBBoxPt(c0); - break; - case CURVETO: - c1.x = e->x1; - c1.y = e->y1; - c2.x = e->x2; - c2.y = e->y2; - c3.x = e->x3; - c3.y = e->y3; - pe = e; - FltnCurve(c0, c1, c2, c3, &fr); - c0 = c3; - break; - case CLOSEPATH: - break; - default: { - FlushLogFiles(); - sprintf(globmsg, "Undefined operator in %s character.\n", fileName); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - } - e = e->next; - } - xmin = FHalfRnd(xmin); - ymin = FHalfRnd(ymin); - xmax = FHalfRnd(xmax); - ymax = FHalfRnd(ymax); -} - -public -PPathElt FindSubpathBBox(e) PPathElt e; -{ - FltnRec fr; - Cd c0, c1, c2, c3; - if (e == NULL) { - xmin = ymin = xmax = ymax = 0; - pxmn = pxmx = pymn = pymx = NULL; - return NULL; - } - fr.report = FPBBoxPt; - xmin = ymin = FixInt(10000); - xmax = ymax = -xmin; -#if 0 - e = GetDest(e); /* back up to moveto */ -#else - /* This and the following change (in the next else clause) were made - to fix the coloring in characters in the SolEol lists. These are - supposed to have subpath bbox colored, but were getting path bbox - colored instead. */ - if (e->type != MOVETO) e = GetDest(e); /* back up to moveto */ -#endif - while (e != NULL) { - switch (e->type) { - case MOVETO: - case LINETO: - c0.x = e->x; - c0.y = e->y; - pe = e; - FPBBoxPt(c0); - break; - case CURVETO: - c1.x = e->x1; - c1.y = e->y1; - c2.x = e->x2; - c2.y = e->y2; - c3.x = e->x3; - c3.y = e->y3; - pe = e; - FltnCurve(c0, c1, c2, c3, &fr); - c0 = c3; - break; - case CLOSEPATH: -#if 0 - break; -#else - e = e->next; - goto done; -#endif - default: { - FlushLogFiles(); - sprintf(globmsg, "Undefined operator in %s character.\n", fileName); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - } - e = e->next; - } -#if 1 -done: -#endif - xmin = FHalfRnd(xmin); - ymin = FHalfRnd(ymin); - xmax = FHalfRnd(xmax); - ymax = FHalfRnd(ymax); - return e; -} - -public -procedure FindCurveBBox( - x0, y0, px1, py1, px2, py2, x1, y1, pllx, plly, purx, pury) - Fixed x0, - y0, px1, py1, px2, py2, x1, y1, *pllx, *plly, *purx, *pury; -{ - FltnRec fr; - Cd c0, c1, c2, c3; - fr.report = FPBBoxPt; - xmin = ymin = FixInt(10000); - xmax = ymax = -xmin; - c0.x = x0; - c0.y = y0; - c1.x = px1; - c1.y = py1; - c2.x = px2; - c2.y = py2; - c3.x = x1; - c3.y = y1; - FPBBoxPt(c0); - FltnCurve(c0, c1, c2, c3, &fr); - *pllx = FHalfRnd(xmin); - *plly = FHalfRnd(ymin); - *purx = FHalfRnd(xmax); - *pury = FHalfRnd(ymax); -} - -public -procedure ClrVBnds() { - Fixed tmp; - PPathElt p; - if (pathStart == NULL || VColorChar()) return; - FindPathBBox(); - vMn = itfmx(xmin); - vMx = itfmx(xmax); - pvMn = pxmn; - pvMx = pxmx; - if (vMn > vMx) { - tmp = vMn; - vMn = vMx; - vMx = tmp; - p = pvMn; - pvMn = pvMx; - pvMx = p; - } - AddColorPoint(vMn, 0L, vMx, 0L, 'y', pvMn, pvMx); -} - -public -procedure ReClrVBnds() { - AddColorPoint(vMn, 0L, vMx, 0L, 'y', pvMn, pvMx); -} - -public -procedure ClrHBnds() { - Fixed tmp; - PPathElt p; - if (pathStart == NULL || HColorChar()) return; - FindPathBBox(); - hMn = itfmy(ymin); - hMx = itfmy(ymax); - phMn = pymn; - phMx = pymx; - if (hMn > hMx) { - tmp = hMn; - hMn = hMx; - hMx = tmp; - p = phMn; - phMn = phMx; - phMx = p; - } - AddColorPoint(0L, hMn, 0L, hMx, 'b', phMn, phMx); -} - -public -procedure ReClrHBnds() { - AddColorPoint(0L, hMn, 0L, hMx, 'b', phMn, phMx); -} - -private -boolean CheckValOverlaps(lft, rht, lst, xflg) - Fixed lft, - rht; -PClrVal lst; -boolean xflg; -{ - Fixed lft2, rht2, tmp; - if (xflg) { - lft = itfmx(lft); - rht = itfmx(rht); - } else { - lft = itfmy(lft); - rht = itfmy(rht); - } - if (lft > rht) { - tmp = lft; - lft = rht; - rht = tmp; - } - while (lst != NULL) { - lft2 = lst->vLoc1; - rht2 = lst->vLoc2; - if (xflg) { - lft2 = itfmx(lft2); - rht2 = itfmx(rht2); - } else { - lft2 = itfmy(lft2); - rht2 = itfmy(rht2); - } - if (lft2 > rht2) { - tmp = lft2; - lft2 = rht2; - rht2 = tmp; - } - if (lft2 <= rht && lft <= rht2) return TRUE; - lst = lst->vNxt; - } - return FALSE; -} - -public -procedure AddBBoxHV(Hflg, subs) boolean Hflg, subs; -{ - PPathElt e; - PClrVal val; - PClrSeg seg1, seg2; - e = pathStart; - while (e != NULL) { - if (subs) - e = FindSubpathBBox(e); - else { - FindPathBBox(); - e = NULL; - } - if (!Hflg) { - if (!CheckValOverlaps(xmin, xmax, Vcoloring, TRUE)) { - val = (PClrVal)Alloc(sizeof(ClrVal)); - seg1 = (PClrSeg)Alloc(sizeof(ClrSeg)); - seg1->sLoc = xmin; - seg1->sElt = pxmn; - seg1->sBonus = 0; - seg1->sType = sLINE; - seg1->sMin = ymin; - seg1->sMax = ymax; - seg1->sNxt = NULL; - seg1->sLnk = NULL; - seg2 = (PClrSeg)Alloc(sizeof(ClrSeg)); - seg2->sLoc = xmax; - seg2->sElt = pxmx; - seg2->sBonus = 0; - seg2->sType = sLINE; - seg2->sMin = ymin; - seg2->sMax = ymax; - seg2->sNxt = NULL; - seg2->sLnk = NULL; - val->vVal = 100; - val->vSpc = 0; - val->vLoc1 = xmin; - val->vLoc2 = xmax; - val->vSeg1 = seg1; - val->vSeg2 = seg2; - val->vGhst = FALSE; - val->vNxt = Vcoloring; - val->vBst = val; - Vcoloring = val; - } - } else { - if (!CheckValOverlaps(ymin, ymax, Hcoloring, FALSE)) { - val = (PClrVal)Alloc(sizeof(ClrVal)); - seg1 = (PClrSeg)Alloc(sizeof(ClrSeg)); - seg1->sLoc = ymax; - seg1->sElt = pymx; - seg1->sBonus = 0; - seg1->sType = sLINE; - seg1->sMin = xmin; - seg1->sMax = xmax; - seg1->sNxt = NULL; - seg1->sLnk = NULL; - seg2 = (PClrSeg)Alloc(sizeof(ClrSeg)); - seg2->sLoc = ymin; - seg2->sElt = pymn; - seg2->sBonus = 0; - seg2->sType = sLINE; - seg2->sMin = xmin; - seg2->sMax = xmax; - seg2->sNxt = NULL; - seg2->sLnk = NULL; - val->vVal = 100; - val->vSpc = 0; - val->vLoc1 = ymax; /* bot is > top because y axis is reversed */ - val->vLoc2 = ymin; - val->vSeg1 = seg1; - val->vSeg2 = seg2; - val->vGhst = FALSE; - val->vNxt = Hcoloring; - val->vBst = val; - Hcoloring = val; - } - } - } -} - -public -procedure ClrBBox() { - Fixed llx, lly, urx, ury, tmp; - PPathElt p, p0, p1; - if (!useV) { - llx = itfmx(xmin); - urx = itfmx(xmax); - p0 = pxmn; - p1 = pxmx; - if (llx > urx) { - tmp = llx; - llx = urx; - urx = tmp; - p = p0; - p0 = p1; - p1 = p0; - } - AddColorPoint(llx, 0L, urx, 0L, 'y', p0, p1); - } - if (!useH) { - lly = itfmy(ymax); - ury = itfmy(ymin); - p0 = pymx; - p1 = pymn; - if (lly > ury) { - tmp = lly; - lly = ury; - ury = tmp; - p = p0; - p0 = p1; - p1 = p0; - } - AddColorPoint(0L, lly, 0L, ury, 'b', p0, p1); - } -} - -public -procedure CheckPathBBox() { - Fixed llx, lly, urx, ury, tmp; - FindPathBBox(); - llx = itfmx(xmin); - urx = itfmx(xmax); - if (llx > urx) { - tmp = llx; - llx = urx; - urx = tmp; - } - lly = itfmy(ymax); - ury = itfmy(ymin); - if (lly > ury) { - tmp = lly; - lly = ury; - ury = tmp; - } - if (llx < FixInt(-600) || lly < FixInt(-600) || - urx > FixInt(1600) || ury > FixInt(1600)) - ReportBBoxBogus(llx, lly, urx, ury); -} - -public -Fixed GetPathLSB(void) { - Fixed llx, urx, tmp; - FindPathBBox(); - llx = itfmx(xmin); - urx = itfmx(xmax); - if (llx > urx) { - tmp = llx; - llx = urx; - urx = tmp; - } - return (llx); -} - -public -boolean CheckBBoxes(e1, e2) PPathElt e1, e2; -{ - /* return TRUE if e1 and e2 in same subpath or i - the bbox for one is inside the bbox of the other */ - Fixed xmn, xmx, ymn, ymx; - e1 = GetDest(e1); - e2 = GetDest(e2); - if (e1 == e2) return TRUE; /* same subpath */ - FindSubpathBBox(e1); - xmn = xmin; - xmx = xmax; - ymn = ymin; - ymx = ymax; - FindSubpathBBox(e2); - return ((xmn <= xmin && xmax <= xmx && ymn <= ymin && ymax <= ymx) || - (xmn >= xmin && xmax >= xmx && ymn >= ymin && ymax >= ymx)); -} diff --git a/c/autohint/autohintlib/source/ac/bfstub.c b/c/autohint/autohintlib/source/ac/bfstub.c deleted file mode 100644 index b33326579..000000000 --- a/c/autohint/autohintlib/source/ac/bfstub.c +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ - -/* bfstub.c - to resolve otherwise unresolved external references. These need to - be defined because of AC's dependency on filookup, but not on fiblues. */ -#include "ac.h" - -/* Procedures defined in bf/fiblues.c - BuildFont */ -public -boolean checkbandspacing() { - return true; -} - -public -boolean checkbandwidths(overshootptsize, undershoot) float overshootptsize; -boolean undershoot; -{ - return true; -} - -public -int build_bands() { - return true; -} - -public -void SetMasterDir(dirindx) - indx dirindx; -{ -} - -public -void WriteBlendedArray(barray, totalvals, subarraysz, str, dirCount) int *barray; -char *str; -int totalvals, subarraysz; -short dirCount; -{ -} - -boolean multiplemaster = 0; /* AC is never run at the MM level */ diff --git a/c/autohint/autohintlib/source/ac/charprop.c b/c/autohint/autohintlib/source/ac/charprop.c deleted file mode 100644 index 18f224909..000000000 --- a/c/autohint/autohintlib/source/ac/charprop.c +++ /dev/null @@ -1,274 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* charprop.c */ - -#include "ac.h" -#include "machinedep.h" -#if PYTHONLIB -extern char *FL_glyphname; -#endif - -public -char *VColorList[] = { - "m", "M", "T", "ellipsis", NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}; -public -char *HColorList[] = { - "element", "equivalence", "notelement", "divide", NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, - NULL, NULL, NULL, NULL}; - -private -char *UpperSpecialChars[] = { - "questiondown", "exclamdown", "semicolon", NULL}; - -private -char *LowerSpecialChars[] = { - "question", "exclam", "colon", NULL}; - -private -char *NoBlueList[] = { - "at", "bullet", "copyright", "currency", "registered", NULL}; - -private -char *SolEol0List[] = { - "asciitilde", "asterisk", "bullet", "period", "periodcentered", - "colon", "dieresis", - "divide", "ellipsis", "exclam", "exclamdown", "guillemotleft", - "guillemotright", "guilsinglleft", "guilsinglright", "quotesingle", - "quotedbl", "quotedblbase", "quotesinglbase", "quoteleft", - "quoteright", "quotedblleft", "quotedblright", "tilde", NULL}; - -private -char *SolEol1List[] = { - "i", "j", "questiondown", "semicolon", NULL}; - -private -char *SolEolNeg1List[] = {"question", NULL}; - -public -boolean StrEqual(s1, s2) register char *s1, *s2; -{ - register unsigned char c1, c2; - while (TRUE) { - c1 = *s1++; - c2 = *s2++; - if (c1 != c2) return FALSE; - if (c1 == 0 && c2 == 0) return TRUE; - if (c1 == 0 || c2 == 0) return FALSE; - } -} - -extern boolean FindNameInList(nm, lst) char *nm, **lst; -{ - char **l, *lnm; - l = lst; - while (TRUE) { - lnm = *l; - if (lnm == NULL) return FALSE; - if (StrEqual(lnm, nm)) return TRUE; - l++; - } -} - -/* Adds specified characters to CounterColorList array. */ -extern int AddCounterColorChars(charlist, ColorList) char *charlist, *ColorList[]; -{ - const char *setList = "(), \t\n\r"; - char *token; - short length; - boolean firstTime = TRUE; - short ListEntries = COUNTERDEFAULTENTRIES; - - while (TRUE) { - if (firstTime) { - token = (char *)strtok(charlist, setList); - firstTime = FALSE; - } else - token = (char *)strtok(NULL, setList); - if (token == NULL) break; - if (FindNameInList(token, ColorList)) - continue; - /* Currently, ColorList must end with a NULL pointer. */ - if (ListEntries == (COUNTERLISTSIZE - 1)) { - FlushLogFiles(); - sprintf(globmsg, "Exceeded counter hints list size. (maximum is %d.)\n Cannot add %s or subsequent characters.\n", (int)COUNTERLISTSIZE, token); - LogMsg(globmsg, WARNING, OK, TRUE); - break; - } - length = (short)strlen(token); -#if DOMEMCHECK - ColorList[ListEntries] = memck_malloc(length + 1); -#else - ColorList[ListEntries] = AllocateMem(1, length + 1, "counter hints list"); -#endif - strcpy(ColorList[ListEntries++], token); - } - return (ListEntries - COUNTERDEFAULTENTRIES); -} - -public -integer SpecialCharType() { - /* 1 = upper; -1 = lower; 0 = neither */ -#if PYTHONLIB - if (featurefiledata) { - if (FindNameInList(FL_glyphname, UpperSpecialChars)) return 1; - if (FindNameInList(FL_glyphname, LowerSpecialChars)) return -1; - } -#endif - if (FindNameInList(bezGlyphName, UpperSpecialChars)) return 1; - if (FindNameInList(bezGlyphName, LowerSpecialChars)) return -1; - return 0; -} - -public -boolean HColorChar() { -#if PYTHONLIB - if (featurefiledata) { - return FindNameInList(FL_glyphname, HColorList); - } -#endif - return FindNameInList(bezGlyphName, HColorList); -} - -public -boolean VColorChar() { -#if PYTHONLIB - if (featurefiledata) { - return FindNameInList(FL_glyphname, VColorList); - } -#endif - return FindNameInList(bezGlyphName, VColorList); -} - -public -boolean NoBlueChar() { -#if PYTHONLIB - if (featurefiledata) { - return FindNameInList(FL_glyphname, NoBlueList); - } -#endif - return FindNameInList(bezGlyphName, NoBlueList); -} - -public -integer SolEolCharCode() { -#if PYTHONLIB - if (featurefiledata) { - if (FindNameInList(FL_glyphname, SolEol0List)) return 0; - if (FindNameInList(FL_glyphname, SolEol1List)) return 1; - if (FindNameInList(FL_glyphname, SolEolNeg1List)) return -1; - } -#endif - if (FindNameInList(bezGlyphName, SolEol0List)) return 0; - if (FindNameInList(bezGlyphName, SolEol1List)) return 1; - if (FindNameInList(bezGlyphName, SolEolNeg1List)) return -1; - return 2; -} - -/* This change was made to prevent bogus sol-eol's. And to prevent - adding sol-eol if there are a lot of subpaths. */ -public -boolean SpecialSolEol() { - integer code = SolEolCharCode(); - integer count; - if (code == 2) return FALSE; - count = CountSubPaths(); - if (code != 0 && count != 2) return FALSE; - if (code == 0 && count > 3) return FALSE; - return TRUE; -} - -private -PPathElt SubpathEnd(e) PPathElt e; -{ - while (TRUE) { - e = e->next; - if (e == NULL) return pathEnd; - if (e->type == MOVETO) return e->prev; - } -} - -private -PPathElt SubpathStart(e) PPathElt e; -{ - while (e != pathStart) { - if (e->type == MOVETO) break; - e = e->prev; - } - return e; -} - -private -PPathElt SolEol(e) PPathElt e; -{ - e = SubpathStart(e); - e->sol = TRUE; - e = SubpathEnd(e); - e->eol = TRUE; - return e; -} - -private -procedure SolEolAll() { - PPathElt e; - e = pathStart->next; - while (e != NULL) { - e = SolEol(e); - e = e->next; - } -} - -private -procedure SolEolUpperOrLower(upper) boolean upper; -{ - PPathElt e, s1, s2; - Fixed x1, y1, s1y, s2y; - boolean s1Upper; - if (pathStart == NULL) return; - e = s1 = pathStart->next; - GetEndPoint(e, &x1, &y1); - s1y = itfmy(y1); - e = SubpathEnd(e); - e = e->next; - if (e == NULL) return; - s2 = e; - GetEndPoint(e, &x1, &y1); - s2y = itfmy(y1); - s1Upper = (s1y > s2y); - if ((upper && s1Upper) || (!upper && !s1Upper)) - (void)SolEol(s1); - else - (void)SolEol(s2); -} - -/* This change was made to prevent bogus sol-eol's. And to prevent - adding sol-eol if there are a lot of subpaths. */ -public -procedure AddSolEol() { - if (pathStart == NULL) return; - if (!SpecialSolEol()) return; - switch (SolEolCharCode()) { - /* 1 means upper, -1 means lower, 0 means all */ - case 0: - SolEolAll(); - break; - case 1: - SolEolUpperOrLower(TRUE); - break; - case -1: - SolEolUpperOrLower(FALSE); - break; - } -} - -public -boolean MoveToNewClrs() { -#if PYTHONLIB - if (featurefiledata) { - return StrEqual(FL_glyphname, "percent") || StrEqual(FL_glyphname, "perthousand"); - } -#endif - return StrEqual(fileName, "percent") || StrEqual(fileName, "perthousand"); -} diff --git a/c/autohint/autohintlib/source/ac/check.c b/c/autohint/autohintlib/source/ac/check.c deleted file mode 100644 index 4eb87b280..000000000 --- a/c/autohint/autohintlib/source/ac/check.c +++ /dev/null @@ -1,811 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* check.c */ - -#include "ac.h" -#include "bftoac.h" -#include "machinedep.h" - -private -boolean xflat, yflat, xdone, ydone, bbquit; -private -integer xstate, ystate, xstart, ystart; -static Fixed x0, cy0, x1, cy1, xloc, yloc; -private -Fixed x, y, xnxt, ynxt; -private -Fixed yflatstartx, yflatstarty, yflatendx, yflatendy; -private -Fixed xflatstarty, xflatstartx, xflatendx, xflatendy; -private -boolean vert, started, reCheckSmooth; -private -Fixed loc, frst, lst, fltnvalue; -private -PPathElt e; -private -boolean forMultiMaster = FALSE, inflPtFound = FALSE; - -#define STARTING (0L) -#define goingUP (1L) -#define goingDOWN (2L) - -/* DEBUG 8 BIT. The SDELTA value must tbe increased by 2 due to change in coordinate system from 7 to 8 bit FIXED fraction. */ - -#define SDELTA (FixInt(8)) -#define SDELTA3 (FixInt(10)) - -private -procedure chkBad() { - reCheckSmooth = ResolveConflictBySplit(e, FALSE, NULL, NULL); - ; -} - -#define GrTan(n, d) (ac_abs(n) * 100L > ac_abs(d) * sCurveTan) -#define LsTan(n, d) (ac_abs(n) * 100L < ac_abs(d) * sCurveTan) - -private -procedure chkYDIR() { - if (y > yloc) { /* going up */ - if (ystate == goingUP) return; - if (ystate == STARTING) - ystart = ystate = goingUP; - else /*if (ystate == goingDOWN)*/ { - if (ystart == goingUP) { - yflatendx = xloc; - yflatendy = yloc; - } else if (!yflat) { - yflatstartx = xloc; - yflatstarty = yloc; - yflat = TRUE; - } - ystate = goingUP; - } - } else if (y < yloc) { /* going down */ - if (ystate == goingDOWN) return; - if (ystate == STARTING) - ystart = ystate = goingDOWN; - else /*if (ystate == goingUP)*/ { - if (ystart == goingDOWN) { - yflatendx = xloc; - yflatendy = yloc; - } else if (!yflat) { - yflatstartx = xloc; - yflatstarty = yloc; - yflat = TRUE; - } - ystate = goingDOWN; - } - } -} - -private -procedure chkYFLAT() { - Fixed abstmp; - if (!yflat) { - if (LsTan(y - yloc, x - xloc)) { - yflat = TRUE; - yflatstartx = xloc; - yflatstarty = yloc; - } - return; - } - if (ystate != ystart) return; - if (GrTan(y - yloc, x - xloc)) { - yflatendx = xloc; - yflatendy = yloc; - ydone = TRUE; - } -} - -private -procedure chkXFLAT() { - Fixed abstmp; - if (!xflat) { - if (LsTan(x - xloc, y - yloc)) { - xflat = TRUE; - xflatstartx = xloc; - xflatstarty = yloc; - } - return; - } - if (xstate != xstart) return; - if (GrTan(x - xloc, y - yloc)) { - xflatendx = xloc; - xflatendy = yloc; - xdone = TRUE; - } -} - -private -procedure chkXDIR() { - if (x > xloc) { /* going up */ - if (xstate == goingUP) return; - if (xstate == STARTING) - xstart = xstate = goingUP; - else /*if (xstate == goingDOWN)*/ { - if (xstart == goingUP) { - xflatendx = xloc; - xflatendy = yloc; - } else if (!xflat) { - xflatstartx = xloc; - xflatstarty = yloc; - xflat = TRUE; - } - xstate = goingUP; - } - } else if (x < xloc) { - if (xstate == goingDOWN) return; - if (xstate == STARTING) - xstart = xstate = goingDOWN; - else /*if (xstate == goingUP)*/ { - if (xstart == goingDOWN) { - xflatendx = xloc; - xflatendy = yloc; - } else if (!xflat) { - xflatstartx = xloc; - xflatstarty = yloc; - xflat = TRUE; - } - xstate = goingDOWN; - } - } -} - -private -procedure chkDT(c) Cd c; -{ - Fixed abstmp; - Fixed loc; - - x = c.x, y = c.y; - ynxt = y; - xnxt = x; - if (!ydone) { - chkYDIR(); - chkYFLAT(); - if (ydone && yflat && - ac_abs(yflatstarty - cy0) > SDELTA && - ac_abs(cy1 - yflatendy) > SDELTA) { - if ((ystart == goingUP && yflatstarty - yflatendy > SDELTA) || - (ystart == goingDOWN && yflatendy - yflatstarty > SDELTA)) { - if (editChar && !forMultiMaster) - chkBad(); - return; - } - if (ac_abs(yflatstartx - yflatendx) > SDELTA3) { - DEBUG_ROUND(yflatstartx); - DEBUG_ROUND(yflatendx); - DEBUG_ROUND(yflatstarty); - DEBUG_ROUND(yflatendy); - - loc = (yflatstarty + yflatendy) / 2; - DEBUG_ROUND(loc); - - if (!forMultiMaster) { - AddHSegment(yflatstartx, yflatendx, loc, - e, (PPathElt)NULL, sCURVE, 13L); - } else { - inflPtFound = TRUE; - fltnvalue = itfmy(loc); - } - } - } - } - if (!xdone) { - chkXDIR(); - chkXFLAT(); - if (xdone && xflat && - ac_abs(xflatstartx - x0) > SDELTA && - ac_abs(x1 - xflatendx) > SDELTA) { - if ((xstart == goingUP && xflatstartx - xflatendx > SDELTA) || - (xstart == goingDOWN && xflatendx - xflatstartx > SDELTA)) { - if (editChar && !forMultiMaster) - chkBad(); - return; - } - if (ac_abs(xflatstarty - xflatendy) > SDELTA3) { - DEBUG_ROUND(xflatstarty); - DEBUG_ROUND(xflatendy); - DEBUG_ROUND(xflatstartx); - DEBUG_ROUND(xflatendx); - - loc = (xflatstartx + xflatendx) / 2; - DEBUG_ROUND(loc); - - if (!forMultiMaster) - - { - AddVSegment(xflatstarty, xflatendy, loc, - e, (PPathElt)NULL, sCURVE, 13L); - } else { - inflPtFound = TRUE; - fltnvalue = itfmx(loc); - } - } - } - } - xloc = xnxt; - yloc = ynxt; -} - -#define FQ(x) ((long int)((x) >> 6)) -private -integer CPDirection(x1, cy1, x2, y2, x3, y3) Fixed x1, cy1, x2, y2, x3, y3; -{ - long int q, q1, q2, q3; - q1 = FQ(x2) * FQ(y3 - cy1); - q2 = FQ(x1) * FQ(y2 - y3); - q3 = FQ(x3) * FQ(cy1 - y2); - q = q1 + q2 + q3; - if (q > 0) return 1L; - if (q < 0) return -1L; - return 0L; -} - -private -PPathElt PointLine(e, whichcp) PPathElt e; -integer whichcp; -{ - PPathElt newline; - if (whichcp == cpCurve1) - whichcp = cpStart; - else if (whichcp == cpCurve2) - whichcp = cpEnd; - if (whichcp == cpEnd && e->type == CLOSEPATH) { - e = GetDest(e); - e = e->next; - whichcp = cpStart; - } - newline = (PPathElt)Alloc(sizeof(PathElt)); - newline->type = LINETO; - if (whichcp == cpStart) { /* insert line in front of e */ - newline->next = e; - newline->prev = e->prev; - if (e == pathStart) { - FlushLogFiles(); - sprintf(globmsg, "Malformed path list (Start) in %s.\n", fileName); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - e->prev->next = newline; - e->prev = newline; - } else { /* add line after e */ - newline->next = e->next; - e->next->prev = newline; - if (e == pathEnd) { - FlushLogFiles(); - sprintf(globmsg, "Malformed path list (End) in %s.\n", fileName); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - e->next = newline; - newline->prev = e; - } - GetEndPoint(newline->prev, &newline->x, &newline->y); - return newline; -} - -private -procedure MovePoint(x, y, e, whichcp) - Fixed x, - y; -PPathElt e; -int whichcp; -{ - if (whichcp == cpStart) { - e = e->prev; - whichcp = cpEnd; - } - if (whichcp == cpEnd) { - if (e->type == CLOSEPATH) e = GetDest(e); - if (e->type == CURVETO) { - e->x3 = x; - e->y3 = y; - } else { - e->x = x; - e->y = y; - } - return; - } - if (whichcp == cpCurve1) { - e->x1 = x; - e->y1 = y; - return; - } - if (whichcp == cpCurve2) { - e->x2 = x; - e->y2 = y; - return; - } - { - FlushLogFiles(); - sprintf(globmsg, "Malformed path list in %s.\n", fileName); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } -} - -public -procedure RMovePoint(dx, dy, whichcp, e) - Fixed dx, - dy; -PPathElt e; -integer whichcp; -{ - if (whichcp == cpStart) { - e = e->prev; - whichcp = cpEnd; - } - if (whichcp == cpEnd) { - if (e->type == CLOSEPATH) e = GetDest(e); - if (e->type == CURVETO) { - e->x3 += dx; - e->y3 += dy; - } else { - e->x += dx; - e->y += dy; - } - return; - } - if (whichcp == cpCurve1) { - e->x1 += dx; - e->y1 += dy; - return; - } - if (whichcp == cpCurve2) { - e->x2 += dx; - e->y2 += dy; - return; - } - { - FlushLogFiles(); - sprintf(globmsg, "Malformed path list in %s.\n", fileName); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } -} - -private -boolean ZeroLength(e) PPathElt e; -{ - Fixed x0, cy0, x1, cy1; - GetEndPoints(e, &x0, &cy0, &x1, &cy1); - return (x0 == x1 && cy0 == cy1); -} - -private -boolean ConsiderClipSharpPoint(rx0, ry0, rx1, ry1, rx2, ry2, e) - Fixed rx0, - ry0, rx1, ry1, rx2, ry2; -PPathElt e; -{ - Fixed x0 = rx0, cy0 = ry0, x1 = rx1, cy1 = ry1, x2 = rx2, y2 = ry2; - Fixed dx0, dy0, dx1, dy1, nlx, nly; - real rdx0, rdx1, rdy0, rdy1; - PPathElt newline; - x0 = itfmx(x0); - x1 = itfmx(x1); - x2 = itfmx(x2); - cy0 = itfmy(cy0); - cy1 = itfmy(cy1); - y2 = itfmy(y2); - dx0 = x1 - x0; - dy0 = cy1 - cy0; - dx1 = x2 - x1; - dy1 = y2 - cy1; - acfixtopflt(dx0, &rdx0); - acfixtopflt(dx1, &rdx1); - acfixtopflt(dy0, &rdy0); - acfixtopflt(dy1, &rdy1); - if (rdx1 * rdy0 < rdx0 * rdy1) return FALSE; - /* clip right turns (point toward inside of character) */ - /* do not clip left turns (point toward outside of character) */ - if (e->type != CLOSEPATH && e->next->type == CLOSEPATH && - ZeroLength(e->next)) - newline = e->next; - else - newline = PointLine(e, cpEnd); /* insert a zero length line */ - GetEndPoint(newline, &nlx, &nly); - (void)NxtForBend(newline, &x1, &cy1, &x2, &y2); - PrvForBend(newline, &x0, &cy0); - /* x0 cy0 is the point before newline */ - /* x1 cy1 is the point after newline */ - /* nlx nly is the location of newline */ - if (cy0 == nly) - MovePoint(nlx, (cy1 > cy0) ? nly + FixOne : nly - FixOne, newline, cpEnd); - else if (cy1 == nly) - MovePoint(nlx, (cy0 > cy1) ? nly + FixOne : nly - FixOne, newline, cpStart); - else if (x0 == nlx) - MovePoint((x1 > x0) ? nlx + FixOne : nlx - FixOne, nly, newline, cpEnd); - else if (x1 == nlx) - MovePoint((x0 > x1) ? nlx + FixOne : nlx - FixOne, nly, newline, cpStart); - else if (ProdGe0(nlx - x0, x1 - nlx)) { /* nlx between x0 and x1 */ - MovePoint((x1 > x0) ? nlx + FixHalf : nlx - FixHalf, nly, newline, cpEnd); - MovePoint((x0 > x1) ? nlx + FixHalf : nlx - FixHalf, nly, newline, cpStart); - } else if (ProdGe0(nly - cy0, cy1 - nly)) { /* nly between cy0 and cy1 */ - MovePoint(nlx, (cy1 > cy0) ? nly + FixHalf : nly - FixHalf, newline, cpEnd); - MovePoint(nlx, (cy0 > cy1) ? nly + FixHalf : nly - FixHalf, newline, cpStart); - } else { - real dydx0, dydx1; - integer wh1, wh2; - dx0 = x0 - nlx; - dy0 = cy0 - nly; - acfixtopflt(dx0, &rdx0); - acfixtopflt(dy0, &rdy0); - dydx0 = rdy0 / rdx0; - if (dydx0 < 0) dydx0 = -dydx0; - dx1 = x1 - nlx; - dy1 = cy1 - nly; - acfixtopflt(dx1, &rdx1); - acfixtopflt(dy1, &rdy1); - dydx1 = rdy1 / rdx1; - if (dydx1 < 0) dydx1 = -dydx1; - if (dydx1 < dydx0) { - wh1 = cpStart; - wh2 = cpEnd; - } else { - wh2 = cpStart; - wh1 = cpEnd; - } - MovePoint(nlx, (dy0 > 0) ? nly + FixOne : nly - FixOne, newline, wh1); - MovePoint((dx0 > 0) ? nlx + FixOne : nlx - FixOne, nly, newline, wh2); - } - return TRUE; -} - -public -procedure Delete(e) PPathElt e; -{ - PPathElt nxt, prv; - nxt = e->next; - prv = e->prev; - if (nxt != NULL) - nxt->prev = prv; - else - pathEnd = prv; - if (prv != NULL) - prv->next = nxt; - else - pathStart = nxt; -} - -/* This procedure is called from BuildFont when adding hints - to base designs of a multi-master font. */ -public -boolean GetInflectionPoint(x, y, x1, cy1, x2, y2, x3, y3, inflPt) - Fixed x, - y, x1, cy1, x2, y2, x3, y3; -Fixed *inflPt; -{ - FltnRec fltnrec; - Cd c0, c1, c2, c3; - - fltnrec.report = chkDT; - c0.x = tfmx(x); - c0.y = tfmy(y); - c1.x = tfmx(x1); - c1.y = tfmy(cy1); - c2.x = tfmx(x2); - c2.y = tfmy(y2); - c3.x = tfmx(x3); - c3.y = tfmy(y3); - xstate = ystate = STARTING; - xdone = ydone = xflat = yflat = inflPtFound = FALSE; - x0 = c0.x; - cy0 = c0.y; - x1 = c3.x; - cy1 = c3.y; - xloc = x0; - yloc = cy0; - forMultiMaster = TRUE; - FltnCurve(c0, c1, c2, c3, &fltnrec); - if (inflPtFound) - *inflPt = fltnvalue; - return inflPtFound; -} - -private -procedure CheckSCurve(ee) PPathElt ee; -{ - FltnRec fr; - Cd c0, c1, c2, c3; - if (ee->type != CURVETO) { - FlushLogFiles(); - sprintf(globmsg, "Malformed path list in %s.\n", fileName); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - - GetEndPoint(ee->prev, &c0.x, &c0.y); - fr.report = chkDT; - c1.x = ee->x1; - c1.y = ee->y1; - c2.x = ee->x2; - c2.y = ee->y2; - c3.x = ee->x3; - c3.y = ee->y3; - xstate = ystate = STARTING; - xdone = ydone = xflat = yflat = FALSE; - x0 = c0.x; - cy0 = c0.y; - x1 = c3.x; - cy1 = c3.y; - xloc = x0; - yloc = cy0; - e = ee; - forMultiMaster = FALSE; - FltnCurve(c0, c1, c2, c3, &fr); -} - -private -procedure CheckZeroLength() { - PPathElt e, NxtE; - Fixed x0, cy0, x1, cy1, x2, y2, x3, y3; - e = pathStart; - while (e != NULL) { /* delete zero length elements */ - NxtE = e->next; - GetEndPoints(e, &x0, &cy0, &x1, &cy1); - if (e->type == LINETO && x0 == x1 && cy0 == cy1) { - Delete(e); - goto Nxt1; - } - if (e->type == CURVETO) { - x2 = e->x1; - y2 = e->y1; - x3 = e->x2; - y3 = e->y2; - if (x0 == x1 && cy0 == cy1 && x2 == x1 && x3 == x1 && y2 == cy1 && y3 == cy1) { - Delete(e); - goto Nxt1; - } - } - Nxt1: - e = NxtE; - } -} - -public -procedure CheckSmooth() { - PPathElt e, nxt, NxtE; - boolean recheck; - Fixed x0, cy0, x1, cy1, x2, y2, x3, y3, smdiff, xx, yy; - CheckZeroLength(); -restart: - reCheckSmooth = FALSE; - recheck = FALSE; - e = pathStart; - while (e != NULL) { - NxtE = e->next; - if (e->type == MOVETO || IsTiny(e) || e->isFlex) goto Nxt; - GetEndPoint(e, &x1, &cy1); - if (e->type == CURVETO) { - integer cpd0, cpd1; - x2 = e->x1; - y2 = e->y1; - x3 = e->x2; - y3 = e->y2; - GetEndPoint(e->prev, &x0, &cy0); - cpd0 = CPDirection(x0, cy0, x2, y2, x3, y3); - cpd1 = CPDirection(x2, y2, x3, y3, x1, cy1); - if (ProdLt0(cpd0, cpd1)) - CheckSCurve(e); - } - nxt = NxtForBend(e, &x2, &y2, &xx, &yy); - if (nxt->isFlex) goto Nxt; - PrvForBend(nxt, &x0, &cy0); - if (!CheckSmoothness(x0, cy0, x1, cy1, x2, y2, &smdiff)) - ReportSmoothError(x1, cy1); - if (smdiff > FixInt(140)) { /* trim off sharp angle */ - /* As of version 2.21 angle blunting will not occur. */ - /* - if (editChar && ConsiderClipSharpPoint(x0, cy0, x1, cy1, x2, y2, e)) { - ReportClipSharpAngle(x1, cy1); recheck = TRUE; } - else */ - if (smdiff > FixInt(160)) - ReportSharpAngle(x1, cy1); - } - Nxt: - e = NxtE; - } - if (reCheckSmooth) goto restart; - if (!recheck) return; - CheckZeroLength(); - /* in certain cases clip sharp point can produce a zero length line */ -} - -#define BBdist (FixInt(20)) /* DEBUG 8 BIT. DOuble value from 10 to 20 for change in coordinate system. */ - -private -procedure chkBBDT(c) Cd c; -{ - Fixed x = c.x, y = c.y, abstmp; - if (bbquit) return; - if (vert) { - lst = y; - if (!started && ac_abs(x - loc) <= BBdist) { - started = TRUE; - frst = y; - } else if (started && ac_abs(x - loc) > BBdist) - bbquit = TRUE; - } else { - lst = x; - if (!started && ac_abs(y - loc) <= BBdist) { - started = TRUE; - frst = x; - } else if (started && ac_abs(y - loc) > BBdist) - bbquit = TRUE; - } -} - -public -procedure CheckForMultiMoveTo() { - PPathElt e = pathStart; - boolean moveto; - moveto = FALSE; - while (e != NULL) { - if (e->type != MOVETO) - moveto = FALSE; - else if (!moveto) - moveto = TRUE; - else - Delete(e->prev); /* delete previous moveto */ - e = e->next; - } -} - -public -procedure CheckBBoxEdge(e, vrt, lc, pf, pl) - PPathElt e; -boolean vrt; -Fixed lc, *pf, *pl; -{ - FltnRec fr; - Cd c0, c1, c2, c3; - if (e->type != CURVETO) { - FlushLogFiles(); - sprintf(globmsg, "Malformed path list in %s.\n", fileName); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - - GetEndPoint(e->prev, &c0.x, &c0.y); - fr.report = chkBBDT; - bbquit = FALSE; - c1.x = e->x1; - c1.y = e->y1; - c2.x = e->x2; - c2.y = e->y2; - c3.x = e->x3; - c3.y = e->y3; - loc = lc; - vert = vrt; - started = FALSE; - chkBBDT(c0); - FltnCurve(c0, c1, c2, c3, &fr); - *pf = frst; - *pl = lst; -} - -private -procedure MakeColinear(tx, ty, x0, cy0, x1, cy1, xptr, yptr) - Fixed tx, - ty, x0, cy0, x1, cy1, *xptr, *yptr; -{ - Fixed dx, dy; - real rdx, rdy, dxdy, dxsq, dysq, dsq, xi, yi, rx, ry, rx0, ry0; - dx = x1 - x0; - dy = cy1 - cy0; - if (dx == 0 && dy == 0) { - *xptr = tx; - *yptr = ty; - return; - } - if (dx == 0) { - *xptr = x0; - *yptr = ty; - return; - } - if (dy == 0) { - *xptr = tx; - *yptr = cy0; - return; - } - acfixtopflt(dx, &rdx); - acfixtopflt(dy, &rdy); - acfixtopflt(x0, &rx0); - acfixtopflt(cy0, &ry0); - acfixtopflt(tx, &rx); - acfixtopflt(ty, &ry); - dxdy = rdx * rdy; - dxsq = rdx * rdx; - dysq = rdy * rdy; - dsq = dxsq + dysq; - xi = (rx * dxsq + rx0 * dysq + (ry - ry0) * dxdy) / dsq; - yi = ry0 + ((xi - rx0) * rdy) / rdx; - *xptr = acpflttofix(&xi); - *yptr = acpflttofix(&yi); -} - -#define DEG(x) ((x)*57.29577951308232088) -extern double atan2(); -private -Fixed ATan(a, b) Fixed a, b; -{ - real aa, bb, cc; - acfixtopflt(a, &aa); - acfixtopflt(b, &bb); - cc = (real)DEG(atan2((double)aa, (double)bb)); - while (cc < 0) cc += 360.0; - return acpflttofix(&cc); -} - -public -boolean CheckSmoothness(x0, cy0, x1, cy1, x2, y2, pd) - Fixed x0, - cy0, x1, cy1, x2, y2, *pd; -{ - Fixed dx, dy, smdiff, smx, smy, at0, at1, abstmp; - dx = x0 - x1; - dy = cy0 - cy1; - *pd = 0L; - if (dx == 0 && dy == 0) return TRUE; - at0 = ATan(dx, dy); - dx = x1 - x2; - dy = cy1 - y2; - if (dx == 0 && dy == 0) return TRUE; - at1 = ATan(dx, dy); - smdiff = at0 - at1; - if (smdiff < 0) smdiff = -smdiff; - if (smdiff >= FixInt(180)) smdiff = FixInt(360) - smdiff; - *pd = smdiff; - if (smdiff == 0 || smdiff > FixInt(30)) return TRUE; - MakeColinear(x1, cy1, x0, cy0, x2, y2, &smx, &smy); - smx = FHalfRnd(smx); - smy = FHalfRnd(smy); - /* DEBUG 8 BIT. Double hard coded distance values, for change from 7 to 8 bits for fractions. */ - return ac_abs(smx - x1) < FixInt(4) && ac_abs(smy - cy1) < FixInt(4); -} - -public -procedure CheckForDups() { - register PPathElt ob, nxt; - register Fixed x, y; - ob = pathStart; - while (ob != NULL) { - nxt = ob->next; - if (ob->type == MOVETO) { - x = ob->x; - y = ob->y; - ob = nxt; - while (ob != NULL) { - if (ob->type == MOVETO && x == ob->x && y == ob->y) - goto foundMatch; - ob = ob->next; - } - } - ob = nxt; - } - return; -foundMatch: - x = itfmx(x); - y = itfmy(y); - ReportDuplicates(x, y); -} - -public -procedure MoveSubpathToEnd(e) PPathElt e; -{ - PPathElt subEnd, subStart, subNext, subPrev; - subEnd = (e->type == CLOSEPATH) ? e : GetClosedBy(e); - subStart = GetDest(subEnd); - if (subEnd == pathEnd) return; /* already at end */ - subNext = subEnd->next; - if (subStart == pathStart) { - pathStart = subNext; - subNext->prev = NULL; - } else { - subPrev = subStart->prev; - subPrev->next = subNext; - subNext->prev = subPrev; - } - pathEnd->next = subStart; - subStart->prev = pathEnd; - subEnd->next = NULL; - pathEnd = subEnd; -} diff --git a/c/autohint/autohintlib/source/ac/control.c b/c/autohint/autohintlib/source/ac/control.c deleted file mode 100644 index 6276177e4..000000000 --- a/c/autohint/autohintlib/source/ac/control.c +++ /dev/null @@ -1,906 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/************************************************************************/ -/* control.c */ - -#include "ac.h" -#include "machinedep.h" - -#if ALLOWCSOUTPUT && THISISACMAIN -extern boolean charstringoutput; -#endif - -extern void CSWrite(void); - -private -procedure DoHStems(); -private -procedure DoVStems(); - -private -boolean CounterFailed; - -public -procedure InitAll(integer reason) { - InitData(reason); /* must be first */ - InitAuto(reason); - InitFix(reason); - InitGen(reason); - InitPick(reason); -} - -private -integer PtLstLen(PClrPoint lst) { - integer cnt = 0; - while (lst != NULL) { - cnt++; - lst = lst->next; - } - return cnt; -} - -public -integer PointListCheck(PClrPoint new, PClrPoint lst) { - /* -1 means not a member, 1 means already a member, 0 means conflicts */ - Fixed l1, l2, n1, n2, tmp, halfMargin; - char ch = new->c; - halfMargin = FixHalfMul(bandMargin); - halfMargin = FixHalfMul(halfMargin); - /* DEBUG 8 BIT. In the previous version, with 7 bit fraction coordinates instead of the current - 8 bit, bandMargin is declared as 30, but scaled by half to match the 7 bit fraction coordinate -> a value of 15. - In the current version this scaling doesn't happen. However, in this part of the code, the hint values are scaled up to 8 bits of fraction even in the original version, but topBand is applied without correcting for the scaling difference. In this version I need to divide by half again in order to get to the same value. I think the original is a bug, but it has been working for 30 years, so I am not going to change the test now. - */ - switch (ch) { - case 'y': - case 'm': { - n1 = new->x0; - n2 = new->x1; - break; - } - case 'b': - case 'v': { - n1 = new->y0; - n2 = new->y1; - break; - } - default: { - FlushLogFiles(); - sprintf(globmsg, "Illegal character in point list in %s.\n", fileName); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - } - if (n1 > n2) { - tmp = n1; - n1 = n2; - n2 = tmp; - } - while (TRUE) { - if (lst == NULL) { - return -1; - } - if (lst->c == ch) { /* same kind of color */ - switch (ch) { - case 'y': - case 'm': { - l1 = lst->x0; - l2 = lst->x1; - break; - } - case 'b': - case 'v': { - l1 = lst->y0; - l2 = lst->y1; - break; - } - } - if (l1 > l2) { - tmp = l1; - l1 = l2; - l2 = tmp; - } - if (l1 == n1 && l2 == n2) { - return 1L; - } - /* Add this extra margin to the band to fix a problem in - TimesEuropa/Italic/v,w,y where a main hstem hint was - being merged with newcolors. This main hstem caused - problems in rasterization so it shouldn't be included. */ - l1 -= halfMargin; - l2 += halfMargin; - if (l1 <= n2 && n1 <= l2) { - return 0L; - } - } - lst = lst->next; - } -} - -private -boolean SameColorLists(PClrPoint lst1, PClrPoint lst2) { - if (PtLstLen(lst1) != PtLstLen(lst2)) { - return FALSE; - } - while (lst1 != NULL) { /* go through lst1 */ - if (PointListCheck(lst1, lst2) != 1) { - return FALSE; - } - lst1 = lst1->next; - } - return TRUE; -} - -public -boolean SameColors(integer cn1, integer cn2) { - if (cn1 == cn2) { - return TRUE; - } - return SameColorLists(ptLstArray[cn1], ptLstArray[cn2]); -} - -public -procedure MergeFromMainColors(char ch) { - register PClrPoint lst; - for (lst = ptLstArray[0]; lst != NULL; lst = lst->next) { - if (lst->c != ch) { - continue; - } - if (PointListCheck(lst, pointList) == -1) { - if (ch == 'b') { - AddColorPoint(0L, lst->y0, 0L, lst->y1, ch, lst->p0, lst->p1); - } else { - AddColorPoint(lst->x0, 0L, lst->x1, 0L, ch, lst->p0, lst->p1); - } - } - } -} - -public -procedure AddColorPoint(Fixed x0, Fixed y0, Fixed x1, Fixed y1, char ch, PPathElt p0, PPathElt p1) { - register PClrPoint pt; - integer chk; - pt = (PClrPoint)Alloc(sizeof(ClrPoint)); - pt->x0 = x0; - pt->y0 = y0; - pt->x1 = x1; - pt->y1 = y1; - pt->c = ch; - pt->done = FALSE; - pt->next = NULL; - pt->p0 = p0; - pt->p1 = p1; - chk = PointListCheck(pt, pointList); - if (chk == 0 && showClrInfo) { - ReportColorConflict(x0, y0, x1, y1, ch); - } - if (chk == -1) { - pt->next = pointList; - pointList = pt; - if (logging) { - LogColorInfo(pointList); - } - } -} - -private -procedure CopyClrFromLst(char clr, register PClrPoint lst) { - boolean bvflg = (clr == 'b' || clr == 'v'); - while (lst != NULL) { - if (lst->c == clr) { - if (bvflg) { - AddColorPoint(0L, lst->y0, 0L, lst->y1, clr, lst->p0, lst->p1); - } else { - AddColorPoint(lst->x0, 0L, lst->x1, 0L, clr, lst->p0, lst->p1); - } - } - lst = lst->next; - } -} - -public -procedure CopyMainV() { - CopyClrFromLst('m', ptLstArray[0]); -} - -public -procedure CopyMainH() { - CopyClrFromLst('v', ptLstArray[0]); -} - -public -procedure AddHPair(PClrVal v, char ch) { - Fixed bot, top, tmp; - PPathElt p0, p1, p; - bot = itfmy(v->vLoc1); - top = itfmy(v->vLoc2); - p0 = v->vBst->vSeg1->sElt; - p1 = v->vBst->vSeg2->sElt; - if (top < bot) { - tmp = top; - top = bot; - bot = tmp; - p = p0; - p0 = p1; - p1 = p; - } - if (v->vGhst) { - if (v->vSeg1->sType == sGHOST) { - bot = top; - p0 = p1; - p1 = NULL; - top = bot - FixInt(20); /* width == -20 iff bottom seg is ghost */ - } else { - top = bot; - p1 = p0; - p0 = NULL; - bot = top + FixInt(21); /* width == -21 iff top seg is ghost */ - } - } - AddColorPoint(0L, bot, 0L, top, ch, p0, p1); -} - -public -procedure AddVPair(PClrVal v, char ch) { - Fixed lft, rght, tmp; - PPathElt p0, p1, p; - lft = itfmx(v->vLoc1); - rght = itfmx(v->vLoc2); - p0 = v->vBst->vSeg1->sElt; - p1 = v->vBst->vSeg2->sElt; - if (lft > rght) { - tmp = lft; - lft = rght; - rght = tmp; - p = p0; - p0 = p1; - p1 = p; - } - AddColorPoint(lft, 0L, rght, 0L, ch, p0, p1); -} - -private -boolean UseCounter(PClrVal sLst, boolean mclr) { - integer cnt = 0; - Fixed minLoc, midLoc, maxLoc, abstmp, prevBstVal, bestVal; - Fixed minDelta, midDelta, maxDelta, loc, delta, th; - PClrVal lst, newLst; - minLoc = midLoc = maxLoc = FixInt(20000L); - minDelta = midDelta = maxDelta = 0; - lst = sLst; - while (lst != NULL) { - cnt++; - lst = lst->vNxt; - } - if (cnt < 3) { - return FALSE; - } - cnt -= 3; - prevBstVal = 0; - while (cnt > 0) { - cnt--; - if (cnt == 0) { - prevBstVal = sLst->vVal; - } - sLst = sLst->vNxt; - } - bestVal = sLst->vVal; - if (prevBstVal > FixInt(1000L) || bestVal < prevBstVal * 10L) { - return FALSE; - } - newLst = sLst; - while (sLst != NULL) { - loc = sLst->vLoc1; - delta = sLst->vLoc2 - loc; - loc += FixHalfMul(delta); - if (loc < minLoc) { - maxLoc = midLoc; - maxDelta = midDelta; - midLoc = minLoc; - midDelta = minDelta; - minLoc = loc; - minDelta = delta; - } else if (loc < midLoc) { - maxLoc = midLoc; - maxDelta = midDelta; - midLoc = loc; - midDelta = delta; - } else { - maxLoc = loc; - maxDelta = delta; - } - sLst = sLst->vNxt; - } - th = FixInt(5) / 100L; - if (ac_abs(minDelta - maxDelta) < th && - ac_abs((maxLoc - midLoc) - (midLoc - minLoc)) < th) { - if (mclr) { - Vcoloring = newLst; - } else { - Hcoloring = newLst; - } - return TRUE; - } - if (ac_abs(minDelta - maxDelta) < FixInt(3) && - ac_abs((maxLoc - midLoc) - (midLoc - minLoc)) < FixInt(3)) { - ReportError(mclr ? "Near miss for using V counter hinting." : "Near miss for using H counter hinting."); - } - return FALSE; -} - -private -procedure GetNewPtLst() { - if (numPtLsts >= maxPtLsts) { /* increase size */ - PClrPoint *newArray; - integer i; - maxPtLsts += 5; - newArray = (PClrPoint *)Alloc(maxPtLsts * sizeof(PClrPoint)); - for (i = 0; i < maxPtLsts - 5; i++) { - newArray[i] = ptLstArray[i]; - } - ptLstArray = newArray; - } - ptLstIndex = numPtLsts; - numPtLsts++; - pointList = NULL; - ptLstArray[ptLstIndex] = NULL; -} - -public -procedure XtraClrs(PPathElt e) { - /* this can be simplified for standalone coloring */ - ptLstArray[ptLstIndex] = pointList; - if (e->newcolors == 0) { - GetNewPtLst(); - e->newcolors = (short)ptLstIndex; - } - ptLstIndex = e->newcolors; - pointList = ptLstArray[ptLstIndex]; -} - -private -procedure Blues() { - Fixed pv, pd, pc, pb, pa; - PClrVal sLst; - - /* - Top alignment zones are in the global 'topBands', bottom in 'botBands'. - - This function looks through the path, as defined by the linked list of 'elts', starting at the global 'pathStart', and adds to several lists. Coordinates are stored in the elt.(x,y) as (original value)/2.0, aka right shifted by 1 bit from the original 24.8 Fixed. I suspect that is to allow a larger integer portion - when this program was written, an int was 16 bits. - - - HStems, Vstems are global lists of Fixed 24.8 numbers.. - - segLists is an array of 4 ClrSeg linked lists. list 0 and 1 are respectively up and down vertical segments. Lists 2 and 3 are - respectively left pointing and right pointing horizontal segments. On a counter-clockwise path, this is the same as selecting - top and bottom stem locations. - - NoBlueChar() consults a hard-coded list of glyph names, If the glyph is in this list, set the alignment zones (top and botBands) to empty. - - 1) gen.c:GenHPts() . Buid the raw list of stem segments in global 'topList' and 'botList'. - - gen.c:GenHPts() steps through the liked list of path segments, starting at 'pathStart' It decides if a path is mostly H, - and if so, adds it to a linked list of hstem candidates in segLists, by calling gen.c:AddHSegment(). This calls ReportAddHSeg() (useful in debugging), - and then gen.c:AddSegment. - - If the path segment is in fact entirely vertical and is followed by a sharp bend, - gen.c:GenHPts adds two new path segments just 1 unit long, after the segment end point, - called H/VBends (segment type sBend=1). I have no idea what these are for. - - AddSegment is pretty simple. It creates a new hint segment 'ClrSeg' for the parent path elt , fills it in, - adds it to appropriate list of the 4 segLists, and then sorts by hstem location. - seg->sElt is the parent elt - seg->sType is the type - seg->sLoc is the location in Fixed 18.14: right shift 7 to get integer value. - - If the current path elt is a Closepath, It also calls LinkSegment() to add the current stem segment to the list of stem segments referenced by this elt. - e->Hs/Vs. - - Note that a hint segment is created for each nearly vertical or horioztonal path elt. Ths means that in an H, there will be two hint segments created for - the bottom and top of the H, as there are two horizontal paths with the same Y at the top and bottom of the H. - - Assign the top and bottom Hstem location lists. - topList = segLists[2] - botList = segLists[3]; - - 2) eval.c::EvalH(). Evaluate every combination of botList and topList, and assign a priority value and a 'Q' value. - - For each bottom stem - for each top stem - 1) assign priority (spc) and weight (val) values with EvalHPair() - 2) report stem near misses in the 'HStems' list with HStemMiss() - 3) decide whether to add pair to 'HStems' list with AddHValue() - - Add ghost hints. - For each bottom stem segment and then for each top stem segment: - if it is in an alignment zone, make a ghost hint segment and add it with AddHValue(). - - EvalHPair() sets priority (spc) and weight (val) values. - Omit pair by setting value to 0 if: - bottom is in bottom alignment zone, and top is in top alignment zone. (otherwise, these will override the ghost hints). - - Boost priority by +2 if either the bot or top segment is in an alignment zone. - - dy = stem widt ( top - bot) - - Calculcate dist. Dist is set to a fudge factor *dy. - if bottom segment xo->x1 overlaps top x0->x1, the fudge factor is 1.0. The - less the overlap, the larger the fduge factor. - if bottom segment xo->x1 overlaps top x0->x1:. - if top and bottom overlap exactly, dist = dy - if they barely overlap, dist = 1.4*dy - in between, interpolate. - else, look at closest ends betwen bottom and top segments. - dx = min X separation between top and bottom segments. - dist = 1.4 *dy - dist += dx*dx - if dx > dy: - dist *= dx / dy; - Look through the HStems global list. For each match to dy, boost priority by + 1. - Calculate weight with gen.c:AdjustVal() - if dy is more than twice the 1.1.5* the largest hint in HStems, set weight to 0. - Calculate weight as related to length of the segments squared divied by the distance squared. - Basically, the greater the ratio segment overlap to stem width, the higher the value. - if dy is greater than the largest stem hint in HStems, decrease the value - scale weight by of *(largest stem hint in HStems)/ dy)**3. - - AddHValue() decides whether add a (bottom, top) pair of color segments. - Do not add the pair if: - if weight (val) is 0, - if both are sBEND segments - if neither are a ghost hint, and weight <= pruneD and priority (spc) is <= 0: - if either is an sBEND: skip - if the BBox for one segment is the same or inside the BBox for the other: skip - - else add it with eval.c:InsertHValue() - add new ClrVal to global valList. - item->vVal = val; # weight - item->initVal = val; # originl weight from EvalHPair() - item->vSpc = spc; # priority - item->vLoc1 = bot; # bottom Y value in Fixed 18.14 - item->vLoc2 = top; # top Y value in Fixed 18.14 - item->vSeg1 = bSeg; # bottom color segment - item->vSeg2 = tSeg; # top color segment - item->vGhst = ghst; # if it is a ghost segment. - The new item is inserted after the first element where vlist->vLoc2 >= top and vlist->vLoc1 >= bottom - - 3) merge.c:PruneHVals(); - - item2 in the list knocks out item1 if: - 1) (item2 val is more than 3* greater than item1 val) and - val 1 is less than FixedInt(100) and - item2 top and bottom is within item 1 top and bottom - and ( if val1 is more than 50* less than val2 and - either top seg1 is close to top seg 2, or bottom seg1 is close to bottom seg 2 - ) - and (val 1 < FixInt(16)) or ( ( item1 top not in blue zone, or top1 = top2) and - ( item1 bottom not in blue zone, or top1 = bottom2)) - "Close to" for the bottom segment means you can get to the bottom elt for item 2 from bottom elt for 1 within the same path, by - stepping either forward or back from item 1's elt, and without going outside the bounds between - location 1 and location 2. Same for top segments. - - - - - 4) pick.c:FindBestHVals(); - When a hint segment */ - - if (showClrInfo) { - PrintMessage("generate blues"); - } - if (NoBlueChar()) { - lenTopBands = lenBotBands = 0; - } - GenHPts(); - if (showClrInfo) { - PrintMessage("evaluate"); - } - if (!CounterFailed && HColorChar()) { - pv = pruneValue; - pruneValue = (Fixed)minVal; - pa = pruneA; - pruneA = (Fixed)minVal; - pd = pruneD; - pruneD = (Fixed)minVal; - pc = pruneC; - pruneC = (Fixed)maxVal; - pb = pruneB; - pruneB = (Fixed)minVal; - } - EvalH(); - PruneHVals(); - FindBestHVals(); - MergeVals(FALSE); - - if (showClrInfo) { - ShowHVals(valList); - PrintMessage("pick best"); - } - MarkLinks(valList, TRUE); - CheckVals(valList, FALSE); - DoHStems(valList); /* Report stems and alignment zones, if this has been requested. */ - PickHVals(valList); /* Moves best ClrVal items from valList to Hcoloring list. (? Choose from set of ClrVals for the samte stem values.) */ - if (!CounterFailed && HColorChar()) { - pruneValue = pv; - pruneD = pd; - pruneC = pc; - pruneB = pb; - pruneA = pa; - useH = UseCounter(Hcoloring, FALSE); - if (!useH) { /* try to fix */ - AddBBoxHV(TRUE, TRUE); - useH = UseCounter(Hcoloring, FALSE); - if (!useH) { /* still bad news */ - ReportError("Note: Glyph is in list for using H counter hints, but didn't find any candidates."); - CounterFailed = TRUE; - } - } - } else { - useH = FALSE; - } - if (Hcoloring == NULL) { - AddBBoxHV(TRUE, FALSE); - } - if (showClrInfo) { - PrintMessage("results"); - PrintMessage(useH ? "rv" : "rb"); - ShowHVals(Hcoloring); - } - if (useH) { - PrintMessage("Using H counter hints."); - } - sLst = Hcoloring; - while (sLst != NULL) { - AddHPair(sLst, useH ? 'v' : 'b'); /* actually adds hint */ - sLst = sLst->vNxt; - } -} - -private -procedure DoHStems(PClrVal sLst1) { - Fixed bot, top; - Fixed charTop = MINinteger, charBot = MAXinteger; - boolean curved; - if (!doAligns && !doStems) { - return; - } - while (sLst1 != NULL) { - bot = itfmy(sLst1->vLoc1); - top = itfmy(sLst1->vLoc2); - if (top < bot) { - Fixed tmp = top; - top = bot; - bot = tmp; - } - if (top > charTop) { - charTop = top; - } - if (bot < charBot) { - charBot = bot; - } - /* skip if ghost or not a line on top or bottom */ - if (sLst1->vGhst) { - sLst1 = sLst1->vNxt; - continue; - } - curved = !FindLineSeg(sLst1->vLoc1, botList) && - !FindLineSeg(sLst1->vLoc2, topList); - AddHStem(top, bot, curved); - sLst1 = sLst1->vNxt; - if (top != MINinteger || bot != MAXinteger) { - AddStemExtremes(UnScaleAbs(bot), UnScaleAbs(top)); - } - } - if (charTop != MINinteger || charBot != MAXinteger) { - AddCharExtremes(UnScaleAbs(charBot), UnScaleAbs(charTop)); - } -} - -private -procedure Yellows() { - Fixed pv, pd, pc, pb, pa; - PClrVal sLst; - if (showClrInfo) { - PrintMessage("generate yellows"); - } - GenVPts(SpecialCharType()); - if (showClrInfo) { - PrintMessage("evaluate"); - } - if (!CounterFailed && VColorChar()) { - pv = pruneValue; - pruneValue = (Fixed)minVal; - pa = pruneA; - pruneA = (Fixed)minVal; - pd = pruneD; - pruneD = (Fixed)minVal; - pc = pruneC; - pruneC = (Fixed)maxVal; - pb = pruneB; - pruneB = (Fixed)minVal; - } - EvalV(); - PruneVVals(); - FindBestVVals(); - MergeVals(TRUE); - if (showClrInfo) { - ShowVVals(valList); - PrintMessage("pick best"); - } - MarkLinks(valList, FALSE); - CheckVals(valList, TRUE); - DoVStems(valList); - PickVVals(valList); - if (!CounterFailed && VColorChar()) { - pruneValue = pv; - pruneD = pd; - pruneC = pc; - pruneB = pb; - pruneA = pa; - useV = UseCounter(Vcoloring, TRUE); - if (!useV) { /* try to fix */ - AddBBoxHV(FALSE, TRUE); - useV = UseCounter(Vcoloring, TRUE); - if (!useV) { /* still bad news */ - ReportError("Note: Glyph is in list for using V counter hints, but didn't find any candidates."); - CounterFailed = TRUE; - } - } - } else { - useV = FALSE; - } - if (Vcoloring == NULL) { - AddBBoxHV(FALSE, FALSE); - } - if (showClrInfo) { - PrintMessage("results"); - PrintMessage(useV ? "rm" : "ry"); - ShowVVals(Vcoloring); - } - if (useV) { - PrintMessage("Using V counter hints."); - } - sLst = Vcoloring; - while (sLst != NULL) { - AddVPair(sLst, useV ? 'm' : 'y'); - sLst = sLst->vNxt; - } -} - -private -procedure DoVStems(PClrVal sLst) { - Fixed lft, rght; - boolean curved; - if (!doAligns && !doStems) { - return; - } - while (sLst != NULL) { - curved = !FindLineSeg(sLst->vLoc1, leftList) && - !FindLineSeg(sLst->vLoc2, rightList); - lft = itfmx(sLst->vLoc1); - rght = itfmx(sLst->vLoc2); - if (lft > rght) { - Fixed tmp = lft; - lft = rght; - rght = tmp; - } - AddVStem(rght, lft, curved); - sLst = sLst->vNxt; - } -} - -private -procedure RemoveRedundantFirstColors() { - register PPathElt e; - if (numPtLsts < 2 || !SameColors(0L, 1L)) { - return; - } - e = pathStart; - while (e != NULL) { - if (e->newcolors == 1) { - e->newcolors = 0; - return; - } - e = e->next; - } -} - -private -procedure PreCheckForSolEol() { - integer code; - Fixed yStart, yEnd, x1, y1; - if (!SpecialSolEol() || useV || useH || pathStart == NULL) { - return; - } - code = SolEolCharCode(); - if (code == 0) { - return; - } - GetEndPoint(pathStart, &x1, &y1); - yStart = itfmy(y1); - GetEndPoint(GetDest(pathEnd), &x1, &y1); - yEnd = itfmy(y1); - if (editChar && ((code == 1 && yStart > yEnd) || (code == -1 && yStart < yEnd))) { - MoveSubpathToEnd(pathStart); - } -} - -private -procedure AddColorsSetup() { - int i; - Fixed abstmp; - vBigDist = 0; - for (i = 0; i < NumVStems; i++) { - if (VStems[i] > vBigDist) { - vBigDist = VStems[i]; - } - } - vBigDist = dtfmx(vBigDist); - if (vBigDist < initBigDist) { - vBigDist = initBigDist; - } - vBigDist = (vBigDist * 23L) / 20L; - acfixtopflt(vBigDist, &vBigDistR); - hBigDist = 0; - for (i = 0; i < NumHStems; i++) { - if (HStems[i] > hBigDist) { - hBigDist = HStems[i]; - } - } - hBigDist = ac_abs(dtfmy(hBigDist)); - if (hBigDist < initBigDist) { - hBigDist = initBigDist; - } - hBigDist = (hBigDist * 23L) / 20L; - acfixtopflt(hBigDist, &hBigDistR); - if ((!scalinghints) && (roundToInt)) { - RoundPathCoords(); - } - CheckForMultiMoveTo(); - /* PreCheckForSolEol(); */ -} - -/* If extracolor is TRUE then it is ok to have multi-level - coloring. */ -private -procedure AddColorsInnerLoop(boolean extracolor) { - integer solEolCode = 2, retryColoring = 0; - boolean isSolEol = FALSE; - while (TRUE) { - PreGenPts(); - CheckSmooth(); - InitShuffleSubpaths(); - Blues(); - if (!doAligns) { - Yellows(); - } - if (editChar) { - DoShuffleSubpaths(); - } - Hprimary = CopyClrs(Hcoloring); - Vprimary = CopyClrs(Vcoloring); - /* - isSolEol = SpecialSolEol() && !useV && !useH; - solEolCode = isSolEol? SolEolCharCode() : 2; - */ - PruneElementColorSegs(); - if (listClrInfo) { - ListClrInfo(); - } - if (extracolor) { - AutoExtraColors(MoveToNewClrs(), isSolEol, solEolCode); - } - ptLstArray[ptLstIndex] = pointList; - if (isSolEol) { - break; - } - retryColoring++; - /* we want to retry coloring if - `1) CounterFailed or - 2) doFixes changed something, but in both cases, only on the first pass. - */ - if (CounterFailed && retryColoring == 1) { - goto retry; - } - if (!DoFixes()) { - break; - } - if (retryColoring > 1) { - break; - } - retry: - /* if we are doing the stem and zones reporting, we need to discard the reported. */ - if (reportRetryCB != NULL) { - reportRetryCB(); - } - if (pathStart == NULL || pathStart == pathEnd) { - FlushLogFiles(); - sprintf(globmsg, "No character path in %s.\n", fileName); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - - /* SaveFile(); SaveFile is always called in AddColorsCleanup, so this is a duplciate */ - InitAll(RESTART); - if (writecoloredbez && !ReadCharFile(FALSE, FALSE, FALSE, TRUE)) { - break; - } - AddColorsSetup(); - if (!PreCheckForColoring()) { - break; - } - if (flexOK) { - hasFlex = FALSE; - AutoAddFlex(); - } - reportErrors = FALSE; - } -} - -private -procedure AddColorsCleanup() { - RemoveRedundantFirstColors(); - reportErrors = TRUE; - if (writecoloredbez) { - if (pathStart == NULL || pathStart == pathEnd) { - sprintf(globmsg, "The %s character path vanished while adding hints.\n File not written.", fileName); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } else { -#if ALLOWCSOUTPUT && THISISACMAIN - if (charstringoutput) { - CSWrite(); - } else { -#endif - SaveFile(); -#if ALLOWCSOUTPUT && THISISACMAIN - } -#endif - } - } - InitAll(RESTART); -} - -private -procedure AddColors(boolean extracolor) { - if (pathStart == NULL || pathStart == pathEnd) { - PrintMessage("No character path, so no hints."); -#if ALLOWCSOUTPUT && THISISACMAIN - if (charstringoutput) { - CSWrite(); - } else { -#endif - SaveFile(); /* make sure it gets saved with no coloring */ -#if ALLOWCSOUTPUT && THISISACMAIN - } -#endif - return; - } - reportErrors = TRUE; - CounterFailed = bandError = FALSE; - CheckPathBBox(); - CheckForDups(); - AddColorsSetup(); - if (!PreCheckForColoring()) { - return; - } - if (flexOK) { - hasFlex = FALSE; - AutoAddFlex(); - } - AddColorsInnerLoop(extracolor); - AddColorsCleanup(); - Test(); -} - -public -boolean DoFile(char *fname, boolean extracolor) { - integer lentop = lenTopBands, lenbot = lenBotBands; - fileName = fname; - if (!ReadCharFile(TRUE, FALSE, FALSE, TRUE)) { - sprintf(globmsg, "Cannot open %s file.\n", fileName); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - PrintMessage(""); /* Just print the file name. */ - LogYMinMax(); - AddColors(extracolor); - lenTopBands = lentop; - lenBotBands = lenbot; - return TRUE; -} diff --git a/c/autohint/autohintlib/source/ac/cswrite.c b/c/autohint/autohintlib/source/ac/cswrite.c deleted file mode 100644 index a48b51b36..000000000 --- a/c/autohint/autohintlib/source/ac/cswrite.c +++ /dev/null @@ -1,643 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* cswrite.c */ - -#include "ac.h" -#if THISISACMAIN && ALLOWCSOUTPUT /* entire file */ - -#include "machinedep.h" - -#include "opcodes.h" -/*#include "type_crypt_lib.h"*/ - -#if __CENTERLINE__ -#define STDOUT 1 -#define DEBUG 0 -#else -#define STDOUT 0 -#endif - -#ifndef DEBUG -#define DEBUG 0 -#endif - -extern int get_char_width(char *cname); -extern Fixed GetPathLSB(void); - -FILE *cstmpfile; -extern FILE *outputfile; -private -Fixed currentx, currenty; -private -boolean firstFlex, wrtColorInfo; -private -char S0[128]; -private -PClrPoint bst; -private -char bch; -private -Fixed bx, by; -private -boolean bstB; -private -Fixed lsb; -private -boolean needtoSubLSB; -private -short trilockcount = 0; -#if DEBUG -#else -FILE *outIOFILE; -/*crypt_Token tok;*/ -long val; -#endif - -#if DEBUG -private -ws(char *str) { - fputc(' ', cstmpfile); - fputs(str, cstmpfile); -} - -#define WRTNUM(i) \ - { \ - sprintf(S0, "%ld", (i)); \ - ws(S0); \ - } - -#else -void test(void) { - fprintf(stderr, "hi"); -} - -private -void ws(char *str) { - if (str[0] != ' ') { - fputc(' ', cstmpfile); - } - fputs(str, cstmpfile); - if ((str[0] <= '0' || str[0] >= '9') && str[0] != '-' && str[strlen(str) - 1] != '\n') { - fputc('\n', cstmpfile); - } -} - -#define WRTNUM(i) \ - { \ - sprintf(S0, "%ld", (i)); \ - ws(S0); \ - } -#endif - -/*To avoid pointless hint subs*/ -#define HINTMAXSTR 2048 -static char hintmaskstr[HINTMAXSTR]; -static char prevhintmaskstr[HINTMAXSTR]; - -private -void safestrcat(char *s1, char *s2) { - if (strlen(s1) + strlen(s2) + 1 > HINTMAXSTR) { - sprintf(S0, "ERROR: Hint information overflowing buffer: %s\n", fileName); - LogMsg(S0, LOGERROR, FATALERROR, TRUE); - } else { - strcat(s1, s2); - } -} - -private -void sws(char *str) { - safestrcat(hintmaskstr, " "); - safestrcat(hintmaskstr, str); - if ((str[0] <= '0' || str[0] >= '9') && str[0] != '-') { - safestrcat(hintmaskstr, "\n"); - } -} - -#define SWRTNUM(i) \ - { \ - sprintf(S0, "%ld", (i)); \ - sws(S0); \ - } - -private -void wrtfx(Fixed f) { - Fixed i = FRnd(f); - WRTNUM(FTrunc(i)); -} - -private -procedure wrtx(Fixed x, boolean subLSB) { - Fixed i = FRnd(x); - if (subLSB) { - WRTNUM(FTrunc(i - currentx - lsb)); - } else { - WRTNUM(FTrunc(i - currentx)); - } - currentx = i; -} - -private -procedure wrty(Fixed y) { - Fixed i = FRnd(y); - WRTNUM(FTrunc(i - currenty)); - currenty = i; -} - -#define wrtcd(c) \ - wrtx(c.x, 0); \ - wrty(c.y) - -private -procedure NewBest(PClrPoint lst) { - Fixed x0, x1, y0, y1; - bst = lst; - bch = lst->c; - if (bch == 'y' || bch == 'm') { - bstB = TRUE; - x0 = lst->x0; - x1 = lst->x1; - bx = MIN(x0, x1); - } else { - bstB = FALSE; - y0 = lst->y0; - y1 = lst->y1; - by = MIN(y0, y1); - } -} - -private -procedure WriteOne(Fixed s) { /* write s to output file */ - Fixed r = UnScaleAbs(s); - if (scalinghints) { - r = FRnd(r); - } - if (FracPart(r) == 0) { - SWRTNUM(FTrunc(r)); - } else { - if (FracPart(r * 10L) == 0) { - SWRTNUM(FTrunc(FRnd(r * 10L))); - sws("10 div"); - } else { - SWRTNUM(FTrunc(FRnd(r * 100L))); - sws("100 div"); - } - } -} - -private -procedure WritePointItem(PClrPoint lst) { - switch (lst->c) { - case 'b': - WriteOne(lst->y0); - WriteOne(lst->y1 - lst->y0); - sws("hstem"); - trilockcount = 0; - break; - - case 'v': - WriteOne(lst->y0); - WriteOne(lst->y1 - lst->y0); - trilockcount++; - if (trilockcount == 3) { - sws("hstem3"); - trilockcount = 0; - } - break; - - case 'y': - WriteOne(lst->x0 - lsb); - WriteOne(lst->x1 - lst->x0); - sws("vstem"); - trilockcount = 0; - break; - - case 'm': - WriteOne(lst->x0 - lsb); - WriteOne(lst->x1 - lst->x0); - trilockcount++; - if (trilockcount == 3) { - sws("vstem3"); - trilockcount = 0; - } - break; - default: - break; - } -} - -private -procedure WrtPntLst(PClrPoint lst) { - PClrPoint ptLst; - char ch; - Fixed x0, x1, y0, y1; - - ptLst = lst; - while (lst != NULL) { /* mark all as not yet done */ - lst->done = FALSE; - lst = lst->next; - } - while (TRUE) { /* write in sort order */ - lst = ptLst; - bst = NULL; - while (lst != NULL) { /* find first not yet done as init best */ - if (!lst->done) { - NewBest(lst); - break; - } - lst = lst->next; - } - if (bst == NULL) { - break; /* finished with entire list */ - } - lst = bst->next; - while (lst != NULL) { /* search for best */ - if (!lst->done) { - ch = lst->c; - if (ch > bch) { - NewBest(lst); - } else if (ch == bch) { - if (bstB) { - x0 = lst->x0; - x1 = lst->x1; - if (MIN(x0, x1) < bx) { - NewBest(lst); - } - } else { - y0 = lst->y0; - y1 = lst->y1; - if (MIN(y0, y1) < by) { - NewBest(lst); - } - } - } - } - lst = lst->next; - } - bst->done = TRUE; /* mark as having been done */ - WritePointItem(bst); - } -} - -private -procedure wrtnewclrs(PPathElt e) { - if (!wrtColorInfo) { - return; - } - hintmaskstr[0] = '\0'; - WrtPntLst(ptLstArray[e->newcolors]); - if (strcmp(prevhintmaskstr, hintmaskstr)) { - ws("4 callsubr"); - ws(hintmaskstr); - strcpy(prevhintmaskstr, hintmaskstr); - } -} - -private -boolean IsFlex(PPathElt e) { - PPathElt e0, e1; - if (firstFlex) { - e0 = e; - e1 = e->next; - } else { - e0 = e->prev; - e1 = e; - } - return (e0 != NULL && e0->isFlex && e1 != NULL && e1->isFlex); -} - -private -procedure mt(Cd c, PPathElt e) { - if (e->newcolors != 0) { - wrtnewclrs(e); - } - if (needtoSubLSB) { - if (FRnd(c.y) == currenty) { - wrtx(c.x, 1); - ws("hmoveto"); - needtoSubLSB = FALSE; - } else if ((FRnd(c.x) - currentx - FRnd(lsb)) == 0) { - wrty(c.y); - ws("vmoveto"); - } else { - wrtx(c.x, 1); - wrty(c.y); - ws("rmoveto"); - needtoSubLSB = FALSE; - } - } else { - if (FRnd(c.y) == currenty) { - wrtx(c.x, 0); - ws("hmoveto"); - } else if (FRnd(c.x) == currentx) { - wrty(c.y); - ws("vmoveto"); - } else { - wrtcd(c); - ws("rmoveto"); - } - } -} - -private -Fixed currentFlexx, currentFlexy; -private -boolean firstFlexMT; - -private -procedure wrtFlexx(Fixed x, boolean subLSB) { - Fixed i = FRnd(x); - if (subLSB) { - WRTNUM(FTrunc(i - currentFlexx - lsb)); - } else { - WRTNUM(FTrunc(i - currentFlexx)); - } - - currentFlexx = i; -} - -private -procedure wrtFlexy(Fixed y) { - Fixed i = FRnd(y); - WRTNUM(FTrunc(i - currentFlexy)); - currentFlexy = i; -} - -private -procedure wrtFlexmt(Cd c) { - if (firstFlexMT) { - if (FRnd(c.y) == currentFlexy) { - wrtFlexx(c.x, 1); - ws("hmoveto"); - } else if ((FRnd(c.x) - currentFlexx - FRnd(lsb)) == 0) { - wrtFlexy(c.y); - ws("vmoveto"); - } else { - wrtFlexx(c.x, 1); - wrtFlexy(c.y); - ws("rmoveto"); - } - firstFlexMT = FALSE; - } else { - if (FRnd(c.y) == currentFlexy) { - wrtFlexx(c.x, 0); - ws("hmoveto"); - } else if (FRnd(c.x) == currentFlexx) { - wrtFlexy(c.y); - ws("vmoveto"); - } else { - wrtFlexx(c.x, 0); - wrtFlexy(c.y); - ws("rmoveto"); - } - } -} - -private -procedure dt(Cd c, PPathElt e) { - if (e->newcolors != 0) { - wrtnewclrs(e); - } - if (needtoSubLSB) { - if (FRnd(c.y) == currenty) { - wrtx(c.x, 1); - ws("hlineto"); - needtoSubLSB = FALSE; - } else if ((FRnd(c.x) - currentx - FRnd(lsb)) == 0) { - wrty(c.y); - ws("vlineto"); - } else if (FRnd(c.x) == currentx) { - wrty(c.y); - ws("vlineto"); - needtoSubLSB = FALSE; - } else { - wrtx(c.x, 1); - wrty(c.y); - ws("rlineto"); - needtoSubLSB = FALSE; - } - } else { - if (FRnd(c.y) == currenty) { - wrtx(c.x, 0); - ws("hlineto"); - } else if (FRnd(c.x) == currentx) { - wrty(c.y); - ws("vlineto"); - } else { - wrtx(c.x, 0); - wrty(c.y); - ws("rlineto"); - } - } -} - -private -Fixed flX, flY; -private -Cd fc1, fc2, fc3; - -private -procedure wrtflex(Cd c1, Cd c2, Cd c3, PPathElt e) { - integer dmin, delta; - boolean yflag; - Cd c13; - real shrink, r1, r2; - if (firstFlex) { - flX = currentx; - flY = currenty; - fc1 = c1; - fc2 = c2; - fc3 = c3; - firstFlex = FALSE; - return; - } - yflag = e->yFlex; - dmin = DMIN; - delta = DELTA; - ws("1 callsubr"); - if (yflag) { - if (fc3.y == c3.y) { - c13.y = c3.y; - } else { - acfixtopflt(fc3.y - c3.y, &shrink); - shrink = (real)delta / shrink; - if (shrink < 0.0) { - shrink = -shrink; - } - acfixtopflt(fc3.y - c3.y, &r1); - r1 *= shrink; - acfixtopflt(c3.y, &r2); - r1 += r2; - c13.y = acpflttofix(&r1); - } - c13.x = fc3.x; - } else { - if (fc3.x == c3.x) { - c13.x = c3.x; - } else { - acfixtopflt(fc3.x - c3.x, &shrink); - shrink = (real)delta / shrink; - if (shrink < 0.0) { - shrink = -shrink; - } - acfixtopflt(fc3.x - c3.x, &r1); - r1 *= shrink; - acfixtopflt(c3.x, &r2); - r1 += r2; - c13.x = acpflttofix(&r1); - } - c13.y = fc3.y; - } - -#define wrtpreflx2(c) \ - wrtFlexmt(c); \ - ws("2 callsubr") - - currentFlexx = currentx; - currentFlexy = currenty; - - wrtpreflx2(c13); - wrtpreflx2(fc1); - wrtpreflx2(fc2); - wrtpreflx2(fc3); - wrtpreflx2(c1); - wrtpreflx2(c2); - wrtpreflx2(c3); - currentx = c3.x; - currenty = c3.y; - - WRTNUM(dmin); - WRTNUM(FTrunc(FRnd(currentx))); - WRTNUM(FTrunc(FRnd(currenty))); - ws("0 callsubr"); - firstFlex = TRUE; -} - -private -procedure ct(Cd c1, Cd c2, Cd c3, PPathElt e) { - if (e->newcolors != 0) { - wrtnewclrs(e); - } - if (e->isFlex && IsFlex(e)) { - wrtflex(c1, c2, c3, e); - } else if (needtoSubLSB && ((FRnd(c1.x) - currentx - FRnd(lsb)) == 0) && (c2.y == c3.y)) { - wrty(c1.y); - wrtx(c2.x, 1); - wrty(c2.y); - wrtx(c3.x, 0); - ws("vhcurveto"); - needtoSubLSB = FALSE; - } else if ((FRnd(c1.x) == currentx) && (c2.y == c3.y)) { - wrty(c1.y); - wrtx(c2.x, 0); - wrty(c2.y); - wrtx(c3.x, 0); - ws("vhcurveto"); - needtoSubLSB = FALSE; - } else if ((FRnd(c1.y) == currenty) && (c2.x == c3.x)) { - wrtx(c1.x, needtoSubLSB); - wrtcd(c2); - wrty(c3.y); - ws("hvcurveto"); - needtoSubLSB = FALSE; - } else { - wrtx(c1.x, needtoSubLSB); - wrty(c1.y); - wrtcd(c2); - wrtcd(c3); - ws("rrcurveto"); - needtoSubLSB = FALSE; - } - if (firstFlex) { - firstFlexMT = FALSE; - } -} - -private -procedure cp(PPathElt e) { - if (e->newcolors != 0) { - wrtnewclrs(e); - } - ws("closepath"); -} - -void CSWrite(void) { - register PPathElt e = pathStart; - Cd c1, c2, c3; - char outfile[MAXPATHLEN], tempfilename[MAXPATHLEN]; - int width; - - width = get_char_width(fileName); - lsb = GetPathLSB(); - - sprintf(tempfilename, "%s", TEMPFILE); -#if STDOUT - cstmpfile = stdout; -#else - cstmpfile = ACOpenFile(tempfilename, "w", OPENWARN); -#endif - if (cstmpfile == NULL) { - return; - } - - wrtColorInfo = (pathStart != NULL && pathStart != pathEnd); - fprintf(cstmpfile, "## -| {"); - - wrtfx(lsb); - WRTNUM((long int)width); - ws("hsbw"); - - prevhintmaskstr[0] = '\0'; - if (wrtColorInfo && !e->newcolors) { - hintmaskstr[0] = '\0'; - WrtPntLst(ptLstArray[0]); - ws(hintmaskstr); - strcpy(prevhintmaskstr, hintmaskstr); - } - - firstFlex = TRUE; - needtoSubLSB = TRUE; - firstFlexMT = TRUE; - - currentx = currenty = 0L; - while (e != NULL) { - switch (e->type) { - case CURVETO: - c1.x = UnScaleAbs(itfmx(e->x1)); - c1.y = UnScaleAbs(itfmy(e->y1)); - c2.x = UnScaleAbs(itfmx(e->x2)); - c2.y = UnScaleAbs(itfmy(e->y2)); - c3.x = UnScaleAbs(itfmx(e->x3)); - c3.y = UnScaleAbs(itfmy(e->y3)); - ct(c1, c2, c3, e); - break; - case LINETO: - c1.x = UnScaleAbs(itfmx(e->x)); - c1.y = UnScaleAbs(itfmy(e->y)); - dt(c1, e); - break; - case MOVETO: - c1.x = UnScaleAbs(itfmx(e->x)); - c1.y = UnScaleAbs(itfmy(e->y)); - mt(c1, e); - break; - case CLOSEPATH: - cp(e); - break; - default: { - sprintf(S0, "Illegal path list for file: %s.\n", fileName); - LogMsg(S0, LOGERROR, NONFATALERROR, TRUE); - } - } - - e = e->next; - } - - ws("endchar"); - fprintf(cstmpfile, " } |- \n"); - fclose(cstmpfile); - sprintf(outfile, "%s%s", outPrefix, fileName); - RenameFile(tempfilename, outfile); -} - -#endif /*THISISACMAIN && ALLOWCSOUTPUT*/ diff --git a/c/autohint/autohintlib/source/ac/enum.c b/c/autohint/autohintlib/source/ac/enum.c deleted file mode 100644 index 2fc5a1f66..000000000 --- a/c/autohint/autohintlib/source/ac/enum.c +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* enum.c */ - -#include "ac.h" -#include "bftoac.h" -#include "machinedep.h" - -public -int IncludeFile(struct direct *direntry) { - if (strcmp(direntry->d_name, ".notdef") == 0) - return (TRUE); /* added 22Apr98 */ - - /* skip dot and .BAK files */ - if (direntry->d_name[0] != '.' && !BAKFile(direntry->d_name)) - return (TRUE); - return (FALSE); -} - -public -boolean DoArgsIgnoreTime(cnt, nms, extracolor) int cnt; -char *nms[]; -boolean extracolor; -{ - int i; - boolean result = TRUE; - - for (i = 0; i < cnt; i++) { - if (!DoFile(nms[i], extracolor)) - result = FALSE; - } - return result; -} diff --git a/c/autohint/autohintlib/source/ac/eval.c b/c/autohint/autohintlib/source/ac/eval.c deleted file mode 100644 index fa331e7cc..000000000 --- a/c/autohint/autohintlib/source/ac/eval.c +++ /dev/null @@ -1,594 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* eval.c */ - -#include "ac.h" - -#define MAXF (1L << 15) -private -procedure AdjustVal(pv, l1, l2, dist, d, hFlg) - Fixed *pv, - l1, l2, dist, d; -boolean hFlg; -{ - real v, q, r1, r2, rd; - Fixed abstmp; - /* DEBUG 8 BIT. To get the saem result as the old auothint, had to change from FixedOne to FixedTwo. Since the returned weight is proportional to the square of l1 and l2, - these need to be clamped to twice the old clamped value, else when the clamped values are used, the weight comes out as 1/4 of the original value. */ - if (dist < FixTwo) - dist = FixTwo; - if (l1 < FixTwo) - l1 = FixTwo; - if (l2 < FixTwo) - l2 = FixTwo; - if (ac_abs(l1) < MAXF) - r1 = (real)(l1 * l1); - else { - r1 = (real)l1; - r1 = r1 * r1; - } - if (ac_abs(l2) < MAXF) - r2 = (real)(l2 * l2); - else { - r2 = (real)l2; - r2 = r2 * r2; - } - if (ac_abs(dist) < MAXF) - q = (real)(dist * dist); - else { - q = (real)dist; - q = q * q; - } - v = (real)((1000.0 * r1 * r2) / (q * q)); - if (d <= (hFlg ? hBigDist : vBigDist)) - goto done; - acfixtopflt(d, &rd); - q = (hFlg ? hBigDistR : vBigDistR) / rd; /* 0 < q < 1.0 */ - if (q <= 0.5) { - v = 0.0; - goto done; - } - q *= q; - q *= q; - q *= q; /* raise q to 8th power */ - v = v * q; /* if d is twice bigDist, value goes down by factor of 256 */ -done: - if (v > maxVal) - v = maxVal; - else if (v > 0.0 && v < minVal) - v = minVal; - *pv = acpflttofix(&v); -} - -private -Fixed CalcOverlapDist(d, overlaplen, minlen) - Fixed d, - overlaplen, minlen; -{ - real r = (real)d, ro = (real)overlaplen, rm = (real)minlen; - r = r * ((real)(1.0 + 0.4 * (1.0 - ro / rm))); - d = (Fixed)r; - return d; -} - -#define GapDist(d) (((d) < FixInt(127)) ? FTrunc(((d) * (d)) / 40) : ((long)(((double)(d)) * (d) / (40 * 256)))) -/* if d is >= 127.0 Fixed, then d*d will overflow the signed int 16 bit value. */ -/* DEBUG 8 BIT. No idea why d*d was divided by 20, but we need to divide it by 2 more to get a dist that is only 2* the old autohint value. - With the 8.8 fixed coordinate system, we still overflow a long int with d*(d/40), so rather than casting this to a long int and then doing >>8, we need to divide by 256, then cast to long int. - I also fail to understand why the original used FTrunc, which right shifts by 256. For the current coordinate space, which has a fractional part of 8 bits, you do need to divide by 256 after doing a simple int multiply, but the previous coordinate space - has a 7 bit Fixed fraction, and should be dividing by 128. I suspect that there was a yet earlier version which used a 8 bit fraction, and this is a bug. - */ - -private -procedure EvalHPair(botSeg, topSeg, pspc, pv) - PClrSeg botSeg, - topSeg; -Fixed *pspc, *pv; -{ - Fixed brght, blft, bloc, tloc, trght, tlft, ldst, rdst; - Fixed mndist, dist, dx, dy, minlen, overlaplen, abstmp; - boolean inBotBand, inTopBand; - int i; - *pspc = 0; - brght = botSeg->sMax; - blft = botSeg->sMin; - trght = topSeg->sMax; - tlft = topSeg->sMin; - bloc = botSeg->sLoc; - tloc = topSeg->sLoc; - dy = ac_abs(bloc - tloc); - if (dy < minDist) { - *pv = 0; - return; - } - inBotBand = InBlueBand(bloc, lenBotBands, botBands); - inTopBand = InBlueBand(tloc, lenTopBands, topBands); - if (inBotBand && inTopBand) { /* delete these */ - *pv = 0; - return; - } - if (inBotBand || inTopBand) /* up the priority of these */ - *pspc = FixInt(2); - /* left is always < right */ - if ((tlft <= brght) && (trght >= blft)) { /* overlap */ - overlaplen = MIN(trght, brght) - MAX(tlft, blft); - minlen = MIN(trght - tlft, brght - blft); - if (minlen == overlaplen) - dist = dy; - else - dist = CalcOverlapDist(dy, overlaplen, minlen); - } else { /* no overlap; take closer ends */ - ldst = ac_abs(tlft - brght); - rdst = ac_abs(trght - blft); - dx = MIN(ldst, rdst); - dist = GapDist(dx); - dist += (7 * dy) / 5; /* extra penalty for nonoverlap */ - /* changed from 7/5 to 12/5 for Perpetua/Regular/ */ - /* n, r ,m and other lowercase serifs; */ - /* undid change for Berthold/AkzidenzGrotesk 9/16/91; */ - /* this did not make Perpetua any worse. */ - DEBUG_ROUND(dist) /* DEBUG 8 BIT */ - if (dx > dy) - dist *= dx / dy; - } - mndist = FixTwoMul(minDist); - dist = MAX(dist, mndist); - if (NumHStems > 0) { - Fixed w = idtfmy(dy); - w = ac_abs(w); - for (i = 0; i < NumHStems; i++) - if (w == HStems[i]) { - *pspc += FixOne; - break; - } - } - AdjustVal(pv, brght - blft, trght - tlft, dist, dy, TRUE); -} - -private -procedure HStemMiss(botSeg, topSeg) - PClrSeg botSeg, - topSeg; -{ - Fixed brght, blft, bloc, tloc, trght, tlft, abstmp; - Fixed mndist, dist, dy, minlen, overlaplen; - Fixed b, t, diff, minDiff, minW, w, sw; - int i; - if (NumHStems == 0) - return; - brght = botSeg->sMax; - blft = botSeg->sMin; - trght = topSeg->sMax; - tlft = topSeg->sMin; - bloc = botSeg->sLoc; - tloc = topSeg->sLoc; - dy = ac_abs(bloc - tloc); - if (dy < minDist) return; - /* left is always < right */ - if ((tlft <= brght) && (trght >= blft)) { /* overlap */ - overlaplen = MIN(trght, brght) - MAX(tlft, blft); - minlen = MIN(trght - tlft, brght - blft); - if (minlen == overlaplen) - dist = dy; - else - dist = CalcOverlapDist(dy, overlaplen, minlen); - } else - return; - mndist = FixTwoMul(minDist); - if (dist < mndist) - return; - minDiff = FixInt(1000); - minW = 0; - b = itfmy(bloc); - t = itfmy(tloc); - w = t - b; - /* don't check ghost bands for near misses */ - if (((w = t - b) == botGhst) || (w == topGhst)) - return; - w = ac_abs(w); - for (i = 0; i < NumHStems; i++) { - sw = HStems[i]; - diff = ac_abs(sw - w); - if (diff == 0) - return; - if (diff < minDiff) { - minDiff = diff; - minW = sw; - } - } - if (minDiff > FixInt(2)) - return; - ReportStemNearMiss(FALSE, w, minW, b, t, - (botSeg->sType == sCURVE) || (topSeg->sType == sCURVE)); -} - -private -procedure EvalVPair(leftSeg, rightSeg, pspc, pv) - PClrSeg leftSeg, - rightSeg; -Fixed *pspc, *pv; -{ - Fixed ltop, lbot, lloc, rloc, rtop, rbot, tdst, bdst; - Fixed mndist, dx, dy, dist, overlaplen, minlen, abstmp; - Fixed bonus, lbonus, rbonus; - int i; - *pspc = 0; - ltop = leftSeg->sMax; - lbot = leftSeg->sMin; - rtop = rightSeg->sMax; - rbot = rightSeg->sMin; - lloc = leftSeg->sLoc; - rloc = rightSeg->sLoc; - dx = ac_abs(lloc - rloc); - if (dx < minDist) { - *pv = 0; - return; - } - /* top is always > bot, independent of YgoesUp */ - if ((ltop >= rbot) && (lbot <= rtop)) { /* overlap */ - overlaplen = MIN(ltop, rtop) - MAX(lbot, rbot); - minlen = MIN(ltop - lbot, rtop - rbot); - if (minlen == overlaplen) - dist = dx; - else - dist = CalcOverlapDist(dx, overlaplen, minlen); - } else { /* no overlap; take closer ends */ - tdst = ac_abs(ltop - rbot); - bdst = ac_abs(lbot - rtop); - dy = MIN(tdst, bdst); - dist = (7 * dx) / 5 + GapDist(dy); /* extra penalty for nonoverlap */ - DEBUG_ROUND(dist) /* DEBUG 8 BIT */ - if (dy > dx) - dist *= dy / dx; - } - mndist = FixTwoMul(minDist); - dist = MAX(dist, mndist); - lbonus = leftSeg->sBonus; - rbonus = rightSeg->sBonus; - bonus = MIN(lbonus, rbonus); - *pspc = (bonus > 0) ? FixInt(2) : 0; /* this is for sol-eol characters */ - if (NumVStems > 0) { - Fixed w = idtfmx(dx); - w = ac_abs(w); - for (i = 0; i < NumVStems; i++) - if (w == VStems[i]) { - *pspc = *pspc + FixOne; - break; - } - } - AdjustVal(pv, ltop - lbot, rtop - rbot, dist, dx, FALSE); -} - -private -procedure VStemMiss(leftSeg, rightSeg) - PClrSeg leftSeg, - rightSeg; -{ - Fixed ltop, lbot, lloc, rloc, rtop, rbot; - Fixed mndist, dx, dist, overlaplen, minlen, abstmp; - Fixed l, r, diff, minDiff, minW, w, sw; - int i; - if (NumVStems == 0) - return; - ltop = leftSeg->sMax; - lbot = leftSeg->sMin; - rtop = rightSeg->sMax; - rbot = rightSeg->sMin; - lloc = leftSeg->sLoc; - rloc = rightSeg->sLoc; - dx = ac_abs(lloc - rloc); - if (dx < minDist) return; - /* top is always > bot, independent of YgoesUp */ - if ((ltop >= rbot) && (lbot <= rtop)) { /* overlap */ - overlaplen = MIN(ltop, rtop) - MAX(lbot, rbot); - minlen = MIN(ltop - lbot, rtop - rbot); - if (minlen == overlaplen) - dist = dx; - else - dist = CalcOverlapDist(dx, overlaplen, minlen); - } else - return; - mndist = FixTwoMul(minDist); - dist = MAX(dist, mndist); - l = itfmx(lloc); - r = itfmx(rloc); - w = ac_abs(r - l); - minDiff = FixInt(1000); - minW = 0; - for (i = 0; i < NumVStems; i++) { - sw = VStems[i]; - diff = ac_abs(sw - w); - if (diff < minDiff) { - minDiff = diff; - minW = sw; - } - if (minDiff == 0) - return; - } - if (minDiff > FixInt(2)) - return; - ReportStemNearMiss(TRUE, w, minW, l, r, - (leftSeg->sType == sCURVE) || (rightSeg->sType == sCURVE)); -} - -private -procedure InsertVValue(lft, rght, val, spc, lSeg, rSeg) - Fixed lft, - rght, val, spc; -PClrSeg lSeg, rSeg; -{ - register PClrVal item, vlist, vprev; - item = (PClrVal)Alloc(sizeof(ClrVal)); - item->vVal = val; - item->initVal = val; - item->vLoc1 = lft; - item->vLoc2 = rght; - item->vSpc = spc; - item->vSeg1 = lSeg; - item->vSeg2 = rSeg; - item->vGhst = FALSE; - vlist = valList; - vprev = NULL; - while (vlist != NULL) { - if (vlist->vLoc1 >= lft) break; - vprev = vlist; - vlist = vlist->vNxt; - } - while (vlist != NULL && vlist->vLoc1 == lft) { - if (vlist->vLoc2 >= rght) break; - vprev = vlist; - vlist = vlist->vNxt; - } - if (vprev == NULL) - valList = item; - else - vprev->vNxt = item; - item->vNxt = vlist; - if (showClrInfo && showVs) - ReportAddVVal(item); -} - -#define LePruneValue(val) ((val) < FixOne && ((val) << 10) <= pruneValue) - -private -procedure AddVValue(lft, rght, val, spc, lSeg, rSeg) - Fixed lft, - rght, val, spc; -PClrSeg lSeg, rSeg; -{ - if (val == 0) return; - if (LePruneValue(val) && spc <= 0) return; - if (lSeg != NULL && lSeg->sType == sBEND && - rSeg != NULL && rSeg->sType == sBEND) return; - if (val <= pruneD && spc <= 0 && lSeg != NULL && rSeg != NULL) { - if (lSeg->sType == sBEND || rSeg->sType == sBEND || - !CheckBBoxes(lSeg->sElt, rSeg->sElt)) - return; - } - InsertVValue(lft, rght, val, spc, lSeg, rSeg); -} - -private -procedure InsertHValue(bot, top, val, spc, bSeg, tSeg, ghst) - Fixed bot, - top, val, spc; -PClrSeg bSeg, tSeg; -boolean ghst; -{ - PClrVal item, vlist, vprev, vl; - Fixed b; - b = itfmy(bot); - vlist = valList; - vprev = NULL; - while (vlist != NULL) { - if (vlist->vLoc2 >= top) break; - vprev = vlist; - vlist = vlist->vNxt; - } - while (vlist != NULL && vlist->vLoc2 == top) { - if (vlist->vLoc1 >= bot) break; - vprev = vlist; - vlist = vlist->vNxt; - } - /* prune ghost pair that is same as non ghost pair for same segment - only if val for ghost is less than an existing val with same - top and bottom segment (vl) */ - vl = vlist; - while (ghst && vl != NULL && vl->vLoc2 == top && vl->vLoc1 == bot) { - if (!vl->vGhst && (vl->vSeg1 == bSeg || vl->vSeg2 == tSeg) && vl->vVal > val) - return; - vl = vl->vNxt; - } - item = (PClrVal)Alloc(sizeof(ClrVal)); - item->vVal = val; - item->initVal = val; - item->vSpc = spc; - item->vLoc1 = bot; - item->vLoc2 = top; - item->vSeg1 = bSeg; - item->vSeg2 = tSeg; - item->vGhst = ghst; - if (vprev == NULL) - valList = item; - else - vprev->vNxt = item; - item->vNxt = vlist; - if (showClrInfo && showHs) - ReportAddHVal(item); -} - -private -procedure AddHValue(bot, top, val, spc, bSeg, tSeg) - Fixed bot, - top, val, spc; -PClrSeg bSeg, tSeg; -{ - boolean ghst; - if (val == 0) return; - if (LePruneValue(val) && spc <= 0) return; - if (bSeg->sType == sBEND && tSeg->sType == sBEND) return; - ghst = bSeg->sType == sGHOST || tSeg->sType == sGHOST; - if (!ghst && val <= pruneD && spc <= 0) { - if (bSeg->sType == sBEND || tSeg->sType == sBEND || - !CheckBBoxes(bSeg->sElt, tSeg->sElt)) - return; - } - InsertHValue(bot, top, val, spc, bSeg, tSeg, ghst); -} - -private -real mfabs(real in) { - if (in > 0) return in; - return -in; -} - -private -Fixed CombVals(v1, v2) Fixed v1, v2; -{ - register integer i; - real r1, r2; - register real x, a, xx; - acfixtopflt(v1, &r1); - acfixtopflt(v2, &r2); - /* home brew sqrt */ - a = r1 * r2; - x = a; - for (i = 0; i < 16; i++) { - xx = ((real)0.5) * (x + a / x); - if (i >= 8 && mfabs(xx - x) <= mfabs(xx) * 0.0000001) break; - x = xx; - } - r1 += r2 + ((real)2.0) * xx; - if (r1 > maxVal) - r1 = maxVal; - else if (r1 > 0 && r1 < minVal) - r1 = minVal; - return acpflttofix(&r1); -} - -private -procedure CombineValues() { /* works for both H and V */ - PClrVal vlist, v1; - Fixed loc1, loc2; - Fixed val; - boolean match; - vlist = valList; - while (vlist != NULL) { - v1 = vlist->vNxt; - loc1 = vlist->vLoc1; - loc2 = vlist->vLoc2; - val = vlist->vVal; - match = FALSE; - while (v1 != NULL && v1->vLoc1 == loc1 && v1->vLoc2 == loc2) { - if (v1->vGhst) - val = v1->vVal; - else - val = CombVals(val, v1->vVal); - /* increase value to compensate for length squared effect */ - match = TRUE; - v1 = v1->vNxt; - } - if (match) { - while (vlist != v1) { - vlist->vVal = val; - vlist = vlist->vNxt; - } - } else - vlist = v1; - } -} - -public -procedure EvalV() { - PClrSeg lList, rList; - Fixed lft, rght; - Fixed val, spc; - valList = NULL; - lList = leftList; - while (lList != NULL) { - rList = rightList; - while (rList != NULL) { - lft = lList->sLoc; - rght = rList->sLoc; - if (lft < rght) { - EvalVPair(lList, rList, &spc, &val); - VStemMiss(lList, rList); - AddVValue(lft, rght, val, spc, lList, rList); - } - rList = rList->sNxt; - } - lList = lList->sNxt; - } - CombineValues(); -} - -public -procedure EvalH() { - PClrSeg bList, tList, lst, ghostSeg; - Fixed lstLoc, tempLoc, cntr; - Fixed val, spc; - valList = NULL; - bList = botList; - while (bList != NULL) { - tList = topList; - while (tList != NULL) { - Fixed bot, top; - bot = bList->sLoc; - top = tList->sLoc; - if ((bot < top && YgoesUp) || (bot > top && !YgoesUp)) { - EvalHPair(bList, tList, &spc, &val); - HStemMiss(bList, tList); - AddHValue(bot, top, val, spc, bList, tList); - } - tList = tList->sNxt; - } - bList = bList->sNxt; - } - ghostSeg = (PClrSeg)Alloc(sizeof(ClrSeg)); - ghostSeg->sType = sGHOST; - ghostSeg->sElt = NULL; - if (lenBotBands < 2 && lenTopBands < 2) goto done; - lst = botList; - while (lst != NULL) { - lstLoc = lst->sLoc; - if (InBlueBand(lstLoc, lenBotBands, botBands)) { - tempLoc = lstLoc; - if (YgoesUp) - tempLoc += ghostWidth; - else - tempLoc -= ghostWidth; - ghostSeg->sLoc = tempLoc; - cntr = (lst->sMax + lst->sMin) / 2; - ghostSeg->sMax = cntr + ghostLength / 2; - ghostSeg->sMin = cntr - ghostLength / 2; - DEBUG_ROUND(ghostSeg->sMax) /* DEBUG 8 BIT */ - DEBUG_ROUND(ghostSeg->sMin) /* DEBUG 8 BIT */ - spc = FixInt(2); - val = FixInt(20); - AddHValue(lstLoc, tempLoc, val, spc, lst, ghostSeg); - } - lst = lst->sNxt; - } - lst = topList; - while (lst != NULL) { - lstLoc = lst->sLoc; - if (InBlueBand(lstLoc, lenTopBands, topBands)) { - tempLoc = lstLoc; - if (!YgoesUp) - tempLoc += ghostWidth; - else - tempLoc -= ghostWidth; - ghostSeg->sLoc = tempLoc; - cntr = (lst->sMin + lst->sMax) / 2; - ghostSeg->sMax = cntr + ghostLength / 2; - ghostSeg->sMin = cntr - ghostLength / 2; - spc = FixInt(2); - val = FixInt(20); - AddHValue(tempLoc, lstLoc, val, spc, ghostSeg, lst); - } - lst = lst->sNxt; - } -done: - CombineValues(); -} diff --git a/c/autohint/autohintlib/source/ac/fix.c b/c/autohint/autohintlib/source/ac/fix.c deleted file mode 100644 index 48d6d3fd1..000000000 --- a/c/autohint/autohintlib/source/ac/fix.c +++ /dev/null @@ -1,363 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* fix.c */ - -#include "ac.h" -#include "machinedep.h" - -#define maxFixes (100) -private -Fixed HFixYs[maxFixes], HFixDYs[maxFixes]; -private -Fixed VFixXs[maxFixes], VFixDXs[maxFixes]; -private -integer HFixCount, VFixCount; -private -Fixed bPrev, tPrev; - -public -procedure InitFix(reason) integer reason; -{ - switch (reason) { - case STARTUP: - case RESTART: - HFixCount = VFixCount = 0; - bPrev = tPrev = FixedPosInf; - } -} - -private -procedure RecordHFix(y, dy) Fixed y, dy; -{ - HFixYs[HFixCount] = y; - HFixDYs[HFixCount] = dy; - HFixCount++; -} - -private -procedure RecordVFix(x, dx) Fixed x, dx; -{ - VFixXs[VFixCount] = x; - VFixDXs[VFixCount] = dx; - VFixCount++; -} - -private -procedure RecordForFix(vert, w, minW, b, t) - boolean vert; -Fixed w, minW, b, t; -{ - Fixed mn, mx, delta; - if (b < t) { - mn = b; - mx = t; - } else { - mn = t; - mx = b; - } - if (!vert && HFixCount + 4 < maxFixes && autoHFix) { - Fixed fixdy = w - minW; - if (abs(fixdy) <= FixOne) { - RecordHFix(mn, fixdy); - RecordHFix(mx - fixdy, fixdy); - } else { - delta = FixHalfMul(fixdy); - RecordHFix(mn, delta); - RecordHFix(mn + fixdy, -delta); - RecordHFix(mx, -delta); - RecordHFix(mx - fixdy, delta); - } - } else if (vert && VFixCount + 4 < maxFixes && autoVFix) { - Fixed fixdx = w - minW; - if (abs(fixdx) <= FixOne) { - RecordVFix(mn, fixdx); - RecordVFix(mx - fixdx, fixdx); - } else { - delta = FixHalfMul(fixdx); - RecordVFix(mn, delta); - RecordVFix(mn + fixdx, -delta); - RecordVFix(mx, -delta); - RecordVFix(mx - fixdx, delta); - } - } -} - -private -boolean CheckForInsideBands(loc, blues, numblues) - Fixed loc, - *blues; -integer numblues; -{ - integer i; - for (i = 0; i < numblues; i += 2) { - if (loc >= blues[i] && loc <= blues[i + 1]) return TRUE; - } - return FALSE; -} - -#define bFuzz (FixInt(6)) -private -procedure CheckForNearBands(loc, blues, numblues) - Fixed loc, - *blues; -integer numblues; -{ - integer i; - boolean bottom = TRUE; - for (i = 0; i < numblues; i++) { - if ((bottom && loc >= blues[i] - bFuzz && loc < blues[i]) || - (!bottom && loc <= blues[i] + bFuzz && loc > blues[i])) { -#if 0 - ReportBandError(bottom? "below" : "above", loc, blues[i]); -#else - ReportBandNearMiss(bottom ? "below" : "above", loc, blues[i]); -#endif -#if 0 - bandError = TRUE; -#endif - } - bottom = !bottom; - } -} - -public -boolean FindLineSeg(loc, sL) Fixed loc; -PClrSeg sL; -{ - while (sL != NULL) { - if (sL->sLoc == loc && sL->sType == sLINE) return TRUE; - sL = sL->sNxt; - } - return FALSE; -} - -#if 1 -/* Traverses hSegList to check for near misses to - the horizontal alignment zones. The list contains - segments that may or may not have hints added. */ -public -procedure CheckTfmVal(hSegList, bandList, length) - PClrSeg hSegList; -Fixed *bandList; -long int length; -{ - Fixed tfmval; - PClrSeg sList = hSegList; - - while (sList != NULL) { - tfmval = itfmy(sList->sLoc); - if ((length >= 2) && !bandError && - !CheckForInsideBands(tfmval, bandList, length)) - CheckForNearBands(tfmval, bandList, length); - sList = sList->sNxt; - } -} -#else -public -procedure CheckTfmVal(b, t, vert) Fixed b, t; -boolean vert; -{ - if (t < b) { - Fixed tmp; - tmp = t; - t = b; - b = tmp; - } - if (!vert && (lenTopBands >= 2 || lenBotBands >= 2) && !bandError && - !CheckForInsideBands(t, topBands, lenTopBands) && - !CheckForInsideBands(b, botBands, lenBotBands)) { - CheckForNearBands(t, topBands, lenTopBands); - CheckForNearBands(b, botBands, lenBotBands); - } -} -#endif - -public -procedure CheckVal(val, vert) PClrVal val; -boolean vert; -{ - Fixed *stems; - integer numstems, i; - Fixed wd, diff, minDiff, minW, b, t, w; - boolean curve = FALSE; - if (vert) { - stems = VStems; - numstems = NumVStems; - b = itfmx(val->vLoc1); - t = itfmx(val->vLoc2); - } else { - stems = HStems; - numstems = NumHStems; - b = itfmy(val->vLoc1); - t = itfmy(val->vLoc2); - } - w = abs(t - b); - minDiff = FixInt(1000); - minW = 0; - for (i = 0; i < numstems; i++) { - wd = stems[i]; - diff = abs(wd - w); - if (diff < minDiff) { - minDiff = diff; - minW = wd; - if (minDiff == 0) break; - } - } - if (minDiff == 0 || minDiff > FixInt(2)) - return; - if (b != bPrev || t != tPrev) { - if ((vert && (!FindLineSeg(val->vLoc1, leftList) || - !FindLineSeg(val->vLoc2, rightList))) || - (!vert && (!FindLineSeg(val->vLoc1, botList) || - !FindLineSeg(val->vLoc2, topList)))) - curve = TRUE; - if (!val->vGhst) - ReportStemNearMiss(vert, w, minW, b, t, curve); - } - bPrev = b; - tPrev = t; - if ((vert && autoVFix) || (!vert && autoHFix)) - RecordForFix(vert, w, minW, b, t); -} - -public -procedure CheckVals(vlst, vert) PClrVal vlst; -boolean vert; -{ - while (vlst != NULL) { - CheckVal(vlst, vert); - vlst = vlst->vNxt; - } -} - -private -procedure FixH(e, fixy, fixdy) PPathElt e; -Fixed fixy, fixdy; -{ - PPathElt prev, nxt; - RMovePoint(0L, fixdy, cpStart, e); - RMovePoint(0L, fixdy, cpEnd, e); - prev = e->prev; - if (prev != NULL && prev->type == CURVETO && prev->y2 == fixy) - RMovePoint(0L, fixdy, cpCurve2, prev); - if (e->type == CLOSEPATH) e = GetDest(e); - nxt = e->next; - if (nxt != NULL && nxt->type == CURVETO && nxt->y1 == fixy) - RMovePoint(0L, fixdy, cpCurve1, nxt); -} - -private -procedure FixHs(fixy, fixdy) - Fixed fixy, - fixdy; -{ /* y dy in user space */ - PPathElt e; - Fixed xlst, ylst, xinit, yinit; - fixy = tfmy(fixy); - fixdy = dtfmy(fixdy); - e = pathStart; - while (e != NULL) { - switch (e->type) { - case MOVETO: - xlst = xinit = e->x; - ylst = yinit = e->y; - break; - case LINETO: - if (e->y == fixy && ylst == fixy) - FixH(e, fixy, fixdy); - xlst = e->x; - ylst = e->y; - break; - case CURVETO: - xlst = e->x3; - ylst = e->y3; - break; - case CLOSEPATH: - if (yinit == fixy && ylst == fixy && xinit != xlst) - FixH(e, fixy, fixdy); - break; - default: { - FlushLogFiles(); - sprintf(globmsg, "Illegal operator in path list in %s.\n", fileName); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - } - e = e->next; - } -} - -private -procedure FixV(e, fixx, fixdx) PPathElt e; -Fixed fixx, fixdx; -{ - PPathElt prev, nxt; - RMovePoint(fixdx, 0L, cpStart, e); - RMovePoint(fixdx, 0L, cpEnd, e); - prev = e->prev; - if (prev != NULL && prev->type == CURVETO && prev->x2 == fixx) - RMovePoint(fixdx, 0L, cpCurve2, prev); - if (e->type == CLOSEPATH) e = GetDest(e); - nxt = e->next; - if (nxt != NULL && nxt->type == CURVETO && nxt->x1 == fixx) - RMovePoint(fixdx, 0L, cpCurve1, nxt); -} - -private -procedure FixVs(fixx, fixdx) - Fixed fixx, - fixdx; -{ /* x dx in user space */ - PPathElt e; - Fixed xlst, ylst, xinit, yinit; - fixx = tfmx(fixx); - fixdx = dtfmx(fixdx); - e = pathStart; - while (e != NULL) { - switch (e->type) { - case MOVETO: - xlst = xinit = e->x; - ylst = yinit = e->y; - break; - case LINETO: - if (e->x == fixx && xlst == fixx) - FixV(e, fixx, fixdx); - xlst = e->x; - ylst = e->y; - break; - case CURVETO: - xlst = e->x3; - ylst = e->y3; - break; - case CLOSEPATH: - if (xinit == fixx && xlst == fixx && yinit != ylst) - FixV(e, fixx, fixdx); - break; - default: { - FlushLogFiles(); - sprintf(globmsg, "Illegal operator in point list in %s.\n", fileName); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - } - e = e->next; - } -} - -public -boolean DoFixes() { - boolean didfixes = FALSE; - integer i; - if (HFixCount > 0 && autoHFix) { - PrintMessage("Fixing horizontal near misses."); - didfixes = TRUE; - for (i = 0; i < HFixCount; i++) - FixHs(HFixYs[i], HFixDYs[i]); - } - if (VFixCount > 0 && autoVFix) { - PrintMessage("Fixing vertical near misses."); - didfixes = TRUE; - for (i = 0; i < VFixCount; i++) - FixVs(VFixXs[i], VFixDXs[i]); - } - return didfixes; -} diff --git a/c/autohint/autohintlib/source/ac/flat.c b/c/autohint/autohintlib/source/ac/flat.c deleted file mode 100644 index 18b79b1f6..000000000 --- a/c/autohint/autohintlib/source/ac/flat.c +++ /dev/null @@ -1,375 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* flat.c */ - -#include "ac.h" - -private -procedure FMiniFltn(f0, f1, f2, f3, pfr, inside) - Cd f0, - f1, f2, f3; -register PFltnRec pfr; -boolean inside; -{ - /* Like FFltnCurve, but assumes abs(deltas) <= 127 pixels */ - /* 8 bits of fraction gives enough precision for splitting curves */ -#define MFix(f) (f) -#define UnMFix(f) (f) -#define MFixInt(f) ((f) << 8) -#define MiniFltnMaxDepth (6) -#define inrect (p[-10]) -#define inbbox (p[-9]) -#define c0x (p[-8]) -#define c0y (p[-7]) -#define c1x (p[-6]) -#define c1y (p[-5]) -#define c2x (p[-4]) -#define c2y (p[-3]) -#define c3x (p[-2]) -#define c3y (p[-1]) -#define inrect2 (p[0]) -#define bbox2 (p[1]) -#define d0x (p[2]) -#define d0y (p[3]) -#define d1x (p[4]) -#define d1y (p[5]) -#define d2x (p[6]) -#define d2y (p[7]) -#define d3x (p[8]) -#define d3y (p[9]) -#define MiniBlkSz (10) -#define mdpt(a, b) (((long)(a) + (long)(b)) >> 1) - long int cds[MiniBlkSz * MiniFltnMaxDepth], dpth, eps; - long int bbLLX, bbLLY, bbURX, bbURY; - register long int *p; - p = cds; - dpth = 1; - *(p++) = inside; /* initial value of inrect2. Set to True by caller, and is never set false. */ - *(p++) = FALSE; /* inbbox2 starts out FALSE */ - /* shift coordinates so that lower left of BBox is at (0,0)*/ - /* This fills the first MiniBlkSz series of ints with the start point, control point, end end point - (x,y) values for the curve, minus the lower left (x,y) for the curve. - One each pass, it splits the curve in two, replacing the current MiniBlkSz series of ints with the first - of the two split curves, and the next MiniBlkSz series of ints with the second of the curves. - It then sets the pointer p so that the second MiniBlkSz series of ints becomes the current set, - and iterates, thereby splitting the second curve in two parts. This continues until the control points - get very close to the start point, or we reach the limit of MiniFltnMaxDepth iterations. At that time, - the PathBBox update function is called with the end point of the first of the most recently split curves. - -Once the the current set of points meets the test that one of the control points is very close to the start point, - then the algoithm iteratively steps back to the previous set. If thsi does not meet the test, the algorith - iterates forward again - */ - /*DEBUG 8 BIT. AFter chaning the fractinoal part to 8 bits form 7 bits, had to change all the short values to long in order to not overflow math operations. The only reason these were all shorts was speed and memory issues in 1986. */ - { - register Fixed llx, lly; - llx = pfr->llx; - lly = pfr->lly; - *(p++) = (long)MFix(f0.x - llx); - *(p++) = (long)MFix(f0.y - lly); - *(p++) = (long)MFix(f1.x - llx); - *(p++) = (long)MFix(f1.y - lly); - *(p++) = (long)MFix(f2.x - llx); - *(p++) = (long)MFix(f2.y - lly); - *(p++) = (long)MFix(f3.x - llx); - *(p++) = (long)MFix(f3.y - lly); - } - if (!inrect) { - register Fixed c, f128; - c = (long)pfr->ll.x; - bbLLX = (c <= 0) ? 0 : (long)MFix(c); - c = (long)pfr->ll.y; - bbLLY = (c <= 0) ? 0 : (long)MFix(c); - f128 = FixInt(128); - c = (long)pfr->ur.x; - bbURX = (c >= f128) ? 0x7fff : (long)MFix(c); - c = (long)pfr->ur.y; - bbURY = (c >= f128) ? 0x7fff : (long)MFix(c); - } - eps = (long)MFix(pfr->feps); - // if (eps < 8) - // eps = 8; /* Brotz patch */ - if (eps < 16) /* DEBUG 8 BIT FIX */ - eps = 16; /* Brotz patch */ - while (TRUE) { - /* Iterate until curve has been flattened into MiniFltnMaxDepth segments */ - if (dpth == MiniFltnMaxDepth) - goto ReportC3; - if (!inrect) { - register long int llx, lly, urx, ury, c; - llx = urx = c0x; - if ((c = c1x) < llx) - llx = c; - else if (c > urx) - urx = c; - if ((c = c2x) < llx) - llx = c; - else if (c > urx) - urx = c; - if ((c = c3x) < llx) - llx = c; - else if (c > urx) - urx = c; - if (urx < bbLLX || llx > bbURX) - goto ReportC3; - lly = ury = c0y; - if ((c = c1y) < lly) - lly = c; - else if (c > ury) - ury = c; - if ((c = c2y) < lly) - lly = c; - else if (c > ury) - ury = c; - if ((c = c3y) < lly) - lly = c; - else if (c > ury) - ury = c; - if (ury < bbLLY || lly > bbURY) - goto ReportC3; - if (urx <= bbURX && ury <= bbURY && - llx >= bbLLX && lly >= bbLLY) inrect = TRUE; - } - if (!inbbox) { - register long int mrgn = eps, r0, r3, ll, ur, c; - r0 = c0x; - r3 = c3x; - if (r0 < r3) { - ll = r0 - mrgn; - ur = r3 + mrgn; - } else { - ll = r3 - mrgn; - ur = r0 + mrgn; - } - if (ur < 0) - ur = MFixInt(128) - 1; - c = c1x; - if (c > ll && c < ur) { - c = c2x; - if (c > ll && c < ur) { - r0 = c0y; - r3 = c3y; - if (r0 < r3) { - ll = r0 - mrgn; - ur = r3 + mrgn; - } else { - ll = r3 - mrgn; - ur = r0 + mrgn; - } - if (ur < 0) - ur = MFixInt(128) - 1; - c = c1y; - if (c > ll && c < ur) { - c = c2y; - if (c > ll && c < ur) inbbox = TRUE; - } - } - } - } - if (inbbox) { - register long int eqa, eqb, x, y; - register Fixed EPS, d; - x = c0x; - y = c0y; - eqa = c3y - y; - eqb = x - c3x; - if (eqa == 0 && eqb == 0) goto ReportC3; - EPS = ((abs(eqa) > abs(eqb)) ? (long)eqa : (long)eqb) * (long)eps; - if (EPS < 0) EPS = -EPS; - d = (long)eqa * (long)(c1x - x); - d += (long)eqb * (long)(c1y - y); - if (abs(d) < EPS) { - d = (long)eqa * (long)(c2x - x); - d += (long)eqb * (long)(c2y - y); - if (abs(d) < EPS) - goto ReportC3; - } - } - { /* Bezier divide */ - register long int c0, c1, c2, d1, d2, d3; - d0x = c0 = c0x; - c1 = c1x; - c2 = c2x; - d1x = d1 = (long)mdpt(c0, c1); - d3 = (long)mdpt(c1, c2); - d2x = d2 = (long)mdpt(d1, d3); - c2x = c2 = (long)mdpt(c2, c3x); - c1x = c1 = (long)mdpt(d3, c2); - c0x = d3x = (long)mdpt(d2, c1); - d0y = c0 = c0y; - c1 = c1y; - c2 = c2y; - d1y = d1 = (long)mdpt(c0, c1); - d3 = (long)mdpt(c1, c2); - d2y = d2 = (long)mdpt(d1, d3); - c2y = c2 = (long)mdpt(c2, c3y); - c1y = c1 = (long)mdpt(d3, c2); - c0y = d3y = (long)mdpt(d2, c1); - bbox2 = inbbox; - inrect2 = inrect; - p += MiniBlkSz; - dpth++; - continue; - } - ReportC3 : { - Cd c; - if (--dpth == 0) - c = f3; - else { - c.x = UnMFix(c3x) + pfr->llx; - c.y = UnMFix(c3y) + pfr->lly; - } - (*pfr->report)(c); // call FPBBoxPt() to reset bbox. - if (dpth == 0) - return; - p -= MiniBlkSz; - } - } -} /* end of FMiniFltn */ -#undef MFix -#undef UnMFix -#undef MFixInt -#undef MiniFltnMaxDepth -#undef inrect -#undef inbbox -#undef c0x -#undef c0y -#undef c1x -#undef c1y -#undef c2x -#undef c2y -#undef c3x -#undef c3y -#undef inrect2 -#undef bbox2 -#undef d0x -#undef d0y -#undef d1x -#undef d1y -#undef d2x -#undef d2y -#undef d3x -#undef d3y -#undef MiniBlkSz -#undef mdpt - -#define FixedMidPoint(m, a, b) \ - (m).x = ((a).x + (b).x) >> 1; \ - (m).y = ((a).y + (b).y) >> 1 - -#define FixedBezDiv(a0, a1, a2, a3, b0, b1, b2, b3) \ - b3 = a3; \ - FixedMidPoint(b2, a2, a3); \ - FixedMidPoint(a3, a1, a2); \ - FixedMidPoint(a1, a0, a1); \ - FixedMidPoint(a2, a1, a3); \ - FixedMidPoint(b1, a3, b2); \ - FixedMidPoint(b0, a2, b1); \ - a3 = b0 - -private -procedure FFltnCurve(c0, c1, c2, c3, pfr, inrect) - /* inrect = !testRect */ - Cd c0, - c1, c2, c3; -register PFltnRec pfr; -register boolean inrect; -/* Like FltnCurve, but works in the Fixed domain. */ -/* abs values of coords must be < 2^14 so will not overflow when - find midpoint by add and shift */ -{ - Cd d0, d1, d2, d3; - register Fixed llx, lly, urx, ury; - if (c0.x == c1.x && c0.y == c1.y && c2.x == c3.x && c2.y == c3.y) - goto ReportC3; /* it is a flat curve - do not need to flatten. */ - if (pfr->limit <= 0) - goto ReportC3; - { /* set initial bbox of llx,lly, urx, ury from bez control and end points */ - register Fixed c; - llx = urx = c0.x; - if ((c = c1.x) < llx) - llx = c; - else if (c > urx) - urx = c; - if ((c = c2.x) < llx) - llx = c; - else if (c > urx) - urx = c; - if ((c = c3.x) < llx) - llx = c; - else if (c > urx) - urx = c; - lly = ury = c0.y; - if ((c = c1.y) < lly) - lly = c; - else if (c > ury) - ury = c; - if ((c = c2.y) < lly) - lly = c; - else if (c > ury) - ury = c; - if ((c = c3.y) < lly) - lly = c; - else if (c > ury) - ury = c; - } - - if (!inrect) { - if (urx < pfr->ll.x || llx > pfr->ur.x || - ury < pfr->ll.y || lly > pfr->ur.y) - goto ReportC3; - if (urx <= pfr->ur.x && ury <= pfr->ur.y && - llx >= pfr->ll.x && lly >= pfr->ll.y) - inrect = TRUE; - } - { /* if the height or width of the initial bbox is > 256, split it, and this function on the two parts. */ - register Fixed th; - th = FixInt(256); /* DEBUG 8 Bit */ /* delta threshhold of 127 pixels */ - /* The reason we split this is that the FMiniFltn function uses and 8.8 Fixed to hold coordindate data - so the max - intger part must be no more than 127, to allow for signed values. This made sense when an int was 16 bits, but is no longer an optimization. I still subdivide, so that FMiniFltn, which subdivides into a maximum of 6 curve segments, will be owkring with short segments. */ - if (urx - llx >= th || ury - lly >= th) { - goto Split; - } - } - pfr->llx = llx; - pfr->lly = lly; - if (!inrect) { - pfr->ll.x -= llx; - pfr->ur.x -= llx; - pfr->ll.y -= lly; - pfr->ur.y -= lly; - } - FMiniFltn(c0, c1, c2, c3, pfr, inrect); - if (!inrect) { - pfr->ll.x += llx; - pfr->ur.x += llx; - pfr->ll.y += lly; - pfr->ur.y += lly; - } - return; - -Split: - /* Split the bez curve in half */ - FixedBezDiv(c0, c1, c2, c3, d0, d1, d2, d3); - pfr->limit--; - FFltnCurve(c0, c1, c2, c3, pfr, inrect); - FFltnCurve(d0, d1, d2, d3, pfr, inrect); - pfr->limit++; - return; - -ReportC3: - (*pfr->report)(c3); -} - -public -procedure FltnCurve(c0, c1, c2, c3, pfr) - Cd c0, - c1, c2, c3; -PFltnRec pfr; -{ - pfr->limit = 6; /* limit on how many times a bez curve can be split in half by recursive calls to FFltnCurve() */ - /* pfr->feps = FixHalf; */ - pfr->feps = FixOne; /* DEBUG 8 BIT FIX */ - FFltnCurve(c0, c1, c2, c3, pfr, TRUE); -} diff --git a/c/autohint/autohintlib/source/ac/fontinfo.c b/c/autohint/autohintlib/source/ac/fontinfo.c deleted file mode 100644 index e8a559ad8..000000000 --- a/c/autohint/autohintlib/source/ac/fontinfo.c +++ /dev/null @@ -1,248 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* fontinfo.c */ - -#include "ac.h" -#include "fipublic.h" - -#define UNDEFINED (MAXinteger) - -public -integer NumHColors, NumVColors; - -private -procedure ParseStems(kw, stems, pnum) char *kw; -Fixed *stems; -integer *pnum; -{ - int istems[MAXSTEMS], i; - ParseIntStems(kw, ACOPTIONAL, MAXSTEMS, istems, pnum, NULL); - for (i = 0; i < *pnum; i++) - stems[i] = FixInt(istems[i]); -} - -private -procedure GetKeyValue(keyword, optional, value) char *keyword; -boolean optional; -long int *value; -{ - char *fontinfostr; - - fontinfostr = GetFntInfo(keyword, optional); - - if ((fontinfostr != NULL) && (fontinfostr[0] != 0)) { - *value = atol(fontinfostr); -#if DOMEMCHECK - memck_free(fontinfostr); -#else - ACFREEMEM(fontinfostr); -#endif - } - return; -} - -private -procedure GetKeyFixedValue(char *keyword, boolean optional, Fixed *value) { - char *fontinfostr; - float tempValue; - - fontinfostr = GetFntInfo(keyword, optional); - - if ((fontinfostr != NULL) && (fontinfostr[0] != 0)) { - sscanf(fontinfostr, "%g", &tempValue); - *value = (Fixed)tempValue * (1 << FixShift); -#if DOMEMCHECK - memck_free(fontinfostr); -#else - ACFREEMEM(fontinfostr); -#endif - } - return; -} - -public -boolean ReadFontInfo() { - char *fontinfostr; - long - AscenderHeight, - AscenderOvershoot, - BaselineYCoord, - BaselineOvershoot, - Baseline5, - Baseline5Overshoot, - Baseline6, - Baseline6Overshoot, - CapHeight, - CapOvershoot, - DescenderHeight, - DescenderOvershoot, - FigHeight, - FigOvershoot, - Height5, - Height5Overshoot, - Height6, - Height6Overshoot, - LcHeight, - LcOvershoot, - OrdinalBaseline, - OrdinalOvershoot, - SuperiorBaseline, - SuperiorOvershoot; - boolean ORDINARYCOLORING = !scalinghints && writecoloredbez; - - AscenderHeight = - AscenderOvershoot = - BaselineYCoord = - BaselineOvershoot = - Baseline5 = - Baseline5Overshoot = - Baseline6 = - Baseline6Overshoot = - CapHeight = - CapOvershoot = - DescenderHeight = - DescenderOvershoot = - FigHeight = - FigOvershoot = - Height5 = - Height5Overshoot = - Height6 = - Height6Overshoot = - LcHeight = - LcOvershoot = - OrdinalBaseline = - OrdinalOvershoot = - SuperiorBaseline = - SuperiorOvershoot = UNDEFINED; /* mark as undefined */ - NumHStems = NumVStems = 0; - NumHColors = NumVColors = 0; - lenBotBands = lenTopBands = 0; - - if (scalinghints) { - SetFntInfoFileName(SCALEDHINTSINFO); - } else { /* check for FlexOK, AuxHStems, AuxVStems */ - /* for intelligent scaling, it's too hard to check these */ - ParseStems("StemSnapH", HStems, &NumHStems); - ParseStems("StemSnapV", VStems, &NumVStems); - if (NumHStems == 0) { - ParseStems("DominantH", HStems, &NumHStems); - ParseStems("DominantV", VStems, &NumVStems); - } - } - fontinfostr = GetFntInfo("FlexOK", !ORDINARYCOLORING); - flexOK = (fontinfostr != NULL) && (fontinfostr[0] != '\0') && strcmp(fontinfostr, "false"); - -#if DOMEMCHECK - memck_free(fontinfostr); -#else - ACFREEMEM(fontinfostr); -#endif - fontinfostr = GetFntInfo("FlexStrict", TRUE); - if (fontinfostr != NULL) - flexStrict = strcmp(fontinfostr, "false"); -#if DOMEMCHECK - memck_free(fontinfostr); -#else - ACFREEMEM(fontinfostr); -#endif - - /* get bluefuzz. It is already set to its default value in ac.c::InitData(). - GetKeyFixedValue does nto change the value if it is not present in fontinfo. */ - GetKeyFixedValue("BlueFuzz", ACOPTIONAL, &bluefuzz); - - /* Check for counter coloring characters. */ - if ((fontinfostr = GetFntInfo("VCounterChars", ACOPTIONAL)) != NULL) { - NumVColors = AddCounterColorChars(fontinfostr, VColorList); -#if DOMEMCHECK - memck_free(fontinfostr); -#else - ACFREEMEM(fontinfostr); -#endif - }; - if ((fontinfostr = GetFntInfo("HCounterChars", ACOPTIONAL)) != NULL) { - NumHColors = AddCounterColorChars(fontinfostr, HColorList); -#if DOMEMCHECK - memck_free(fontinfostr); -#else - ACFREEMEM(fontinfostr); -#endif - }; - GetKeyValue("AscenderHeight", ACOPTIONAL, &AscenderHeight); - GetKeyValue("AscenderOvershoot", ACOPTIONAL, &AscenderOvershoot); - GetKeyValue("BaselineYCoord", !ORDINARYCOLORING, &BaselineYCoord); - GetKeyValue("BaselineOvershoot", !ORDINARYCOLORING, &BaselineOvershoot); - GetKeyValue("Baseline5", ACOPTIONAL, &Baseline5); - GetKeyValue("Baseline5Overshoot", ACOPTIONAL, &Baseline5Overshoot); - GetKeyValue("Baseline6", ACOPTIONAL, &Baseline6); - GetKeyValue("Baseline6Overshoot", ACOPTIONAL, &Baseline6Overshoot); - GetKeyValue("CapHeight", !ORDINARYCOLORING, &CapHeight); - GetKeyValue("CapOvershoot", !ORDINARYCOLORING, &CapOvershoot); - GetKeyValue("DescenderHeight", ACOPTIONAL, &DescenderHeight); - GetKeyValue("DescenderOvershoot", ACOPTIONAL, &DescenderOvershoot); - GetKeyValue("FigHeight", ACOPTIONAL, &FigHeight); - GetKeyValue("FigOvershoot", ACOPTIONAL, &FigOvershoot); - GetKeyValue("Height5", ACOPTIONAL, &Height5); - GetKeyValue("Height5Overshoot", ACOPTIONAL, &Height5Overshoot); - GetKeyValue("Height6", ACOPTIONAL, &Height6); - GetKeyValue("Height6Overshoot", ACOPTIONAL, &Height6Overshoot); - GetKeyValue("LcHeight", ACOPTIONAL, &LcHeight); - GetKeyValue("LcOvershoot", ACOPTIONAL, &LcOvershoot); - GetKeyValue("OrdinalBaseline", ACOPTIONAL, &OrdinalBaseline); - GetKeyValue("OrdinalOvershoot", ACOPTIONAL, &OrdinalOvershoot); - GetKeyValue("SuperiorBaseline", ACOPTIONAL, &SuperiorBaseline); - GetKeyValue("SuperiorOvershoot", ACOPTIONAL, &SuperiorOvershoot); - - lenBotBands = lenTopBands = 0; - if (BaselineYCoord != UNDEFINED && BaselineOvershoot != UNDEFINED) { - botBands[lenBotBands++] = ScaleAbs(FixInt(BaselineYCoord + BaselineOvershoot)); - botBands[lenBotBands++] = ScaleAbs(FixInt(BaselineYCoord)); - } - if (Baseline5 != UNDEFINED && Baseline5Overshoot != UNDEFINED) { - botBands[lenBotBands++] = ScaleAbs(FixInt(Baseline5 + Baseline5Overshoot)); - botBands[lenBotBands++] = ScaleAbs(FixInt(Baseline5)); - } - if (Baseline6 != UNDEFINED && Baseline6Overshoot != UNDEFINED) { - botBands[lenBotBands++] = ScaleAbs(FixInt(Baseline6 + Baseline6Overshoot)); - botBands[lenBotBands++] = ScaleAbs(FixInt(Baseline6)); - } - if (SuperiorBaseline != UNDEFINED && SuperiorOvershoot != UNDEFINED) { - botBands[lenBotBands++] = ScaleAbs(FixInt(SuperiorBaseline + SuperiorOvershoot)); - botBands[lenBotBands++] = ScaleAbs(FixInt(SuperiorBaseline)); - } - if (OrdinalBaseline != UNDEFINED && OrdinalOvershoot != UNDEFINED) { - botBands[lenBotBands++] = ScaleAbs(FixInt(OrdinalBaseline + OrdinalOvershoot)); - botBands[lenBotBands++] = ScaleAbs(FixInt(OrdinalBaseline)); - } - if (DescenderHeight != UNDEFINED && DescenderOvershoot != UNDEFINED) { - botBands[lenBotBands++] = ScaleAbs(FixInt(DescenderHeight + DescenderOvershoot)); - botBands[lenBotBands++] = ScaleAbs(FixInt(DescenderHeight)); - } - if (CapHeight != UNDEFINED && CapOvershoot != UNDEFINED) { - topBands[lenTopBands++] = ScaleAbs(FixInt(CapHeight)); - topBands[lenTopBands++] = ScaleAbs(FixInt(CapHeight + CapOvershoot)); - } - if (LcHeight != UNDEFINED && LcOvershoot != UNDEFINED) { - topBands[lenTopBands++] = ScaleAbs(FixInt(LcHeight)); - topBands[lenTopBands++] = ScaleAbs(FixInt(LcHeight + LcOvershoot)); - } - if (AscenderHeight != UNDEFINED && AscenderOvershoot != UNDEFINED) { - topBands[lenTopBands++] = ScaleAbs(FixInt(AscenderHeight)); - topBands[lenTopBands++] = ScaleAbs(FixInt(AscenderHeight + AscenderOvershoot)); - } - if (FigHeight != UNDEFINED && FigOvershoot != UNDEFINED) { - topBands[lenTopBands++] = ScaleAbs(FixInt(FigHeight)); - topBands[lenTopBands++] = ScaleAbs(FixInt(FigHeight + FigOvershoot)); - } - if (Height5 != UNDEFINED && Height5Overshoot != UNDEFINED) { - topBands[lenTopBands++] = ScaleAbs(FixInt(Height5)); - topBands[lenTopBands++] = ScaleAbs(FixInt(Height5 + Height5Overshoot)); - } - if (Height6 != UNDEFINED && Height6Overshoot != UNDEFINED) { - topBands[lenTopBands++] = ScaleAbs(FixInt(Height6)); - topBands[lenTopBands++] = ScaleAbs(FixInt(Height6 + Height6Overshoot)); - } - if (scalinghints) - ResetFntInfoFileName(); - return TRUE; -} diff --git a/c/autohint/autohintlib/source/ac/gen.c b/c/autohint/autohintlib/source/ac/gen.c deleted file mode 100644 index 2ddb47e18..000000000 --- a/c/autohint/autohintlib/source/ac/gen.c +++ /dev/null @@ -1,1007 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ - -#include "ac.h" -#include "bftoac.h" - -extern procedure ReportRemVSeg(Fixed from, Fixed to, Fixed loc); -extern procedure ReportRemHSeg(Fixed from, Fixed to, Fixed loc); - -private -PSegLnkLst Hlnks, Vlnks; -private -integer cpFrom, cpTo; - -public -procedure InitGen(reason) integer reason; -{ - integer i; - switch (reason) { - case STARTUP: - case RESTART: - for (i = 0; i < 4; i++) segLists[i] = NULL; - Hlnks = Vlnks = NULL; - } -} - -private -procedure LinkSegment(e, Hflg, seg) - PPathElt e; -boolean Hflg; -PClrSeg seg; -{ - PSegLnk newlnk; - PSegLnkLst newlst, globlst; - newlnk = (PSegLnk)Alloc(sizeof(SegLnk)); - newlnk->seg = seg; - newlst = (PSegLnkLst)Alloc(sizeof(SegLnkLst)); - globlst = (PSegLnkLst)Alloc(sizeof(SegLnkLst)); - globlst->lnk = newlnk; - newlst->lnk = newlnk; - if (Hflg) { - newlst->next = e->Hs; - e->Hs = newlst; - globlst->next = Hlnks; - Hlnks = globlst; - } else { - newlst->next = e->Vs; - e->Vs = newlst; - globlst->next = Vlnks; - Vlnks = globlst; - } -} - -private -procedure CopySegmentLink(e1, e2, Hflg) - PPathElt e1, - e2; -boolean Hflg; -{ - /* copy reference to first link from e1 to e2 */ - PSegLnkLst newlst; - newlst = (PSegLnkLst)Alloc(sizeof(SegLnkLst)); - if (Hflg) { - newlst->lnk = e1->Hs->lnk; - newlst->next = e2->Hs; - e2->Hs = newlst; - } else { - newlst->lnk = e1->Vs->lnk; - newlst->next = e2->Vs; - e2->Vs = newlst; - } -} - -private -procedure AddSegment(from, to, loc, lftLstNm, rghtLstNm, e1, e2, Hflg, typ) - Fixed from, - to, loc; -integer lftLstNm, rghtLstNm; -PPathElt e1, e2; -boolean Hflg; -integer typ; -{ - PClrSeg seg, segList, prevSeg; - integer segNm; - seg = (PClrSeg)Alloc(sizeof(ClrSeg)); - seg->sLoc = loc; - if (from > to) { - seg->sMax = from; - seg->sMin = to; - } else { - seg->sMax = to; - seg->sMin = from; - } - seg->sBonus = bonus; - seg->sType = (short)typ; - if (e1 != NULL) { - if (e1->type == CLOSEPATH) e1 = GetDest(e1); - LinkSegment(e1, Hflg, seg); - seg->sElt = e1; - } - if (e2 != NULL) { - if (e2->type == CLOSEPATH) e2 = GetDest(e2); - CopySegmentLink(e1, e2, Hflg); - if (e1 == NULL || e2 == e1->prev) seg->sElt = e2; - } - segNm = (from > to) ? lftLstNm : rghtLstNm; - segList = segLists[segNm]; - prevSeg = NULL; - while (TRUE) { /* keep list in increasing order by sLoc */ - if (segList == NULL) { /* at end of list */ - if (prevSeg == NULL) { - segLists[segNm] = seg; - break; - } - prevSeg->sNxt = seg; - break; - } - if (segList->sLoc >= loc) { /* insert before this one */ - if (prevSeg == NULL) - segLists[segNm] = seg; - else - prevSeg->sNxt = seg; - seg->sNxt = segList; - break; - } - prevSeg = segList; - segList = segList->sNxt; - } -} - -public -procedure AddVSegment(from, to, loc, p1, p2, typ, i) - Fixed from, - to, loc; -PPathElt p1, p2; -integer typ, i; -{ - if (DEBUG) ReportAddVSeg(from, to, loc, i); - if (YgoesUp) - AddSegment(from, to, loc, 0, 1, p1, p2, FALSE, typ); - else - AddSegment(from, to, loc, 1, 0, p1, p2, FALSE, typ); -} - -public -procedure AddHSegment(from, to, loc, p1, p2, typ, i) - Fixed from, - to, loc; -PPathElt p1, p2; -integer typ, i; -{ - if (DEBUG) ReportAddHSeg(from, to, loc, i); - AddSegment(from, to, loc, 2, 3, p1, p2, TRUE, typ); -} - -private -Fixed CPFrom(cp2, cp3) Fixed cp2, cp3; -{ - Fixed val = 2 * (((cp3 - cp2) * cpFrom) / 200L); /*DEBUG 8 BIT: hack to get same rounding as old version */ - val += cp2; - - DEBUG_ROUND(val) - return val; /* DEBUG 8 BIT to match results with 7 bit fractions */ -} - -private -Fixed CPTo(cp0, cp1) Fixed cp0, cp1; -{ - Fixed val = 2 * (((cp1 - cp0) * cpTo) / 200L); /*DEBUG 8 BIT: hack to get same rounding as old version */ - val += cp0; - DEBUG_ROUND(val) - return val; /* DEBUG 8 BIT to match results with 7 bit fractions */ -} - -private -boolean TestBend(x0, y0, x1, y1, x2, y2) Fixed x0, y0, x1, y1, x2, y2; -{ - /* return true if bend angle is sharp enough (135 degrees or less) */ - real dx1, dy1, dx2, dy2, dotprod, lensqprod; - acfixtopflt(x1 - x0, &dx1); - acfixtopflt(y1 - y0, &dy1); - acfixtopflt(x2 - x1, &dx2); - acfixtopflt(y2 - y1, &dy2); - dotprod = dx1 * dx2 + dy1 * dy2; - lensqprod = (dx1 * dx1 + dy1 * dy1) * (dx2 * dx2 + dy2 * dy2); - return (dotprod * dotprod / lensqprod) <= .5; -} - -#define TestTan(d1, d2) (abs(d1) > (abs(d2) * bendTan) / 1000L) -#define FRound(x) FTrunc(FRnd(x)) - -private -boolean IsCCW(x0, y0, x1, y1, x2, y2) - Fixed x0, - y0, x1, y1, x2, y2; -{ - /* returns true if (x0,y0) -> (x1,y1) -> (x2,y2) is counter clockwise - in character space */ - integer dx0, dy0, dx1, dy1; - boolean ccw; - dx0 = FRound(x1 - x0); - dy0 = FRound(y1 - y0); - dx1 = FRound(x2 - x1); - dy1 = FRound(y2 - y1); - if (!YgoesUp) { - dy0 = -dy0; - dy1 = -dy1; - } - ccw = (dx0 * dy1) >= (dx1 * dy0); - return ccw; -} - -private -procedure DoHBendsNxt(x0, y0, x1, y1, p) - Fixed x0, - y0, x1, y1; -PPathElt p; -{ - Fixed x2, y2, delta, strt, end, x3, y3; - boolean ysame, ccw, above, doboth; - if (y0 == y1) return; - (void)NxtForBend(p, &x2, &y2, &x3, &y3); - ysame = ProdLt0(y2 - y1, y1 - y0); /* y0 and y2 on same side of y1 */ - if (ysame || - (TestTan(x1 - x2, y1 - y2) && - (ProdLt0(x2 - x1, x1 - x0) || - (IsVertical(x0, y0, x1, y1) && TestBend(x0, y0, x1, y1, x2, y2))))) { - delta = FixHalfMul(bendLength); - doboth = FALSE; - if ((x0 <= x1 && x1 < x2) || (x0 < x1 && x1 <= x2)) { - } else if ((x2 < x1 && x1 <= x0) || (x2 <= x1 && x1 < x0)) - delta = -delta; - else if (ysame) { - above = y0 > y1; - if (!YgoesUp) above = !above; - ccw = IsCCW(x0, y0, x1, y1, x2, y2); - if (above != ccw) delta = -delta; - } else - doboth = TRUE; - strt = x1 - delta; - end = x1 + delta; - AddHSegment(strt, end, y1, p, (PPathElt)NULL, sBEND, 0L); - if (doboth) - AddHSegment(end, strt, y1, p, (PPathElt)NULL, sBEND, 1L); - } -} - -private -procedure DoHBendsPrv(x0, y0, x1, y1, p) - Fixed x0, - y0, x1, y1; -PPathElt p; -{ - Fixed x2, y2, delta, strt, end; - boolean ysame, ccw, above, doboth; - if (y0 == y1) return; - (void)PrvForBend(p, &x2, &y2); - ysame = ProdLt0(y2 - y0, y0 - y1); - if (ysame || - (TestTan(x0 - x2, y0 - y2) && - (ProdLt0(x2 - x0, x0 - x1) || - (IsVertical(x0, y0, x1, y1) && TestBend(x2, y2, x0, y0, x1, y1))))) { - delta = FixHalfMul(bendLength); - doboth = FALSE; - if ((x2 < x0 && x0 <= x1) || (x2 <= x0 && x0 < x1)) { - } else if ((x1 < x0 && x0 <= x2) || (x1 <= x0 && x0 < x2)) - delta = -delta; - else if (ysame) { - above = (y2 > y0); - if (!YgoesUp) above = !above; - ccw = IsCCW(x2, y2, x0, y0, x1, y1); - if (above != ccw) delta = -delta; - } - strt = x0 - delta; - end = x0 + delta; - AddHSegment(strt, end, y0, p->prev, (PPathElt)NULL, sBEND, 2L); - if (doboth) - AddHSegment(end, strt, y0, p->prev, (PPathElt)NULL, sBEND, 3L); - } -} - -private -procedure DoVBendsNxt(x0, y0, x1, y1, p) - Fixed x0, - y0, x1, y1; -PPathElt p; -{ - Fixed x2, y2, delta, strt, end, x3, y3; - boolean xsame, ccw, right, doboth; - if (x0 == x1) return; - (void)NxtForBend(p, &x2, &y2, &x3, &y3); - xsame = ProdLt0(x2 - x1, x1 - x0); - if (xsame || - (TestTan(y1 - y2, x1 - x2) && - (ProdLt0(y2 - y1, y1 - y0) || - (IsHorizontal(x0, y0, x1, y1) && TestBend(x0, y0, x1, y1, x2, y2))))) { - delta = FixHalfMul(bendLength); - doboth = FALSE; - if ((y0 <= y1 && y1 < y2) || (y0 < y1 && y1 <= y2)) { - } else if ((y2 < y1 && y1 <= y0) || (y2 <= y1 && y1 < y0)) - delta = -delta; - else if (xsame) { - right = x0 > x1; - ccw = IsCCW(x0, y0, x1, y1, x2, y2); - if (right != ccw) delta = -delta; - if (!YgoesUp) delta = -delta; - } else - doboth = TRUE; - strt = y1 - delta; - end = y1 + delta; - AddVSegment(strt, end, x1, p, (PPathElt)NULL, sBEND, 0L); - if (doboth) - AddVSegment(end, strt, x1, p, (PPathElt)NULL, sBEND, 1L); - } -} - -private -procedure DoVBendsPrv(x0, y0, x1, y1, p) - Fixed x0, - y0, x1, y1; -PPathElt p; -{ - Fixed x2, y2, delta, strt, end; - boolean xsame, ccw, right, doboth; - if (x0 == x1) return; - (void)PrvForBend(p, &x2, &y2); - xsame = ProdLt0(x2 - x0, x0 - x1); - if (xsame || - (TestTan(y0 - y2, x0 - x2) && - (ProdLt0(y2 - y0, y0 - y1) || - (IsHorizontal(x0, y0, x1, y1) && TestBend(x2, y2, x0, y0, x1, y1))))) { - delta = FixHalfMul(bendLength); - doboth = FALSE; - if ((y2 < y0 && y0 <= y1) || (y2 <= y0 && y0 < y1)) { - } else if ((y1 < y0 && y0 <= y2) || (y1 <= y0 && y0 < y2)) - delta = -delta; - else if (xsame) { - right = x0 > x1; - ccw = IsCCW(x2, y2, x0, y0, x1, y1); - if (right != ccw) delta = -delta; - if (!YgoesUp) delta = -delta; - } - strt = y0 - delta; - end = y0 + delta; - AddVSegment(strt, end, x0, p->prev, (PPathElt)NULL, sBEND, 2L); - if (doboth) - AddVSegment(end, strt, x0, p->prev, (PPathElt)NULL, sBEND, 3L); - } -} - -private -procedure MergeLnkSegs(seg1, seg2, lst) - PSegLnkLst lst; -PClrSeg seg1, seg2; -{ - /* replace lnk refs to seg1 by seg2 */ - PSegLnk lnk; - while (lst != NULL) { - lnk = lst->lnk; - if (lnk->seg == seg1) lnk->seg = seg2; - lst = lst->next; - } -} - -private -procedure MergeHSegs(seg1, seg2) PClrSeg seg1, seg2; -{ - MergeLnkSegs(seg1, seg2, Hlnks); -} - -private -procedure MergeVSegs(seg1, seg2) PClrSeg seg1, seg2; -{ - MergeLnkSegs(seg1, seg2, Vlnks); -} - -private -procedure ReportRemSeg(l, lst) integer l; -PClrSeg lst; -{ - Fixed from, to, loc; - /* this assumes !YgoesUp */ - switch (l) { - case 1: - case 2: - from = lst->sMax; - to = lst->sMin; - break; - case 0: - case 3: - from = lst->sMin; - to = lst->sMax; - break; - } - loc = lst->sLoc; - switch (l) { - case 0: - case 1: - ReportRemVSeg(from, to, loc); - break; - case 2: - case 3: - ReportRemHSeg(from, to, loc); - break; - } -} - -/* Filters out bogus bend segments. */ -private -procedure RemExtraBends(l0, l1) integer l0, l1; -{ - register PClrSeg lst0, lst, n, p; - PClrSeg nxt, prv; - register Fixed loc0, loc; - lst0 = segLists[l0]; - prv = NULL; - while (lst0 != NULL) { - nxt = lst0->sNxt; - loc0 = lst0->sLoc; - lst = segLists[l1]; - p = NULL; - while (lst != NULL) { - n = lst->sNxt; - loc = lst->sLoc; - if (loc > loc0) break; /* list in increasing order by sLoc */ - if (loc == loc0 && - lst->sMin < lst0->sMax && lst->sMax > lst0->sMin) { - if (lst0->sType == sBEND && lst->sType != sBEND && - lst->sType != sGHOST && - (lst->sMax - lst->sMin) > (lst0->sMax - lst0->sMin) * 3) { - /* delete lst0 */ - if (prv == NULL) - segLists[l0] = nxt; - else - prv->sNxt = nxt; - if (DEBUG) ReportRemSeg(l0, lst0); - lst0 = prv; - break; - } - if (lst->sType == sBEND && lst0->sType != sBEND && - lst0->sType != sGHOST && - (lst0->sMax - lst0->sMin) > (lst->sMax - lst->sMin) * 3) { - /* delete lst */ - if (p == NULL) - segLists[l1] = n; - else - p->sNxt = n; - if (DEBUG) ReportRemSeg(l1, lst); - lst = p; - } - } - p = lst; - lst = n; - } - prv = lst0; - lst0 = nxt; - } -} - -private -procedure CompactList(i, nm) - integer i; -procedure (*nm)(); -{ - PClrSeg lst, prv, nxtprv, nxt; - Fixed lstmin, lstmax, nxtmin, nxtmax; - boolean flg; - lst = segLists[i]; - prv = NULL; - while (lst != NULL) { - nxt = lst->sNxt; - nxtprv = lst; - while (TRUE) { - if ((nxt == NULL) || (nxt->sLoc > lst->sLoc)) { - flg = TRUE; - break; - } - lstmin = lst->sMin; - lstmax = lst->sMax; - nxtmin = nxt->sMin; - nxtmax = nxt->sMax; - if (lstmax >= nxtmin && lstmin <= nxtmax) { - /* do not worry about YgoesUp since "sMax" is really max in - device space, not in character space */ - if (abs(lstmax - lstmin) > abs(nxtmax - nxtmin)) { - /* merge into lst and remove nxt */ - (*nm)(nxt, lst); - lst->sMin = MIN(lstmin, nxtmin); - lst->sMax = MAX(lstmax, nxtmax); - lst->sBonus = MAX(lst->sBonus, nxt->sBonus); - nxtprv->sNxt = nxt->sNxt; - } else { /* merge into nxt and remove lst */ - (*nm)(lst, nxt); - nxt->sMin = MIN(lstmin, nxtmin); - nxt->sMax = MAX(lstmax, nxtmax); - nxt->sBonus = MAX(lst->sBonus, nxt->sBonus); - lst = lst->sNxt; - if (prv == NULL) - segLists[i] = lst; - else - prv->sNxt = lst; - } - flg = FALSE; - break; - } - nxtprv = nxt; - nxt = nxt->sNxt; - } - if (flg) { - prv = lst; - lst = lst->sNxt; - } - } -} - -private -Fixed PickVSpot(x0, y0, x1, y1, px1, py1, px2, py2, prvx, prvy, nxtx, nxty) - Fixed x0, - y0, x1, y1, px1, py1, px2, py2, prvx, prvy, nxtx, nxty; -{ - register Fixed a1, a2; - if (x0 == px1 && x1 != px2) return x0; - if (x0 != px1 && x1 == px2) return x1; - if (x0 == prvx && x1 != nxtx) return x0; - if (x0 != prvx && x1 == nxtx) return x1; - a1 = abs(py1 - y0); - a2 = abs(py2 - y1); - if (a1 > a2) return x0; - a1 = abs(py2 - y1); - a2 = abs(py1 - y0); - if (a1 > a2) return x1; - if (x0 == prvx && x1 == nxtx) { - a1 = abs(y0 - prvy); - a2 = abs(y1 - nxty); - if (a1 > a2) return x0; - return x1; - } - return FixHalfMul(x0 + x1); -} - -private -Fixed AdjDist(d, q) Fixed d, q; -{ - Fixed val; - if (q == FixOne) { - DEBUG_ROUND(d) /* DEBUG 8 BIT */ - return d; - } - val = (d * q) >> 8; - DEBUG_ROUND(val) /* DEBUG 8 BIT */ - return val; -} - -/* serifs of ITCGaramond Ultra have points that are not quite horizontal - e.g., in H: (53,51)(74,52)(116,54) - the following was added to let these through */ -private -boolean TstFlat(dmn, dmx) Fixed dmn, dmx; -{ - if (dmn < 0) dmn = -dmn; - if (dmx < 0) dmx = -dmx; - return (dmx >= PSDist(50) && dmn <= PSDist(4)); -} - -private -boolean NxtHorz(x, y, p) Fixed x, y; -PPathElt p; -{ - Fixed x2, y2, x3, y3; - p = NxtForBend(p, &x2, &y2, &x3, &y3); - return TstFlat(y2 - y, x2 - x); -} - -private -boolean PrvHorz(x, y, p) Fixed x, y; -PPathElt p; -{ - Fixed x2, y2; - p = PrvForBend(p, &x2, &y2); - return TstFlat(y2 - y, x2 - x); -} - -private -boolean NxtVert(x, y, p) Fixed x, y; -PPathElt p; -{ - Fixed x2, y2, x3, y3; - p = NxtForBend(p, &x2, &y2, &x3, &y3); - return TstFlat(x2 - x, y2 - y); -} - -private -boolean PrvVert(x, y, p) Fixed x, y; -PPathElt p; -{ - Fixed x2, y2; - p = PrvForBend(p, &x2, &y2); - return TstFlat(x2 - x, y2 - y); -} - -/* PrvSameDir and NxtSameDir were added to check the direction of a - path and not add a band if the point is not at an extreme and is - going in the same direction as the previous path. */ -private -boolean TstSameDir(x0, y0, x1, y1, x2, y2) - Fixed x0, - y0, x1, y1, x2, y2; -{ - if (ProdLt0(y0 - y1, y1 - y2) || ProdLt0(x0 - x1, x1 - x2)) - return FALSE; - return !TestBend(x0, y0, x1, y1, x2, y2); -} - -private -boolean PrvSameDir(x0, y0, x1, y1, p) - Fixed x0, - y0, x1, y1; -PPathElt p; -{ - Fixed x2, y2; - p = PrvForBend(p, &x2, &y2); - if (p != NULL && p->type == CURVETO && p->prev != NULL) - GetEndPoint(p->prev, &x2, &y2); - return TstSameDir(x0, y0, x1, y1, x2, y2); -} - -private -boolean NxtSameDir(x0, y0, x1, y1, p) - Fixed x0, - y0, x1, y1; -PPathElt p; -{ - Fixed x2, y2, x3, y3; - p = NxtForBend(p, &x2, &y2, &x3, &y3); - if (p != NULL && p->type == CURVETO) { - x2 = p->x3; - y2 = p->y3; - } - return TstSameDir(x0, y0, x1, y1, x2, y2); -} - -public -procedure GenVPts(specialCharType) integer specialCharType; -{ - /* specialCharType 1 = upper; -1 = lower; 0 = neither */ - PPathElt p, fl; - boolean isVert, flex1, flex2; - Fixed flx0, fly0, llx, lly, urx, ury, yavg, yend, ydist, q, q2; - Fixed prvx, prvy, nxtx, nxty, xx, yy, yd2; - p = pathStart; - flex1 = flex2 = FALSE; - cpTo = CPpercent; - cpFrom = 100L - cpTo; - flx0 = fly0 = 0; - fl = NULL; - while (p != NULL) { - Fixed x0, y0, x1, y1; - GetEndPoints(p, &x0, &y0, &x1, &y1); - if (p->type == CURVETO) { - Fixed px1, py1, px2, py2; - isVert = FALSE; - if (p->isFlex) { - if (flex1) { - if (IsVertical(flx0, fly0, x1, y1)) - AddVSegment(fly0, y1, x1, fl->prev, p, sLINE, 4L); - flex1 = FALSE; - flex2 = TRUE; - } else { - flex1 = TRUE; - flex2 = FALSE; - flx0 = x0; - fly0 = y0; - fl = p; - } - } else - flex1 = flex2 = FALSE; - px1 = p->x1; - py1 = p->y1; - px2 = p->x2; - py2 = p->y2; - if (!flex2) { - if ((q = VertQuo(px1, py1, x0, y0)) == 0L) /* first two not vertical */ - DoVBendsPrv(x0, y0, px1, py1, p); - else { - isVert = TRUE; - if (px1 == x0 || - (px2 != x1 && - (PrvVert(px1, py1, p) || !PrvSameDir(x1, y1, x0, y0, p)))) { - if ((q2 = VertQuo(px2, py2, x0, y0)) > 0L && - ProdGe0(py1 - y0, py2 - y0) && - abs(py2 - y0) > abs(py1 - y0)) { - ydist = AdjDist(CPTo(py1, py2) - y0, q2); - yend = AdjDist(CPTo(y0, py1) - y0, q); - if (abs(yend) > abs(ydist)) ydist = yend; - AddVSegment(y0, y0 + ydist, x0, p->prev, p, sCURVE, 5L); - } else { - ydist = AdjDist(CPTo(y0, py1) - y0, q); - AddVSegment(y0, CPTo(y0, py1), x0, p->prev, p, sCURVE, 6L); - } - } - } - } - if (!flex1) { - if ((q = VertQuo(px2, py2, x1, y1)) == 0L) /* last 2 not vertical */ - DoVBendsNxt(px2, py2, x1, y1, p); - else if (px2 == x1 || - (px1 != x0 && - (NxtVert(px2, py2, p) || !NxtSameDir(x0, y0, x1, y1, p)))) { - ydist = AdjDist(y1 - CPFrom(py2, y1), q); - isVert = TRUE; - q2 = VertQuo(x0, y0, x1, y1); - yd2 = (q2 > 0L) ? AdjDist(y1 - y0, q2) : 0L; - if (isVert && q2 > 0L && abs(yd2) > abs(ydist)) { - if (x0 == px1 && px1 == px2 && px2 == x1) - ReportLinearCurve(p, x0, y0, x1, y1); - ydist = FixHalfMul(yd2); - yavg = FixHalfMul(y0 + y1); - (void)PrvForBend(p, &prvx, &prvy); - (void)NxtForBend(p, &nxtx, &nxty, &xx, &yy); - AddVSegment(yavg - ydist, yavg + ydist, - PickVSpot(x0, y0, x1, y1, px1, py1, px2, py2, prvx, prvy, nxtx, nxty), - p, (PPathElt)NULL, sCURVE, 7L); - } else { - q2 = VertQuo(px1, py1, x1, y1); - if (q2 > 0L && ProdGe0(py1 - y1, py2 - y1) && - abs(py2 - y1) < abs(py1 - y1)) { - yend = AdjDist(y1 - CPFrom(py1, py2), q2); - if (abs(yend) > abs(ydist)) ydist = yend; - AddVSegment(y1 - ydist, y1, x1, p, (PPathElt)NULL, sCURVE, 8L); - } else - AddVSegment(y1 - ydist, y1, x1, p, (PPathElt)NULL, sCURVE, 9L); - } - } - } - if (!flex1 && !flex2) { - Fixed minx, maxx; - maxx = MAX(x0, x1); - minx = MIN(x0, x1); - if (px1 - maxx >= FixTwo || px2 - maxx >= FixTwo || - px1 - minx <= FixTwo || px2 - minx <= FixTwo) { - FindCurveBBox(x0, y0, px1, py1, px2, py2, x1, y1, &llx, &lly, &urx, &ury); - if (urx - maxx > FixTwo || minx - llx > FixTwo) { - Fixed loc, frst, lst; - loc = (minx - llx > urx - maxx) ? llx : urx; - CheckBBoxEdge(p, TRUE, loc, &frst, &lst); - yavg = FixHalfMul(frst + lst); - ydist = (frst == lst) ? (y1 - y0) / 10L : FixHalfMul(lst - frst); - if (abs(ydist) < bendLength) - ydist = (ydist > 0L) ? FixHalfMul(bendLength) : FixHalfMul(-bendLength); - AddVSegment(yavg - ydist, yavg + ydist, loc, - p, (PPathElt)NULL, sCURVE, 10L); - } - } - } - } else if (p->type == MOVETO) { - bonus = 0; - if (specialCharType == -1L) { - if (IsLower(p)) bonus = FixInt(200); - } else if (specialCharType == 1L) { - if (IsUpper(p)) bonus = FixInt(200); - } - } else if (!IsTiny(p)) { - if ((q = VertQuo(x0, y0, x1, y1)) > 0L) { - if (x0 == x1) - AddVSegment(y0, y1, x0, p->prev, p, sLINE, 11L); - else { - if (q < FixQuarter) q = FixQuarter; - ydist = FixHalfMul(AdjDist(y1 - y0, q)); - yavg = FixHalfMul(y0 + y1); - (void)PrvForBend(p, &prvx, &prvy); - (void)NxtForBend(p, &nxtx, &nxty, &xx, &yy); - AddVSegment(yavg - ydist, yavg + ydist, - PickVSpot(x0, y0, x1, y1, x0, y0, x1, y1, prvx, prvy, nxtx, nxty), - p, (PPathElt)NULL, sLINE, 12L); - if (abs(x0 - x1) <= FixTwo) - ReportNonVError(x0, y0, x1, y1); - } - } else { - DoVBendsNxt(x0, y0, x1, y1, p); - DoVBendsPrv(x0, y0, x1, y1, p); - } - } - p = p->next; - } - CompactList(0, MergeVSegs); - CompactList(1, MergeVSegs); - RemExtraBends(0, 1); - leftList = segLists[0]; - rightList = segLists[1]; -} - -public -boolean InBlueBand(loc, n, p) Fixed loc; -register Fixed *p; -integer n; -{ - register int i; - register Fixed y; - if (n <= 0) return FALSE; - y = itfmy(loc); - /* Augment the blue band by bluefuzz in each direction. This will - result in "near misses" being colored and so adjusted by the - PS interpreter. */ - for (i = 0; i < n; i += 2) - if ((p[i] - bluefuzz) <= y && - (p[i + 1] + bluefuzz) >= y) return TRUE; - return FALSE; -} - -private -Fixed PickHSpot(x0, y0, x1, y1, xdist, px1, py1, px2, py2, prvx, prvy, nxtx, nxty) - Fixed x0, - y0, x1, y1, xdist, px1, py1, px2, py2, prvx, prvy, nxtx, nxty; -{ - boolean topSeg = (xdist < 0L) ? TRUE : FALSE; - Fixed upper, lower; - boolean inBlue0, inBlue1; - if (topSeg) { - inBlue0 = InBlueBand(y0, lenTopBands, topBands); - inBlue1 = InBlueBand(y1, lenTopBands, topBands); - } else { - inBlue0 = InBlueBand(y0, lenBotBands, botBands); - inBlue1 = InBlueBand(y1, lenBotBands, botBands); - } - if (inBlue0 && !inBlue1) return y0; - if (inBlue1 && !inBlue0) return y1; - if (y0 == py1 && y1 != py2) return y0; - if (y0 != py1 && y1 == py2) return y1; - if (y0 == prvy && y1 != nxty) return y0; - if (y0 != prvy && y1 == nxty) return y1; - if (inBlue0 && inBlue1) { - if (y0 > y1) { - upper = y0; - lower = y1; - } else { - upper = y1; - lower = y0; - } - if (!YgoesUp) { - Fixed tmp = lower; - lower = upper; - upper = tmp; - } - return topSeg ? upper : lower; - } - if (abs(px1 - x0) > abs(px2 - x1)) return y0; - if (abs(px2 - x1) > abs(px1 - x0)) return y1; - if (y0 == prvy && y1 == nxty) { - if (abs(x0 - prvx) > abs(x1 - nxtx)) return y0; - return y1; - } - return FixHalfMul(y0 + y1); -} - -public -procedure GenHPts() { - PPathElt p, fl; - boolean isHoriz, flex1, flex2; - Fixed flx0, fly0, llx, lly, urx, ury, xavg, xend, xdist, q, q2; - Fixed prvx, prvy, nxtx, nxty, xx, yy, xd2; - p = pathStart; - bonus = 0; - flx0 = fly0 = 0; - fl = NULL; - flex1 = flex2 = FALSE; - cpTo = CPpercent; - cpFrom = 100L - cpTo; - while (p != NULL) { - Fixed x0, y0, x1, y1; - GetEndPoints(p, &x0, &y0, &x1, &y1); - if (p->type == CURVETO) { - Fixed px1, py1, px2, py2; - isHoriz = FALSE; - if (p->isFlex) { - if (flex1) { - flex1 = FALSE; - flex2 = TRUE; - if (IsHorizontal(flx0, fly0, x1, y1)) - AddHSegment(flx0, x1, y1, fl->prev, p, sLINE, 4L); - } else { - flex1 = TRUE; - flex2 = FALSE; - flx0 = x0; - fly0 = y0; - fl = p; - } - } else - flex1 = flex2 = FALSE; - px1 = p->x1; - py1 = p->y1; - px2 = p->x2; - py2 = p->y2; - if (!flex2) { - if ((q = HorzQuo(px1, py1, x0, y0)) == 0L) - DoHBendsPrv(x0, y0, px1, py1, p); - else { - isHoriz = TRUE; - if (py1 == y0 || - (py2 != y1 && - (PrvHorz(px1, py1, p) || !PrvSameDir(x1, y1, x0, y0, p)))) { - if ((q2 = HorzQuo(px2, py2, x0, y0)) > 0L && - ProdGe0(px1 - x0, px2 - x0) && - abs(px2 - x0) > abs(px1 - x0)) { - xdist = AdjDist(CPTo(px1, px2) - x0, q2); - xend = AdjDist(CPTo(x0, px1) - x0, q); - if (abs(xend) > abs(xdist)) xdist = xend; - AddHSegment(x0, x0 + xdist, y0, p->prev, p, sCURVE, 5L); - } else { - xdist = AdjDist(CPTo(x0, px1) - x0, q); - AddHSegment(x0, x0 + xdist, y0, p->prev, p, sCURVE, 6L); - } - } - } - } - if (!flex1) { - if ((q = HorzQuo(px2, py2, x1, y1)) == 0L) - DoHBendsNxt(px2, py2, x1, y1, p); - else if (py2 == y1 || - (py1 != y0 && - (NxtHorz(px2, py2, p) || !NxtSameDir(x0, y0, x1, y1, p)))) { - xdist = AdjDist(x1 - CPFrom(px2, x1), q); - q2 = HorzQuo(x0, y0, x1, y1); - isHoriz = TRUE; - xd2 = (q2 > 0L) ? AdjDist(x1 - x0, q2) : 0L; - if (isHoriz && q2 > 0 && abs(xd2) > abs(xdist)) { - Fixed hspot; - if (y0 == py1 && py1 == py2 && py2 == y1) - ReportLinearCurve(p, x0, y0, x1, y1); - (void)PrvForBend(p, &prvx, &prvy); - (void)NxtForBend(p, &nxtx, &nxty, &xx, &yy); - xdist = FixHalfMul(xd2); - xavg = FixHalfMul(x0 + x1); - hspot = PickHSpot( - x0, y0, x1, y1, xdist, px1, py1, px2, py2, prvx, prvy, nxtx, nxty); - AddHSegment( - xavg - xdist, xavg + xdist, hspot, p, (PPathElt)NULL, sCURVE, 7L); - } else { - q2 = HorzQuo(px1, py1, x1, y1); - if (q2 > 0L && ProdGe0(px1 - x1, px2 - x1) && - abs(px2 - x1) < abs(px1 - x1)) { - xend = AdjDist(x1 - CPFrom(px1, px2), q2); - if (abs(xend) > abs(xdist)) xdist = xend; - AddHSegment(x1 - xdist, x1, y1, p, (PPathElt)NULL, sCURVE, 8L); - } else - AddHSegment(x1 - xdist, x1, y1, p, (PPathElt)NULL, sCURVE, 9L); - } - } - } - if (!flex1 && !flex2) { - Fixed miny, maxy; - maxy = MAX(y0, y1); - miny = MIN(y0, y1); - if (py1 - maxy >= FixTwo || py2 - maxy >= FixTwo || - py1 - miny <= FixTwo || py2 - miny <= FixTwo) { - FindCurveBBox(x0, y0, px1, py1, px2, py2, x1, y1, &llx, &lly, &urx, &ury); - if (ury - maxy > FixTwo || miny - lly > FixTwo) { - Fixed loc, frst, lst; - loc = (miny - lly > ury - maxy) ? lly : ury; - CheckBBoxEdge(p, FALSE, loc, &frst, &lst); - xavg = FixHalfMul(frst + lst); - xdist = (frst == lst) ? (x1 - x0) / 10L : FixHalfMul(lst - frst); - if (abs(xdist) < bendLength) - xdist = (xdist > 0.0) ? FixHalfMul(bendLength) : FixHalfMul(-bendLength); - AddHSegment( - xavg - xdist, xavg + xdist, loc, p, (PPathElt)NULL, sCURVE, 10L); - } - } - } - } else if (p->type != MOVETO && !IsTiny(p)) { - if ((q = HorzQuo(x0, y0, x1, y1)) > 0L) { - if (y0 == y1) - AddHSegment(x0, x1, y0, p->prev, p, sLINE, 11L); - else { - if (q < FixQuarter) q = FixQuarter; - xdist = FixHalfMul(AdjDist(x1 - x0, q)); - xavg = FixHalfMul(x0 + x1); - (void)PrvForBend(p, &prvx, &prvy); - (void)NxtForBend(p, &nxtx, &nxty, &xx, &yy); - yy = PickHSpot(x0, y0, x1, y1, xdist, x0, y0, x1, y1, prvx, prvy, nxtx, nxty); - AddHSegment(xavg - xdist, xavg + xdist, yy, p->prev, p, sLINE, 12L); - if (abs(y0 - y1) <= FixTwo) - ReportNonHError(x0, y0, x1, y1); - } - } else { - DoHBendsNxt(x0, y0, x1, y1, p); - DoHBendsPrv(x0, y0, x1, y1, p); - } - } - p = p->next; - } - CompactList(2, MergeHSegs); - CompactList(3, MergeHSegs); - RemExtraBends(2, 3); - topList = segLists[2]; /* this is probably unnecessary */ - botList = segLists[3]; - CheckTfmVal(topList, topBands, lenTopBands); - CheckTfmVal(botList, botBands, lenBotBands); -} - -public -procedure PreGenPts() { - Hlnks = Vlnks = NULL; - segLists[0] = NULL; - segLists[1] = NULL; - segLists[2] = NULL; - segLists[3] = NULL; -} diff --git a/c/autohint/autohintlib/source/ac/head.c b/c/autohint/autohintlib/source/ac/head.c deleted file mode 100644 index 38dc1fa55..000000000 --- a/c/autohint/autohintlib/source/ac/head.c +++ /dev/null @@ -1,281 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* head.c */ - -#include "ac.h" -#include "machinedep.h" - -public -PPathElt GetDest(cldest) register PPathElt cldest; -{ - if (cldest == NULL) return NULL; - while (TRUE) { - cldest = cldest->prev; - if (cldest == NULL) return pathStart; - if (cldest->type == MOVETO) return cldest; - } -} - -public -PPathElt GetClosedBy(clsdby) register PPathElt clsdby; -{ - if (clsdby == NULL) return NULL; - if (clsdby->type == CLOSEPATH) return clsdby; - while (TRUE) { - clsdby = clsdby->next; - if (clsdby == NULL) return NULL; - if (clsdby->type == MOVETO) return NULL; - if (clsdby->type == CLOSEPATH) return clsdby; - } -} - -public -procedure GetEndPoint(e, x1p, y1p) register PPathElt e; -Fixed *x1p, *y1p; -{ - if (e == NULL) { - *x1p = 0; - *y1p = 0; - return; - } -retry: - switch (e->type) { - case MOVETO: - case LINETO: - *x1p = e->x; - *y1p = e->y; - break; - case CURVETO: - *x1p = e->x3; - *y1p = e->y3; - break; - case CLOSEPATH: - e = GetDest(e); - if (e == NULL || e->type == CLOSEPATH) { - sprintf(globmsg, "Bad character description file: %s.\n", fileName); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - goto retry; - default: { - sprintf(globmsg, "Illegal operator in character file: %s.\n", fileName); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - } -} - -public -procedure GetEndPoints(p, px0, py0, px1, py1) - PPathElt p; -Fixed *px0, *py0, *px1, *py1; -{ - GetEndPoint(p, px1, py1); - GetEndPoint(p->prev, px0, py0); -} - -#define Interpolate(q, v0, q0, v1, q1) (v0 + (q - q0) * ((v1 - v0) / (q1 - q0))) -private -Fixed HVness(pq) real *pq; -{ - register real q; - real result; - /* approximately == 2 q neg exp */ - /* as q -> 0, result goes to 1.0 */ - /* as q -> inf, result goes to 0.0 */ - q = *pq; - if (q < .25) - result = (real)Interpolate(q, 1.0, 0.0, .841, .25); - else if (q < .5) - result = (real)Interpolate(q, .841, .25, .707, .5); - else if (q < 1) - result = (real)Interpolate(q, .707, .5, .5, 1.0); - else if (q < 2) - result = (real)Interpolate(q, .5, 1.0, .25, 2.0); - else if (q < 4) - result = (real)Interpolate(q, .25, 2.0, 0.0, 4.0); - else - result = 0.0; - return acpflttofix(&result); -} - -public -Fixed VertQuo(xk, yk, xl, yl) Fixed xk, yk, xl, yl; -{ - /* FixOne means exactly vertical. 0 means not vertical */ - /* intermediate values mean almost vertical */ - register Fixed xabs, yabs; - real rx, ry, q; - xabs = xk - xl; - if (xabs < 0L) - xabs = -xabs; - if (xabs == 0) - return FixOne; - yabs = yk - yl; - if (yabs < 0L) - yabs = -yabs; - if (yabs == 0) - return 0L; - acfixtopflt(xabs, &rx); - acfixtopflt(yabs, &ry); - q = (real)(rx * rx) / (theta * ry); /* DEBUG 8 BIT. Used to by 2*(rx*rx)/(theta*ry). Don't need thsi with the 8 bits of Fixed fraction. */ - return HVness(&q); -} - -public -Fixed HorzQuo(xk, yk, xl, yl) Fixed xk, yk, xl, yl; -{ - register Fixed xabs, yabs; - real rx, ry, q; - yabs = yk - yl; - if (yabs < 0) - yabs = -yabs; - if (yabs == 0L) - return FixOne; - xabs = xk - xl; - if (xabs < 0) - xabs = -xabs; - if (xabs == 0L) - return 0L; - acfixtopflt(xabs, &rx); - acfixtopflt(yabs, &ry); - q = (real)(ry * ry) / (theta * rx); /* DEBUG 8 BIT. Used to by 2*(ry*ry)/(theta*ry). Don't need thsi with the 8 bits of Fixed fraction. */ - return HVness(&q); -} - -public -boolean IsTiny(e) PPathElt e; -{ - Fixed x0, y0, x1, y1, abstmp; - GetEndPoints(e, &x0, &y0, &x1, &y1); - return ((ac_abs(x0 - x1) < FixTwo) && (ac_abs(y0 - y1) < FixTwo)) ? TRUE : FALSE; -} - -public -boolean IsShort(e) PPathElt e; -{ - Fixed x0, y0, x1, y1, dx, dy, mn, mx, abstmp; - GetEndPoints(e, &x0, &y0, &x1, &y1); - dx = ac_abs(x0 - x1); - dy = ac_abs(y0 - y1); - if (dx > dy) { - mn = dy; - mx = dx; - } else { - mn = dx; - mx = dy; - } - return ((mx + (mn * 42L) / 125L) < FixInt(6)) ? TRUE : FALSE; /* DEBUG 8 BIT. Increased threshold from 3 to 6, for change in coordinare system. */ -} - -public -PPathElt NxtForBend(p, px2, py2, px3, py3) - PPathElt p; -Fixed *px2, *py2, *px3, *py3; -{ - PPathElt nxt, nxtMT = NULL; - Fixed x, y, x2, y2; - nxt = p; - GetEndPoint(p, &x, &y); - while (TRUE) { - if (nxt->type == CLOSEPATH) { - nxt = GetDest(nxt); - /* The following test was added to prevent an infinite loop. */ - if (nxtMT != NULL && nxtMT == nxt) { - ReportPossibleLoop(p); - nxt = NULL; - } else { - nxtMT = nxt; - nxt = nxt->next; - } - } else - nxt = nxt->next; - if (nxt == NULL) { /* forget it */ - *px2 = *py2 = *px3 = *py3 = FixInt(-9999); - return nxt; - } - if (!IsTiny(nxt)) break; - } - if (nxt->type == CURVETO) { - x2 = nxt->x1; - y2 = nxt->y1; - if (x2 == x && y2 == y) { - x2 = nxt->x2; - y2 = nxt->y2; - } - *px2 = x2; - *py2 = y2; - } else - GetEndPoint(nxt, px2, py2); - GetEndPoint(nxt, px3, py3); - return nxt; -} - -public -PPathElt PrvForBend(p, px2, py2) PPathElt p; -Fixed *px2, *py2; -{ - PPathElt prv, prvCP = NULL; - Fixed x2, y2; - prv = p; - while (TRUE) { - prv = prv->prev; - if (prv == NULL) goto Bogus; - if (prv->type == MOVETO) { - prv = GetClosedBy(prv); - /* The following test was added to prevent an infinite loop. */ - if (prv == NULL || (prvCP != NULL && prvCP == prv)) - goto Bogus; - prvCP = prv; - } - if (!IsTiny(prv)) break; - } - if (prv->type == CURVETO) { - x2 = prv->x2; - y2 = prv->y2; - if (x2 == prv->x3 && y2 == prv->y3) { - x2 = prv->x1; - y2 = prv->y1; - } - *px2 = x2; - *py2 = y2; - } else { - p = prv->prev; - if (p == NULL) goto Bogus; - GetEndPoint(p, px2, py2); - } - return prv; -Bogus: - *px2 = *py2 = FixInt(-9999); - return prv; -} - -private -boolean CheckHeight(upperFlag, p) - boolean upperFlag; -PPathElt p; -{ - PPathElt ee; - Fixed y, yy; - ee = pathStart; - y = itfmy(p->y); - while (ee != NULL) { - if (ee->type == MOVETO && ee != p) { - yy = itfmy(ee->y); - if ((upperFlag && yy > y) || (!upperFlag && yy < y)) return FALSE; - } - ee = ee->next; - } - return TRUE; -} - -public -boolean IsLower(p) PPathElt p; -{ - return CheckHeight(FALSE, p); -} - -public -boolean IsUpper(p) PPathElt p; -{ - return CheckHeight(TRUE, p); -} diff --git a/c/autohint/autohintlib/source/ac/memcheck.c b/c/autohint/autohintlib/source/ac/memcheck.c deleted file mode 100644 index 5e52677f1..000000000 --- a/c/autohint/autohintlib/source/ac/memcheck.c +++ /dev/null @@ -1,922 +0,0 @@ -#if DOMEMCHECK - -#include -#include -#include -#include -#include - -#include "memcheck.h" - -#define PREFERREDALIGN 8 -#define MEMCK_NEED_ALIGN8 1 - -#define OSProvided_Malloc(x) malloc(x) -#define OSProvided_Free(x) free(x) -#define OSProvided_Calloc(x, y) calloc(x, y) -#define OSProvided_Realloc(x, y) realloc(x, y) - -#define DebugAssert(x) -#define Assert(x) - -typedef uint32_t Card32; -typedef uint32_t *pCard32; -typedef int32_t Int32; -typedef uint16_t Card16; -typedef uint8_t Card8; -typedef uint8_t *pCard8; -typedef bool boolean; - -#define NUM_MEM_MASK 32 -#define NUM_MEM_BLK 32 * NUM_MEM_MASK - -typedef struct _t_MemoryData { - void *address[NUM_MEM_BLK]; - Card32 allocNdx[NUM_MEM_BLK]; - Card32 inUseMask[NUM_MEM_MASK]; - Card32 keepMask[NUM_MEM_MASK]; - char *fileName[NUM_MEM_BLK]; - Card32 size[NUM_MEM_BLK]; - Card32 lineNo[NUM_MEM_BLK]; - Card32 memStore[NUM_MEM_BLK]; - Card32 numInUse; - struct _t_MemoryData *next; -} * MemoryData, MemoryDataRec; - -static MemoryData memoryData; - -static Card32 distAllocNdx = 0; -static Card32 distAllocCount = 0; -static Card32 totalAllocCount = 0; -static Card32 distAllocNdxStopper = 0; - -SINGEXPORT int memck_PrintAllAllocFreeCalls = 0; /* print out all allocations/reallocations/frees */ - -static FILE *logfile = NULL; - -/* ----------------------------------------------------------- */ - -static int MIN(int a, int b) { - if (a < b) return a; - return b; -} - -static int MAX(int a, int b) { - if (a > b) return a; - return b; -} - -static char *CheckName(char *filename) { -#define MEMCKMAXNUMFILENAMES 256 - static char outOfMemStr[] = ""; - static char *fileNames[MEMCKMAXNUMFILENAMES]; - static int numNames = 0; - - char *cptr; - int i; - - for (cptr = filename; *cptr; ++cptr) - if (*cptr == '/') filename = cptr + 1; - - for (i = 0; i < numNames; ++i) - if (!strcmp(filename, fileNames[i])) break; - if (i < numNames) return fileNames[i]; - if (numNames < (MEMCKMAXNUMFILENAMES - 1)) { - cptr = fileNames[numNames++] = (char *)OSProvided_Malloc(strlen(filename) + 1); - if (cptr) - strcpy(cptr, filename); - else - cptr = outOfMemStr; - } else - cptr = outOfMemStr; - return cptr; -} - -/* You can call this function from gdb or set the global distAllocNdxStopper - * directly to stop at a given allocation index with an assertion failure - * after the memory leak report has detected one and given you an index. */ -SINGEXPORT void StopOnAllocation(Card32 stopNum) { - distAllocNdxStopper = stopNum; -} - -/* - * This is a good place to set a breakpoint when we reach the given allocation - index - */ -static void AllocationBreakStop(Card32 stopNum) { - fprintf(stdout, "MemCheck allocator reached allocation #%d\n", stopNum); -} - -static boolean StoreAllocation( - void *ptr, - int size, - MemCheck_MemStore memStore, - char *filename, - int lineno) { - MemoryData mPtr, *prev; - - /* This debugassert will trip on the given allocation numbered - * distAllocNdx as * reported in the memory leak report. This is much - * faster than a conditional * breakpoint. */ - if (distAllocNdxStopper != 0 && distAllocNdxStopper <= distAllocNdx) { - AllocationBreakStop(distAllocNdx); - distAllocNdxStopper = 0; - } - DebugAssert(distAllocNdxStopper == 0 || distAllocNdxStopper != distAllocNdx); - prev = &memoryData; - for (mPtr = memoryData; mPtr; mPtr = mPtr->next) { - if (mPtr->numInUse < NUM_MEM_BLK) { - int i, j, k; - void **addr; - pCard32 mask = mPtr->inUseMask; - for (i = 0; i < NUM_MEM_MASK; ++i, ++mask) - if (*mask != 0xFFFFFFFF) break; - addr = &mPtr->address[i << 5]; - for (j = 0; j < 32; ++j, ++addr) - if (*addr == NULL) break; - k = (i << 5) + j; - *mask |= ((Card32)1 << j); - mPtr->keepMask[i] |= ((Card32)1 << j); - ++mPtr->numInUse; - *addr = ptr; - mPtr->allocNdx[k] = distAllocNdx; - mPtr->fileName[k] = CheckName(filename); - mPtr->lineNo[k] = lineno; - mPtr->size[k] = size; - mPtr->memStore[k] = memStore; - return 1; - } - prev = &mPtr->next; - } - *prev = mPtr = (MemoryData)OSProvided_Calloc(sizeof(MemoryDataRec), 1); - if (!mPtr) return 0; - mPtr->address[0] = ptr; - mPtr->allocNdx[0] = distAllocNdx; - mPtr->inUseMask[0] = 1; - mPtr->keepMask[0] = 1; - mPtr->fileName[0] = CheckName(filename); - mPtr->lineNo[0] = lineno; - mPtr->size[0] = size; - mPtr->memStore[0] = memStore; - mPtr->numInUse = 1; - mPtr->next = NULL; - return 1; -} - -static void ReplaceAllocation(void *ptr1, - void *ptr2, - int size, - char *filename, - int lineno) { - MemoryData mPtr, *prev; - - prev = &memoryData; - for (mPtr = memoryData; mPtr; mPtr = mPtr->next) { - int i, j, k; - void **addr; - pCard32 mask = mPtr->inUseMask; - pCard32 keep = mPtr->keepMask; - DebugAssert(mPtr->numInUse > 0); - for (i = 0; i < NUM_MEM_MASK; ++i, ++mask, ++keep) { - if (*mask == 0) continue; - addr = &mPtr->address[i << 5]; - for (k = i << 5, j = 0; j < 32; ++j, ++k, ++addr) { - if (*addr == ptr1) { - if ((*addr = ptr2) != NULL) { - mPtr->fileName[k] = CheckName(filename); - mPtr->allocNdx[k] = distAllocNdx; - mPtr->lineNo[k] = lineno; - mPtr->size[k] = size; - return; - } - *mask &= ~((Card32)1 << j); - *keep &= ~((Card32)1 << j); - if (--mPtr->numInUse == 0) { - MemoryData next = mPtr->next; - OSProvided_Free(mPtr); - *prev = next; - } - return; - } - } - } - prev = &mPtr->next; - } - DebugAssert(0); -} - -static void ResetAllocations(void) { - MemoryData mPtr; - for (mPtr = memoryData; mPtr; mPtr = mPtr->next) - memset(mPtr->keepMask, 0, NUM_MEM_MASK << 2); -} - -static void PrintAllocations() { - MemoryData mPtr; - int i, j, k; - int numLeft = 0; - - for (mPtr = memoryData; mPtr; mPtr = mPtr->next) { - void **addr; - pCard32 mask = mPtr->inUseMask; - pCard32 keep = mPtr->keepMask; - DebugAssert(mPtr->numInUse > 0); - for (i = 0; i < NUM_MEM_MASK; ++i, ++mask, ++keep) { - if (*mask == 0 || *keep == 0) continue; - addr = &mPtr->address[i << 5]; - for (j = 0; j < 32; ++j, ++addr) - if (*addr != NULL && (*keep & (1 << j)) != 0) ++numLeft; - } - } - if (!numLeft) return; - - if (logfile) - fprintf(logfile, "WARNING: Possible memory leak; %d items left allocated\n", numLeft); - for (mPtr = memoryData; mPtr; mPtr = mPtr->next) { - void **addr; - pCard32 mask = mPtr->inUseMask; - pCard32 keep = mPtr->keepMask; - DebugAssert(mPtr->numInUse > 0); - for (i = 0; i < NUM_MEM_MASK; ++i, ++mask, ++keep) { - if (*mask == 0 || *keep == 0) continue; - addr = &mPtr->address[i << 5]; - for (k = i << 5, j = 0; j < 32; ++j, ++k, ++addr) { - if (*addr == NULL || (*keep & (1 << j)) == 0) continue; - - if (logfile) - fprintf(logfile, - " (Store=%d)\t 0x%x size=%d (ndx=%d) file=%s@%d\n", - mPtr->memStore[k], - *addr, - mPtr->size[k], - mPtr->allocNdx[k], - mPtr->fileName[k], mPtr->lineNo[k]); - } - } - } - if (logfile) fflush(logfile); -} - -/* ----------------------------------------------------------- */ - -/* ----------------------------------------------------------- */ -/* ----------------------------------------------------------- */ -/* Mem Store buffers are allocated in per_store_Data Blocks */ -typedef struct t_PerstoreData *PPerstoreData; -typedef struct t_PerstoreData { - pCard8 data; /* use char* for easy pointer math */ - Int32 size; /* original size of the block */ - Int32 left; /* contiguious bytes left over in this block */ - Int32 discard; /* this block can be freed IF discard+left == size */ - PPerstoreData next; - PPerstoreData prev; -} PerstoreData; - -typedef struct t_MemStore { - PerstoreData head[1]; - - /* statistics for debugging */ - int allocated; /* Actual allocated size for this memStore - including freed */ - int used; /* size used AND re-used */ - int freed; /* allocated - freed = size used for this memStore */ - int maxInUse; /* Maximal mem size in use for this memStore: MAX(allocated-freed) */ - int maxBlock; /* max block size */ - int numBlocks; /* blocks left over */ - int reqBlocks; /* num of blocks requested - inlcuding freed ones */ -} MemStore, *PMemStore; - -#define PD_BLOCK_MIN_SIZE 0x4000 /* default min size */ -#define PD_BLOCK_MAX_SIZE 0xFFF0 /* Max size allowed from MemStores */ - -/* All blocks allocated are in one of the stores */ -static MemStore gMStores[memck_store_maxMemStore]; - -/* 2 Giga bytes is memck_*alloc()'s max size - * so the size in ((size << 1) | MEMCK_OSMALLOC_BIT) can be recovered - */ -#define MEMCK_MAX_SIZE 0x7FFFFFF0 -#define MEMCK_OSMALLOC_BIT 0x00000001 - -/* - * Every memck_*alloc()'d ptr has an Card32 tag in its front - * each buffer looks like this : - * (HEAD)(UserPtr)(TAIL) - * - * If the pointer is from OSProvided_*alloc(): - * (HEAD) has MEMCK_OSMALLOC_BIT set which will never be set - * by memstore_*alloc() - * - * If the pointer is from memstore_*alloc(): - * (HEAD) is divided into two Card16 (DS)(SZ) where - * SZ = size of (HEAD + UserPtr + TAIL), it is always even. - * DS = DistanceToBlockHeader, its maximal value is - * PD_BLOCK_MAX_SIZE - SZ - * - * In Release build. (TAIL) is not included - * - * For Sparc Solaris we have the additional requirement that all malloc - * pointers returned to the client must be 8-byte aligned. This is to - * allow the client to store doubles in the segment (if the ptr is not - * 8-byte aligned a BUS error will happen). So for Solaris we wrap the - * entire buffer like this: - * - * 1) If the client pointer is unaligned (only 4-byte aligned): - * - * Base malloc pointer - * | - * | Unaligned unwrapped client pointer - * | | - * | | Aligned wrapped client pointer - * | | | - * V V V - * 4 byte 4 byte 4 byte 4 byte - * +--------+--------+-------------------------------+--------+--------+ - * | HEAD | = 1 | Client segment | unused | TAIL | - * +--------+--------+-------------------------------+--------+--------+ - * - * |<--- MEMCK_GetInnerClientSize --->| - * - * |<-------------- MEMCK_GetClientSize --------------->| - * - * - * 2) If the client pointer is aligned (8-byte aligned): - * - * Base malloc pointer - * | - * | Aligned unwrapped client pointer - * | | - * | | Aligned wrapped client pointer - * | | | - * V V V - * 4 byte 4 byte 4 byte 4 byte - * +--------+--------+--------+-------------------------------+--------+ - * | HEAD | = 2 | = 2 | Client segment | TAIL | - * +--------+--------+--------+-------------------------------+--------+ - * - * |<--- MEMCK_GetInnerClientSize --->| - * - * |<-------------- MEMCK_GetClientSize --------------->| - * - * The 4-byte unsigned integers between the base pointer and the client - * pointer indicate whether or not the base pointer is unaligned. - * - * Exported functions: - * - * memck_mallocinternal - * memck_callocinternal - * memck_freeinternal - * memck_reallocinternal - * - * Internal call-hierarchy: - * - * memck_callocinternal - * | - * `---> memck_mallocinternal - * - * memck_reallocinternal - * | - * `---> memstore_reallocinternal - * | - * `---> memck_mallocinternal - * `---> mekck_freeinternal - */ - -#if MEMCK_NEED_ALIGN8 - -#define MEMCK_IS_ALIGNED8(ptr) ((((Card32)(ptr)) % 8) == 0) -#define MEMCK_PADDING_ALIGN8 (sizeof(Card32) * 2) - -/*------------------------------------------*/ -#define MEMCK_WRAP8(wPtr) \ - \ - { \ - if (wPtr) { \ - if (MEMCK_IS_ALIGNED8(wPtr)) { \ - *((pCard32)wPtr) = 2; \ - ((pCard32)wPtr)++; \ - *((pCard32)wPtr) = 2; \ - ((pCard32)wPtr)++; \ - } else { \ - *((pCard32)wPtr) = 1; \ - ((pCard32)wPtr)++; \ - } \ - DebugAssert(MEMCK_IS_ALIGNED8(wPtr)); \ - } \ - } - -/*--------------------------------------------*/ -#define MEMCK_UNWRAP8(wPtr) \ - \ - { \ - DebugAssert(wPtr); \ - DebugAssert(MEMCK_IS_ALIGNED8(wPtr)); \ - ((pCard32)wPtr)--; \ - if (*((pCard32)wPtr) == 2) { \ - ((pCard32)wPtr)--; \ - DebugAssert(*((pCard32)wPtr) == 2); \ - } else { \ - DebugAssert(*((pCard32)wPtr) == 1); \ - } \ - } - -#else - -#define MEMCK_PADDING_ALIGN8 (0) -#define MEMCK_WRAP8(wPtr) -#define MEMCK_UNWRAP8(wPtr) - -#endif - -#define MEMCK_HEAD_SIZE (sizeof(Card32)) - -/*------------------------------------------------*/ -/* From internal data pointer to clients' pointer */ -/*------------------------------------------------*/ - -#define MEMCK_MakeClientPtr(basePtr) ((void *)((pCard8)(basePtr) + MEMCK_HEAD_SIZE)) - -/*------------------------------*/ -/* From client's pointer to ... */ -/*------------------------------*/ - -#define MEMCK_BasePtr(clientPtr) ((void *)((pCard8)(clientPtr)-MEMCK_HEAD_SIZE)) -#define MEMCK_GET_HEAD32(clientPtr) (*((pCard32)MEMCK_BasePtr(clientPtr))) -#define PD_GET_SZ16(clientPtr) (MEMCK_GET_HEAD32(clientPtr) & 0x0000FFFF) -#define PD_GET_DS16(clientPtr) ((MEMCK_GET_HEAD32(clientPtr) & 0xFFFF0000) >> 16) -#define MEMCK_IsOSmalloc(clientPtr) (MEMCK_GET_HEAD32(clientPtr) & MEMCK_OSMALLOC_BIT) -#define PD_GetBlock(clientPtr) ((pCard8)(clientPtr)-PD_GET_DS16(clientPtr)) - -/* -** size set by MEMCK_SetTotalSize() inlcudes MEMCK_EXTRA_BYTES, actual saved -** (HEAD) is either ( size<<1 | 1) or (DS)(SZ) depends on if Blk==NULL -*/ - -#define MEMCK_SetTotalSize(clientPtr, Blk, siz) \ - \ - MEMCK_GET_HEAD32(clientPtr) = \ - ((Blk == NULL) ? ((((Card32)(siz)) << 1) | MEMCK_OSMALLOC_BIT) : ((Card32)(siz) | (((Card32)(clientPtr) - (Card32)(Blk)) << 16))) - -#define MEMCK_GetTotalSize(clientPtr) \ - (MEMCK_IsOSmalloc(clientPtr) ? (MEMCK_GET_HEAD32(clientPtr) >> 1) : PD_GET_SZ16(clientPtr)) - -#define MEMCK_AlignSize(M_Size) \ - (((((M_Size) + PREFERREDALIGN - 1) / PREFERREDALIGN) * PREFERREDALIGN) + MEMCK_PADDING_ALIGN8) - -/* -** Guard the tail for debugging purpose - because a corrupted -** tail is not easily spotted if it is from the big block -*/ - -#define MEMCK_TAIL_SIZE (sizeof(Card32)) -#define MEMCK_EXTRA_BYTES (MEMCK_HEAD_SIZE + MEMCK_TAIL_SIZE) -#define MEMCK_TAIL_GUARD 0xADBEADBE /* ADoBE ADoBE */ -#define MEMCK_TAIL_FREED 0xFEEDFEED /* FrEED FrEED */ - -#define MEMCK_GetClientSize(clientPtr) (MEMCK_GetTotalSize(clientPtr) - MEMCK_EXTRA_BYTES) - -#if MEMCK_NEED_ALIGN8 -#define MEMCK_GetInnerClientSize(clientPtr) (MEMCK_GetClientSize(clientPtr) - MEMCK_PADDING_ALIGN8) -#endif - -/*---------------------------------------*/ -/* From client's Ptr to its tail's value */ -/*---------------------------------------*/ - -#define MEMCK_GET_TAIL(clientPtr) *((pCard32)((pCard8)(clientPtr) + MEMCK_GetClientSize(clientPtr))) - -/*----------------------------*/ -/* Guard client's pointer Ptr */ -/*----------------------------*/ - -#define MEMCK_GuardTail(clientPtr) MEMCK_GET_TAIL(clientPtr) = (Card32)MEMCK_TAIL_GUARD -#define MEMCK_FreedTail(clientPtr) MEMCK_GET_TAIL(clientPtr) = (Card32)MEMCK_TAIL_FREED -#define MEMCK_BadTail(clientPtr) (MEMCK_GET_TAIL(clientPtr) != (Card32)MEMCK_TAIL_GUARD) - -/* -------------------------------------------------- */ -/* ------------ pointers from MemStores ------------- */ -/* -------------------------------------------------- */ -static void *memstore_mallocinternal( - int len, - MemCheck_MemStore index, - char *filename, - int lineno) { - PMemStore pms = &(gMStores[index]); - PPerstoreData ppd; - int size; - pCard8 pByte = NULL; - - pms->used += len; - DebugAssert(len < PD_BLOCK_MAX_SIZE + 4); - - /* The buffer we return has some extra bytes for internal use */ - len += MEMCK_EXTRA_BYTES; - /* Make len multiple of 4 */ - len = ((len + 3) / 4) * 4; - - /* search left overs */ - for (ppd = pms->head[0].next; ppd; ppd = ppd->next) { - if (ppd->left < len) - continue; - pByte = ppd->data + ppd->size - ppd->left; - ppd->left -= len; - break; - } - - if (pByte == NULL) { - /* need a new block for this store */ - if (len < PD_BLOCK_MIN_SIZE) - size = MAX(2 * len, PD_BLOCK_MIN_SIZE); - else - size = len; - size += sizeof(PerstoreData); - /* One OSProvided_Malloc() allocates both the structure and its data */ - ppd = (PPerstoreData)OSProvided_Malloc(size); - if (!ppd) - return NULL; - - ppd->data = (pCard8)((pCard8)ppd + sizeof(PerstoreData)); - ppd->size = - ppd->left = size - sizeof(PerstoreData); - ppd->discard = 0; - ppd->next = pms->head[0].next; - if (pms->head[0].next) - pms->head[0].next->prev = ppd; - ppd->prev = &(pms->head[0]); - pms->head[0].next = ppd; - - pByte = ppd->data; - ppd->left -= len; - - pms->numBlocks++; - pms->reqBlocks++; - pms->allocated += size; - if (size > pms->maxBlock) - pms->maxBlock = size; - if ((pms->allocated - pms->freed) > pms->maxInUse) - pms->maxInUse = (pms->allocated - pms->freed); - } - - if (pByte) { - /* Now tag pByte with length and block - size include the extra bytes */ - pByte = (pCard8)MEMCK_MakeClientPtr(pByte); - /* size set by MEMCK_SetTotalSize() inlcudes MEMCK_EXTRA_BYTES */ - MEMCK_SetTotalSize(pByte, ppd, len); - MEMCK_GuardTail(pByte); - } - return ((void *)pByte); -} - -static MemCheck_MemStore FindMemStore( - PPerstoreData ptr) { - PPerstoreData ppd; - int index; - for (index = memck_store_default; index < memck_store_maxMemStore; index++) { - ppd = gMStores[index].head[0].next; - while (ppd) { - if ((Card32)ptr > (Card32)ppd && - (Card32)ptr < (Card32)(ppd->data + ppd->size)) { - Assert(ppd == (PPerstoreData)PD_GetBlock(ptr)); - return (MemCheck_MemStore)index; - } - ppd = ppd->next; - } - } - return memck_store_maxMemStore; -} - -static boolean memstore_remove_from_store( - PPerstoreData ppd, - MemCheck_MemStore index) { - PMemStore pms = &(gMStores[index]); - if (ppd->discard + ppd->left == ppd->size) { - pms->numBlocks--; - pms->freed += ppd->size + sizeof(PerstoreData); - if (ppd->next) - ppd->next->prev = ppd->prev; - if (ppd->prev) - ppd->prev->next = ppd->next; - OSProvided_Free((void *)ppd); - return 1; - } - return 0; -} - -/* ptr must be memck_per_*alloc()-ed */ -static void memstore_freeinternal( - void *ptr) { - PPerstoreData ppd; - Int32 size; - ppd = (PPerstoreData)PD_GetBlock(ptr); - /* size set by MEMCK_SetTotalSize() inlcudes MEMCK_EXTRA_BYTES */ - size = MEMCK_GetTotalSize(ptr); - if (MEMCK_BasePtr(ptr) == (void *)(ppd->data + ppd->size - ppd->left - size)) { - /* Coalesce to left space */ - ppd->left += size; - } else { - /* don't bother to coalesce with other free items, just remember the size freed */ - ppd->discard += size; - /* remove the block if we can */ - if (ppd->discard + ppd->left == ppd->size) { - MemCheck_MemStore index = FindMemStore((PerstoreData *)ptr); - memstore_remove_from_store(ppd, index); - } - } -} - -#if (MEMCK_NEED_ALIGN8 == 0) - -static void *memstore_reallocinternal( - void *old_ptr, - int new_size, - char *filename, - int lineno) { - void *new_ptr; - MemCheck_MemStore index = FindMemStore((PerstoreData *)old_ptr); - DebugAssert(index < memck_store_maxMemStore); - /* realloc from Store index */ - new_ptr = memck_mallocinternal(new_size, index, filename, lineno); - if (new_ptr) { - /* size set by MEMCK_SetTotalSize() inlcudes MEMCK_EXTRA_BYTES */ - int old_size = MEMCK_GetTotalSize(old_ptr); - old_size -= MEMCK_EXTRA_BYTES; - - DebugAssert(old_size < gMStores[index].maxBlock); - DebugAssert(old_size >= 0); - - bcopy(old_ptr, new_ptr, MIN(old_size, new_size)); - memck_freeinternal(old_ptr, filename, lineno); - } - return (new_ptr); -} - -#endif /* MEMCK_NEED_ALIGN8 == 0 */ - -static void FreeOneMemStore( - MemCheck_MemStore index) { - PMemStore pms = &(gMStores[index]); - PPerstoreData ppd, next; - - if (pms->head[0].next == NULL) - return; - - /* Free the list */ - ppd = pms->head[0].next; - while (ppd) { - next = ppd->next; - memstore_remove_from_store(ppd, index); - ppd = next; - } - - /* These are report for current job - reset for next job*/ - pms->maxInUse = 0; - pms->allocated = 0; - pms->used = 0; - pms->freed = 0; -} - -/* -------------------------------------------------- */ -/* ----------------- SINGEXPORT functions ---------- */ - -SINGEXPORT int memck_Startup(char *logfilePathName) { - time_t timer; - - logfile = fopen(logfilePathName, "a+"); - if (logfile) { - time(&timer); - fprintf(logfile, "========= Started: %s\n", ctime(&timer)); - } - return (logfile == NULL); -} - -SINGEXPORT void memck_Shutdown(void) { - time_t timer; - int index; - for (index = memck_store_default; index < memck_store_maxMemStore; index++) - FreeOneMemStore((MemCheck_MemStore)index); - if (logfile) { - time(&timer); - fprintf(logfile, "========== Finished: %s\n", ctime(&timer)); - } - - fclose(logfile); - logfile = NULL; -} - -/* ----------------------------------------------------------- */ -SINGEXPORT void *memck_mallocinternal( - int size, - MemCheck_MemStore index, - char *filename, - int lineno) { - void *result; - - DebugAssert(index >= memck_store_default); - DebugAssert(index < memck_store_maxMemStore); - - /* malloc()/mc_Malloc() also allows 0 byte allocation */ - if (size < 0 || size > MEMCK_MAX_SIZE) - return NULL; - - size = MEMCK_AlignSize(size); - - if ((index > memck_store_default) && size < PD_BLOCK_MAX_SIZE) { - result = memstore_mallocinternal(size, index, filename, lineno); - DebugAssert(!MEMCK_IsOSmalloc(result)); - } else { - /* old way, but with MEMCK_EXTRA_BYTES more bytes allocated */ - result = OSProvided_Malloc(size + MEMCK_EXTRA_BYTES); - /* Convert to user's pointer, skip the header bytes and tag it */ - if (result) { - result = MEMCK_MakeClientPtr(result); - /* size set by MEMCK_SetTotalSize() inlcudes MEMCK_EXTRA_BYTES */ - MEMCK_SetTotalSize(result, NULL, size + MEMCK_EXTRA_BYTES); - MEMCK_GuardTail(result); - } - } - - if (!result) - return NULL; - - if (!StoreAllocation(result, size, index, filename, lineno)) { - if (MEMCK_IsOSmalloc(result)) - OSProvided_Free(MEMCK_BasePtr(result)); - else - memstore_freeinternal(result); - return NULL; - } - - ++distAllocCount; - ++distAllocNdx; - if (memck_PrintAllAllocFreeCalls) { - if (logfile) - fprintf(logfile, - "Malloc 0x%x\t siz=%d tcnt=%d cnt=%d file=%s@%d\n", - result, - size, - ++totalAllocCount, - distAllocCount, filename, lineno); - if (logfile) fflush(logfile); - } - - MEMCK_WRAP8(result); - - return (result); -} - -/* ----------------------------------------------------------- */ -SINGEXPORT void *memck_callocinternal( - int count, - int size, - MemCheck_MemStore index, - char *filename, - int lineno) { - void *result; - - DebugAssert(index >= memck_store_default); - DebugAssert(index < memck_store_maxMemStore); - - result = memck_mallocinternal(count * size, index, filename, lineno); - if (result) - memset(result, 0, count * size); - return result; -} - -/* ----------------------------------------------------------- */ -SINGEXPORT void memck_freeinternal( - void *ptr, - char *filename, - int lineno) { - /* Just ignore if ptr is NULL, but memck_free used to Assert() */ - DebugAssert(ptr != NULL); - - if (ptr == NULL) - return; - - MEMCK_UNWRAP8(ptr); - - ReplaceAllocation(ptr, 0, 0, 0, 0); - --distAllocCount; - if (MEMCK_BadTail(ptr)) { - if (logfile) { - fprintf(logfile, "WARNING: pointer 0x%x had been over written! Freed in file=%s@%d\n", ptr, filename, lineno); - fflush(logfile); - } - DebugAssert(0); - } else { - /* Mark tail to different value, so we can trap multiple - OSProvided_Free() on same pointer */ - MEMCK_FreedTail(ptr); - } - - if (memck_PrintAllAllocFreeCalls) { - if (logfile) { - fprintf(logfile, - "Free 0x%x\t cnt=%d file=%s@%d\n", - ptr, - distAllocCount, - filename, lineno); - fflush(logfile); - } - } - - if (MEMCK_IsOSmalloc(ptr)) { - OSProvided_Free(MEMCK_BasePtr(ptr)); - } else { - memstore_freeinternal(ptr); - } -} - -/* ----------------------------------------------------------- */ -SINGEXPORT void *memck_reallocinternal( - void *old_ptr, - int new_size, - char *filename, - int lineno) { -#if MEMCK_NEED_ALIGN8 - - int old_size; - MemCheck_MemStore myIndex; - void *new_ptr; - void *tmp_ptr = old_ptr; - - MEMCK_UNWRAP8(tmp_ptr); - - if (MEMCK_IsOSmalloc(tmp_ptr)) - myIndex = memck_store_default; - else { - myIndex = FindMemStore((PerstoreData *)tmp_ptr); - DebugAssert(myIndex < memck_store_maxMemStore); - } - - old_size = MEMCK_GetInnerClientSize(tmp_ptr); - - new_ptr = memck_mallocinternal(new_size, myIndex, filename, lineno); - if (new_ptr == NULL) - return (NULL); - - memcpy(new_ptr, old_ptr, MIN(old_size, new_size)); - memck_freeinternal(old_ptr, filename, lineno); - return (new_ptr); - -#else /* !MEMCK_NEED_ALIGN8 */ - - new_size = MEMCK_AlignSize(new_size); - - if (MEMCK_IsOSmalloc(old_ptr)) { - void *new_ptr; - /* old way, but with MEMCK_EXTRA_BYTES more bytes allocated */ - new_ptr = OSProvided_Realloc(MEMCK_BasePtr(old_ptr), new_size + MEMCK_EXTRA_BYTES); - if (new_ptr) { - new_ptr = MEMCK_MakeClientPtr(new_ptr); - /* size set by MEMCK_SetTotalSize() inlcudes MEMCK_EXTRA_BYTES */ - MEMCK_SetTotalSize(new_ptr, NULL, new_size + MEMCK_EXTRA_BYTES); - MEMCK_GuardTail(new_ptr); - } - if (new_ptr == NULL) - return NULL; - - ReplaceAllocation(old_ptr, new_ptr, new_size, filename, lineno); - ++distAllocNdx; - if (new_ptr != old_ptr) { - if (memck_PrintAllAllocFreeCalls) { - if (logfile) { - fprintf(logfile, - "Realloc 0x%x\t cnt=%d file=%s@%d\n", - old_ptr, - --distAllocCount, - filename, lineno); - fprintf(logfile, - "==> 0x%x\t siz=%d cnt=%d file=%s@%d\n", - new_ptr, - new_size, - ++distAllocCount, filename, lineno); - fflush(logfile); - } - } - } - return (new_ptr); - } else { - return (memstore_reallocinternal(old_ptr, new_size, filename, lineno)); - } - -#endif /* MEMCK_NEED_ALIGN8 */ -} - -/* ----------------------------------------------------------- */ - -SINGEXPORT void memck_ResetMemLeakDetection(void) { - distAllocCount = 0; - distAllocNdx = 0; - ResetAllocations(); -} - -SINGEXPORT void memck_CheckMemLeaks(void) { - PrintAllocations(); - memck_ResetMemLeakDetection(); -} - -#else -static int placeholder(void) { - return 0; -} -#endif diff --git a/c/autohint/autohintlib/source/ac/merge.c b/c/autohint/autohintlib/source/ac/merge.c deleted file mode 100644 index 01c7d473c..000000000 --- a/c/autohint/autohintlib/source/ac/merge.c +++ /dev/null @@ -1,469 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* merge.c */ - -#include "ac.h" - -private -boolean CloseElements(e1, e2, loc1, loc2, vert) -/* TRUE iff you can go from e1 to e2 without going out of band loc1..loc2 */ -/* if vert is TRUE, then band is vert (test x values) */ -/* else band is horizontal (test y values) */ -/* band is expanded by CLSMRG in each direction */ -#define CLSMRG (PSDist(20)) - register PPathElt e1, - e2; -register Fixed loc1, loc2; -register boolean vert; -{ - register Fixed tmp; - Fixed x, y; - register PPathElt e; - if (e1 == e2) return TRUE; - if (loc1 < loc2) { - if ((loc2 - loc1) > 5 * CLSMRG) - return FALSE; - loc1 -= CLSMRG; - loc2 += CLSMRG; - } else { - if ((loc1 - loc2) > 5 * CLSMRG) - return FALSE; - tmp = loc1; - loc1 = loc2 - CLSMRG; - loc2 = tmp + CLSMRG; - } - - e = e1; - while (TRUE) { - if (e == e2) return TRUE; - GetEndPoint(e, &x, &y); - tmp = vert ? x : y; - if (tmp > loc2 || tmp < loc1) return FALSE; - if (e->type == CLOSEPATH) - e = GetDest(e); - else - e = e->next; - if (e == e1) return FALSE; - } -} - -public -boolean CloseSegs(s1, s2, vert) PClrSeg s1, s2; -boolean vert; -{ - /* TRUE if the elements for these segs are "close" in the path */ - PPathElt e1, e2; - Fixed loc1, loc2; - if (s1 == s2) return TRUE; - e1 = s1->sElt; - e2 = s2->sElt; - if (e1 == NULL || e2 == NULL) return TRUE; - loc1 = s1->sLoc; - loc2 = s2->sLoc; - return (CloseElements(e1, e2, loc1, loc2, vert) || - CloseElements(e2, e1, loc2, loc1, vert)) - ? TRUE - : FALSE; -} - -public -procedure DoPrune() { - /* Step through valList to the first item which is not pruned; set - that to be the head of the list. Then remove from the list - any subsequent element for which 'pruned' is true. - */ - PClrVal vL = valList, vPrv; - while (vL != NULL && vL->pruned) - vL = vL->vNxt; - valList = vL; - if (vL == NULL) return; - vPrv = vL; - vL = vL->vNxt; - while (vL != NULL) { - if (vL->pruned) - vPrv->vNxt = vL = vL->vNxt; - else { - vPrv = vL; - vL = vL->vNxt; - } - } -} - -private -PClrVal PruneOne(sLst, hFlg, sL, i) - PClrVal sLst, - sL; -boolean hFlg; -integer i; -{ - /* Simply set the 'pruned' field to True for sLst. */ - if (hFlg) - ReportPruneHVal(sLst, sL, i); - else - ReportPruneVVal(sLst, sL, i); - sLst->pruned = TRUE; - return sLst->vNxt; -} - -#define PRNDIST (PSDist(10)) -#define PRNFCTR (3L) - -#define PruneLt(val, v) \ - (((v) < (FixedPosInf / 10L) && (val) < (FixedPosInf / PRNFCTR)) ? ((val)*PRNFCTR < (v)*10L) : ((val) / 10L < (v) / PRNFCTR)) -#define PruneLe(val, v) \ - (((val) < (FixedPosInf / PRNFCTR)) ? ((v) <= (val)*PRNFCTR) : ((v) / PRNFCTR <= (val))) -#define PruneGt(val, v) \ - (((val) < (FixedPosInf / PRNFCTR)) ? ((v) > (val)*PRNFCTR) : ((v) / PRNFCTR > (val))) -#define MUCHFCTR (50L) -#define PruneMuchGt(val, v) \ - (((val) < (FixedPosInf / MUCHFCTR)) ? ((v) > (val)*MUCHFCTR) : ((v) / MUCHFCTR > (val))) -#define VERYMUCHFCTR (100L) -#define PruneVeryMuchGt(val, v) \ - (((val) < (FixedPosInf / VERYMUCHFCTR)) ? ((v) > (val)*VERYMUCHFCTR) : ((v) / VERYMUCHFCTR > (val))) - -/* The changes made here and in PruneHVals are to fix a bug in - MinisterLight/E where the top left point was not getting colored. */ -public -procedure PruneVVals() { - PClrVal sLst, sL, sPrv; - PClrSeg seg1, seg2, sg1, sg2; - Fixed lft, rht, l, r, prndist; - Fixed val, v, abstmp; - boolean flg, otherLft, otherRht; - sLst = valList; - sPrv = NULL; - prndist = PRNDIST; - while (sLst != NULL) { - flg = TRUE; - otherLft = otherRht = FALSE; - val = sLst->vVal; - lft = sLst->vLoc1; - rht = sLst->vLoc2; - seg1 = sLst->vSeg1; - seg2 = sLst->vSeg2; - sL = valList; - while (sL != NULL) { - v = sL->vVal; - sg1 = sL->vSeg1; - sg2 = sL->vSeg2; - l = sL->vLoc1; - r = sL->vLoc2; - if ((l == lft && r == rht) || PruneLe(val, v)) goto NxtSL; - if (rht + prndist >= r && lft - prndist <= l && - (val < FixInt(100L) && PruneMuchGt(val, v) ? (CloseSegs(seg1, sg1, TRUE) || CloseSegs(seg2, sg2, TRUE)) : (CloseSegs(seg1, sg1, TRUE) && CloseSegs(seg2, sg2, TRUE)))) { - sLst = PruneOne(sLst, FALSE, sL, 1L); - flg = FALSE; - break; - } - if (seg1 != NULL && seg2 != NULL) { - if (ac_abs(l - lft) < FixOne) { - if (!otherLft && PruneLt(val, v) && ac_abs(l - r) < ac_abs(lft - rht) && - CloseSegs(seg1, sg1, TRUE)) - otherLft = TRUE; - if (seg2->sType == sBEND && CloseSegs(seg1, sg1, TRUE)) { - sLst = PruneOne(sLst, FALSE, sL, 2L); - flg = FALSE; - break; - } - } - if (ac_abs(r - rht) < FixOne) { - if (!otherRht && PruneLt(val, v) && ac_abs(l - r) < ac_abs(lft - rht) && - CloseSegs(seg2, sg2, TRUE)) - otherRht = TRUE; - if (seg1->sType == sBEND && CloseSegs(seg2, sg2, TRUE)) { - sLst = PruneOne(sLst, FALSE, sL, 3L); - flg = FALSE; - break; - } - } - if (otherLft && otherRht) { - sLst = PruneOne(sLst, FALSE, sL, 4L); - flg = FALSE; - break; - } - } - NxtSL: - sL = sL->vNxt; - } - if (flg) { - sPrv = sLst; - sLst = sLst->vNxt; - } - } - DoPrune(); -} - -#define Fix16 (FixOne << 4) -public -procedure PruneHVals() { - PClrVal sLst, sL, sPrv; - PClrSeg seg1, seg2, sg1, sg2; - Fixed bot, top, t, b; - Fixed val, v, abstmp, prndist; - boolean flg, otherTop, otherBot, topInBlue, botInBlue, ghst; - sLst = valList; - sPrv = NULL; - prndist = PRNDIST; - while (sLst != NULL) { - flg = TRUE; - otherTop = otherBot = FALSE; - seg1 = sLst->vSeg1; - seg2 = sLst->vSeg2; /* seg1 is bottom, seg2 is top */ - ghst = sLst->vGhst; - val = sLst->vVal; - bot = sLst->vLoc1; - top = sLst->vLoc2; - topInBlue = InBlueBand(top, lenTopBands, topBands); - botInBlue = InBlueBand(bot, lenBotBands, botBands); - sL = valList; - while (sL != NULL) { - if ((sL->pruned) && (doAligns || !doStems)) - goto NxtSL; - - sg1 = sL->vSeg1; - sg2 = sL->vSeg2; /* sg1 is b, sg2 is t */ - v = sL->vVal; - if (!ghst && sL->vGhst && !PruneVeryMuchGt(val, v)) - goto NxtSL; /* Do not bother checking if we should prune, if slSt is not ghost hint, sL is ghost hint, */ - /* and not (sL->vVal is more than 50* bigger than sLst->vVal. */ - /* Basically, we prefer non-ghost hints over ghost unless vVal is really low. */ - b = sL->vLoc1; - t = sL->vLoc2; - if (t == top && b == bot) - goto NxtSL; /* Don't compare two valList elements that have the same top and bot. */ - - if ( /* Prune sLst if the following are all true */ - PruneGt(val, v) && /* v is more than 3* val */ - - ((YgoesUp && top + prndist >= t && bot - prndist <= b) || - (!YgoesUp && top - prndist <= t && bot + prndist >= b)) && /* The sL hint is within the sLst hint */ - - (val < FixInt(100L) && - PruneMuchGt(val, v) - ? (CloseSegs(seg1, sg1, FALSE) || CloseSegs(seg2, sg2, FALSE)) - : (CloseSegs(seg1, sg1, FALSE) && CloseSegs(seg2, sg2, FALSE))) && /* val is less than 100, and the segments are close to each other.*/ - - (val < Fix16 || - /* needs to be greater than FixOne << 3 for - HelveticaNeue 95 Black G has val == 2.125 - Poetica/ItalicOne H has val == .66 */ - ( - (!topInBlue || top == t) && - (!botInBlue || bot == b))) /* either val is small ( < Fixed 16) or, for both bot and top, the value is the same as SL, and not in a blue zone. */ - - ) { - sLst = PruneOne(sLst, TRUE, sL, 5L); - flg = FALSE; - break; - } - - if (seg1 == NULL || seg2 == NULL) - goto NxtSL; /* If the sLst is aghost hint, skip */ - - if (ac_abs(b - bot) < FixOne) { - /* If the bottoms of the stems are within 1 unit */ - - if (PruneGt(val, v) && /* If v is more than 3* val) */ - !topInBlue && - seg2->sType == sBEND && - CloseSegs(seg1, sg1, FALSE) /* and the tops are close */ - ) { - sLst = PruneOne(sLst, TRUE, sL, 6L); - flg = FALSE; - break; - } - - if (!otherBot && PruneLt(val, v) && ac_abs(t - b) < ac_abs(top - bot)) { - if (CloseSegs(seg1, sg1, FALSE)) - otherBot = TRUE; - } - } - - if (ac_abs(t - top) < FixOne) { - /* If the tops of the stems are within 1 unit */ - if (PruneGt(val, v) && /* If v is more than 3* val) */ - !botInBlue && - seg2->sType == sBEND && - CloseSegs(seg1, sg1, FALSE)) /* and the tops are close */ - { - sLst = PruneOne(sLst, TRUE, sL, 7L); - flg = FALSE; - break; - } - - if (!otherTop && PruneLt(val, v) && ac_abs(t - b) < ac_abs(top - bot)) { - if (CloseSegs(seg2, sg2, FALSE)) - otherTop = TRUE; - } - } - - if (otherBot && otherTop) { - /* if v less than val by a factor of 3, and the sl stem width is less than the sLst stem width, - and the tops and bottoms are close */ - sLst = PruneOne(sLst, TRUE, sL, 8L); - flg = FALSE; - break; - } - NxtSL: - sL = sL->vNxt; - } - if (flg) { - sPrv = sLst; - sLst = sLst->vNxt; - } - } - DoPrune(); -} - -private -procedure FindBestVals(vL) register PClrVal vL; -{ - register Fixed bV, bS; - register Fixed t, b; - register PClrVal vL2, vPrv, bstV; - for (; vL != NULL; vL = vL->vNxt) { - if (vL->vBst != NULL) continue; /* already assigned */ - bV = vL->vVal; - bS = vL->vSpc; - bstV = vL; - b = vL->vLoc1; - t = vL->vLoc2; - vL2 = vL->vNxt; - vPrv = vL; - for (; vL2 != NULL; vL2 = vL2->vNxt) { - if (vL2->vBst != NULL || vL2->vLoc1 != b || vL2->vLoc2 != t) continue; - if ((vL2->vSpc == bS && vL2->vVal > bV) || (vL2->vSpc > bS)) { - bS = vL2->vSpc; - bV = vL2->vVal; - bstV = vL2; - } - vL2->vBst = vPrv; - vPrv = vL2; - } - while (vPrv != NULL) { - vL2 = vPrv->vBst; - vPrv->vBst = bstV; - vPrv = vL2; - } - } -} - -/* The following changes were made to fix a problem in Ryumin-Light and - possibly other fonts as well. The old version causes bogus coloring - and extra newcolors. */ -private -procedure ReplaceVals(oldB, oldT, newB, newT, newBst, vert) register Fixed oldB, oldT, newB, newT; -boolean vert; -register PClrVal newBst; -{ - register PClrVal vL; - for (vL = valList; vL != NULL; vL = vL->vNxt) { - if (vL->vLoc1 != oldB || vL->vLoc2 != oldT || vL->merge) continue; - if (showClrInfo) { - if (vert) - ReportMergeVVal(oldB, oldT, newB, newT, - vL->vVal, vL->vSpc, newBst->vVal, newBst->vSpc); - else - ReportMergeHVal(oldB, oldT, newB, newT, - vL->vVal, vL->vSpc, newBst->vVal, newBst->vSpc); - } - vL->vLoc1 = newB; - vL->vLoc2 = newT; - vL->vVal = newBst->vVal; - vL->vSpc = newBst->vSpc; - vL->vBst = newBst; - vL->merge = TRUE; - } -} - -public -procedure MergeVals(vert) boolean vert; -{ - register PClrVal vLst, vL; - PClrVal bstV, bV; - PClrSeg seg1, seg2, sg1, sg2; - Fixed bot, top, b, t; - Fixed val, v, spc, s, abstmp; - boolean ghst; - FindBestVals(valList); - /* We want to get rid of wider hstems in favor or overlapping smaller hstems only if we are NOT reporting all possible alignment zones. */ - if (addStemExtremesCB == NULL) - return; - - for (vL = valList; vL != NULL; vL = vL->vNxt) vL->merge = FALSE; - while (TRUE) { - /* pick best from valList with merge field still set to false */ - vLst = valList; - vL = NULL; - while (vLst != NULL) { - if (vLst->merge) { - } else if (vL == NULL || CompareValues(vLst->vBst, vL->vBst, SFACTOR, 0L)) - vL = vLst; - vLst = vLst->vNxt; - } - if (vL == NULL) break; - vL->merge = TRUE; - ghst = vL->vGhst; - b = vL->vLoc1; - t = vL->vLoc2; - sg1 = vL->vSeg1; /* left or bottom */ - sg2 = vL->vSeg2; /* right or top */ - vLst = valList; - bV = vL->vBst; - v = bV->vVal; - s = bV->vSpc; - while (vLst != NULL) { /* consider replacing vLst by vL */ - if (vLst->merge || ghst != vLst->vGhst) goto NxtVL; - bot = vLst->vLoc1; - top = vLst->vLoc2; - if (bot == b && top == t) - goto NxtVL; - bstV = vLst->vBst; - val = bstV->vVal; - spc = bstV->vSpc; - if ((top == t && CloseSegs(sg2, vLst->vSeg2, vert) && - (vert || (!InBlueBand(t, lenTopBands, topBands) && - !InBlueBand(bot, lenBotBands, botBands) && - !InBlueBand(b, lenBotBands, botBands)))) || - (bot == b && CloseSegs(sg1, vLst->vSeg1, vert) && - (vert || (!InBlueBand(b, lenBotBands, botBands) && - !InBlueBand(t, lenTopBands, topBands) && - !InBlueBand(top, lenTopBands, topBands)))) || - (ac_abs(top - t) <= maxMerge && ac_abs(bot - b) <= maxMerge && - (vert || (t == top || !InBlueBand(top, lenTopBands, topBands))) && - (vert || (b == bot || !InBlueBand(bot, lenBotBands, botBands))))) { - if (s == spc && val == v && !vert) { - if (InBlueBand(t, lenTopBands, topBands)) { - if ((YgoesUp && t > top) || (!YgoesUp && t < top)) - goto replace; - } else if (InBlueBand(b, lenBotBands, botBands)) { - if ((YgoesUp && b < bot) || (!YgoesUp && b > bot)) - goto replace; - } - } else - goto replace; - } else if (s == spc && sg1 != NULL && sg2 != NULL) { - seg1 = vLst->vSeg1; - seg2 = vLst->vSeg2; - if (seg1 != NULL && seg2 != NULL) { - if (ac_abs(bot - b) <= FixOne && ac_abs(top - t) <= maxBendMerge) { - if (seg2->sType == sBEND && - (vert || !InBlueBand(top, lenTopBands, topBands))) - goto replace; - } else if (ac_abs(top - t) <= FixOne && ac_abs(bot - b) <= maxBendMerge) { - if (v > val && seg1->sType == sBEND && - (vert || !InBlueBand(bot, lenBotBands, botBands))) - goto replace; - } - } - } - goto NxtVL; - replace: - ReplaceVals(bot, top, b, t, bV, vert); - NxtVL: - vLst = vLst->vNxt; - } - vL = vL->vNxt; - } -} diff --git a/c/autohint/autohintlib/source/ac/misc.c b/c/autohint/autohintlib/source/ac/misc.c deleted file mode 100644 index 0dc641d1b..000000000 --- a/c/autohint/autohintlib/source/ac/misc.c +++ /dev/null @@ -1,276 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* misc.c */ - -#include "ac.h" -#include "machinedep.h" - -public -integer CountSubPaths() { - register PPathElt e = pathStart; - integer cnt = 0; - while (e != NULL) { - if (e->type == MOVETO) cnt++; - e = e->next; - } - return cnt; -} -public -procedure RoundPathCoords() { - register PPathElt e; - e = pathStart; - while (e != NULL) { - if (e->type == CURVETO) { - e->x1 = FHalfRnd(e->x1); - e->y1 = FHalfRnd(e->y1); - e->x2 = FHalfRnd(e->x2); - e->y2 = FHalfRnd(e->y2); - e->x3 = FHalfRnd(e->x3); - e->y3 = FHalfRnd(e->y3); - } else if (e->type == LINETO || e->type == MOVETO) { - e->x = FHalfRnd(e->x); - e->y = FHalfRnd(e->y); - } - e = e->next; - } -} - -private -integer CheckForClr() { - PPathElt mt, cp; - mt = pathStart; - while (mt != NULL) { - if (mt->type != MOVETO) { - ExpectedMoveTo(mt); - return -1L; - } - cp = GetClosedBy(mt); - if (cp == NULL) { - ReportMissingClosePath(); - return -1L; - } - mt = cp->next; - } - return 0L; -} - -public -boolean PreCheckForColoring() { - PPathElt e, nxt; - integer cnt = 0; - integer chk; - while (pathEnd != NULL) { - if (pathEnd->type == MOVETO) - Delete(pathEnd); - else if (pathEnd->type != CLOSEPATH) { - ReportMissingClosePath(); - return FALSE; - } else - break; - } - e = pathStart; - while (e != NULL) { - if (e->type == CLOSEPATH) { - if (e == pathEnd) break; - nxt = e->next; - if (nxt->type == MOVETO) { - e = nxt; - continue; - } - if (nxt->type == CLOSEPATH) { /* remove double closepath */ - Delete(nxt); - continue; - } - } - e = e->next; - } - while (TRUE) { - chk = CheckForClr(); - if (chk == -1L) return FALSE; - if (chk == 0L) break; - if (++cnt > 10) { - LogMsg("Looping in PreCheckForHints!\n", WARNING, OK, TRUE); - break; - } - } - return TRUE; -} - -private -PPathElt GetSubpathNext(e) register PPathElt e; -{ - while (TRUE) { - e = e->next; - if (e == NULL) break; - if (e->type == CLOSEPATH) break; - if (!IsTiny(e)) break; - } - return e; -} - -private -PPathElt GetSubpathPrev(e) register PPathElt e; -{ - while (TRUE) { - e = e->prev; - if (e == NULL) break; - if (e->type == MOVETO) e = GetClosedBy(e); - if (!IsTiny(e)) break; - } - return e; -} - -private -boolean AddAutoFlexProp(e, yflag) PPathElt e; -boolean yflag; -{ - PPathElt e0 = e, e1 = e->next; - if (e0->type != CURVETO || e1->type != CURVETO) { - FlushLogFiles(); - sprintf(globmsg, "Illegal input in character file: %s.\n", fileName); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - /* Don't add flex to linear curves. */ - if (yflag && e0->y3 == e1->y1 && e1->y1 == e1->y2 && e1->y2 == e1->y3) - return FALSE; - else if (e0->x3 == e1->x1 && e1->x1 == e1->x2 && e1->x2 == e1->x3) - return FALSE; - e0->yFlex = yflag; - e1->yFlex = yflag; - e0->isFlex = TRUE; - e1->isFlex = TRUE; - return TRUE; -} - -#define LENGTHRATIOCUTOFF 0.11 /* 0.33^2 : two curves must be in approximate length ratio of 1:3 or better */ - -private -procedure TryYFlex(e, n, x0, y0, x1, y1) - PPathElt e, - n; -Fixed x0, y0, x1, y1; -{ - Fixed x2, y2, x3, y3, x4, y4, abstmp; - PPathElt p, q; - boolean top, dwn; - longreal d0sq, d1sq, quot, dx, dy; - - GetEndPoint(n, &x2, &y2); - dy = ac_abs(y0 - y2); - if (dy > flexCand) return; /* too big diff in bases. If dy is within flexCand, flex will fail , but we will report it as a candidate. */ - dx = ac_abs(x0 - x2); - if (dx < MAXFLEX) return; /* Let's not add flex to features less than MAXFLEX wide. */ - if (dx < (3 * ac_abs(y0 - y2))) return; /* We want the width to be at least three times the height. */ - if (ProdLt0(y1 - y0, y1 - y2)) return; /* y0 and y2 not on same side of y1 */ - - /* check the ratios of the "lengths" of 'e' and 'n' */ - dx = (x1 - x0); - dy = (y1 - y0); - d0sq = dx * dx + dy * dy; - dx = (x2 - x1); - dy = (y2 - y1); - d1sq = dx * dx + dy * dy; - quot = (d0sq > d1sq) ? (d1sq / d0sq) : (d0sq / d1sq); - if (quot < LENGTHRATIOCUTOFF) return; - - if (flexStrict) { - q = GetSubpathNext(n); - GetEndPoint(q, &x3, &y3); - if (ProdLt0(y3 - y2, y1 - y2)) return; /* y1 and y3 not on same side of y2 */ - p = GetSubpathPrev(e); - GetEndPoint(p->prev, &x4, &y4); - if (ProdLt0(y4 - y0, y1 - y0)) return; /* y1 and y4 not on same side of y0 */ - top = (x0 > x1) ? TRUE : FALSE; - if (YgoesUp) - dwn = (y1 < y0) ? TRUE : FALSE; - else - dwn = (y1 > y0) ? TRUE : FALSE; - if ((top && !dwn) || (!top && dwn)) return; /* concave */ - } - if (n != e->next) { /* something in the way */ - n = e->next; - ReportTryFlexError(n->type == CLOSEPATH, x1, y1); - return; - } - if (y0 != y2) { - ReportTryFlexNearMiss(x0, y0, x2, y2); - return; - } - if (AddAutoFlexProp(e, TRUE)) - ReportAddFlex(); -} - -private -procedure TryXFlex(e, n, x0, y0, x1, y1) - PPathElt e, - n; -Fixed x0, y0, x1, y1; -{ - Fixed x2, y2, x3, y3, x4, y4, abstmp; - PPathElt p, q; - boolean lft; - longreal d0sq, d1sq, quot, dx, dy; - - GetEndPoint(n, &x2, &y2); - dx = ac_abs(y0 - y2); - if (dx > flexCand) return; /* too big diff in bases */ - - dy = ac_abs(x0 - x2); - if (dy < MAXFLEX) return; /* Let's not add flex to features less than MAXFLEX wide. */ - if (dy < (3 * ac_abs(x0 - x2))) return; /* We want the width to be at least three times the height. */ - - if (ProdLt0(x1 - x0, x1 - x2)) return; /* x0 and x2 not on same side of x1 */ - - /* check the ratios of the "lengths" of 'e' and 'n' */ - dx = (x1 - x0); - dy = (y1 - y0); - d0sq = dx * dx + dy * dy; - dx = (x2 - x1); - dy = (y2 - y1); - d1sq = dx * dx + dy * dy; - quot = (d0sq > d1sq) ? (d1sq / d0sq) : (d0sq / d1sq); - if (quot < LENGTHRATIOCUTOFF) return; - - if (flexStrict) { - q = GetSubpathNext(n); - GetEndPoint(q, &x3, &y3); - if (ProdLt0(x3 - x2, x1 - x2)) return; /* x1 and x3 not on same side of x2 */ - p = GetSubpathPrev(e); - GetEndPoint(p->prev, &x4, &y4); - if (ProdLt0(x4 - x0, x1 - x0)) return; /* x1 and x4 not on same side of x0 */ - if (YgoesUp) - lft = (y0 > y2) ? TRUE : FALSE; - else - lft = (y0 < y2) ? TRUE : FALSE; - if ((lft && x0 > x1) || (!lft && x0 < x1)) return; /* concave */ - } - if (n != e->next) { /* something in the way */ - n = e->next; - ReportTryFlexError(n->type == CLOSEPATH, x1, y1); - return; - } - if (x0 != x2) { - ReportTryFlexNearMiss(x0, y0, x2, y2); - return; - } - if (AddAutoFlexProp(e, FALSE)) - ReportAddFlex(); -} - -public -procedure AutoAddFlex() { - PPathElt e, n; - Fixed x0, y0, x1, y1, abstmp; - e = pathStart; - while (e != NULL) { - if (e->type != CURVETO || e->isFlex) goto Nxt; - n = GetSubpathNext(e); - if (n->type != CURVETO) goto Nxt; - GetEndPoints(e, &x0, &y0, &x1, &y1); - if (ac_abs(y0 - y1) <= MAXFLEX) TryYFlex(e, n, x0, y0, x1, y1); - if (ac_abs(x0 - x1) <= MAXFLEX) TryXFlex(e, n, x0, y0, x1, y1); - Nxt: - e = e->next; - } -} diff --git a/c/autohint/autohintlib/source/ac/path.c b/c/autohint/autohintlib/source/ac/path.c deleted file mode 100644 index 8d172b906..000000000 --- a/c/autohint/autohintlib/source/ac/path.c +++ /dev/null @@ -1,419 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* path.c */ - -#include "ac.h" - -#if 0 -#define GetSubpathNext(e) ((e)->type == CLOSEPATH) ? GetDest(e) : (e)->next -#define GetSubpathPrev(e) ((e)->type == MOVETO) ? GetClosedBy(e) : (e)->prev - -private -procedure NumberSubpath(e) register PPathElt e; -{ - /* number the elements of the subpath starting at e */ - PPathElt first; - integer cnt; - first = e; - cnt = 0; - while (TRUE) { - e->count = cnt; - e = GetSubpathNext(e); - if (e == first) break; - cnt++; - } -} - -private -integer TstClrLsts(l1, l2, flg) - PSegLnkLst l1, - l2; -boolean flg; -{ - integer result, i; - result = -1; - if (l1 != NULL) - while (l2 != NULL) { - i = TestColorLst(l1, l2->lnk->seg->sLnk, flg, FALSE); - if (i == 0) return 0L; - if (i == 1) result = 1; - l2 = l2->next; - } - return result; -} - -private -integer ClrLstLen(lst) PSegLnkLst lst; -{ - integer cnt = 0; - while (lst != NULL) { - cnt++; - lst = lst->next; - } - return cnt; -} - -private -boolean SameClrLsts(l1, l2, flg) - PSegLnkLst l1, - l2; -boolean flg; -{ - if (ClrLstLen(l1) != ClrLstLen(l2)) return FALSE; - return (TstClrLsts(l1, l2, flg) == -1) ? TRUE : FALSE; -} - -private -procedure FindConflicts(e) PPathElt e; -{ - /* find conflicts in subpath for e */ - PSegLnkLst hLst, vLst, phLst, pvLst; - boolean checked; - PPathElt start, p; - integer h, v; - if (e->type != MOVETO) e = GetDest(e); - while (TRUE) { - hLst = e->Hs; - vLst = e->Vs; - if (hLst == NULL && vLst == NULL) goto Nxt; - /* search for previous subpath element with conflicting colors */ - start = e; - p = GetSubpathPrev(e); - checked = TRUE; - while (p != start) { - if (checked) { - if (p->type == CLOSEPATH) checked = FALSE; - } - phLst = p->Hs; - pvLst = p->Vs; - if (phLst == NULL && pvLst == NULL) goto NxtP; - if (hLst != NULL && phLst != NULL) - h = TstClrLsts(hLst, phLst, YgoesUp); - else if (hLst == NULL && phLst == NULL) - h = -1; - else - h = 1; - if (vLst != NULL && pvLst != NULL) - v = TstClrLsts(vLst, pvLst, TRUE); - else if (vLst == NULL && pvLst == NULL) - v = -1; - else - v = 1; - if (checked && h == -1L && v == -1L && - ClrLstLen(hLst) == ClrLstLen(phLst) && - ClrLstLen(vLst) == ClrLstLen(pvLst)) { /* same coloring */ - p = p->conflict; - if (p != NULL) e->conflict = p; - break; - } - if (h == 0 || v == 0) { - e->conflict = p; - break; - } - NxtP: - p = GetSubpathPrev(p); - } - Nxt: - e = e->next; - if (e == NULL) break; - if (e->type == MOVETO) break; - } -} - -private -integer CountConflicts(e) PPathElt e; -{ - /* e is a proposed closepath. return number of color conflicts */ - integer conflicts, nc, c, cnt; - PPathElt first, conflict; - first = e; - cnt = conflicts = nc = 0; - NumberSubpath(e); - while (TRUE) { - conflict = e->conflict; - if (conflict == NULL) goto Nxt; - c = conflict->count; - if (c >= nc && c < cnt) { - conflicts++; - nc = cnt; - } - Nxt: - e = GetSubpathNext(e); - cnt++; - if (e == first) break; - } - return conflicts; -} - -private -boolean TestColorSection(first, after) - /* returns FALSE if there is a conflict, TRUE otherwise */ - PPathElt first, - after; -{ - PPathElt e; - PSegLnkLst hLst, vLst, hPrv, vPrv; - e = first; - hPrv = vPrv = NULL; - while (e != after) { - hLst = e->Hs; - vLst = e->Vs; - if (hLst != NULL && !SameClrLsts(hLst, hPrv, YgoesUp)) { - if (TestColorLst(hLst, Hprimary, YgoesUp, TRUE) == 0) return FALSE; - hPrv = hLst; - } - if (vLst != NULL && !SameClrLsts(vLst, vPrv, TRUE)) { - if (TestColorLst(vLst, Vprimary, TRUE, TRUE) == 0) return FALSE; - vPrv = vLst; - } - e = GetSubpathNext(e); - } - return TRUE; -} - -private -boolean StartsOkWithPrimaryClrs(cp) - PPathElt cp; -{ - /* return TRUE if proposed cp yields subpath whose - first coloring section is consistent with the primary coloring */ - PPathElt e, conflict, first; - integer c, cnt; - first = e = cp; - NumberSubpath(e); - cnt = 0; - while (TRUE) { - conflict = e->conflict; - if (conflict != NULL) { - c = conflict->count; - if (c < cnt) break; - } - e = GetSubpathNext(e); - if (e == cp) break; - cnt++; - } - /* e is start of new coloring in subpath */ - return TestColorSection(first, e); -} - -private -boolean OkCandidate(cp, conflict, isShort) - PPathElt cp, - conflict; -boolean isShort; -{ - PPathElt cpConflict, nxt, nxtConflict; - if (cp == conflict) return FALSE; - cpConflict = cp->conflict; - if (cpConflict == conflict) return FALSE; - if (!isShort) return TRUE; - /* don't put short closepath between two conflicting elements */ - nxt = cp->next; - if (nxt == NULL) return TRUE; - nxtConflict = nxt->conflict; - if (nxtConflict == cp) return FALSE; - return TRUE; -} - -private -boolean OkJunction(p, e) PPathElt p, e; -{ - Fixed x, y, x0, y0, x1, y1, sm; - if (p->isFlex && e->isFlex) return FALSE; - if (e->type == CURVETO) { - x0 = e->x1; - y0 = e->y1; - } else - GetEndPoint(e, &x0, &y0); - if (p->type == CURVETO) { - x1 = p->x2; - y1 = p->y2; - } else - GetEndPoint(p->prev, &x1, &y1); - GetEndPoint(p, &x, &y); - return CheckSmoothness(x0, y0, x, y, x1, y1, &sm); -} - -private -PPathElt FindMinConflict(e) PPathElt e; -{ - PPathElt conflict, cp, cpnxt, bestCP, first, prevConflict; - integer best, cnt; - boolean isShort; - first = e; - if (e->type != MOVETO) e = GetDest(e); - best = 10000; - prevConflict = bestCP = NULL; - while (TRUE) { - conflict = e->conflict; - if (conflict == NULL || conflict == prevConflict) goto Nxt; - cp = e; - isShort = FALSE; - while (TRUE) { /* search for a possible place for a closepath */ - if ((cp->type == LINETO || cp->type == CLOSEPATH) && !IsShort(cp)) break; - if (!OkCandidate(cp, conflict, isShort)) { - cp = NULL; - break; - } - cp = GetSubpathPrev(cp); - } - if (cp == NULL) { /* consider short cp */ - cp = e; - isShort = TRUE; - while (TRUE) { - if (cp->type == CLOSEPATH || cp->type == LINETO) break; - if (cp->type == CURVETO && cp != e) { - cpnxt = GetSubpathNext(cp); - if (cpnxt->type == CURVETO && OkJunction(cp, cpnxt)) break; - } - if (!OkCandidate(cp, conflict, isShort)) { - cp = NULL; - break; - } - cp = GetSubpathPrev(cp); - } - } - if (cp == NULL) goto Nxt; - if (DEBUG) ReportConflictCheck(e, conflict, cp); - cnt = CountConflicts(cp); - if (isShort) { - cnt++; /* bias against short closepaths */ - if (DEBUG) fprintf(OUTPUTBUFF, "short, "); - } - if (!StartsOkWithPrimaryClrs(cp)) { - cnt++; /* bias against conflict with primary colors */ - if (DEBUG) fprintf(OUTPUTBUFF, "conflicts with primary, "); - } - if (DEBUG) ReportConflictCnt(cp, cnt); - if (cnt < best || (cnt == best && cp->type == CLOSEPATH)) { - /* break ties in favor of leaving closepath where it is */ - bestCP = cp; - best = cnt; - } - Nxt: - e = e->next; - if (e == NULL) break; - if (e->type == MOVETO) break; - if (conflict != NULL) prevConflict = conflict; - } - if (DEBUG) { - fprintf(OUTPUTBUFF, "final choice: cnt %d ", best); - ReportBestCP(first, bestCP); - } - return bestCP; -} - -#define SubpathConflictsWithPrimary(e) \ - (!TestColorSection(e, GetClosedBy(e))) - -private -PPathElt NewCP(cp) PPathElt cp; -{ - PPathElt first; - first = cp; - while (TRUE) { - if (cp->newCP) return cp; - cp = GetSubpathPrev(cp); - if (cp == first) return cp; - } -} - -private -boolean ReorderSubpaths() { - /* if first subpath conflicts with primary, - and there is a later subpath that does not, - do tailsubpaths until later one becomes first */ - PPathElt e, first; - first = e = pathStart; - if (!SubpathConflictsWithPrimary(e)) return FALSE; - while (TRUE) { - e = GetClosedBy(e); - if (e == NULL) break; - e = e->next; /* moveto */ - if (e == NULL) break; - if (!SubpathConflictsWithPrimary(e)) { - first = e; - goto Rt; - } - } - if (e == NULL) { - /* if first subpath start with coloring that conflicts with primary, - and there is a later subpath that does not, - do tailsubpaths until later one becomes first */ - e = GetClosedBy(first); - if (StartsOkWithPrimaryClrs(NewCP(e))) return FALSE; - while (TRUE) { - e = e->next; /* moveto */ - if (e == NULL) return FALSE; - e = GetClosedBy(e); - if (e == NULL) return FALSE; - if (StartsOkWithPrimaryClrs(NewCP(e))) break; - } - } - first = GetDest(e); -Rt: - if (DEBUG) ReportMoveSubpath(first, "front"); - while (TRUE) { - e = pathStart; - if (e == first) break; - if (DEBUG) ReportMoveSubpath(e, "end"); - MoveSubpathToEnd(e); - } - return TRUE; -} - -public -boolean RotateSubpaths(flg) boolean flg; -{ - PPathElt e, cp, nxt; - boolean chng = FALSE, chngSub; - DEBUG = flg; - e = pathStart; - if (DEBUG) PrintMessage("RotateSubpaths"); - while (e != NULL) { - e->conflict = NULL; - e->newCP = FALSE; - e = e->next; - } - e = pathStart; - while (e != NULL) { - FindConflicts(e); - cp = FindMinConflict(e); - e = GetClosedBy(e); - nxt = e->next; - if (cp == NULL) goto Nxt; - if (cp->type == CLOSEPATH) goto Nxt; - cp->newCP = TRUE; - /* dont change yet so preserve info for ReorderSubpaths */ - chng = TRUE; - Nxt: - e = nxt; - } - chngSub = chng; - if (DEBUG) PrintMessage("ReorderSubpaths"); - if (ReorderSubpaths()) chng = TRUE; - if (!chngSub) goto Done; - e = pathStart; /* must reload since may have reordered */ - while (e != NULL) { - nxt = GetClosedBy(e); /* closepath for this subpath */ - if (nxt != NULL) nxt = nxt->next; /* start of next subpath */ - while (e != NULL) { - if (e->type == CLOSEPATH) break; - if (e->newCP) { - ReportRotateSubpath(e); - /* fix this someday - if (e->type == CURVETO) PointClosePath(cpEnd); - else ChangeClosePath(); - */ - break; - } - e = e->next; - } - e = nxt; - } -Done: - if (DEBUG) PrintMessage("done with ReorderSubpaths"); - return chng; -} -#endif diff --git a/c/autohint/autohintlib/source/ac/pick.c b/c/autohint/autohintlib/source/ac/pick.c deleted file mode 100644 index 3f791d9a0..000000000 --- a/c/autohint/autohintlib/source/ac/pick.c +++ /dev/null @@ -1,420 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* pick.c */ - -#include "ac.h" -#include "machinedep.h" - -private -PClrVal Vrejects, Hrejects; - -public -procedure InitPick(reason) integer reason; -{ - switch (reason) { - case STARTUP: - case RESTART: - Vrejects = Hrejects = NULL; - } -} - -#define LtPruneB(val) ((val) < FixOne && ((val) << 10) < pruneB) - -private -boolean ConsiderPicking(bestSpc, bestVal, colorList, prevBestVal) - Fixed bestSpc, - bestVal, prevBestVal; -PClrVal colorList; -{ - if (bestSpc > 0L) return TRUE; - if (colorList == NULL) return bestVal >= pruneD; - if (bestVal > pruneA) return TRUE; - if (LtPruneB(bestVal)) return FALSE; - return (bestVal < FixedPosInf / pruneC) ? (prevBestVal <= bestVal * pruneC) : (prevBestVal / pruneC <= bestVal); -} - -public -procedure PickVVals(valList) PClrVal valList; -{ - PClrVal colorList, rejectList, vlist, prev, best, bestPrev, nxt; - Fixed bestVal, prevBestVal; - Fixed lft, rght, vlft, vrght; - colorList = rejectList = NULL; - prevBestVal = 0; - while (TRUE) { - vlist = valList; - prev = bestPrev = best = NULL; - while (vlist != NULL) { - if ((best == NULL || CompareValues(vlist, best, spcBonus, 0L)) && - ConsiderPicking(vlist->vSpc, vlist->vVal, colorList, prevBestVal)) { - best = vlist; - bestPrev = prev; - bestVal = vlist->vVal; - } - prev = vlist; - vlist = vlist->vNxt; - } - if (best == NULL) break; /* no more */ - if (bestPrev == NULL) - valList = best->vNxt; - else - bestPrev->vNxt = best->vNxt; - /* have now removed best from valList */ - best->vNxt = colorList; /* add best to front of list */ - colorList = best; - prevBestVal = bestVal; - lft = best->vLoc1 - bandMargin; - rght = best->vLoc2 + bandMargin; - /* remove segments from valList that overlap lft..rght */ - vlist = valList; - prev = NULL; - while (vlist != NULL) { - vlft = vlist->vLoc1; - vrght = vlist->vLoc2; - if ((vlft <= rght) && (vrght >= lft)) { - nxt = vlist->vNxt; - vlist->vNxt = rejectList; - rejectList = vlist; - vlist = nxt; - if (prev == NULL) - valList = vlist; - else - prev->vNxt = vlist; - } else { - prev = vlist; - vlist = vlist->vNxt; - } - } - } - vlist = valList; /* move rest of valList to rejectList */ - while (vlist != NULL) { - nxt = vlist->vNxt; - vlist->vNxt = rejectList; - rejectList = vlist; - vlist = nxt; - } - if (colorList == NULL) ClrVBnds(); - Vcoloring = colorList; - Vrejects = rejectList; -} - -private -boolean InSerifBand(y0, y1, n, p) register Fixed y0, y1, *p; -integer n; -{ - register integer i; - if (n <= 0) return FALSE; - y0 = itfmy(y0); - y1 = itfmy(y1); - if (y0 > y1) { - Fixed tmp = y1; - y1 = y0; - y0 = tmp; - } - for (i = 0; i < n; i += 2) - if (p[i] <= y0 && p[i + 1] >= y1) return TRUE; - return FALSE; -} - -private -boolean ConsiderValForSeg(val, seg, loc, nb, b, ns, s, primary) - PClrVal val; -PClrSeg seg; -Fixed loc, *b, *s; -integer nb, ns; -boolean primary; -{ - if (primary && val->vSpc > 0.0) return TRUE; - if (InBlueBand(loc, nb, b)) return TRUE; - if (val->vSpc <= 0.0 && - InSerifBand(seg->sMax, seg->sMin, ns, s)) return FALSE; - if (LtPruneB(val->vVal)) return FALSE; - return TRUE; -} - -private -PClrVal FndBstVal( - seg, seg1Flg, cList, rList, nb, b, ns, s, locFlg, hFlg) - PClrSeg seg; -PClrVal cList, rList; -boolean seg1Flg; -integer nb, ns; -Fixed *b, *s; -boolean locFlg, hFlg; -{ - Fixed loc, vloc; - PClrVal best, vList, initLst; - PClrSeg vseg; - best = NULL; - loc = seg->sLoc; - vList = cList; - while (TRUE) { - initLst = vList; - while (vList != NULL) { - if (seg1Flg) { - vseg = vList->vSeg1; - vloc = vList->vLoc1; - } else { - vseg = vList->vSeg2; - vloc = vList->vLoc2; - } - if (abs(loc - vloc) <= maxMerge && - (locFlg ? !vList->vGhst : (vseg == seg || CloseSegs(seg, vseg, !hFlg))) && - (best == NULL || - (vList->vVal == best->vVal && vList->vSpc == best->vSpc && - vList->initVal > best->initVal) || - CompareValues(vList, best, spcBonus, 3L)) && - /* last arg is "ghostshift" that penalizes ghost values */ - /* ghost values are set to 20 */ - /* so ghostshift of 3 means prefer nonghost if its value is > (20 >> 3) */ - ConsiderValForSeg(vList, seg, loc, nb, b, ns, s, TRUE)) - best = vList; - vList = vList->vNxt; - } - if (initLst == rList) break; - vList = rList; - } - if (showClrInfo) - ReportFndBstVal(seg, best, hFlg); - return best; -} - -#define FixSixteenth (0x10L) -private -PClrVal FindBestValForSeg( - seg, seg1Flg, cList, rList, nb, b, ns, s, hFlg) - PClrSeg seg; -PClrVal cList, rList; -boolean seg1Flg, hFlg; -integer nb, ns; -Fixed *b, *s; -{ - PClrVal best, nonghst, ghst = NULL; - best = FndBstVal(seg, seg1Flg, cList, rList, nb, b, ns, s, FALSE, hFlg); - if (best != NULL && best->vGhst) { - nonghst = FndBstVal(seg, seg1Flg, cList, rList, nb, b, ns, s, TRUE, hFlg); - /* If nonghst hints are "better" use it instead of ghost band. */ - if (nonghst != NULL && nonghst->vVal >= FixInt(2)) { - /* threshold must be greater than 1.004 for ITC Garamond Ultra "q" */ - ghst = best; - best = nonghst; - } - } - if (best != NULL) { - if (best->vVal < FixSixteenth && - (ghst == NULL || ghst->vVal < FixSixteenth)) best = NULL; - /* threshold must be > .035 for Monotype/Plantin/Bold Thorn - and < .08 for Bookman2/Italic asterisk */ - else - best->pruned = FALSE; - } - return best; -} - -private -boolean MembValList(val, vList) register PClrVal val, vList; -{ - while (vList != NULL) { - if (val == vList) return TRUE; - vList = vList->vNxt; - } - return FALSE; -} - -private -PClrVal PrevVal(val, vList) register PClrVal val, vList; -{ - PClrVal prev; - if (val == vList) return NULL; - prev = vList; - while (TRUE) { - vList = vList->vNxt; - if (vList == NULL) { - FlushLogFiles(); - sprintf(globmsg, "Malformed value list in %s.\n", fileName); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - - if (vList == val) return prev; - prev = vList; - } -} - -private -procedure FindRealVal(vlist, top, bot, pseg1, pseg2) - PClrVal vlist; -PClrSeg *pseg1, *pseg2; -Fixed top, bot; -{ - while (vlist != NULL) { - if (vlist->vLoc2 == top && vlist->vLoc1 == bot && !vlist->vGhst) { - *pseg1 = vlist->vSeg1; - *pseg2 = vlist->vSeg2; - return; - } - vlist = vlist->vNxt; - } -} - -public -procedure PickHVals(valList) PClrVal valList; -{ - PClrVal vlist, colorList, rejectList, bestPrev, prev, best, nxt; - Fixed bestVal, prevBestVal; - Fixed bot, top, vtop, vbot; - PClrVal newBst; - PClrSeg seg1, seg2; - colorList = rejectList = NULL; - prevBestVal = 0; - while (TRUE) { - vlist = valList; - prev = bestPrev = best = NULL; - while (vlist != NULL) { - if ((best == NULL || CompareValues(vlist, best, spcBonus, 0L)) && - ConsiderPicking(vlist->vSpc, vlist->vVal, colorList, prevBestVal)) { - best = vlist; - bestPrev = prev; - bestVal = vlist->vVal; - } - prev = vlist; - vlist = vlist->vNxt; - } - if (best != NULL) { - seg1 = best->vSeg1; - seg2 = best->vSeg2; - if (best->vGhst) { /* find real segments at same loc as best */ - FindRealVal(valList, best->vLoc2, best->vLoc1, &seg1, &seg2); - } - if (seg1->sType == sGHOST) { - /* newBst = FindBestValForSeg(seg2, FALSE, valList, - (PClrVal)NULL, 0L, (Fixed *)NIL, 0L, (Fixed *)NIL, TRUE);*/ - newBst = seg2->sLnk; - if (newBst != NULL && newBst != best && MembValList(newBst, valList)) { - best = newBst; - bestPrev = PrevVal(best, valList); - } - } else if (seg2->sType == sGHOST) { - /* newBst = FindBestValForSeg(seg1, TRUE, valList, - (PClrVal)NULL, 0L, (Fixed *)NIL, 0L, (Fixed *)NIL, TRUE); */ - newBst = seg2->sLnk; - if (newBst != NULL && newBst != best && MembValList(newBst, valList)) { - best = newBst; - bestPrev = PrevVal(best, valList); - } - } - } - if (best == NULL) goto noMore; - prevBestVal = bestVal; - if (bestPrev == NULL) - valList = best->vNxt; - else - bestPrev->vNxt = best->vNxt; - /* have now removed best from valList */ - best->vNxt = colorList; - colorList = best; /* add best to front of list */ - bot = best->vLoc1; - top = best->vLoc2; - /* The next if statement was added so that ghost bands are given - 0 width for doing the conflict tests for bands too close together. - This was a problem in Minion/DisplayItalic onequarter and onehalf. */ - if (best->vGhst) { /* collapse width */ - if (best->vSeg1->sType == sGHOST) - bot = top; - else - top = bot; - } - if (YgoesUp) { - bot -= bandMargin; - top += bandMargin; - } else { - bot += bandMargin; - top -= bandMargin; - } - /* remove segments from valList that overlap bot..top */ - vlist = valList; - prev = NULL; - while (vlist != NULL) { - vbot = vlist->vLoc1; - vtop = vlist->vLoc2; - /* The next if statement was added so that ghost bands are given - 0 width for doing the conflict tests for bands too close together. */ - if (vlist->vGhst) { /* collapse width */ - if (vlist->vSeg1->sType == sGHOST) - vbot = vtop; - else - vtop = vbot; - } - if ((YgoesUp && (vbot <= top) && (vtop >= bot)) || - ((!YgoesUp && (vbot >= top) && (vtop <= bot)))) { - nxt = vlist->vNxt; - vlist->vNxt = rejectList; - rejectList = vlist; - vlist = nxt; - if (prev == NULL) - valList = vlist; - else - prev->vNxt = vlist; - } else { - prev = vlist; - vlist = vlist->vNxt; - } - } - } -noMore: - vlist = valList; /* move rest of valList to rejectList */ - while (vlist != NULL) { - nxt = vlist->vNxt; - vlist->vNxt = rejectList; - rejectList = vlist; - vlist = nxt; - } - if (colorList == NULL) ClrHBnds(); - Hcoloring = colorList; - Hrejects = rejectList; -} - -private -procedure FindBestValForSegs(sList, seg1Flg, cList, rList, nb, b, ns, s, hFlg) - PClrSeg sList; -PClrVal cList, rList; -boolean seg1Flg, hFlg; -integer nb, ns; -Fixed *b, *s; -{ - PClrVal best; - while (sList != NULL) { - best = FindBestValForSeg(sList, seg1Flg, cList, rList, nb, b, ns, s, hFlg); - sList->sLnk = best; - sList = sList->sNxt; - } -} - -private -procedure SetPruned() { - register PClrVal vL = valList; - while (vL != NULL) { - vL->pruned = TRUE; - vL = vL->vNxt; - } -} - -public -procedure FindBestHVals() { - SetPruned(); - FindBestValForSegs(topList, FALSE, valList, NULL, - lenTopBands, topBands, 0L, (Fixed *)NULL, TRUE); - FindBestValForSegs(botList, TRUE, valList, NULL, - lenBotBands, botBands, 0L, (Fixed *)NULL, TRUE); - DoPrune(); -} - -public -procedure FindBestVVals() { - SetPruned(); - FindBestValForSegs(leftList, TRUE, valList, NULL, - 0L, (Fixed *)NULL, numSerifs, serifs, FALSE); - FindBestValForSegs(rightList, FALSE, valList, NULL, - 0L, (Fixed *)NULL, numSerifs, serifs, FALSE); - DoPrune(); -} diff --git a/c/autohint/autohintlib/source/ac/read.c b/c/autohint/autohintlib/source/ac/read.c deleted file mode 100644 index 350fc64db..000000000 --- a/c/autohint/autohintlib/source/ac/read.c +++ /dev/null @@ -1,866 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* read.c */ - -#include -#include "ac.h" -#include "bftoac.h" -#include "charpath.h" -#include "cryptdefs.h" -#include "fipublic.h" -#include "machinedep.h" -#include "opcodes.h" -#include "optable.h" -#define PRINT_READ (0) - -#ifdef IS_LIB -extern const char *bezstring; -#endif - -char bezGlyphName[64]; - -private -Fixed currentx, currenty; /* used to calculate absolute coordinates */ -private -Fixed tempx, tempy; /* used to calculate relative coordinates */ -#define STKMAX (20) -private -Fixed stk[STKMAX]; -private -integer stkindex; -private -boolean flex, startchar; -private -boolean forMultiMaster, includeHints; -/* Reading file for comparison of multiple master data and hint information. - Reads into PCharPathElt structure instead of PPathElt. */ - -private -real origEmSquare = 0.0; - -public -Fixed ScaleAbs(unscaled) Fixed unscaled; -{ - Fixed temp1; - if (!scalinghints) - return unscaled; - if (origEmSquare == 0.0) { - char *fistr; - SetFntInfoFileName(SCALEDHINTSINFO); - if ((fistr = GetFntInfo("OrigEmSqUnits", ACOPTIONAL)) == NULL) - origEmSquare = 1000.0; - else { - sscanf(fistr, "%g", &origEmSquare); -#if DOMEMCHECK - memck_free(fistr); -#else - ACFREEMEM(fistr); -#endif - } - ResetFntInfoFileName(); - } - temp1 = (Fixed)(1000.0 / origEmSquare * ((real)unscaled)); - return temp1; -} - -public -Fixed UnScaleAbs(scaled) Fixed scaled; -{ - Fixed temp1; - if (!scalinghints) - return scaled; - if (origEmSquare == 0.0) { - char *fistr; - SetFntInfoFileName(SCALEDHINTSINFO); - if ((fistr = GetFntInfo("OrigEmSqUnits", ACOPTIONAL)) == NULL) - origEmSquare = 1000.0; - else { - sscanf(fistr, "%g", &origEmSquare); -#if DOMEMCHECK - memck_free(fistr); -#else - ACFREEMEM(fistr); -#endif - } - ResetFntInfoFileName(); - } - temp1 = (Fixed)(origEmSquare / 1000.0 * ((real)scaled)); - temp1 = FRnd(temp1); - return (temp1); -} - -private -Fixed Pop() { - if (stkindex <= 0) { - FlushLogFiles(); - sprintf(globmsg, "Stack underflow while reading %s file.\n", fileName); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - stkindex--; - return stk[stkindex]; -} - -private -procedure Push(r) Fixed r; -{ - if (stkindex >= STKMAX) { - FlushLogFiles(); - sprintf(globmsg, "Stack underflow while reading %s file.\n", fileName); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - stk[stkindex] = r; - stkindex++; -} - -private -procedure Pop2() { - (void)Pop(); - (void)Pop(); -} - -private -procedure PopPCd(pcd) Cd *pcd; -{ - pcd->y = Pop(); - pcd->x = Pop(); -} - -#define DoDelta(dx, dy) \ - currentx += (dx); \ - currenty += (dy) - -private -PPathElt AppendElement(etype) integer etype; -{ - PPathElt e; - e = (PPathElt)Alloc(sizeof(PathElt)); - e->type = (short)etype; - if (pathEnd != NULL) { - pathEnd->next = e; - e->prev = pathEnd; - } else - pathStart = e; - pathEnd = e; - return e; -} - -private -procedure psDIV() { - Fixed x, y; - y = Pop(); - x = Pop(); - if (y == FixInt(100)) - x /= 100L; /* this will usually be the case */ - else - x = (x * FixOne) / y; - Push(x); -} - -private -procedure RDcurveto(c1, c2, c3) Cd c1, c2, c3; -{ - if (!forMultiMaster) { - PPathElt new; - new = AppendElement(CURVETO); - new->x1 = tfmx(ScaleAbs(c1.x)); - new->y1 = tfmy(ScaleAbs(c1.y)); - new->x2 = tfmx(ScaleAbs(c2.x)); - new->y2 = tfmy(ScaleAbs(c2.y)); - new->x3 = tfmx(ScaleAbs(c3.x)); - new->y3 = tfmy(ScaleAbs(c3.y)); - } else { - PCharPathElt new; - new = AppendCharPathElement(RCT); - new->x = tempx; - new->y = tempy; - new->x1 = c1.x; - new->y1 = c1.y; - new->x2 = c2.x; - new->y2 = c2.y; - new->x3 = c3.x; - new->y3 = c3.y; - new->rx1 = c1.x - tempx; - new->ry1 = c1.y - tempy; - new->rx2 = c2.x - c1.x; - new->ry2 = c2.y - c1.y; - new->rx3 = c3.x - c2.x; - new->ry3 = c3.y - c2.y; - if (flex) new->isFlex = TRUE; - } -} - -private -procedure RDmtlt(etype) integer etype; -{ - if (!forMultiMaster) { - PPathElt new; - new = AppendElement(etype); - new->x = tfmx(ScaleAbs(currentx)); - new->y = tfmy(ScaleAbs(currenty)); - return; - } else { - PCharPathElt new; - new = AppendCharPathElement(etype == LINETO ? RDT : RMT); - new->x = currentx; - new->y = currenty; - new->rx = tempx; - new->ry = tempy; - } -} - -#define RDlineto() RDmtlt(LINETO) -#define RDmoveto() RDmtlt(MOVETO) - -private -procedure psRDT() { - Cd c; - PopPCd(&c); - tempx = c.x; - tempy = c.y; - DoDelta(c.x, c.y); - RDlineto(); -} - -private -procedure psHDT() { - Fixed dx; - tempy = 0; - dx = tempx = Pop(); - currentx += dx; - RDlineto(); -} - -private -procedure psVDT() { - Fixed dy; - tempx = 0; - dy = tempy = Pop(); - currenty += dy; - RDlineto(); -} - -private -procedure psRMT() { - Cd c; - PopPCd(&c); - if (flex) return; - tempx = c.x; - tempy = c.y; - DoDelta(c.x, c.y); - RDmoveto(); -} - -private -procedure psHMT() { - Fixed dx; - tempy = 0; - dx = tempx = Pop(); - currentx += dx; - RDmoveto(); -} - -private -procedure psVMT() { - Fixed dy; - tempx = 0; - dy = tempy = Pop(); - currenty += dy; - RDmoveto(); -} - -private -procedure Rct(c1, c2, c3) Cd c1, c2, c3; -{ - tempx = currentx; - tempy = currenty; - DoDelta(c1.x, c1.y); - c1.x = currentx; - c1.y = currenty; - DoDelta(c2.x, c2.y); - c2.x = currentx; - c2.y = currenty; - DoDelta(c3.x, c3.y); - c3.x = currentx; - c3.y = currenty; - RDcurveto(c1, c2, c3); -} - -private -procedure psRCT() { - Cd c1, c2, c3; - PopPCd(&c3); - PopPCd(&c2); - PopPCd(&c1); - Rct(c1, c2, c3); -} - -private -procedure psVHCT() { - Cd c1, c2, c3; - c3.y = 0; - c3.x = Pop(); - PopPCd(&c2); - c1.y = Pop(); - c1.x = 0; - Rct(c1, c2, c3); -} - -private -procedure psHVCT() { - Cd c1, c2, c3; - c3.y = Pop(); - c3.x = 0; - PopPCd(&c2); - c1.y = 0; - c1.x = Pop(); - Rct(c1, c2, c3); -} - -private -procedure psCP() { - if (!forMultiMaster) - AppendElement(CLOSEPATH); - else - AppendCharPathElement(CP); -} - -private -procedure psMT() { - Cd c; - c.y = Pop(); - c.x = Pop(); - tempx = c.x - currentx; - tempy = c.y - currenty; - currenty = c.y; - currentx = c.x; - RDmoveto(); -} - -private -procedure psDT() { - Cd c; - c.y = Pop(); - c.x = Pop(); - tempx = c.x - currentx; - tempy = c.y - currenty; - currenty = c.y; - currentx = c.x; - RDlineto(); -} - -private -procedure psCT() { - Cd c1, c2, c3; - tempx = currentx; - tempy = currenty; - PopPCd(&c3); - PopPCd(&c2); - PopPCd(&c1); - RDcurveto(c1, c2, c3); -} - -private -procedure psFLX() { - Cd c0, c1, c2, c3, c4, c5; - integer i; - for (i = 0; i < 5; i++) (void)Pop(); - PopPCd(&c5); - PopPCd(&c4); - PopPCd(&c3); - PopPCd(&c2); - PopPCd(&c1); - PopPCd(&c0); - Rct(c0, c1, c2); - Rct(c3, c4, c5); - flex = FALSE; -} - -private -procedure ReadHintInfo(nm, str) char nm; -const char *str; -{ - Cd c0; - short hinttype = - nm == 'y' ? RY : nm == 'b' ? RB : nm == 'm' ? RM + ESCVAL : RV + ESCVAL; - long elt1, elt2; - PopPCd(&c0); - c0.y += c0.x; /* make absolute */ - /* Look for comment of path elements used to determine this band. */ - if (sscanf(str, " %% %ld %ld", &elt1, &elt2) != 2) { - FlushLogFiles(); - sprintf(globmsg, "Extra hint information required for blended fonts is not in\n character file: %s. Please re-hint using the latest software.\n Hints will not be included in this font.\n", fileName); - LogMsg(globmsg, WARNING, NONFATALERROR, TRUE); - SetNoHints(); - includeHints = FALSE; - } else - SetHintsElt(hinttype, &c0, elt1, elt2, (boolean)!startchar); -} - -private -integer StrLen(s) register char *s; -{ - register integer cnt = 0; - while (*s++ != 0) cnt++; - return cnt; -} - -/*Used instead of StringEqual to keep ac from cloberring source string*/ - -int isPrefix(const char *s, const char *pref) { - while (*pref) { - if (*pref != *s) - return 0; - pref++; - s++; - } - return 1; -} - -private -procedure DoName(nm, buff, len) const char *nm, *buff; -int len; -{ - switch (len) { - case 2: - switch (nm[0]) { - case 'c': /* ct, cp */ - switch (nm[1]) { - case 't': - psCT(); - break; - case 'p': - psCP(); - break; - default: - goto badFile; - } - break; - case 'm': /* mt */ - if (nm[1] != 't') goto badFile; - psMT(); - break; - case 'd': /* dt */ - if (nm[1] != 't') goto badFile; - psDT(); - break; - case 's': /* sc */ - if (nm[1] != 'c') goto badFile; - startchar = TRUE; - break; - case 'e': /* ed */ - if (nm[1] != 'd') goto badFile; - break; - case 'r': /* rm, rv, ry, rb */ - if (includeHints) - ReadHintInfo(nm[1], buff); - else - Pop2(); - break; - case 'i': /* id */ - if (nm[1] != 'd') goto badFile; - Pop(); - idInFile = TRUE; - break; - default: - goto badFile; - } - break; - case 3: - switch (nm[0]) { - case 'r': /* rdt, rmt, rct */ - if (nm[2] != 't') goto badFile; - switch (nm[1]) { - case 'd': - psRDT(); - break; - case 'm': - psRMT(); - break; - case 'c': - psRCT(); - break; - default: - goto badFile; - } - break; - case 'h': /* hdt, hmt */ - if (nm[2] != 't') goto badFile; - switch (nm[1]) { - case 'd': - psHDT(); - break; - case 'm': - psHMT(); - break; - default: - goto badFile; - } - break; - case 'v': /* vdt, vmt */ - if (nm[2] != 't') goto badFile; - switch (nm[1]) { - case 'd': - psVDT(); - break; - case 'm': - psVMT(); - break; - default: - goto badFile; - } - break; - case 's': /* sol, snc */ - case 'e': /* eol, enc */ - switch (nm[1]) { - case 'o': - if (nm[2] != 'l') goto badFile; - break; - case 'n': - if (nm[2] != 'c') goto badFile; - break; - default: - goto badFile; - } - break; - case 'f': /* flx */ - if (nm[1] == 'l' && nm[2] == 'x') - psFLX(); - else - goto badFile; - break; - case 'd': /* div */ - if (nm[1] == 'i' && nm[2] == 'v') - psDIV(); - else - goto badFile; - break; - default: - goto badFile; - } - break; - case 4: - if (nm[2] != 'c' || nm[3] != 't') goto badFile; - switch (nm[0]) { - case 'v': /* vhct */ - if (nm[1] != 'h') goto badFile; - psVHCT(); - break; - case 'h': /* hvct */ - if (nm[1] != 'v') goto badFile; - psHVCT(); - break; - default: - goto badFile; - } - break; - case 7: - switch (nm[6]) { - case '1': /* preflx1 */ - case '2': /* preflx2 */ - if (nm[0] != 'p' || nm[1] != 'r' || nm[2] != 'e' || - nm[3] != 'f' || nm[4] != 'l' || nm[5] != 'x') - goto badFile; - flex = TRUE; - break; - case 'r': /* endsubr */ - if (!isPrefix(nm, "endsubr")) goto badFile; - break; - default: - goto badFile; - } - break; - case 9: - switch (nm[0]) { - case 'b': /* beginsubr */ - if (!isPrefix(nm, "beginsubr")) goto badFile; - break; - case 'n': /* newcolors */ - if (!isPrefix(nm, "newcolors")) goto badFile; - break; - default: - goto badFile; - } - break; - default: - goto badFile; - } - return; -badFile : { - char op[80]; - if (len > 79) len = 79; - strncpy(op, nm, len); - op[len] = 0; - - FlushLogFiles(); - sprintf(globmsg, "Bad file format. Unknown operator: %s in %s character.\n", op, fileName); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); -} -} - -private -procedure ParseString(s) const char *s; -{ - const char *s0; - char c; - char *c0; - boolean neg; - boolean isReal; - float rval; - integer val; - Fixed r; - pathStart = pathEnd = NULL; - bezGlyphName[0] = 0; - - while (TRUE) { - c = *s++; - nxtChar: - switch (c) { - case '-': /* negative number */ - neg = TRUE; - val = 0; - goto rdnum; - case '%': /* comment */ - if (bezGlyphName[0] == 0) { - unsigned int end = 0; - while (*s == ' ') - s++; - - while ((s[end] != ' ') && (s[end] != '\r') && (s[end] != '\n')) - end++; - - strncpy(bezGlyphName, s, end); - if (end < 64) - bezGlyphName[end] = 0; - else { - bezGlyphName[63] = 0; - sprintf(globmsg, - "Bad input file. Glyph name %s is greater than 32 chars.\n", - bezGlyphName); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - } - while ((*s != '\n') && (*s != '\r')) { - s++; - } - continue; - case ' ': - continue; - case '\t': - continue; - case '\n': - continue; - case '\r': - continue; - case 0: /* end of file */ - if (stkindex != 0) { - FlushLogFiles(); - sprintf(globmsg, - "Bad input file. Numbers left on stack at end of %s file.\n", - fileName); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - return; - default: - if (c >= '0' && c <= '9') { - neg = FALSE; - val = c - '0'; - goto rdnum; - } - if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z')) { - s0 = s - 1; - while (TRUE) { - c = *s++; - if ((c == ' ') || (c == '\t') || (c == '\n') || (c == '\r') || (c == '\0')) - break; - if (c == 0) - break; - } - DoName(s0, s, s - s0 - 1); - if (c == '\0') - s--; - continue; - } - FlushLogFiles(); - sprintf(globmsg, "Unexpected character in %s file.\n", fileName); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - rdnum: - isReal = false; - c0 = (char *)(s - 1); - while (TRUE) { - c = *s++; - if (c == '.') - isReal = true; - else if (c >= '0' && c <= '9') - val = val * 10 + (c - '0'); - else if ((c == ' ') || (c == '\t')) { - if (isReal) { - sscanf(c0, "%f", &rval); - rval = roundf(rval * 100) / 100; // Autohint can only support 2 digits of decimal precision. - /* do not need to use 'neg' to negate the value, as c0 string includes the minus sign.*/ - r = FixReal(rval); /* convert to Fixed */ - } else { - if (neg) - val = -val; - r = FixInt(val); /* convert to Fixed */ - } - /* Push(r); */ - if (stkindex >= STKMAX) { - FlushLogFiles(); - sprintf(globmsg, "Stack overflow while reading %s file.\n", - fileName); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - return; - } - stk[stkindex] = r; - stkindex++; - goto nxtChar; - } else { - FlushLogFiles(); - sprintf(globmsg, - "Illegal number terminator while reading %s file.\n", - fileName); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - return; - } - } /*end while true */ - } -} - -#define TESTING (FALSE) -#if TESTING -private -unsigned char ibuff[MAXBYTES + 2]; -private -integer inputlen; -#endif /*TESTING*/ - -public -procedure SetReadFileName(file_name) char *file_name; -{ - fileName = file_name; -} - -public -boolean ReadCharFile(normal, forBlendData, readHints, prependprefix) - boolean normal, - forBlendData, readHints, prependprefix; -{ - char infile[MAXPATHLEN]; - FILE *fd; - char *inputbuff; - integer cc; - unsigned long filelen; - currentx = currenty = tempx = tempy = stkindex = 0; - flex = idInFile = startchar = FALSE; - forMultiMaster = forBlendData; - includeHints = readHints; - if (prependprefix -#ifdef IS_LIB - && !featurefiledata -#endif - ) { - if (normal) - sprintf(infile, "%s%s", inPrefix, fileName); - else - sprintf(infile, "%s%s", outPrefix, fileName); - } else { - strcpy(infile, fileName); - } -#ifdef IS_LIB - if (bezstring) { - inputbuff = (char *)bezstring; - cc = (integer)strlen(inputbuff); - } else { -#endif - fd = ACOpenFile(infile, "rb", OPENWARN); - if (fd == NULL) return FALSE; - filelen = ACGetFileSize(infile); -#if DOMEMCHECK - inputbuff = (char *)memck_malloc(filelen + 5); -#else - inputbuff = (char *)ACNEWMEM(filelen + 5); -#endif - cc = ACReadFile((char *)inputbuff, fd, (char *)infile, filelen); - inputbuff[cc] = '\0'; -#ifdef IS_LIB - } -#endif - -#if PRINT_READ - fprintf(OUTPUTBUFF, "%s", inputbuff); -#endif - -#if TESTING - inputlen = cc; - for (i = 0; i <= cc; i++) ibuff[i] = inputbuff[i]; -#endif - ParseString(inputbuff); -#if !TESTING -#ifndef IS_LIB - { - char *s; - s = inputbuff; - for (i = 0; i < cc; i++) *s++ = 0; /* erase the plain text version */ - } -#endif -#endif -#ifndef IS_LIB - fclose(fd); -#if DOMEMCHECK - memck_free(inputbuff); -#else - ACFREEMEM(inputbuff); -#endif -#endif - -#if TESTING - if (normal) { - fd = ACOpenFile("file.old", "wb", OPENWARN); - if (fd == NULL) return FALSE; - fprintf(fd, "%s", ibuff); - fclose(fd); - } -#endif - return TRUE; -} - -public -procedure Test() { -#if TESTING - unsigned char buff[MAXBYTES + 2], *s; - char infile[MAXPATHLEN]; - FILE *fd; - integer cc, i; - - sprintf(infile, "%s%s", outPrefix, fileName); - fd = ACOpenFile(infile, "rb", OPENWARN); - if (fd == NULL) return; - cc = ReadDecFile( - fd, (char *)infile, (char *)buff, - TRUE, MAXBYTES, (unsigned long)MAXBYTES, OTHER); - fclose(fd); - if (cc >= MAXBYTES) { - cc--; - buff[cc] = 0; - goto mismatch; - } - buff[cc] = 0; - if (cc != inputlen) { - LogMsg("Test: file length different.\n", WARNING, OK, TRUE); - goto mismatch; - } - for (i = 0; i < cc; i++) - if (buff[i] != ibuff[i]) { - LogMsg("Test: file contents different.\n", WARNING, OK, TRUE); - goto mismatch; - } - /* return; */ -mismatch: - fd = ACOpenFile("file.new", "wb", OPENWARN); - if (fd == NULL) return; - fprintf(fd, "%s", buff); - fclose(fd); -#endif -} diff --git a/c/autohint/autohintlib/source/ac/report.c b/c/autohint/autohintlib/source/ac/report.c deleted file mode 100644 index 94a9eaa25..000000000 --- a/c/autohint/autohintlib/source/ac/report.c +++ /dev/null @@ -1,843 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* report.c */ - -#include "ac.h" -#include "machinedep.h" - -#define MAXFILENAME 32 - -#define YMINFILE "ymin.tmp" -#define YMAXFILE "ymax.tmp" -#define HORZFILE "horz.tmp" -#define VERTFILE "vert.tmp" - -#ifdef _WIN32 -#define L_cuserid 12 -#endif - -#if !IS_LIB -private -FILE *yminfile, *ymaxfile, *logfile, *vertfile, *horzfile; -#else -extern AC_REPORTFUNCPTR libReportCB; -#endif -private -char S0[512]; - -public -double FixToDbl(f) Fixed f; -{ - real r; - acfixtopflt(f, &r); - return r; -} - -#define VERSION "4.1" -public -procedure ACGetVersion(char *name, char *str) { - sprintf(str, "%s ac library version %s.\n", name, VERSION); -} - -public -procedure OpenLogFiles() { -#if !IS_LIB - char dir[MAXPATHLEN]; - char uid[L_cuserid]; - char host[50]; - logfile = ACOpenFile(TMPLOG, "w", OPENERROR); - GetInputDirName(dir, ""); -#ifdef SUN - cuserid(uid); - gethostname(host, 50); -#else - strcpy(host, "Local machine"); - strcpy(uid, "local"); -#endif - fprintf(logfile, "\n# %s -- %s\n# %s\n", uid, host, dir); - ACGetVersion("AC", globmsg); - fprintf(logfile, "# %s#\n\n", globmsg); - if (!logging) return; - yminfile = ACOpenFile(YMINFILE, "w", OPENERROR); - ymaxfile = ACOpenFile(YMAXFILE, "w", OPENERROR); - horzfile = ACOpenFile(HORZFILE, "w", OPENERROR); - vertfile = ACOpenFile(VERTFILE, "w", OPENERROR); -#endif -} - -public -procedure FlushLogFiles() { -#if !IS_LIB - fflush(logfile); - if (!logging) return; - fflush(yminfile); - fflush(ymaxfile); - fflush(horzfile); - fflush(vertfile); -#endif -} - -public -procedure CloseLogFiles() { -#if !IS_LIB - fclose(logfile); - if (!logging) return; - fclose(yminfile); - fclose(ymaxfile); - fclose(horzfile); - fclose(vertfile); -/* - (cd ..;sort -u ymin.tmp | sort -n > ymin.log; rm ymin.tmp) ! - (cd ..;sort -u ymax.tmp | sort -n > ymax.log; rm ymax.tmp) ! - (cd ..;sort -u horz.tmp | sort -n > horz.log; rm horz.tmp) ! - (cd ..;sort -u vert.tmp | sort -n > vert.log; rm vert.tmp) ! -*/ -#endif -} - -public -procedure LogYMinMax() { -#if !IS_LIB - PPathElt e = pathStart; - Fixed temp, y, ymax = FixInt(-10000), ymin = FixInt(10000); - if (!logging || e == NULL || e == pathEnd) return; - while (e != NULL) { - GetEndPoint(e, &temp, &y); - if (y < ymin) ymin = y; - if (y > ymax) ymax = y; - e = e->next; - } - /* The path element coordinates may have been transformed by -FixTwoMul - so check if ymin > ymax and switch values if true. - The untransformed coordinates will be written to the ymin and ymax - files. */ - if (ymin > ymax) { - temp = ymin; - ymin = ymax; - ymax = temp; - } - (void)fprintf(yminfile, "%g\t%s\n", FixToDbl(itfmy(ymin)), fileName); - (void)fprintf(ymaxfile, "%g\t%s\n", FixToDbl(itfmy(ymax)), fileName); -#endif -} - -#if IS_LIB -#define EndLine() -#else -private -procedure EndLine() { - if (!makehintslog) - return; - (void)fprintf(logfile, "\n"); -} -#endif - -#define PrinMsg(s) PrintMessage(s) - -public -procedure PrintMessage(s) char *s; -{ -#if !IS_LIB - if (!makehintslog) - return; - (void)fprintf(logfile, "%s: %s\n", fileName, s); -#else - char msgBuffer[512]; - if ((libReportCB != NULL) && (strlen(s) > 0)) { - sprintf(msgBuffer, "\t%s", s); - libReportCB(msgBuffer); - } -#endif -} - -public -procedure ReportError(s) char *s; -{ -#if !IS_LIB - if (reportErrors) PrintMessage(s); -#else - if (reportErrors && (libReportCB != NULL)) PrintMessage(s); -#endif -} - -public -procedure ReportSmoothError(x, y) Fixed x, y; -{ - (void)sprintf(S0, "Junction at %g %g may need smoothing.", - FixToDbl(itfmx(x)), FixToDbl(itfmy(y))); - ReportError(S0); -} - -public -procedure ReportAddFlex() { - if (hasFlex) return; - hasFlex = TRUE; - PrintMessage("FYI: added flex operators to this character."); -} - -public -procedure ReportClipSharpAngle(x, y) Fixed x, y; -{ - (void)sprintf(S0, "FYI: Too sharp angle at %g %g has been clipped.", - FixToDbl(itfmx(x)), FixToDbl(itfmy(y))); - PrintMessage(S0); -} - -public -procedure ReportSharpAngle(x, y) Fixed x, y; -{ - (void)sprintf(S0, "FYI: angle at %g %g is very sharp. Please check.", - FixToDbl(itfmx(x)), FixToDbl(itfmy(y))); - PrintMessage(S0); -} - -public -procedure ReportLinearCurve(e, x0, y0, x1, y1) - PPathElt e; -Fixed x0, y0, x1, y1; -{ - if (autoLinearCurveFix) { - e->type = LINETO; - e->x = e->x3; - e->y = e->y3; - (void)sprintf(S0, "Curve from %g %g to %g %g was changed to a line.", - FixToDbl(itfmx(x0)), FixToDbl(itfmy(y0)), - FixToDbl(itfmx(x1)), FixToDbl(itfmy(y1))); - } else - (void)sprintf(S0, "Curve from %g %g to %g %g should be changed to a line.", - FixToDbl(itfmx(x0)), FixToDbl(itfmy(y0)), - FixToDbl(itfmx(x1)), FixToDbl(itfmy(y1))); - PrintMessage(S0); -} - -private -procedure ReportNonHVError(x0, y0, x1, y1, s) - Fixed x0, - y0, x1, y1; -char *s; -{ - Fixed dx, dy; - x0 = itfmx(x0); - y0 = itfmy(y0); - x1 = itfmx(x1); - y1 = itfmy(y1); - dx = x0 - x1; - dy = y0 - y1; - if (abs(dx) > FixInt(10) || abs(dy) > FixInt(10) || - FTrunc(dx * dx) + FTrunc(dy * dy) > FixInt(100)) { - (void)sprintf(S0, "The line from %g %g to %g %g is not exactly %s.", - FixToDbl(x0), FixToDbl(y0), FixToDbl(x1), FixToDbl(y1), s); - ReportError(S0); - } -} - -public -procedure ReportNonHError(x0, y0, x1, y1) Fixed x0, y0, x1, y1; -{ - ReportNonHVError(x0, y0, x1, y1, "horizontal"); -} - -public -procedure ReportNonVError(x0, y0, x1, y1) Fixed x0, y0, x1, y1; -{ - ReportNonHVError(x0, y0, x1, y1, "vertical"); -} - -public -procedure ExpectedMoveTo(e) PPathElt e; -{ - char *s; - switch (e->type) { - case LINETO: - s = (char *)"lineto"; - break; - case CURVETO: - s = (char *)"curveto"; - break; - case CLOSEPATH: - s = (char *)"closepath"; - break; - default: - /* LogMsg("Malformed path list.\n", LOGERROR, NONFATALERROR, TRUE); */ - break; - } - FlushLogFiles(); - (void)sprintf(globmsg, "Path for %s character has a %s where a moveto was expected.\n The file is probably truncated.", fileName, s); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); -} - -public -procedure ReportMissingClosePath() { - FlushLogFiles(); - (void)sprintf(globmsg, "Missing closepath in %s character.\n The file is probably truncated.", fileName); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); -} - -public -procedure ReportTryFlexNearMiss(x0, y0, x2, y2) Fixed x0, y0, x2, y2; -{ - (void)sprintf(S0, "Curves from %g %g to %g %g near miss for adding flex.", - FixToDbl(itfmx(x0)), FixToDbl(itfmy(y0)), - FixToDbl(itfmx(x2)), FixToDbl(itfmy(y2))); - ReportError(S0); -} - -public -procedure ReportTryFlexError(CPflg, x, y) - boolean CPflg; -Fixed x, y; -{ - (void)sprintf(S0, - CPflg ? "Please move closepath from %g %g so can add flex." : "Please remove zero length element at %g %g so can add flex.", - FixToDbl(itfmx(x)), FixToDbl(itfmy(y))); - ReportError(S0); -} - -public -procedure ReportSplit(e) PPathElt e; -{ - Fixed x0, y0, x1, y1; - GetEndPoints(e, &x0, &y0, &x1, &y1); - (void)sprintf(S0, "FYI: the element that goes from %g %g to %g %g has been split.", - FixToDbl(itfmx(x0)), FixToDbl(itfmy(y0)), - FixToDbl(itfmx(x1)), FixToDbl(itfmy(y1))); - PrintMessage(S0); -} - -public -procedure AskForSplit(e) PPathElt e; -{ - Fixed x0, y0, x1, y1; - if (e->type == MOVETO) e = GetClosedBy(e); - GetEndPoints(e, &x0, &y0, &x1, &y1); - (void)sprintf(S0, "Please split the element that goes from %g %g to %g %g.", - FixToDbl(itfmx(x0)), FixToDbl(itfmy(y0)), - FixToDbl(itfmx(x1)), FixToDbl(itfmy(y1))); - ReportError(S0); -} - -public -procedure ReportPossibleLoop(e) PPathElt e; -{ - Fixed x0, y0, x1, y1; - if (e->type == MOVETO) e = GetClosedBy(e); - GetEndPoints(e, &x0, &y0, &x1, &y1); - (void)sprintf(S0, "Possible loop in element that goes from %g %g to %g %g. Please check.", - FixToDbl(itfmx(x0)), FixToDbl(itfmy(y0)), - FixToDbl(itfmx(x1)), FixToDbl(itfmy(y1))); - ReportError(S0); -} - -public -procedure ReportConflictCheck(e, conflict, cp) - PPathElt e, - conflict, cp; -{ - Fixed ex, ey, cx, cy, cpx, cpy; - GetEndPoint(e, &ex, &ey); - GetEndPoint(conflict, &cx, &cy); - GetEndPoint(cp, &cpx, &cpy); - (void)sprintf(S0, "Check e %g %g conflict %g %g cp %g %g.", - FixToDbl(itfmx(ex)), FixToDbl(itfmy(ey)), - FixToDbl(itfmx(cx)), FixToDbl(itfmy(cy)), - FixToDbl(itfmx(cpx)), FixToDbl(itfmy(cpy))); - ReportError(S0); -} - -public -procedure ReportConflictCnt(e, cnt) PPathElt e; -integer cnt; -{ - Fixed ex, ey; - GetEndPoint(e, &ex, &ey); - (void)sprintf(S0, "%g %g conflict count = %ld", - FixToDbl(itfmx(ex)), FixToDbl(itfmy(ey)), cnt); - ReportError(S0); -} - -public -procedure ReportRemFlare(e, e2, hFlg, i) - PPathElt e, - e2; -boolean hFlg; -integer i; -{ - Fixed ex1, ey1, ex2, ey2; - if (!showClrInfo) return; - GetEndPoint(e, &ex1, &ey1); - GetEndPoint(e2, &ex2, &ey2); - (void)sprintf(S0, "Removed %s flare at %g %g by %g %g : %ld.", - hFlg ? "horizontal" : "vertical", - FixToDbl(itfmx(ex1)), FixToDbl(itfmy(ey1)), - FixToDbl(itfmx(ex2)), FixToDbl(itfmy(ey2)), - i); - PrintMessage(S0); -} - -public -procedure ReportRemConflict(e) PPathElt e; -{ - Fixed ex, ey; - if (!showClrInfo) return; - GetEndPoint(e, &ex, &ey); - (void)sprintf(S0, "Removed conflicting hints at %g %g.", - FixToDbl(itfmx(ex)), FixToDbl(itfmy(ey))); - ReportError(S0); -} - -public -procedure ReportRotateSubpath(e) PPathElt e; -{ - Fixed ex, ey; - if (!showClrInfo) return; - GetEndPoint(e, &ex, &ey); - sprintf(S0, "FYI: changed closepath to %g %g.", - FixToDbl(itfmx(ex)), FixToDbl(itfmy(ey))); - PrintMessage(S0); -} - -public -procedure ReportRemShortColors(ex, ey) Fixed ex, ey; -{ - if (!showClrInfo) return; - sprintf(S0, "Removed hints from short element at %g %g.", - FixToDbl(itfmx(ex)), FixToDbl(itfmy(ey))); - PrintMessage(S0); -} - -private -procedure PrntVal(v) Fixed v; -{ - if (v >= FixInt(100000L)) - sprintf(S0, "%ld", FTrunc(v)); - else - sprintf(S0, "%g", FixToDbl(v)); - PrinMsg(S0); -} - -private -procedure ShwHV(val) PClrVal val; -{ - Fixed bot, top; - bot = itfmy(val->vLoc1); - top = itfmy(val->vLoc2); - sprintf(S0, "b %g t %g v ", FixToDbl(bot), FixToDbl(top)); - PrinMsg(S0); - PrntVal(val->vVal); - sprintf(S0, " s %g", FixToDbl(val->vSpc)); - PrinMsg(S0); - if (val->vGhst) - PrinMsg(" G"); -} - -public -procedure ShowHVal(val) PClrVal val; -{ - Fixed l, r; - PClrSeg seg; - ShwHV(val); - seg = val->vSeg1; - if (seg == NULL) return; - l = itfmx(seg->sMin); - r = itfmx(seg->sMax); - sprintf(S0, " l1 %g r1 %g ", FixToDbl(l), FixToDbl(r)); - PrinMsg(S0); - seg = val->vSeg2; - l = itfmx(seg->sMin); - r = itfmx(seg->sMax); - sprintf(S0, " l2 %g r2 %g", FixToDbl(l), FixToDbl(r)); - PrinMsg(S0); -} - -public -procedure ShowHVals(lst) PClrVal lst; -{ - while (lst != NULL) { - ShowHVal(lst); - EndLine(); - lst = lst->vNxt; - } -} - -public -procedure ReportAddHVal(val) PClrVal val; -{ - ShowHVal(val); - EndLine(); -} - -private -procedure ShwVV(val) PClrVal val; -{ - Fixed lft, rht; - lft = itfmx(val->vLoc1); - rht = itfmx(val->vLoc2); - sprintf(S0, "l %g r %g v ", FixToDbl(lft), FixToDbl(rht)); - PrinMsg(S0); - PrntVal(val->vVal); - sprintf(S0, " s %g", FixToDbl(val->vSpc)); - PrinMsg(S0); -} - -public -procedure ShowVVal(val) PClrVal val; -{ - Fixed b, t; - PClrSeg seg; - ShwVV(val); - seg = val->vSeg1; - if (seg == NULL) return; - b = itfmy(seg->sMin); - t = itfmy(seg->sMax); - sprintf(S0, " b1 %g t1 %g ", FixToDbl(b), FixToDbl(t)); - PrinMsg(S0); - seg = val->vSeg2; - b = itfmy(seg->sMin); - t = itfmy(seg->sMax); - sprintf(S0, " b2 %g t2 %g", FixToDbl(b), FixToDbl(t)); - PrinMsg(S0); -} - -public -procedure ShowVVals(lst) PClrVal lst; -{ - while (lst != NULL) { - ShowVVal(lst); - EndLine(); - lst = lst->vNxt; - } -} - -public -procedure ReportAddVVal(val) PClrVal val; -{ - ShowVVal(val); - EndLine(); -} - -public -procedure ReportFndBstVal(seg, val, hFlg) - PClrSeg seg; -PClrVal val; -boolean hFlg; -{ - if (hFlg) { - sprintf(S0, "FndBstVal: sLoc %g sLft %g sRght %g ", - FixToDbl(itfmy(seg->sLoc)), - FixToDbl(itfmx(seg->sMin)), - FixToDbl(itfmx(seg->sMax))); - PrinMsg(S0); - if (val) - ShwHV(val); - else - PrinMsg("NULL"); - } else { - sprintf(S0, "FndBstVal: sLoc %g sBot %g sTop %g ", - FixToDbl(itfmx(seg->sLoc)), - FixToDbl(itfmy(seg->sMin)), - FixToDbl(itfmy(seg->sMax))); - PrinMsg(S0); - if (val) - ShwVV(val); - else - PrinMsg("NULL"); - } - EndLine(); -} - -public -procedure ReportCarry(l0, l1, loc, clrs, vert) - Fixed l0, - l1, loc; -PClrVal clrs; -boolean vert; -{ - if (!showClrInfo) return; - if (vert) { - ShowVVal(clrs); - loc = itfmx(loc); - l0 = itfmx(l0); - l1 = itfmx(l1); - } else { - ShowHVal(clrs); - loc = itfmy(loc); - l0 = itfmy(l0); - l1 = itfmy(l1); - } - sprintf(S0, " carry to %g in [%g..%g]", - FixToDbl(loc), FixToDbl(l0), FixToDbl(l1)); - PrintMessage(S0); -} - -public -procedure ReportBestCP(e, cp) PPathElt e, cp; -{ - Fixed ex, ey, px, py; - GetEndPoint(e, &ex, &ey); - if (cp != NULL) { - GetEndPoint(cp, &px, &py); - sprintf(S0, "%g %g best cp at %g %g", - FixToDbl(itfmx(ex)), FixToDbl(itfmy(ey)), - FixToDbl(itfmx(px)), FixToDbl(itfmy(py))); - } else - sprintf(S0, "%g %g no best cp", - FixToDbl(itfmx(ex)), FixToDbl(itfmy(ey))); - PrintMessage(S0); -} - -public -procedure LogColorInfo(pl) PClrPoint pl; -{ - char c = pl->c; - Fixed lft, rht, top, bot, wdth; - if (c == 'y' || c == 'm') { /* vertical lines */ - lft = pl->x0; - rht = pl->x1; - (void)printf("%4g %-30s%5g%5g\n", FixToDbl(rht - lft), fileName, - FixToDbl(lft), FixToDbl(rht)); - } else { - bot = pl->y0; - top = pl->y1; - wdth = top - bot; - if (wdth == FixInt(-21) || wdth == FixInt(-20)) return; /* ghost pair */ - (void)printf("%4g %-30s%5g%5g\n", FixToDbl(wdth), fileName, - FixToDbl(bot), FixToDbl(top)); - } -} - -private -procedure LstHVal(val) PClrVal val; -{ - PrinMsg("\t"); - ShowHVal(val); - PrinMsg(" "); -} - -private -procedure LstVVal(val) PClrVal val; -{ - PrinMsg("\t"); - ShowVVal(val); - PrinMsg(" "); -} - -public -procedure ListClrInfo() { /* debugging routine */ - PPathElt e; - PSegLnkLst hLst, vLst; - PClrSeg seg; - Fixed x, y; - e = pathStart; - while (e != NULL) { - hLst = e->Hs; - vLst = e->Vs; - if ((hLst != NULL) || (vLst != NULL)) { - GetEndPoint(e, &x, &y); - x = itfmx(x); - y = itfmy(y); - sprintf(S0, "x %g y %g ", FixToDbl(x), FixToDbl(y)); - PrinMsg(S0); - while (hLst != NULL) { - seg = hLst->lnk->seg; - LstHVal(seg->sLnk); - hLst = hLst->next; - } - while (vLst != NULL) { - seg = vLst->lnk->seg; - LstVVal(seg->sLnk); - vLst = vLst->next; - } - EndLine(); - } - e = e->next; - } -} - -public -procedure ReportAddVSeg(from, to, loc, i) - Fixed from, - to, loc; -integer i; -{ - if (!showClrInfo || !showVs) return; - (void)sprintf(S0, "add vseg %g %g to %g %g %ld", - FixToDbl(itfmx(loc)), FixToDbl(itfmy(from)), - FixToDbl(itfmx(loc)), FixToDbl(itfmy(to)), i); - PrintMessage(S0); -} - -public -procedure ReportAddHSeg(from, to, loc, i) - Fixed from, - to, loc; -integer i; -{ - if (!showClrInfo || !showHs) return; - (void)sprintf(S0, "add hseg %g %g to %g %g %ld", - FixToDbl(itfmx(from)), FixToDbl(itfmy(loc)), - FixToDbl(itfmx(to)), FixToDbl(itfmy(loc)), i); - PrintMessage(S0); -} - -public -procedure ReportRemVSeg(from, to, loc) - Fixed from, - to, loc; -{ - if (!showClrInfo || !showVs) return; - (void)sprintf(S0, "rem vseg %g %g to %g %g", - FixToDbl(itfmx(loc)), FixToDbl(itfmy(from)), - FixToDbl(itfmx(loc)), FixToDbl(itfmy(to))); - PrintMessage(S0); -} - -public -procedure ReportRemHSeg(from, to, loc) - Fixed from, - to, loc; -{ - if (!showClrInfo || !showHs) return; - (void)sprintf(S0, "rem hseg %g %g to %g %g", - FixToDbl(itfmx(from)), FixToDbl(itfmy(loc)), - FixToDbl(itfmx(to)), FixToDbl(itfmy(loc))); - PrintMessage(S0); -} - -public -procedure ReportBandError(str, loc, blu) char *str; -Fixed loc, blu; -{ - (void)sprintf(S0, "Near miss %s horizontal zone at %g instead of %g.", - str, FixToDbl(loc), FixToDbl(blu)); - ReportError(S0); -} -public -procedure ReportBandNearMiss(str, loc, blu) char *str; -Fixed loc, blu; -{ - (void)sprintf(S0, "Near miss %s horizontal zone at %g instead of %g.", - str, FixToDbl(loc), FixToDbl(blu)); - ReportError(S0); -} - -public -procedure ReportStemNearMiss(vert, w, minW, b, t, curve) - boolean vert, - curve; -Fixed w, minW, b, t; -{ - (void)sprintf(S0, "%s %s stem near miss: %g instead of %g at %g to %g.", - vert ? "Vertical" : "Horizontal", curve ? "curve" : "linear", - FixToDbl(w), FixToDbl(minW), FixToDbl(MIN(b, t)), FixToDbl(MAX(b, t))); - ReportError(S0); -} - -public -procedure ReportColorConflict(x0, y0, x1, y1, ch) - Fixed x0, - y0, x1, y1; -char ch; -{ - unsigned char s[2]; - s[0] = ch; - s[1] = 0; - (void)sprintf(S0, " Conflicts with current hints: %g %g %g %g %s.", - FixToDbl(x0), FixToDbl(y0), FixToDbl(x1), FixToDbl(y1), s); - ReportError(S0); -} - -public -procedure ReportDuplicates(x, y) Fixed x, y; -{ - (void)sprintf(S0, "Check for duplicate subpath at %g %g.", - FixToDbl(x), FixToDbl(y)); - ReportError(S0); -} - -public -procedure ReportBBoxBogus(llx, lly, urx, ury) - Fixed llx, - lly, urx, ury; -{ - (void)sprintf(S0, "Character bounding box looks bogus: %g %g %g %g.", - FixToDbl(llx), FixToDbl(lly), FixToDbl(urx), FixToDbl(ury)); - ReportError(S0); -} - -public -procedure ReportMergeHVal(b0, t0, b1, t1, v0, s0, v1, s1) - Fixed b0, - t0, b1, t1, v0, s0, v1, s1; -{ - if (!showClrInfo) return; - sprintf(S0, "Replace H hints pair at %g %g by %g %g\n\told value ", - FixToDbl(itfmy(b0)), FixToDbl(itfmy(t0)), - FixToDbl(itfmy(b1)), FixToDbl(itfmy(t1))); - PrinMsg(S0); - PrntVal(v0); - sprintf(S0, " %g new value ", FixToDbl(s0)); - PrinMsg(S0); - PrntVal(v1); - sprintf(S0, " %g", FixToDbl(s1)); - PrintMessage(S0); -} - -public -procedure ReportMergeVVal(l0, r0, l1, r1, v0, s0, v1, s1) - Fixed l0, - r0, l1, r1, v0, s0, v1, s1; -{ - if (!showClrInfo) return; - sprintf(S0, "Replace V hints pair at %g %g by %g %g\n\told value ", - FixToDbl(itfmx(l0)), FixToDbl(itfmx(r0)), - FixToDbl(itfmx(l1)), FixToDbl(itfmx(r1))); - PrinMsg(S0); - PrntVal(v0); - sprintf(S0, " %g new value ", FixToDbl(s0)); - PrinMsg(S0); - PrntVal(v1); - sprintf(S0, " %g", FixToDbl(s1)); - PrintMessage(S0); -} - -public -procedure ReportPruneHVal(val, v, i) - PClrVal val, - v; -integer i; -{ - if (!showClrInfo) return; - sprintf(S0, "PruneHVal: %ld\n\t", i); - PrinMsg(S0); - ShowHVal(val); - PrinMsg("\n\t"); - ShowHVal(v); - EndLine(); -} - -public -procedure ReportPruneVVal(val, v, i) - PClrVal val, - v; -integer i; -{ - if (!showClrInfo) return; - sprintf(S0, "PruneVVal: %ld\n\t", i); - PrinMsg(S0); - ShowVVal(val); - PrinMsg("\n\t"); - ShowVVal(v); - EndLine(); -} - -public -procedure ReportMoveSubpath(e, s) PPathElt e; -char *s; -{ - Fixed x, y; - GetEndPoint(e, &x, &y); - sprintf(S0, "FYI: Moving subpath %g %g to %s.", - FixToDbl(itfmx(x)), FixToDbl(itfmy(y)), s); - PrintMessage(S0); -} diff --git a/c/autohint/autohintlib/source/ac/shuffle.c b/c/autohint/autohintlib/source/ac/shuffle.c deleted file mode 100644 index 5e34410ab..000000000 --- a/c/autohint/autohintlib/source/ac/shuffle.c +++ /dev/null @@ -1,206 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* shuffle.c */ - -#include "ac.h" -#define MAXCNT (100) - -private -unsigned char *links; -private -integer rowcnt; - -public -procedure InitShuffleSubpaths() { - register integer cnt = -1; - register PPathElt e = pathStart; - while (e != NULL) { /* every element is marked with its subpath count */ - if (e->type == MOVETO) cnt++; - if (DEBUG) { - if (e->type == MOVETO) { /* DEBUG */ - sprintf(globmsg, "subpath %ld starts at %g %g\n", cnt, - FixToDbl(itfmx(e->x)), FixToDbl(itfmy(e->y))); - PrintMessage(globmsg); - } - } - e->count = (short)cnt; - e = e->next; - } - cnt++; - rowcnt = cnt; - links = (cnt < 4 || cnt >= MAXCNT) ? NULL : (unsigned char *)Alloc(cnt * cnt); -} - -private -procedure PrintLinks() { - integer i, j; - PrintMessage("Links "); - for (i = 0; i < rowcnt; i++) { - sprintf(globmsg, "%ld ", i); - PrintMessage(globmsg); - if (i < 10) PrintMessage(" "); - } - PrintMessage("\n"); - for (i = 0; i < rowcnt; i++) { - sprintf(globmsg, " %ld ", i); - PrintMessage(globmsg); - if (i < 10) PrintMessage(" "); - for (j = 0; j < rowcnt; j++) { - sprintf(globmsg, "%d ", links[rowcnt * i + j]); - PrintMessage(globmsg); - } - PrintMessage("\n"); - } -} - -private -procedure PrintSumLinks(sumlinks) char *sumlinks; -{ - integer i; - PrintMessage("Sumlinks "); - for (i = 0; i < rowcnt; i++) { - sprintf(globmsg, "%ld ", i); - PrintMessage(globmsg); - if (i < 10) PrintMessage(" "); - } - PrintMessage("\n"); - PrintMessage(" "); - for (i = 0; i < rowcnt; i++) { - sprintf(globmsg, "%d ", sumlinks[i]); - PrintMessage(globmsg); - } - PrintMessage("\n"); -} - -private -procedure PrintOutLinks(unsigned char *outlinks) { - integer i; - PrintMessage("Outlinks "); - for (i = 0; i < rowcnt; i++) { - sprintf(globmsg, "%ld ", i); - PrintMessage(globmsg); - if (i < 10) PrintMessage(" "); - } - PrintMessage("\n"); - PrintMessage(" "); - for (i = 0; i < rowcnt; i++) { - sprintf(globmsg, "%d ", outlinks[i]); - PrintMessage(globmsg); - } - PrintMessage("\n"); -} - -public -procedure MarkLinks(vL, hFlg) PClrVal vL; -boolean hFlg; -{ - register integer i, j; - register PClrSeg seg; - register PPathElt e; - if (links == NULL) return; - for (; vL != NULL; vL = vL->vNxt) { - if (vL == NULL) continue; - seg = vL->vSeg1; - if (seg == NULL) continue; - e = seg->sElt; - if (e == NULL) continue; - i = e->count; - seg = vL->vSeg2; - if (seg == NULL) continue; - e = seg->sElt; - if (e == NULL) continue; - j = e->count; - if (i == j) continue; - if (DEBUG) { - if (hFlg) - ShowHVal(vL); - else - ShowVVal(vL); - sprintf(globmsg, " : %ld <-> %ld\n", i, j); - PrintMessage(globmsg); - } - links[rowcnt * i + j] = 1; - links[rowcnt * j + i] = 1; - } -} - -private -procedure Outpath(links, outlinks, output, bst) unsigned char *links, *outlinks, *output; -integer bst; -{ - register unsigned char *lnks, *outlnks; - register integer i = bst; - register PPathElt e = pathStart; - while (e != NULL) { - if (e->count == i) break; - e = e->next; - } - MoveSubpathToEnd(e); - if (DEBUG) { - sprintf(globmsg, "move subpath %ld to end\n", bst); /* DEBUG */ - PrintMessage(globmsg); - } - output[bst] = 1; - lnks = &links[bst * rowcnt]; - outlnks = outlinks; - for (i = 0; i < rowcnt; i++) - *outlnks++ += *lnks++; - if (DEBUG) - PrintOutLinks(outlinks); -} - -/* The intent of this code is to order the subpaths so that - the hints will not need to change constantly because it - is jumping from one subpath to another. Kanji characters - had the most problems with this which caused huge files - to be created. */ -public -procedure DoShuffleSubpaths() { - unsigned char sumlinks[MAXCNT], output[MAXCNT], outlinks[MAXCNT]; - register unsigned char *lnks; - register integer i, j, bst, bstsum, bstlnks; - if (links == NULL) return; - if (DEBUG) - PrintLinks(); - for (i = 0; i < rowcnt; i++) - output[i] = sumlinks[i] = outlinks[i] = 0; - lnks = links; - for (i = 0; i < rowcnt; i++) { - for (j = 0; j < rowcnt; j++) { - if (*lnks++ != 0) sumlinks[i]++; - } - } - if (DEBUG) - PrintSumLinks((char *)sumlinks); - while (TRUE) { - bst = -1; - bstsum = 0; - for (i = 0; i < rowcnt; i++) { - if (output[i] == 0 && (bst == -1 || sumlinks[i] > bstsum)) { - bstsum = sumlinks[i]; - bst = i; - } - } - if (bst == -1) break; - Outpath(links, outlinks, output, bst); - while (TRUE) { - bst = -1; - bstsum = 0; - bstlnks = 0; - for (i = 0; i < rowcnt; i++) { - if (output[i] == 0 && outlinks[i] >= bstlnks) { - if (outlinks[i] > 0 && - (bst == -1 || outlinks[i] > bstlnks || - (outlinks[i] == bstlnks && sumlinks[i] > bstsum))) { - bstlnks = outlinks[i]; - bst = i; - bstsum = sumlinks[i]; - } - } - } - if (bst == -1) break; - Outpath(links, outlinks, output, bst); - } - } -} diff --git a/c/autohint/autohintlib/source/ac/stub.c b/c/autohint/autohintlib/source/ac/stub.c deleted file mode 100644 index 2d69681e2..000000000 --- a/c/autohint/autohintlib/source/ac/stub.c +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* stub.c - to resolve otherwise unresolved external references. */ -#include "ac.h" - -/* Procedures defined in stems/stemreport.c - StemHist */ -public -procedure AddVStem(top, bottom, curved) - Fixed top; -Fixed bottom; -boolean curved; -{ - if (curved && !allstems) - return; - - if (addVStemCB != NULL) { - addVStemCB(top, bottom, bezGlyphName); - } -} - -public -procedure AddHStem(right, left, curved) - Fixed right; -Fixed left; -boolean curved; -{ - if (curved && !allstems) - return; - - if (addHStemCB != NULL) { - addHStemCB(right, left, bezGlyphName); - } -} - -public -procedure AddCharExtremes(bot, top) - Fixed bot, - top; -{ - if (addCharExtremesCB != NULL) { - addCharExtremesCB(top, bot, bezGlyphName); - } -} - -public -procedure AddStemExtremes(bot, top) - Fixed bot, - top; -{ - if (addStemExtremesCB != NULL) { - addStemExtremesCB(top, bot, bezGlyphName); - } -} diff --git a/c/autohint/autohintlib/source/ac/timecheck.c b/c/autohint/autohintlib/source/ac/timecheck.c deleted file mode 100644 index 99db2493d..000000000 --- a/c/autohint/autohintlib/source/ac/timecheck.c +++ /dev/null @@ -1,1326 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* timecheck.c */ - -/* File modification time recording and cross-checking module. This - * module maintains the files .ACtimes and .Converttimes. The format - * of these files has been completely changed from binary to ASCII - * because of porting problems of an alignment and byte ordering - * nature. However, the old format files, version 10 and 11, are - * still read and silently updated to the new ASCII format. - * - * Jerry Hall - 22 Apr 1991 - * Judy Lee 17 Sep 1991 - call standard FileExists in machinedep.c - */ - -#include "ac.h" -#include "bftoac.h" -#include "fipublic.h" -#include "machinedep.h" -#include "buildfont.h" - -#ifdef __MWERKS__ -/*#include "types.h"*/ -/*#include */ -/*#include */ -#else -#include -#if WIN32 -#include -#include -#else -#include -#include -#endif -#endif - -#if !IS_LIB -#include -#endif - -/*#include */ -#include -/*#include */ - -#define VERSION10 1010 /* Mon Jan 9 10:25:53 1989 */ -/* version 11 includes the ability to specify {h,v}counter hinting - characters. It also includes a conversion time if starting - from pschars or ill. */ -#define VERSION11 1011 /* Wed Mar 29 1989 */ -#define VERSION_1_0 "1.0" /* JAH, 04/22/91 */ -#define AC_NAME ".ACtimes" -#define CVT_NAME ".Converttimes" - -/* The counter list is COUNTERLISTSIZE = 20 entries long. It turns out - * that this means that it actually accomodates 19 entries plus a - * terminating NULL. - */ -#define COUNTER_EXTRA_ENTRIES (COUNTERLISTSIZE - COUNTERDEFAULTENTRIES - 1) - -/* The longest line that can appear in a timestamp file is for the - * H or V counter chars and is calculated as: - * 14 + (MAXCHARNAME * COUNTER_EXTRA_ENTRIES - 1) + 1 + 1 = 570. - * The following constant can comfortably accomodate this. - */ -#define MAX_TEXT_LINE 768 - -/* Modification time struct from each file */ -typedef struct { - time_t modTime; - short nameIndx; -} fileTime; - -int newFileCnt = 0; /* Number of files and their ... */ -fileTime* newFileTimes; /* ... timestamps read from charset or directory */ - -int oldFileCnt = 0; /* Number of files and their ... */ -fileTime* oldFileTimes; /* ... timestamps read from the timestamp file */ - -/* Lists of character names/filenames are accumulated in the buffer below - * which is allocated dynamically and grown if it becomes too small. The - * buffer is managed by the routine storeName. A slot of MAXCHARNAME - * characters is reserved at index 0 and is used by the binary name search - * routine to store the search name. The initial buffer size is easily big - * enough to hold 2 name lists for an ISO Adobe character set. These require - * 1095 characters each, including terminating NULLs. - */ -char* nameBuf = 0; /* Character name/filename buffer */ -int bufSize = 0; /* Name buffer size */ -char* nextFree = (char*)MAXCHARNAME; /* Pointer to next free char in buffer */ -#define BUF_INCR 4096 /* Buffer allocation increment */ -#define INDX_PTR(i) ((i) + nameBuf) /* Converts name index to a char pointer */ - -/*char* bsearch();*/ -time_t time(); - -private -char* allocate(); -private -unsigned short calcChksum(); -private -void newTimesFile(const char*, boolean); -private -void readInputDir(const char*, boolean); -private -short storeName(); -private -void formatTime(); -private -void writeTimesFile(boolean convert, float scale); -private -void printArray(); -private -void printCounterList(); -private -void sortFileTimes(); -private -fileTime* findName(); -private -void copyTimes(); -private -void updateTime(); -private -fileTime* checkFile(); -private -void readCharList(); -private -boolean readTimesFile(boolean convert, float scale); -private -boolean readCharSet(); -private -boolean readOldTimesFile(FILE* fp, boolean convert, float scale); -private -int get16(); -private -int get32(); -private -boolean compareData(); -private -boolean readFileTimesData(); -private -boolean compareCounterListData(); -private -boolean compareArrays(); -private -boolean readFileTimes(); -private -boolean compareCounterLists(); -private -boolean compareLists(); -private -boolean compareTimes(boolean, boolean, boolean*, boolean); -private -boolean compareCvtTimes(char* inputDir, boolean release, tConvertfunc convertFunc); - -/* Free up space used for storing file times and filenames. - */ -private -void freeFileTimes(void) { -#if DOMEMCHECK - memck_free(oldFileTimes); - memck_free(newFileTimes); - memck_free(nameBuf); -#else - ACFREEMEM(oldFileTimes); - ACFREEMEM(newFileTimes); - ACFREEMEM(nameBuf); -#endif - oldFileTimes = newFileTimes = NULL; - oldFileCnt = newFileCnt = bufSize = 0; - nextFree = (char*)MAXCHARNAME; - nameBuf = NULL; -} - -/* Creates a new .ACtimes file. A .Converttimes file is also - * created using the current timestamps if a pschars or ill - * directory exists. Called by the -t option to BuildFont. - */ -public -boolean CreateTimesFile(void) { -#if !IS_LIB - if (DirExists(ILLDIR, FALSE, FALSE, FALSE)) - newTimesFile(ILLDIR, TRUE); - else if (DirExists(RAWPSDIR, FALSE, FALSE, FALSE)) - newTimesFile(RAWPSDIR, TRUE); - - newTimesFile(BEZDIR, FALSE); - - freeFileTimes(); -#endif - return TRUE; /* This maintains compatibility with the old version */ -} - -/* Warns about and renames any existing .ACtimes or .Converttimes files - * then creates a new .ACtimes or .Converttimes file using the character - * files' current timestamps. - */ -private -void newTimesFile(const char* dirName, - boolean convert) /* Flags converting from ill/ or pschars/ directory */ -{ -#if IS_LIB -#pragma unused(dirName) -#pragma unused(convert) -#else - float scale; - char* timesFileName = (convert) ? CVT_NAME : AC_NAME; - - readInputDir(dirName, TRUE); - - if (CFileExists(timesFileName, FALSE)) { - /* Rename the old timestamp file */ - char newName[50]; - - sprintf(globmsg, "Renaming existing %s file to %s.old.\n", - timesFileName, timesFileName); - LogMsg(globmsg, WARNING, OK, TRUE); - sprintf(newName, "%s.old", timesFileName); - RenameFile(timesFileName, newName); - } - - set_scale(&scale); - writeTimesFile(convert, scale); -#endif -} - -/* Reads in file names from input directory instead of - * character set. Ignores .BAK files. - */ -private -void readInputDir(const char* dirName, - boolean creating) /* Flags creation (not updating) of timestamp file */ -{ -#if IS_LIB -#pragma unused(dirName) -#pragma unused(creating) -#else - - extern int scandir(); - extern int bf_alphasort(); - int fileCnt; - struct direct** nameList; - - fileCnt = BFscandir(dirName, &nameList, IncludeFile, bf_alphasort); - if (fileCnt == -1) { - sprintf(globmsg, "Can't read the %s directory.\n", dirName); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } else { - int i; - fileTime* p; - char charFile[MAXPATHLEN]; - struct stat s; - - /* explicitly look for .notdef bez file */ -#ifdef __MWERKS__ - sprintf(charFile, ":%s:.notdef", dirName); -#else - sprintf(charFile, "%s\\.notdef", dirName); -#endif - if (FileExists(charFile, FALSE) && - !stat(charFile, &s)) { - newFileTimes = (fileTime*)allocate(fileCnt + 1, sizeof(fileTime)); - } else { - newFileTimes = (fileTime*)allocate(fileCnt, sizeof(fileTime)); - } - - p = newFileTimes; - - for (i = 0; i < fileCnt; i++) { -#ifdef __MWERKS__ - sprintf(charFile, ":%s:%s", dirName, nameList[i]->d_name); -#else - sprintf(charFile, "%s\\%s", dirName, nameList[i]->d_name); -#endif - if (FileExists(charFile, FALSE) && - !stat(charFile, &s)) { - p->nameIndx = storeName(nameList[i]->d_name); - p->modTime = (creating) ? s.st_mtime : 0; - p++; - } - } - - /* explicitly handle for .notdef bez file */ -#ifdef __MWERKS__ - sprintf(charFile, ":%s:.notdef", dirName); -#else - sprintf(charFile, "%s\\.notdef", dirName); -#endif - - if (FileExists(charFile, FALSE) && - !stat(charFile, &s)) { - p->nameIndx = storeName(".notdef"); - p->modTime = (creating) ? s.st_mtime : 0; - p++; - } - - newFileCnt = p - newFileTimes; /* Actual number of valid files */ -#if DOMEMCHECK - memck_free(nameList); -#else - ACFREEMEM(nameList); -#endif - } -#endif -} - -/* Dynamic space allocator. - */ -private -char* allocate(int n, int size) { -#if IS_LIB -#if DOMEMCHECK - char* p = (char*)memck_calloc(n, size); -#else - char* p = (char*)ACNEWMEM(n * size); - if (NULL != p) - memset((void*)p, 0x0, n * size); -#endif -#else - char* p = (char*)calloc(n, size); -#endif - if (!p) { - sprintf(globmsg, "Can't allocate space for file times.\n"); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - - return p; -} - -/* Store a name in the name buffer. Return the index to the - * name, not a pointer. This is so the buffer can be moved (by - * realloc) without screwing up all the references that have - * already been made to it. - */ -private -short storeName(const char* name) { - short tmp = nextFree - nameBuf; - - if (strlen(name) + 1 + nextFree - nameBuf > bufSize) { - /* Not enough space so (re)allocate it */ - - bufSize += BUF_INCR; -#if DOMEMCHECK - if (nameBuf) - nameBuf = memck_realloc(nameBuf, bufSize); - else - nameBuf = memck_malloc(bufSize); -#else - if (nameBuf) - nameBuf = ACREALLOCMEM(nameBuf, bufSize); - else - nameBuf = ACNEWMEM(bufSize); -#endif - if (!nameBuf) { - sprintf(globmsg, "Can't allocate space for file names.\n"); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - - nextFree = tmp + nameBuf; /* Realloc can move the block */ - } - - /* Copy name */ - while (*nextFree++ = *name++) - ; - - return tmp; -} - -/* Write out the timestamp file. - */ -private -void writeTimesFile(boolean convert, /* Flags if writing .Converttimes */ - float scale) /* Coversion scale factor */ -{ -#if IS_LIB -#pragma unused(convert) -#pragma unused(scale) -#else - - int i; - char s[25]; - unsigned short chksum; - char* timesFileName = (convert) ? CVT_NAME : AC_NAME; - int lines = 4 + 1 + ((convert) ? 1 : 7) + 1 + newFileCnt; - FILE* fp = ACOpenFile(timesFileName, "w+", OPENWARN); /* Valid for Mac? */ - - if (fp == NULL) - return; - - fprintf(fp, "%%%% File %s\n", timesFileName); - fprintf(fp, "%%%% Version %s\n", VERSION_1_0); - formatTime(time((time_t*)0), s); - fprintf(fp, "%%%% Created %s\n", s); - fprintf(fp, "%%%% Length %d\n", lines); - fprintf(fp, "%%%% Header:\n"); - - if (convert) - /* .Converttimes header */ - fprintf(fp, "Scale %d.%d\n", (int)scale, - (int)((scale - (int)scale) * 1000.0)); - else { - /* .ACtimes header */ - fprintf(fp, "FlexOK %s\n", (flexOK) ? "true" : "false"); - printArray(fp, "HStems", NumHStems, HStems); - printArray(fp, "VStems", NumVStems, VStems); - printArray(fp, "BotBands", lenBotBands, botBands); - printArray(fp, "TopBands", lenTopBands, topBands); - printCounterList(fp, "HCounterChars", NumHColors, - &HColorList[COUNTERDEFAULTENTRIES]); - printCounterList(fp, "VCounterChars", NumVColors, - &VColorList[COUNTERDEFAULTENTRIES]); - } - - fprintf(fp, "%%%% File Timestamps:\n"); - for (i = 0; i < newFileCnt; i++) { - formatTime(newFileTimes[i].modTime, s); - fprintf(fp, "(%s) %s\n", s, INDX_PTR(newFileTimes[i].nameIndx)); - } - - chksum = calcChksum(fp, lines); - - /* Must do this when changing from read to write on a file opened - * for update, see fopen(3S). - */ - fseek(fp, 0L, L_XTND); - - fprintf(fp, "%%%% Checksum %04x\n", chksum); - - if (ferror(fp)) { - sprintf(globmsg, "Error writing the %s file.\n", timesFileName); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - fclose(fp); -#endif - return; -} - -/* Format string with date and time. - */ -private -void formatTime(time_t t, char* s) { - struct tm* tmp; - - tmp = localtime(&t); - sprintf(s, "%02d/%02d/%02d %02d:%02d:%02d", - tmp->tm_mon + 1, tmp->tm_mday, tmp->tm_year, - tmp->tm_hour, tmp->tm_min, tmp->tm_sec); -} - -/* Prints an array of numbers inside square brackets. - */ -private -void printArray( - FILE* fp, /* Timestamp file pointer */ - char* name, /* Array name */ - long len, /* Array length */ - Fixed* a /* Array */) { - int i; - - fprintf(fp, "%s [", name); - for (i = 0; i < len; i++) - if (i + 1 == len) - fprintf(fp, "%d", FTrunc(a[i])); /* Last in array, no space */ - else - fprintf(fp, "%d ", FTrunc(a[i])); - fprintf(fp, "]\n"); -} - -/* Prints a list of strings inside round brackets. - */ -private -void printCounterList( - FILE* fp, /* Timestamp file pointer */ - char* name, /* List name */ - long len, /* List length */ - char** list /* The list */) { - int i; - - fprintf(fp, "%s (", name); - for (i = 0; i < len; i++) - if (i + 1 == len) - fprintf(fp, "%s", list[i]); /* Last in list, no separating space */ - else - fprintf(fp, "%s ", list[i]); - fprintf(fp, ")\n"); -} - -/* Computes the timestamp file checksum by reading the specified - * number of lines from the beginning of the file and accumulating - * checksum as a 16-bit rotated shifted exor. - */ -private -unsigned short calcChksum(FILE* fp, int lines) { - char buf[MAX_TEXT_LINE]; - register unsigned short chksum = 0; - - rewind(fp); - while (lines-- && fgets(buf, MAX_TEXT_LINE, fp)) { - register char* p = buf; - - while (*p) - chksum = ((chksum << 1) + ((chksum & 0x8000) ? 1 : 0)) ^ *p++; - } - - return chksum; -} - -/* Hint the specified files and update their time entries in the - * timestamp file. Called by AC only when hinting a list of characters. - */ -public -boolean DoArgs( - int cnt, /* Number of characters to process */ - char* names[], /* Names of characters to process */ - boolean extraColor, - boolean* renameLog, - boolean release /* Flags release version */) { -#ifdef IS_GGL - return FALSE; -#else - int i; - boolean result = TRUE; - -#ifdef IS_LIB - if (!featurefiledata) { -#endif - - if (release) { - if (!readCharSet()) { - freeFileTimes(); - return FALSE; - } - } else - readInputDir(BEZDIR, FALSE); - - if (readTimesFile(FALSE, 0.0)) - copyTimes(); - -#ifdef IS_LIB - } -#endif - - for (i = 0; i < cnt; i++) { - if (!DoFile(names[i], extraColor)) { - result = FALSE; - continue; - } else - *renameLog = TRUE; -#if !IS_LIB - updateTime(findName(names[i], newFileCnt, newFileTimes), BEZDIR); -#endif - } - -#if !IS_LIB - writeTimesFile(FALSE, 0.0); - - freeFileTimes(); -#endif - - return result; -#endif -} - -/* Reads through the charset file and builds - * a list of character names/filenames. - */ -private -boolean readCharSet() { -#if !IS_LIB - FILE* fp; - char cName[MAXCHARNAME + 4]; - char csFileName[MAXPATHLEN]; - char fName[MAXFILENAME + 4]; - int i; - long masters, hintDir; - short nextName = nextFree - nameBuf; /* Remember first name position */ - - getcharsetname(csFileName); - fp = ACOpenFile(csFileName, "r", OPENWARN); - if (fp == NULL) - return FALSE; - - for (newFileCnt = 0; ReadNames(cName, fName, &masters, &hintDir, fp); newFileCnt++) - (void)storeName(fName); - fclose(fp); - - newFileTimes = (fileTime*)allocate(newFileCnt, sizeof(fileTime)); - - for (i = 0; i < newFileCnt; i++) { - newFileTimes[i].nameIndx = nextName; - nextName += strlen(INDX_PTR(nextName)) + 1; - } - - sortFileTimes(newFileCnt, newFileTimes); -#endif - return TRUE; -} - -/* Compare function for qsort and bsearch */ -private -int cmpNames(const void* va, const void* vb) - -{ - fileTime* a = (fileTime*)va; - fileTime* b = (fileTime*)vb; - return strcmp(INDX_PTR(a->nameIndx), INDX_PTR(b->nameIndx)); -} -/* Sorts a file times list by name into alphabetical order. - */ -private -void sortFileTimes( - int len, /* Length of table */ - fileTime* table /* Table to be sorted */) { - qsort((char*)table, len, sizeof(fileTime), cmpNames); -} - -/* Reads timestamp file. Checks checksum. Compares values read - * with values read from the fontinfo file (in memory). If any - * header values are different then the file times are discarded - * and all the characters will be rehinted. - */ -private -boolean readTimesFile( - boolean convert, /* Flags if reading .Converttimes */ - float scale /* Conversion scale */) { -#if IS_LIB -#pragma unused(scale) -#pragma unused(convert) - return TRUE; -#else - char tmp[MAXFILENAME]; - int lines; - unsigned short chksum; - int linesRead = 0; - char HCounterLine[MAX_TEXT_LINE]; - char VCounterLine[MAX_TEXT_LINE]; - char* timesFileName = (convert) ? CVT_NAME : AC_NAME; - FILE* fp = ACOpenFile(timesFileName, "r", OPENOK); - - if (fp == NULL) - return FALSE; - - /* Read and check the file preamble */ - if (fscanf(fp, "%%%% File %s\n", tmp) != 1) { - /* Try to read in old format */ - if (!readOldTimesFile(fp, convert, scale)) - goto error; - fclose(fp); - return TRUE; - } - - if (strcmp(tmp, timesFileName) || - fscanf(fp, "%%%% Version %s\n", tmp) != 1 || - strcmp(tmp, VERSION_1_0) || - fscanf(fp, "%%%% Created %*s %*s\n") != 0 || - fscanf(fp, "%%%% Length %d\n", &lines) != 1 || - fscanf(fp, "%%%% Header:\n") != 0) - goto error; - linesRead += 5; - - if (convert) { - /* Read and check .Converttimes header */ - int whole; - int frac; - - if (fscanf(fp, "Scale %d.%d\n", &whole, &frac) != 2 || - whole != (int)scale || - frac != (int)((scale - (int)scale) * 1000.0)) - goto error; - linesRead += 1; - } else { /* Read and check .ACtimes header */ - if (fscanf(fp, "FlexOK %s\n", tmp) != 1 || - strcmp(tmp, (flexOK) ? "true" : "false") || - !compareArrays(fp, "HStems", NumHStems, HStems) || - !compareArrays(fp, "VStems", NumVStems, VStems) || - !compareArrays(fp, "BotBands", lenBotBands, botBands) || - !compareArrays(fp, "TopBands", lenTopBands, topBands) || - !fgets(HCounterLine, MAX_TEXT_LINE, fp) || - !fgets(VCounterLine, MAX_TEXT_LINE, fp)) - goto error; - linesRead += 7; - } - - if (fscanf(fp, "%%%% File Timestamps:\n") != 0) - goto error; - linesRead += 1; - - /* Read all of the file times */ - if (!readFileTimes(fp, lines - linesRead)) - goto error; - - /* Now check the checksum */ - if (fscanf(fp, "%%%% Checksum %hx\n", &chksum) != 1 || - chksum != calcChksum(fp, lines)) - goto error; - - if (!convert && - (!compareCounterLists("HCounterChars", HCounterLine, NumHColors, - &HColorList[COUNTERDEFAULTENTRIES]) || - !compareCounterLists("VCounterChars", VCounterLine, NumVColors, - &VColorList[COUNTERDEFAULTENTRIES]))) - goto error; - - fclose(fp); - return TRUE; - -error: /* Just tidy up and return. Yes I've used a goto! I think this is */ - /* one of the few legitimate uses. */ - fclose(fp); -#if DOMEMCHECK - memck_free(oldFileTimes); -#else - UnallocateMem(oldFileTimes); -#endif - oldFileCnt = 0; - return FALSE; -#endif -} - -/* Try to read old format, version 10 or 11, timestamp file. This - * function is very careful about how the numbers in the old file - * are read so as not to introduce byte swapping errors since we - * may not be running on a 680X0 machine. It does assume that - * the file was generated on a 680X0 processor and that the - * objects are therefore 2-byte aligned. This is not an unreasonable - * assumption since BuildFont has not be available on any other - * platform previously and this ASCII timestamp version will be - * the first ported version. - */ -private -boolean readOldTimesFile( - FILE* fp, /* Timestamp file pointer */ - boolean convert, /* Flags if reading .Converttimes */ - float scale /* Conversion scale */) { -#if IS_LIB -#pragma unused(fp) -#pragma unused(convert) -#pragma unused(scale) -#else - - long version; - char buf[MAX_TEXT_LINE]; - long offset; - int counterListLen; - int HCounterCnt; - int VCounterCnt; - float s = (float)scale; - - rewind(fp); - - version = get32(fp); - if (version != VERSION10 && version != VERSION11) - return FALSE; /* Not a valid file */ - - offset = get16(fp); /* File times offset */ - - if (convert) - /* Read and check .Converttimes file */ - return version == VERSION11 && get32(fp) == acpflttofix(&s) && - readFileTimesData(fp, offset); - - /* Read and check .ACtimes file */ - if (get32(fp) != flexOK || - get16(fp) != NumHStems || get16(fp) != NumVStems || - get16(fp) != lenBotBands || get16(fp) != lenTopBands) - return FALSE; - if (version == VERSION11) { - VCounterCnt = get16(fp); /* V before H for some reason */ - HCounterCnt = get16(fp); - } - if (!compareData(fp, NumHStems, HStems) || - !compareData(fp, NumVStems, VStems) || - !compareData(fp, lenBotBands, botBands) || - !compareData(fp, lenTopBands, topBands)) - return FALSE; - - counterListLen = offset - ftell(fp); - if (version == VERSION11 && counterListLen) - if (fread(buf, counterListLen, 1, fp) != 1) - return FALSE; - - if (!readFileTimesData(fp, offset)) - return FALSE; - - if (version == VERSION11) { - char* cp = buf; - - return compareCounterListData(VCounterCnt, &cp, NumVColors, - &VColorList[COUNTERDEFAULTENTRIES]) && - compareCounterListData(HCounterCnt, &cp, NumHColors, - &HColorList[COUNTERDEFAULTENTRIES]); - } else -#endif - return TRUE; -} - -/* Get 16-bit number from stream, assumes hi-byte lo-address ordering. - */ -private -int get16(FILE* fp) { - int hi = getc(fp) & 0xff; - int lo = getc(fp) & 0xff; - - return (hi << 8) | lo; -} - -/* Get 32-bit number from stream, assumes hi-byte lo-address ordering. - */ -private -int get32(FILE* fp) { - int b3 = getc(fp) & 0xff; - int b2 = getc(fp) & 0xff; - int b1 = getc(fp) & 0xff; - int b0 = getc(fp) & 0xff; - - return (b3 << 24) | (b2 << 16) | (b1 << 8) | b0; -} - -/* Reads an array of numbers in old format from the timestamp file - * and compares them with an array derived from the fontinfo file (in memory). - */ -private -boolean compareData( - FILE* fp, /* Timestamp file pointer */ - long len, /* Array length */ - Fixed a[] /* Array */) { - int i; - - for (i = 0; i < len; i++) - if (get32(fp) != a[i]) - return FALSE; - - return TRUE; -} - -/* Read the old format file times data. - */ -private -boolean readFileTimesData( - FILE* fp, /* Timestamp file pointer */ - long offset /* File times offset */) { -#if IS_LIB -#pragma unused(fp) -#pragma unused(offset) -#else - int i; - int len; - short nextName = nextFree - nameBuf; /* Remember first name position */ - - fseek(fp, offset, L_SET); /* Seek to file times */ - for (oldFileCnt = 0; (len = get16(fp)) && !feof(fp); oldFileCnt++) { - int nameLen; - char name[MAXCHARNAME]; - char* p = name; - - (void)get32(fp); /* Discard modification time */ - - while (*p++ = getc(fp)) /* Read the name */ - ; - - nameLen = p - name; - if (nameLen & 1) { - (void)getc(fp); /* Read the odd byte */ - nameLen++; - } - - if (len != 2 + 4 + nameLen) - return FALSE; /* Format error */ - - (void)storeName(name); - } - - oldFileTimes = (fileTime*)allocate(oldFileCnt, sizeof(fileTime)); - - fseek(fp, offset, L_SET); /* Re-seek to file times */ - for (i = 0; i < oldFileCnt; i++) { - len = get16(fp); - - oldFileTimes[i].modTime = get32(fp); - oldFileTimes[i].nameIndx = nextName; - nextName += strlen(INDX_PTR(nextName)) + 1; - - fseek(fp, len - (2 + 4), L_INCR); /* Skip over name */ - } -#endif - return TRUE; -} - -/* Scans the old format counter list input data (which was read earlier) - * and marks the character names. These are then compared with a list - * derived from the fontinfo file (in memory). Names not in the - * intersection of these lists are marked for rehinting. - */ -private -boolean compareCounterListData( - int nameCnt, /* Number of names in the counter list */ - char** cp, /* Counter list */ - long len, /* List length */ - char* list[] /* The list */) { - char* names[COUNTER_EXTRA_ENTRIES]; - int i; - - for (i = 0; i < nameCnt; i++) { - names[i] = *cp; - *cp += strlen(*cp) + 1; - } - - return compareLists(nameCnt, names, len, list); -} - -/* Reads an array of numbers inside square brackets from the - * timestamp file and compares them with an array derived from - * the fontinfo file (in memory). - */ -private -boolean compareArrays( - FILE* fp, /* Timestamp file pointer */ - char* name, /* Array name */ - long len, /* Array length */ - Fixed a[] /* Array */) { - char fmt[MAX_TEXT_LINE]; - int i; - - sprintf(fmt, "%s [", name); /* Make format string with array name */ - if (fscanf(fp, fmt)) /* Read the beginning of the line */ - return FALSE; - - for (i = 0; i < len; i++) { - int val; - - if (fscanf(fp, "%d ", &val) != 1 || FixInt(val) != a[i]) - return FALSE; - } - - return !fscanf(fp, "]\n"); /* Read the rest of the line */ -} - -/* Reads the file times from the timestamp file. - */ -private -boolean readFileTimes( - FILE* fp, /* Timestamp file pointer */ - int timeCnt /* Number of times to read */) { - int i; - - oldFileTimes = (fileTime*)allocate(timeCnt, sizeof(fileTime)); - - for (i = 0; i < timeCnt; i++) { - char name[MAXFILENAME]; - struct tm tm; - - if (fscanf(fp, "(%d/%d/%d %d:%d:%d) %s\n", - &tm.tm_mon, &tm.tm_mday, &tm.tm_year, - &tm.tm_hour, &tm.tm_min, &tm.tm_sec, name) != 7) - return FALSE; - - tm.tm_mon--; /* Because it's stored 0-11!, see ctime(3) */ - oldFileTimes[i].nameIndx = storeName(name); - oldFileTimes[i].modTime = mktime(&tm); - } - - oldFileCnt = timeCnt; - - return TRUE; -} - -/* Scans the counter list input line (which was read earlier) and marks - * and counts the character names. These are then compared with a list - * derived from the fontinfo file (in memory). Names not in the - * intersection of these lists are marked for rehinting. - */ -private -boolean compareCounterLists( - char* listName, /* List name */ - char line[], /* Input line */ - long len, /* List length */ - char* list[] /* The list */) { - char label[64]; - char* names[COUNTER_EXTRA_ENTRIES]; - char* startp; - int nameCnt; - int labelLen; - - sprintf(label, "%s (", listName); /* Make label string with list name */ - labelLen = strlen(label); - if (strncmp(line, label, labelLen)) - return FALSE; - - /* Locate all the names */ - startp = line + labelLen; - for (nameCnt = 0; nameCnt < COUNTER_EXTRA_ENTRIES; - nameCnt++, startp = NULL) - if (!(names[nameCnt] = (char*)strtok(startp, " )\n"))) - break; - - return compareLists(nameCnt, names, len, list); -} - -/* Actually does the work of comparing the counter lists together. - */ -private -boolean compareLists( - int nameCnt, /* Items in names */ - char* names[], /* Name list */ - long len, /* List length */ - char* list[] /* The list */) { - int i; - - if (nameCnt == 0 && len == 0) - return TRUE; /* Nothing to do */ - - for (i = nameCnt; i < COUNTER_EXTRA_ENTRIES; i++) - names[i] = NULL; /* Clear unused entries */ - - for (i = 0; i < len; i++) { - int j; - - for (j = 0; j < nameCnt; j++) - if (!names[j]) - continue; - else if (!strcmp(names[j], list[i])) { - /* Character name in both lists so remove it */ - - names[j] = NULL; - break; - } - - if (j == nameCnt) { - /* Character name not found so force rehinting */ - fileTime* p = findName(list[i], oldFileCnt, oldFileTimes); - - if (p) - p->modTime = 0; - else { - sprintf(globmsg, "Cannot find counter hints character \"%s\" in current %s file.\n", - list[i], AC_NAME); - LogMsg(globmsg, WARNING, OK, TRUE); - } - } - } - - /* Force remaining characters to be rehinted */ - for (i = 0; i < nameCnt; i++) - if (names[i]) { - fileTime* p = findName(names[i], oldFileCnt, oldFileTimes); - - if (p) - p->modTime = 0; - /* OK if character not found in this situation */ - } - - return TRUE; -} - -/* Copies old times list (read from timestamp file) to new - * times list if the name can be found in the new list. - */ -private -void copyTimes() { - int i; - fileTime* op = oldFileTimes; - - for (i = 0; i < oldFileCnt; i++, op++) { - fileTime* np = findName(INDX_PTR(op->nameIndx), - newFileCnt, newFileTimes); - if (np) - np->modTime = op->modTime; - } -} - -/* Searches the specified table for the specified name. - */ -private -fileTime* findName( - char* name, /* Search name */ - int cnt, /* Number of names in table */ - fileTime* table /* Table to search */) { - fileTime ft; - - if (!cnt) - return NULL; - - /* Copy the string to reserved area */ - ft.nameIndx = 0; - strncpy(INDX_PTR(ft.nameIndx), name, MAXCHARNAME - 1); - - return (fileTime*)bsearch((char*)&ft, (char*)table, cnt, - sizeof(fileTime), cmpNames); -} - -/* Updates a file's time by reading the new time from - * the file on disk. - */ -private -void updateTime( - fileTime* p, /* Record to update */ - const char* dirName /* Directory name */) { -#if IS_LIB -#pragma unused(p) -#pragma unused(dirName) -#else - if (p) { - char charFile[MAXPATHLEN]; - struct stat s; -#ifdef __MWERKS__ - sprintf(charFile, ":%s:%s", dirName, INDX_PTR(p->nameIndx)); -#else - sprintf(charFile, "%s\\%s", dirName, INDX_PTR(p->nameIndx)); -#endif - if (!stat(charFile, &s)) - p->modTime = s.st_mtime; - } -#endif -} - -/* Scan all the files and hints the bez files that have changed. - * Called by AC and BuildFont for rehinting whole font. - */ -public -boolean DoAll( - boolean extraColor, - boolean release, /* Flags release version */ - boolean* renameLog, - boolean quiet) { -#ifdef IS_GGL - return FALSE; -#else - boolean result = TRUE; - - if (release) { - if (!readCharSet()) { - freeFileTimes(); - return FALSE; - } - } else - readInputDir(BEZDIR, FALSE); - - readTimesFile(FALSE, 0.0); - result = compareTimes(extraColor, release, renameLog, quiet); - writeTimesFile(FALSE, 0.0); - - freeFileTimes(); - - return result; -#endif -} - -/* Converts characters that have changed since the last run - * of BuildFont in the bez directory. - */ -private -boolean compareTimes( - boolean extraColor, - boolean release, /* Flags release version */ - boolean* renameLog, - boolean quiet) { - boolean result = TRUE; - boolean printStatus = TRUE; - int charCnt = 0; - fileTime* newp; - - for (newp = newFileTimes; newp - newFileTimes < newFileCnt; newp++) { - fileTime* oldp; - - newp = checkFile(&oldp, newp, BEZDIR); - if (newp == NULL) - break; - else if (release) { - sprintf(globmsg, "The %s character has out of date hints.\n Add hints again before creating a release version.\n", INDX_PTR(newp->nameIndx)); - LogMsg(globmsg, LOGERROR, OK, TRUE); - - if (oldp) - newp->modTime = oldp->modTime; - - result = FALSE; - } else if (DoFile(INDX_PTR(newp->nameIndx), extraColor)) { - if (printStatus) { - if (!quiet) { - sprintf(globmsg, "Adding hints %s... ", - (extraColor) ? "" : "(single layer) "); - LogMsg(globmsg, INFO, OK, FALSE); - } - printStatus = FALSE; - } - *renameLog = TRUE; - charCnt++; - updateTime(newp, BEZDIR); - } - } - - if (!quiet && !release && charCnt > 0) { - LogMsg(globmsg, INFO, OK, FALSE); - } - - return result; -} - -/* The character names/filenames in the name list are checked. If - * the circumstances have changed since the last timestamp file was - * generated the function returns so that the character can be rehinted. - * If the circumstances have stayed the same the file time is simply copied - * and the scan continues. Returns NULL when the list is exhausted. - */ -private -fileTime* checkFile( - fileTime** oldp, /* Old file time */ - fileTime* newp, /* File time to check from */ - const char* inputDir /* Conversion input directory */) { -#if IS_LIB -#pragma unused(oldp) -#pragma unused(newp) -#pragma unused(inputDir) -#else - for (; newp - newFileTimes < newFileCnt; newp++) { - char inFile[MAXPATHLEN]; - char* name = INDX_PTR(newp->nameIndx); - struct stat s; -#ifdef __MWERKS__ - sprintf(inFile, ":%s:%s", inputDir, name); -#else - sprintf(inFile, "%s\\%s", inputDir, name); -#endif - if (!stat(inFile, &s)) { - char bezFile[MAXPATHLEN]; - time_t newTime = s.st_mtime; - - *oldp = findName(name, oldFileCnt, oldFileTimes); - -#ifdef __MWERKS__ - sprintf(bezFile, ":%s:%s", BEZDIR, name); -#else - sprintf(bezFile, "%s\\%s", BEZDIR, name); -#endif - if ((*oldp == NULL) || - ((newTime != (*oldp)->modTime) && (strcmp(name, ".notdef") != 0)) || - !FileExists(bezFile, FALSE)) - /* The name wasn't in the old timestamp file or the - * file time has changed or the bez file doesn't - * exist or has the wrong permissions. - */ - return newp; - else - newp->modTime = (*oldp)->modTime; - } - } -#endif - return NULL; -} - -/* Converts characters that have changed since the last run of - * BuildFont from the specified input directory using - * the specified conversion function. Called by BuildFont -o when - * ill/ or pschars/ characters exist and may need converting. - */ -public -boolean ConvertCharFiles(char* inputDir, /* Coversion input directory */ - boolean release, /* Flags release version */ - float scale, /* Conversion scale */ - tConvertfunc convertFunc /* Conversion function */ -) { - boolean result = FALSE; - - if (release) - readCharList(); - else - readInputDir(inputDir, TRUE); - - readTimesFile(TRUE, scale); - result = compareCvtTimes(inputDir, release, convertFunc); - writeTimesFile(TRUE, scale); - - freeFileTimes(); - - return result; -} - -/* Reads through the charset file and builds a list of character/filenames. - */ -private -void readCharList() { - char fName[MAXFILENAME + 4]; - int i; - boolean start = TRUE; - short nextName = nextFree - nameBuf; /* Remember first name position */ - - for (newFileCnt = 0; ReadCharFileNames(fName, &start); newFileCnt++) - (void)storeName(fName); - - newFileTimes = (fileTime*)allocate(newFileCnt, sizeof(fileTime)); - - for (i = 0; i < newFileCnt; i++) { - newFileTimes[i].nameIndx = nextName; - nextName += strlen(INDX_PTR(nextName)) + 1; - } - - sortFileTimes(newFileCnt, newFileTimes); -} - -/* Converts characters that have changed since the last run - * of BuildFont from the input to the bez directory. - */ -private -boolean compareCvtTimes(char* inputDir, boolean release, tConvertfunc convertFunc) { - boolean result = TRUE; - fileTime* newp; - fileTime* oldp; - - for (newp = newFileTimes; newp - newFileTimes < newFileCnt; newp++) { - newp = checkFile(&oldp, newp, inputDir); - if (!newp) - break; - else if (release) { - sprintf(globmsg, "The %s character needs to be converted.\n Convert before creating a release version.\n", INDX_PTR(newp->nameIndx)); - LogMsg(globmsg, LOGERROR, OK, TRUE); - - if (oldp) - newp->modTime = oldp->modTime; - - result = FALSE; - } else { - (*convertFunc)(INDX_PTR(newp->nameIndx), INDX_PTR(newp->nameIndx)); - updateTime(newp, inputDir); - } - } - return result; -} diff --git a/c/autohint/autohintlib/source/ac/write.c b/c/autohint/autohintlib/source/ac/write.c deleted file mode 100644 index a2226dec1..000000000 --- a/c/autohint/autohintlib/source/ac/write.c +++ /dev/null @@ -1,671 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* write.c */ - -#include "ac.h" -#include "cryptdefs.h" -#include "fipublic.h" -#include "machinedep.h" -#include - -#define WRTABS_COMMENT (0) - -FILE *outputfile; -Fixed currentx, currenty; -boolean firstFlex, wrtColorInfo; -char S0[128]; -PClrPoint bst; -PClrPoint prv_bst; -char bch; -Fixed bx, by; -boolean bstB; -short subpathcount; -extern char *bezoutput; -extern int bezoutputalloc; -extern int bezoutputactual; - -#define ws(str) WriteString(str) -public -int writeAbsolute = 1; - -public -long int FRnd(long int x) { - /* This is meant to work on Fixed 24.8 values, not the elt path (x,y) which are 25.7 */ - long int r; - r = x; - if (roundToInt) { - r = r + (1 << 7); - r = r & ~0xFFL; - } - return r; -} - -/* returns the number of characters written and possibly encrypted*/ -static long WriteString(char *str) { - if (bezoutput) { - if ((bezoutputactual + (int)strlen(str)) >= bezoutputalloc) { - int desiredsize = MAX(bezoutputalloc * 2, (bezoutputalloc + (int)strlen(str))); -#if DOMEMCHECK - bezoutput = (char *)memck_realloc(bezoutput, desiredsize); -#else - bezoutput = (char *)ACREALLOCMEM(bezoutput, desiredsize); -#endif - if (bezoutput) { - bezoutputalloc = desiredsize; - } else { - return (-1); /*FATAL ERROR*/ - } - } - strcat(bezoutput, str); - bezoutputactual += (int)strlen(str); - return (long)strlen(str); - } else { - return DoContEncrypt((char *)str, outputfile, FALSE, (unsigned long)INLEN); - } -} - -/* Note: The 8 bit fixed fraction cannot support more than 2 decimal p;laces. */ -#define WRTNUM(i) \ - { \ - sprintf(S0, "%ld ", (long int)(i)); \ - ws(S0); \ - } - -#define WRTRNUM(i) \ - { \ - sprintf(S0, "%0.2f ", roundf((float)(i)*100) / 100); \ - ws(S0); \ - } - -static void wrtfx(Fixed f) { - if ((roundToInt) || (FracPart(f) == 0)) { - Fixed i = FRnd(f); - WRTNUM(FTrunc(i)); - } else { - float r = (float)FIXED2FLOAT(f); - WRTRNUM(r); - } -} - -static void wrtx(Fixed x) { - Fixed i; - Fixed dx; - if ((roundToInt) || (FracPart(x) == 0)) { - i = FRnd(x); - dx = i - currentx; - WRTNUM(FTrunc(dx)); - currentx = i; - } else { - float r; - i = x - currentx; - currentx = x; - r = (float)FIXED2FLOAT(i); - WRTRNUM(r); - } -} - -static void wrtxa(Fixed x) { - Fixed i; - if ((roundToInt) || (FracPart(x) == 0)) { - i = FRnd(x); - WRTNUM(FTrunc(i)); - currentx = i; - } else { - float r; - currentx = x; - r = (float)FIXED2FLOAT(x); - WRTRNUM(r); - } -} - -static void wrty(Fixed y) { - Fixed i; - Fixed dy; - if ((roundToInt) || (FracPart(y) == 0)) { - i = FRnd(y); - dy = i - currenty; - WRTNUM(FTrunc(dy)); - currenty = i; - } else { - float r; - i = y - currenty; - currenty = y; - r = (float)FIXED2FLOAT(i); - WRTRNUM(r); - } -} - -static void wrtya(Fixed y) { - Fixed i; - if ((roundToInt) || (FracPart(y) == 0)) { - i = FRnd(y); - WRTNUM(FTrunc(i)); - currenty = i; - } else { - float r; - currenty = y; - r = (float)FIXED2FLOAT(y); - WRTRNUM(r); - } -} - -#define wrtcd(c) \ - wrtx(c.x); \ - wrty(c.y) - -#define wrtcda(c) \ - wrtxa(c.x); \ - wrtya(c.y) - -/*To avoid pointless hint subs*/ -#define HINTMAXSTR 2048 -static char hintmaskstr[HINTMAXSTR]; -static char prevhintmaskstr[HINTMAXSTR]; - -void safestrcat(char *s1, char *s2) { - if (strlen(s1) + strlen(s2) + 1 > HINTMAXSTR) { - sprintf(S0, "ERROR: Hint information overflowing buffer: %s\n", fileName); - LogMsg(S0, LOGERROR, FATALERROR, TRUE); - } else { - strcat(s1, s2); - } -} - -#define sws(str) safestrcat(hintmaskstr, (char *)str) - -#define SWRTNUM(i) \ - { \ - sprintf(S0, "%ld ", (long int)(i)); \ - sws(S0); \ - } - -#define SWRTNUMA(i) \ - { \ - sprintf(S0, "%0.2f ", roundf((float)(i)*100) / 100); \ - sws(S0); \ - } - -static void NewBest(PClrPoint lst) { - Fixed x0, x1, y0, y1; - bst = lst; - bch = lst->c; - if (bch == 'y' || bch == 'm') { - bstB = TRUE; - x0 = lst->x0; - x1 = lst->x1; - bx = MIN(x0, x1); - } else { - bstB = FALSE; - y0 = lst->y0; - y1 = lst->y1; - by = MIN(y0, y1); - } -} - -static void WriteOne(Fixed s) { /* write s to output file */ - Fixed r = UnScaleAbs(s); - if (scalinghints) { - r = FRnd(r); - } - if (FracPart(r) == 0) { - SWRTNUM(FTrunc(r)) - } else { - float d = (float)FIXED2FLOAT(r); - if (writeAbsolute) { - SWRTNUMA(d); - } else { - d = (float)((d + 0.005) * 100); - SWRTNUM(d); - sws("100 div "); - } - } -} - -static void WritePointItem(PClrPoint lst) { - switch (lst->c) { - case 'b': - case 'v': - WriteOne(lst->y0); - WriteOne(lst->y1 - lst->y0); - sws(((lst->c == 'b') ? "rb" : "rv")); - break; - case 'y': - case 'm': - WriteOne(lst->x0); - WriteOne(lst->x1 - lst->x0); - sws(((lst->c == 'y') ? "ry" : "rm")); - break; - default: { - sprintf(S0, "Illegal point list data for file: %s.\n", - fileName); - LogMsg(S0, LOGERROR, NONFATALERROR, TRUE); - } - } - sws(" % "); - SWRTNUM(lst->p0 != NULL ? lst->p0->count : 0); - SWRTNUM(lst->p1 != NULL ? lst->p1->count : 0); - sws("\n"); -} - -static void WrtPntLst(PClrPoint lst) { - PClrPoint ptLst; - char ch; - Fixed x0, x1, y0, y1; - ptLst = lst; - - while (lst != NULL) { /* mark all as not yet done */ - lst->done = FALSE; - lst = lst->next; - } - while (TRUE) { /* write in sort order */ - lst = ptLst; - bst = NULL; - while (lst != NULL) { /* find first not yet done as init best */ - if (!lst->done) { - NewBest(lst); - break; - } - lst = lst->next; - } - if (bst == NULL) { - break; /* finished with entire list */ - } - lst = bst->next; - while (lst != NULL) { /* search for best */ - if (!lst->done) { - ch = lst->c; - if (ch > bch) { - NewBest(lst); - } else if (ch == bch) { - if (bstB) { - x0 = lst->x0; - x1 = lst->x1; - if (MIN(x0, x1) < bx) { - NewBest(lst); - } - } else { - y0 = lst->y0; - y1 = lst->y1; - if (MIN(y0, y1) < by) { - NewBest(lst); - } - } - } - } - lst = lst->next; - } - bst->done = TRUE; /* mark as having been done */ - WritePointItem(bst); - } -} - -static void wrtnewclrs(PPathElt e) { - if (!wrtColorInfo) { - return; - } - hintmaskstr[0] = '\0'; - WrtPntLst(ptLstArray[e->newcolors]); - if (strcmp(prevhintmaskstr, hintmaskstr)) { - ws("beginsubr snc\n"); - ws(hintmaskstr); - ws("endsubr enc\nnewcolors\n"); - strcpy(prevhintmaskstr, hintmaskstr); - } -} - -boolean IsFlex(PPathElt e) { - PPathElt e0, e1; - if (firstFlex) { - e0 = e; - e1 = e->next; - } else { - e0 = e->prev; - e1 = e; - } - return (e0 != NULL && e0->isFlex && e1 != NULL && e1->isFlex); -} - -static void mt(Cd c, PPathElt e) { - if (e->newcolors != 0) { - wrtnewclrs(e); - } - if (writeAbsolute) { - wrtcda(c); - ws("mt\n"); - } else { - if (FRnd(c.y) == currenty) { - wrtx(c.x); - ws("hmt\n"); - } else if (FRnd(c.x) == currentx) { - wrty(c.y); - ws("vmt\n"); - } else { - wrtcd(c); - ws("rmt\n"); - } - } - if (e->eol) { - ws("eol\n"); - } - if (e->sol) { - ws("sol\n"); - } -} - -static void dt(Cd c, PPathElt e) { - if (e->newcolors != 0) { - wrtnewclrs(e); - } - if (writeAbsolute) { - wrtcda(c); - ws("dt\n"); - } else { - if (FRnd(c.y) == currenty) { - wrtx(c.x); - ws("hdt\n"); - } else if (FRnd(c.x) == currentx) { - wrty(c.y); - ws("vdt\n"); - } else { - wrtcd(c); - ws("rdt\n"); - } - } - if (e->eol) { - ws("eol\n"); - } - if (e->sol) { - ws("sol\n"); - } -} - -Fixed flX, flY; -Cd fc1, fc2, fc3; - -#define wrtpreflx2(c) \ - wrtcd(c); \ - ws("rmt\npreflx2\n") - -#define wrtpreflx2a(c) \ - wrtcda(c); \ - ws("rmt\npreflx2a\n") - -static void wrtflex(Cd c1, Cd c2, Cd c3, PPathElt e) { - integer dmin, delta; - boolean yflag; - Cd c13; - real shrink, r1, r2; - if (firstFlex) { - flX = currentx; - flY = currenty; - fc1 = c1; - fc2 = c2; - fc3 = c3; - firstFlex = FALSE; - return; - } - yflag = e->yFlex; - dmin = DMIN; - delta = DELTA; - ws("preflx1\n"); - if (yflag) { - if (fc3.y == c3.y) { - c13.y = c3.y; - } else { - acfixtopflt(fc3.y - c3.y, &shrink); - shrink = (real)delta / shrink; - if (shrink < 0.0) { - shrink = -shrink; - } - acfixtopflt(fc3.y - c3.y, &r1); - r1 *= shrink; - acfixtopflt(c3.y, &r2); - r1 += r2; - c13.y = acpflttofix(&r1); - } - c13.x = fc3.x; - } else { - if (fc3.x == c3.x) { - c13.x = c3.x; - } else { - acfixtopflt(fc3.x - c3.x, &shrink); - shrink = (real)delta / shrink; - if (shrink < 0.0) { - shrink = -shrink; - } - acfixtopflt(fc3.x - c3.x, &r1); - r1 *= shrink; - acfixtopflt(c3.x, &r2); - r1 += r2; - c13.x = acpflttofix(&r1); - } - c13.y = fc3.y; - } - - if (writeAbsolute) { - wrtpreflx2a(c13); - wrtpreflx2a(fc1); - wrtpreflx2a(fc2); - wrtpreflx2a(fc3); - wrtpreflx2a(c1); - wrtpreflx2a(c2); - wrtpreflx2a(c3); - currentx = flX; - currenty = flY; - wrtcda(fc1); - wrtcda(fc2); - wrtcda(fc3); - wrtcda(c1); - wrtcda(c2); - wrtcda(c3); - WRTNUM(dmin); - WRTNUM(delta); - WRTNUM(yflag); - WRTNUM(FTrunc(FRnd(currentx))); - WRTNUM(FTrunc(FRnd(currenty))); - ws("flxa\n"); - } else { - wrtpreflx2(c13); - wrtpreflx2(fc1); - wrtpreflx2(fc2); - wrtpreflx2(fc3); - wrtpreflx2(c1); - wrtpreflx2(c2); - wrtpreflx2(c3); - currentx = flX; - currenty = flY; - wrtcd(fc1); - wrtcd(fc2); - wrtcd(fc3); - wrtcd(c1); - wrtcd(c2); - wrtcd(c3); - WRTNUM(dmin); - WRTNUM(delta); - WRTNUM(yflag); - WRTNUM(FTrunc(FRnd(currentx))); - WRTNUM(FTrunc(FRnd(currenty))); - ws("flx\n"); - } - firstFlex = TRUE; -} - -static void ct(Cd c1, Cd c2, Cd c3, PPathElt e) { - if (e->newcolors != 0) { - wrtnewclrs(e); - } - if (e->isFlex && IsFlex(e)) { - wrtflex(c1, c2, c3, e); - } else if (writeAbsolute) { - wrtcda(c1); - wrtcda(c2); - wrtcda(c3); - ws("ct\n"); - } else { - if ((FRnd(c1.x) == currentx) && (c2.y == c3.y)) { - wrty(c1.y); - wrtcd(c2); - wrtx(c3.x); - ws("vhct\n"); - } else if ((FRnd(c1.y) == currenty) && (c2.x == c3.x)) { - wrtx(c1.x); - wrtcd(c2); - wrty(c3.y); - ws("hvct\n"); - } else { - wrtcd(c1); - wrtcd(c2); - wrtcd(c3); - ws("rct\n"); - } - } - if (e->eol) { - ws("eol\n"); - } - if (e->sol) { - ws("sol\n"); - } -} - -static void cp(PPathElt e) { - if (e->newcolors != 0) { - wrtnewclrs(e); - } - if (idInFile) { - WRTNUM(subpathcount++); - ws("id\n"); - } - ws("cp\n"); - if (e->eol) { - ws("eol\n"); - } - if (e->sol) { - ws("sol\n"); - } -} - -static void NumberPath() { - register short int cnt; - register PPathElt e; - e = pathStart; - cnt = 1; - while (e != NULL) { - e->count = cnt++; - e = e->next; - } -} - -void SaveFile() { - register PPathElt e = pathStart; - Cd c1, c2, c3; - char outfile[MAXPATHLEN], tempfilename[MAXPATHLEN]; -/* AddSolEol(); */ -#ifdef IS_LIB - if (bezoutput) { - outputfile = NULL; - } else { -#endif - sprintf(tempfilename, "%s%s", outPrefix, TEMPFILE); - outputfile = ACOpenFile(tempfilename, "wb", OPENWARN); - if (outputfile == NULL) { - return; - } - subpathcount = 1; -#ifdef IS_LIB - } -#endif -#ifdef ENCRYPTOUTPUT - DoInitEncrypt(outputfile, OTHER, HEX, 64L, FALSE); -#endif - sprintf(S0, "%% %s\n", fileName); - ws(S0); - wrtColorInfo = (pathStart != NULL && pathStart != pathEnd); - NumberPath(); - prevhintmaskstr[0] = '\0'; - if (wrtColorInfo && (!e->newcolors)) { - hintmaskstr[0] = '\0'; - WrtPntLst(ptLstArray[0]); - ws(hintmaskstr); - strcpy(prevhintmaskstr, hintmaskstr); - } - - ws("sc\n"); - firstFlex = TRUE; - currentx = currenty = 0L; - while (e != NULL) { - switch (e->type) { - case CURVETO: - c1.x = UnScaleAbs(itfmx(e->x1)); - c1.y = UnScaleAbs(itfmy(e->y1)); - c2.x = UnScaleAbs(itfmx(e->x2)); - c2.y = UnScaleAbs(itfmy(e->y2)); - c3.x = UnScaleAbs(itfmx(e->x3)); - c3.y = UnScaleAbs(itfmy(e->y3)); - ct(c1, c2, c3, e); - break; - case LINETO: - c1.x = UnScaleAbs(itfmx(e->x)); - c1.y = UnScaleAbs(itfmy(e->y)); - dt(c1, e); - break; - case MOVETO: - c1.x = UnScaleAbs(itfmx(e->x)); - c1.y = UnScaleAbs(itfmy(e->y)); - mt(c1, e); - break; - case CLOSEPATH: - cp(e); - break; - default: { - sprintf(S0, "Illegal path list for file: %s.\n", fileName); - LogMsg(S0, LOGERROR, NONFATALERROR, TRUE); - } - } -#if WRTABS_COMMENT - ws(" % "); - WRTNUM(e->count) - switch (e->type) { - case CURVETO: - wrtfx(c1.x); - wrtfx(c1.y); - wrtfx(c2.x); - wrtfx(c2.y); - wrtfx(c3.x); - wrtfx(c3.y); - ws("ct"); - break; - case LINETO: - wrtfx(c1.x); - wrtfx(c1.y); - ws("dt"); - break; - case MOVETO: - wrtfx(c1.x); - wrtfx(c1.y); - ws("mt"); - break; - case CLOSEPATH: - ws("cp"); - break; - } - ws("\n"); -#endif - e = e->next; - } - ws("ed\n"); -#ifdef ISLIB - fclose(outputfile); -#endif - -#ifndef IS_LIB - if (featurefiledata) { - sprintf(outfile, "%s", fileName); - } else { -#endif - sprintf(outfile, "%s%s", outPrefix, fileName); -#ifndef IS_LIB - } - RenameFile(tempfilename, outfile); -#endif -} diff --git a/c/autohint/autohintlib/source/actest/AC_C_libtest.c b/c/autohint/autohintlib/source/actest/AC_C_libtest.c deleted file mode 100644 index 597c6b279..000000000 --- a/c/autohint/autohintlib/source/actest/AC_C_libtest.c +++ /dev/null @@ -1,82 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/* AC_C_libtest.c */ - -#include -#include -#include -#include "ac_C_lib.h" - -int main(int argc, char *argv[]) { - int result, i, actualsize, allocsize = 9096; - char returnvalue[9096], *current, source[9048], fontinfo[2048]; - FILE *file; - int c; - - file = fopen(argv[argc - 2], "r"); - if (!file) { - fprintf(stderr, "Couldn't open %s\n", argv[argc - 2]); - return 0; - } - current = source; - while ((c = fgetc(file)) != EOF) { - *current++ = (char)c; - } - *current = '\0'; - - fclose(file); - - file = fopen(argv[argc - 1], "r"); - if (!file) { - fprintf(stderr, "Couldn't open %s\n", argv[argc - 2]); - return 0; - } - current = fontinfo; - while ((c = fgetc(file)) != EOF) { - *current++ = (char)c; - } - *current = '\0'; - - fclose(file); - - actualsize = allocsize; - result = AutoColorString(NULL, fontinfo, returnvalue, &actualsize, 0); - printf("AutoColorString with NULL source returned %d and size %d\n", result, actualsize); - - actualsize = allocsize; - result = AutoColorString(source, NULL, returnvalue, &actualsize, 0); - printf("AutoColorString with NULL fontinfo returned %d and size %d\n", result, actualsize); - - actualsize = allocsize; - result = AutoColorString(NULL, NULL, returnvalue, &actualsize, 0); - printf("AutoColorString with NULL source and fontinfo returned %d and size %d\n", result, actualsize); - - actualsize = allocsize; - result = AutoColorString("", fontinfo, returnvalue, &actualsize, 0); - printf("AutoColorString with empty source returned %d and size %d\n", result, actualsize); - - actualsize = allocsize; - result = AutoColorString(source, "", returnvalue, &actualsize, 0); - printf("AutoColorString with empty fontinfo returned %d and size %d\n", result, actualsize); - - actualsize = allocsize; - result = AutoColorString("", "", returnvalue, &actualsize, 0); - printf("AutoColorString with empty source and fontinfo returned %d and size %d\n", result, actualsize); - - for (i = 0; i < 0; i++) { - actualsize = allocsize; - printf("Source size %d\n", strlen(source)); - result = AutoColorString(source, fontinfo, returnvalue, &actualsize, 0); - printf("AutoColorString returned %d and size %d\n", result, actualsize); - } - actualsize = allocsize; - printf("Source size %d\n", strlen(source)); - result = AutoColorString(source, fontinfo, returnvalue, &actualsize, 0); - printf("AutoColorString returned %d and size %d\n", result, actualsize); - if (!result) { - FILE *outfile = fopen("AC_test.bez", "w"); - fprintf(outfile, "%s", returnvalue); - fclose(outfile); - } - return 0; -} diff --git a/c/autohint/autohintlib/source/bf/afmcharsetdefs.h b/c/autohint/autohintlib/source/bf/afmcharsetdefs.h deleted file mode 100644 index cba981deb..000000000 --- a/c/autohint/autohintlib/source/bf/afmcharsetdefs.h +++ /dev/null @@ -1,24 +0,0 @@ - -#ifndef AFMCHARSETDEFS_H -#define AFMCHARSETDEFS_H - -#include - -#define AFMCHARSETTABLE "AFMcharset.tbl" - -struct FItoAFMCharSetMap { - struct FItoAFMCharSetMap *next; - char *fiName; - char *afmName; -}; - -struct AFMCharSetTbl { - char *defaultCSVal; - struct FItoAFMCharSetMap *charSetMap; -}; - -extern struct AFMCharSetTbl *AFMCharSet_Parse(FILE *file); -extern void FreeAFMCharSetTbl(); -extern char *GetFItoAFMCharSetName(void); - -#endif diff --git a/c/autohint/autohintlib/source/bf/basic.h b/c/autohint/autohintlib/source/bf/basic.h deleted file mode 100644 index 36cf5c491..000000000 --- a/c/autohint/autohintlib/source/bf/basic.h +++ /dev/null @@ -1,92 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* basic.h */ - -#ifndef BASIC_H -#define BASIC_H -#include -#include -#include "pubtypes.h" - -#if __MWERKS__ - -#ifndef __dead2 -#define __dead2 -#define __pure2 -#define __unused -#endif -#include - -#include -#include - -/*#include */ - -#else -#include -#include -#include -#include -#if OSX -#include -#else -#include -#endif -#include -typedef unsigned char boolean; -#endif - -#ifndef FALSE -#define FALSE 0 -#define TRUE 1 -#endif - -/* macro definitions */ -#define NUMMIN(a, b) ((a) <= (b) ? (a) : (b)) -#define NUMMAX(a, b) ((a) >= (b) ? (a) : (b)) -#ifdef ABS -#undef ABS -#endif -#define ABS(a) ((a) >= 0 ? (a) : -(a)) -/* Round the same way as PS. i.e. -6.5 ==> -6.0 */ -#define LROUND(a) ((a > 0) ? (long)(a + 0.5) : ((a + (long)(-a)) == -0.5) ? (long)a : (long)(a - 0.5)) -#define SCALEDRTOL(a, s) (a < 0 ? (long)((a * s) - 0.5) : (long)((a * s) + 0.5)) - -typedef int indx; /* for indexes that could be either short or */ - /* long - let the compiler decide */ - -#define RAWPSDIR "pschars" -#define ILLDIR "ill" -#define BEZDIR "bez" -#define UNSCALEDBEZ "bez.unscaled" -#define TMPDIR "._tmp" -#ifdef MAXPATHLEN -#undef MAXPATHLEN -#endif -#define MAXPATHLEN 1024 /* max path name len for a dir or folder */ - /* (includes 1 byte for null terminator) */ - -/* defines for LogMsg code param */ -#define OK 0 -#define NONFATALERROR 1 -#define FATALERROR 2 - -/* defines for LogMsg level param */ -#define INFO 0 -#define WARNING 1 -#define LOGERROR 2 - -#define MAXMSGLEN 500 /* maximum message length */ -extern char globmsg[MAXMSGLEN + 1]; /* used to format the string passed to LogMsg */ - -extern void LogMsg( - char *, short, short, boolean); - -extern short WarnCount( - void); - -extern void ResetWarnCount( - void); - -#endif /*BASIC_H*/ diff --git a/c/autohint/autohintlib/source/bf/bftoac.h b/c/autohint/autohintlib/source/bf/bftoac.h deleted file mode 100644 index 8dd30cc85..000000000 --- a/c/autohint/autohintlib/source/bf/bftoac.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* bftoac.h */ - -/* procedures in AC called from buildfont */ - -#ifndef BFTOAC_H -#define BFTOAC_H - -#include "memcheck.h" - -extern boolean AutoColor(boolean, boolean, boolean, boolean, boolean, short, char *[], boolean, boolean, boolean, boolean); - -extern boolean CreateACTimes(void); -typedef void (*tConvertfunc)(const char *, const char *); -extern boolean ConvertCharFiles(char *, boolean, float, tConvertfunc); - -extern void FindCurveBBox(Fixed, Fixed, Fixed, Fixed, Fixed, Fixed, Fixed, Fixed, Fixed *, Fixed *, Fixed *, Fixed *); - -extern boolean GetInflectionPoint(Fixed, Fixed, Fixed, Fixed, Fixed, Fixed, Fixed, Fixed, Fixed *); - -extern boolean ReadCharFileNames(char *, boolean *); - -extern void setPrefix(char *); - -extern void SetReadFileName(char *); - -#endif /*BFTOAC_H*/ diff --git a/c/autohint/autohintlib/source/bf/buildfont.h b/c/autohint/autohintlib/source/bf/buildfont.h deleted file mode 100644 index 1c4835cc0..000000000 --- a/c/autohint/autohintlib/source/bf/buildfont.h +++ /dev/null @@ -1,423 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ - -#include "basic.h" - -#ifndef BUILDFONT_H -#define BUILDFONT_H - -#ifdef EXECUTABLE -#define OUTPUTBUFF stdout -#else -#define OUTPUTBUFF stderr -#endif - -#define ASCIIFONTNAME "font.ps" -#define CHARSTRINGSFILENAME ".bfees.bin" -#define COMPAFMFILE ".bfcomposites.afm" -#define COMPFILE "composites.ps" -#define COMPOSITESFILENAME ".bfees2.bin" -#define DEFAULTWIDTH 500 -#define ENCFILENAME ".bfencodingfile" -#define FONTBBOXFILENAME ".bffontbbox" -#define FONTSTKLIMIT 22 -/*****************************************/ -/* font interpreter stack limit - Note */ -/* that the actual limit is 24, but */ -/* because the # of parameters and */ -/* callothersubr # are also pushed on */ -/* the stack, the effective value is 22. */ -/*****************************************/ -#define INTEGER 0 -#define KERNAFMFILE "kerning.afm" -#define MAXBYTES 13000 -/*****************************************/ -/* max number of bytes in a decrypted */ -/* bez file or encoded charstring */ -/*****************************************/ -#define MAXCHARNAME 37 -/*****************************************/ -/* max character name length (including */ -/* byte for null terminator) - a bug in */ -/* early LW ROMs limits PS names to */ -/* 36 bytes */ -/*****************************************/ -#define MAXCHARS 400 -/*****************************************/ -/* max characters in a font (including */ -/* composites) */ -/*****************************************/ -#define MAXENCLINE 65000L -/*****************************************/ -/* linelength used when encrypting */ -/*****************************************/ -#define MAXFILENAME 32 -/*****************************************/ -/* max relative file name length */ -/* (including byte for null terminator) */ -/* - limit imposed by max Mac filename */ -/* length - note that max Mac foldername */ -/* would be 34 chars because of colons */ -/* and that for root is 29 chars */ -/*****************************************/ -#ifndef MAXINT -#define MAXINT 32767L -#endif -#define MAXLINE 1000 -/*****************************************/ -/* maximum length of a line */ -/*****************************************/ -#ifndef MININT -#define MININT -32768L -#endif -#define MULTIFONTBBOXFILENAME ".bfmultifontbbox" -#define SCALEDHINTSINFO "scaledhintsinfo" -#define SUBRSFILENAME ".bfsubrs.bin" -#define TEMPFILE ".bftempfile" -#define UNINITWIDTH -1 -/*****************************************/ -/* width value if no width seen yet */ -/*****************************************/ -#define UNSCALEDASCIIFONT "font.unscaled" -#define WIDTHSFILENAME "widths.ps" -#define diskfontmax 65000L - -/*****************************************************************************/ -/* the following are for scanning "PostScript format" input file lines */ -/*****************************************************************************/ - -#define COMMENT(s) s[strspn(s, " \n\r\t\v\f")] == '%' -#define BLANK(s) sscanf(s, "%*s") == EOF -#define STREQ(a, b) (((a)[0] == (b)[0]) && (strcmp((a), (b)) == 0)) -#define STRNEQ(a, b) (((a)[0] != (b)[0]) || (strcmp((a), (b)) != 0)) - -#define NL '\012' -/*****************************************/ -/* Since the Mac treats both '\n' and */ -/* '\r' as ASCII 13 (i.e. carr. return) */ -/* need to define this. */ -/*****************************************/ - -/*****************************************************************************/ -/* Defines character bounding box. */ -/*****************************************************************************/ -typedef struct Bbox { - long int llx, lly, urx, ury; -} Bbox, *BboxPtr; - -/*****************************************************************************/ -/* Defines character point coordinates. */ -/*****************************************************************************/ -typedef struct -{ - long int x, y; -} Cd, *CdPtr; - -/*****************************************************************************/ -/* Defines parsing method based on fontinfo key CharacterSetFileType */ -/*****************************************************************************/ -typedef enum { - bf_CHARSET_STANDARD, - bf_CHARSET_CID -} CharsetParser; - -#define BF_LAYOUTS "layouts" -#define BF_SUBSETS "subsets" -#define BF_STD_LAYOUT "standard" - -#define OPENERROR 2 -#define OPENWARN 1 -#define OPENOK 0 - -extern char bezdir[MAXPATHLEN]; -extern boolean scalinghints; - -/*****************************************************************************/ -/* Tries to open the given file with the access attribute specified. If it */ -/* fails an error message is printed and the program exits. */ -/*****************************************************************************/ -extern FILE * -ACOpenFile(char *, char *, short); - -/*****************************************************************************/ -/* Deletes the specified file from the bez directory. */ -/*****************************************************************************/ -extern void -DeleteBezFile(char *, char *); - -/*****************************************************************************/ -/* Reads successive character and file names from character set file. */ -/*****************************************************************************/ -extern char * -ReadNames(char *, char *, long *, long *, FILE *); - -/*****************************************************************************/ -/* Reads a token from the data buffer. */ -/*****************************************************************************/ -extern char * -ReadToken(char *, char *, char *, char *); - -/*****************************************************************************/ -/* Returns whether file has .BAK suffix. */ -/*****************************************************************************/ -extern boolean -BAKFile(char *); - -/*****************************************************************************/ -/* Reads the file composites.ps, if it exists, and attempts to create */ -/* composite chars. for those listed. */ -/*****************************************************************************/ -extern long -make_composites(boolean, boolean, long *, char *, boolean, char **); - -/*****************************************************************************/ -/* Returns the max number of composites for the font. */ -/*****************************************************************************/ -extern int - readcomposite(boolean, indx); - -/*****************************************************************************/ -/* Computes the character bounding box. */ -/*****************************************************************************/ -extern int -computesbandbbx(char *, char *, long, BboxPtr, boolean, long, long); - -extern long -GetMaxBytes(void); - -extern void -SetMaxBytes(long); - -extern CharsetParser -GetCharsetParser(); - -extern void -SetCharsetLayout(char *fontinfoString); - -extern char * -GetCharsetLayout(); - -/*****************************************************************************/ -/* Sets the global variable charsetDir. */ -/*****************************************************************************/ -extern void -set_charsetdir(char *); - -/*****************************************************************************/ -/* Sets the global variable matrix. */ -/*****************************************************************************/ -extern int -set_matrix(char *); - -/*****************************************************************************/ -/* Sets the global variable uniqueIDFile. */ -/*****************************************************************************/ -extern void -set_uniqueIDFile(char *); - -/*****************************************************************************/ -/* Transforms a point using the global variable, matrix. */ -/*****************************************************************************/ -extern int -TransformPoint(long *, long *, boolean); - -/*****************************************************************************/ -/* Returns the name of the character set file. */ -/*****************************************************************************/ -extern void -getcharsetname(char *); - -/*****************************************************************************/ -/* Returns the name of the character set file. */ -/*****************************************************************************/ -extern void -setcharsetname(boolean, char *, char *); - -/*****************************************************************************/ -/* Returns the name of the encoding file. */ -/*****************************************************************************/ -extern void -get_encodingfilename(char *, boolean, int); - -/*****************************************************************************/ -/* Make an Adobe PS font or a release font. */ -/*****************************************************************************/ -extern int -makePSfont(char *, boolean, boolean, boolean, long, long, long); - -/*****************************************************************************/ -/* Make a Macintosh printer font. */ -/*****************************************************************************/ -extern int -makelwfn(char *, char *, char); - -/*****************************************************************************/ -/* Make an IBM printer font. */ -/*****************************************************************************/ -extern int -makeibmfont(char *, char *, char); - -extern void -GetFontMatrix(char *, char *); - -/*****************************************************************************/ -/* Returns the total number of input directories. */ -/*****************************************************************************/ -extern short -GetTotalInputDirs(void); - -extern void -SetTotalInputDirs(short); - -/*****************************************************************************/ -/* Parse the private dict portion of an ASCII format font. */ -/*****************************************************************************/ -extern void -ParseFont(FILE *, FILE *, long, long *, long *, long *, long *, boolean); - -/*****************************************************************************/ -/* Program to derive printer font file name for the mac from the PostScript */ -/* printer font name. */ -/*****************************************************************************/ -extern char * -printer_filename(char *); - -extern int -convert_PScharfile(const char *, const char *); - -/*****************************************************************************/ -/* Converts raw PS files to relativized bez format. */ -/*****************************************************************************/ -extern int - convert_rawPSfiles(boolean); - -extern void -convert_illcharfile(const char *, const char *); - -extern void - convert_illfiles(boolean); - -extern long -process_chars(boolean, boolean, boolean, long *, long *, boolean, boolean); - -extern void -set_scale(float *); - -extern short -strindex(char *, char *); - -extern boolean ConvertCharFiles(char *inputDir, - boolean release, - float scale, - void (*convertFunc)(const char *, const char *)); - -/*****************************************************************************/ -/* Creates an Adobe Font Metrics (AFM) file. */ -/*****************************************************************************/ -extern int - make_afm(boolean); - -extern int -ReadWriteFile(FILE *, char *); - -/*****************************************************************************/ -/* Looks up a keyword in the fontinfo file and writes the value to the */ -/* given output file. */ -/*****************************************************************************/ -extern int -WriteEntry(FILE *, char *, char *, boolean, boolean); - -/*****************************************************************************/ -/* Returns whether given character is in StandardEncoding. */ -/*****************************************************************************/ -extern boolean -InStandardEncoding(char *, long *); - -/*****************************************************************************/ -/* Writes copyright notice and trademark information. */ -/*****************************************************************************/ -extern int -WriteCopyrightsAndTrademark(FILE *, char); - -/*****************************************************************************/ -/* Frees composite table. */ -/*****************************************************************************/ -extern void -FreeCompTab(void); - -/*****************************************************************************/ -/* Deallocates memory and deletes temporary files. */ -/*****************************************************************************/ -extern int -cleanup(short); - -extern char * - GetBaseFontPath(boolean); - -extern void -FileNameLenOK(char *); - -extern void -CharNameLenOK(char *); - -extern void -PathNameLenOK(char *); - -extern char * -AllocateMem(unsigned int, unsigned int, const char *); - -extern char * -ReallocateMem(char *, unsigned int, const char *); - -extern void -UnallocateMem(void *ptr); - -extern unsigned long -CheckFileBufferLen(char **, char *); - -extern void -WriteBlendEntry(FILE *, char *, char *, boolean); - -extern int -WriteStart(FILE *, const char *); - -/*****************************************************************************/ -/* Gets the name of the file containing the current uniqueID. */ -/*****************************************************************************/ -extern void -getidfilename(char *); - -extern long -ACReadFile(char *, FILE *, char *, long); - -extern long -getmaxcomps(void); - -extern long -getrealcomps(void); - -extern void -get_working_dir(char *); - -extern void -init_working_dir(void); - -extern void -set_working_dir(void); - -extern void -LoadSubsetData(void); - -extern void -SetSubsetName(char *name); - -extern char * -GetSubsetName(void); - -extern char * -GetSubsetPath(void); - -extern boolean -UsesSubset(void); - -#endif /*BUILDFONT_H*/ diff --git a/c/autohint/autohintlib/source/bf/charlist.c b/c/autohint/autohintlib/source/bf/charlist.c deleted file mode 100644 index fd7df49b5..000000000 --- a/c/autohint/autohintlib/source/bf/charlist.c +++ /dev/null @@ -1,618 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ - -/*****************************************************************************/ -/* This module implements the character list, which is built prior to */ -/* filling in the character table. */ -/*****************************************************************************/ - -#include "buildfont.h" -#include "charlistpriv.h" -#include "charlist.h" -#include "charpath.h" -#include "chartable.h" -#include "derivedchars.h" -#include "transitionalchars.h" -#include "machinedep.h" - -#define MAXCLIST 800 - -static boolean charsetexists; -static int maxclist = 0; - -static void readcharset(boolean); -indx FindCharListEntry(char *); -static indx DumbFindCharListEntry(char *); -static indx FileInCharList(char *); -static void checkduplicates(void); -static void checkfiledups(void); -static void checkcharlist(boolean, boolean, char *, indx); -static void swap(struct cl_elem *, struct cl_elem *); - -static void -readcharset(boolean release) -/*****************************************************************************/ -/* Put entry for each character into charlist. */ -/*****************************************************************************/ -{ - FILE *filelist = NULL; - char cname[MAXCHARNAME]; - char filename[MAXFILENAME]; - char charsetfilename[MAXPATHLEN]; - boolean foundone = FALSE; - long masters; - long hintDir; - - getcharsetname(charsetfilename); - charsetexists = (strlen(charsetfilename) > 0); - if (!charsetexists) return; - -#if 0 /*DEBUG*/ - { - char wd[MAXPATHLEN]; - getwd(wd); - fprintf(OUTPUTBUFF, "open wd:%s\nfile: %s\n", wd, charsetfilename); - } -#endif /*0*/ - -#if OLD - filelist = ACOpenFile(charsetfilename, "r", (release ? OPENERROR : OPENWARN)); - if (filelist == NULL) return; -#else - - filelist = ACOpenFile(charsetfilename, "r", OPENOK); - if (filelist == NULL) { - char charsetdotdot[MAXPATHLEN]; - - sprintf(charsetdotdot, "../%s", charsetfilename); - filelist = ACOpenFile(charsetdotdot, "r", OPENOK); - - if (filelist == NULL) { - /* output warning on original name */ - filelist = ACOpenFile(charsetfilename, "r", - (release ? OPENERROR : OPENWARN)); - return; - } - } -#endif - - while ((ReadNames(cname, filename, &masters, &hintDir, filelist)) != NULL) { - AddCharListEntry(cname, filename, masters, hintDir, - FALSE, FALSE, FALSE, FALSE); - foundone = TRUE; - } - - fclose(filelist); - - if (!foundone) { - sprintf(globmsg, - "There are no character names in the character set file: %s.\n", - charsetfilename); - - if (release) - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - else - LogMsg(globmsg, WARNING, OK, TRUE); - } -} - -extern indx -FindCharListEntry(char *cname) { - indx low = 0; - indx high = clsize - 1; - indx mid; - indx cond; - - while (low <= high) { - mid = (low + high) / 2; - cond = strcmp(cname, charlist[mid].charname); - - if (cond < 0) - high = mid - 1; - else if (cond > 0) - low = mid + 1; - else - return mid; - } - - return -1; -} - -static indx -DumbFindCharListEntry(char *cname) { - int i; - for (i = 0; i < clsize; i++) { - if (STREQ(cname, charlist[i].charname)) - return (i); - } - - return -1; -} - -static indx -FileInCharList(char *fname) { - indx low = 0; - indx high = clsize - 1; - indx mid; - indx cond; - - while (low <= high) { - mid = (low + high) / 2; - cond = strcmp(fname, charlist[mid].filename); - - if (cond < 0) - high = mid - 1; - else if (cond > 0) - low = mid + 1; - else - return mid; - } - - return -1; -} - -static void -checkduplicates() { - indx i = 0; - indx j; - boolean duplicate = FALSE; - - while (i < clsize) { - for (j = i + 1; j < clsize; j++) { - if (STRNEQ(charlist[i].charname, charlist[j].charname)) break; - /* Not a duplicate. */ - - sprintf(globmsg, - "Duplicate character name: %s in the character set.\n", - charlist[i].charname); - LogMsg(globmsg, LOGERROR, OK, TRUE); - duplicate = TRUE; - } - - i = j; - } - - if (duplicate) - LogMsg( - "BuildFont cannot continue with duplication(s) " - "in character set.\n", - LOGERROR, NONFATALERROR, TRUE); -} - -static void -checkfiledups() { - indx i = 0; - indx j; - boolean duplicate = FALSE; - - while (i < clsize) { - for (j = i + 1; j < clsize; j++) { - if (STRNEQ(charlist[i].filename, charlist[j].filename)) break; - /* Not a duplicate. */ - - sprintf(globmsg, "Duplicate file name: %s in the character set.\n", - charlist[i].filename); - LogMsg(globmsg, LOGERROR, OK, TRUE); - duplicate = TRUE; - } - - i = j; - } - - if (duplicate) - LogMsg( - "BuildFont cannot continue with duplicate file name(s) in\n" - " character set.\n", - LOGERROR, NONFATALERROR, TRUE); -} - -static void -checkcharlist(boolean release, boolean quiet, char *indir, indx dirix) -/*****************************************************************************/ -/* If any non-derived, non-composite file is not found, a warning or error */ -/* is given. */ -/*****************************************************************************/ -{ - indx i = 0; - char inname[MAXPATHLEN]; - boolean filemissing = FALSE; - - while (i < clsize) { - if (!charlist[i].composite && - !charlist[i].derived && - (dirix < charlist[i].masters)) /* for cube */ - { - if (!charlist[i].transitional) { - get_filename(inname, indir, charlist[i].filename); - - if (!FileExists(inname, FALSE)) { - if (!quiet) { - sprintf(globmsg, - "The %s file does not exist or" - " is not accessible,\n" - " but is in the character set.\n", - inname); - LogMsg(globmsg, (release ? LOGERROR : WARNING), OK, TRUE); - } - - filemissing = TRUE; - } - } - } - i++; - } - - if (release && filemissing) - LogMsg("BuildFont cannot continue with missing input file(s).\n", LOGERROR, - NONFATALERROR, TRUE); -} - -extern void -AddCharListEntry(char *cname, char *fname, - long masters, /* number of masters, 1-16 */ - long hintDir, /* index of hint directory for this */ - /* character in dir list */ - boolean derived, boolean composite, boolean inBez, boolean transitional) { - indx fnlen; - indx i; - - if (maxclist == 0) { - charlist = (struct cl_elem *)AllocateMem(MAXCLIST, - sizeof(struct cl_elem), "character list"); - maxclist = MAXCLIST; - - for (i = 0; i < maxclist; i++) - charlist[i].inCharTable = charlist[i].inBezDir = FALSE; - - clsize = 0; - } - - if (clsize >= maxclist) { - maxclist += 100; - charlist = (struct cl_elem *)ReallocateMem((char *)charlist, - (unsigned)(maxclist * sizeof(struct cl_elem)), "character list"); - - for (i = clsize; i < maxclist; i++) - charlist[i].inCharTable = charlist[i].inBezDir = FALSE; - } - - if (DumbFindCharListEntry(cname) >= 0) - return; /* already in table, probably as a */ - /* transitional character */ - - charlist[clsize].charname = AllocateMem((unsigned)(strlen(cname) + 1), - sizeof(char), "character name"); - strcpy(charlist[clsize].charname, cname); - - if ((fname != NULL) && ((fnlen = strlen(fname)) > 0)) { - charlist[clsize].filename = AllocateMem((unsigned)(fnlen + 1), - sizeof(char), "file name"); - strcpy(charlist[clsize].filename, fname); - } else - charlist[clsize].filename = charlist[clsize].charname; - - charlist[clsize].derived = derived; - charlist[clsize].composite = composite; - charlist[clsize].inCharTable = FALSE; - charlist[clsize].inBezDir = inBez; - charlist[clsize].masters = masters; - charlist[clsize].hintDir = hintDir; - charlist[clsize].transitional = transitional; - clsize++; -} - -extern boolean -CheckCharListEntry(char *cname, char *fname, boolean derived, - boolean composite, boolean transitional, boolean release, indx dirIx) { - boolean error = FALSE; - indx cli = FindCharListEntry(cname); - - if (cli < 0) { - if (release && derived) { - sprintf(globmsg, - "Derived character: %s is not found" - " in the character set.\n", - cname); - LogMsg(globmsg, LOGERROR, OK, TRUE); - error = TRUE; - } else if (release && transitional) { - sprintf(globmsg, - "Transitional character: %s is not found" - " in the character set.\n", - cname); - LogMsg(globmsg, LOGERROR, OK, TRUE); - error = TRUE; - } else if (charsetexists) { - if (transitional) - sprintf(globmsg, - "Transitional character: %s is not found" - " in the character set.\n", - cname); - if (derived) - sprintf(globmsg, - "Derived character: %s is not found" - " in the character set.\n", - cname); - if (composite) - sprintf(globmsg, - "Composite character: %s is not found" - " in the character set.\n", - cname); - - LogMsg(globmsg, WARNING, OK, TRUE); - } - - return error; - } - - if (charlist[cli].transitional && transitional && (dirIx == 0)) { - sprintf(globmsg, "%s is a duplicate transitional character name.\n", - charlist[cli].charname); - LogMsg(globmsg, LOGERROR, OK, TRUE); - error = TRUE; - } - - if (charlist[cli].derived && derived && (dirIx == 0)) { - sprintf(globmsg, "%s is a duplicate derived character name.\n", - charlist[cli].charname); - LogMsg(globmsg, LOGERROR, OK, TRUE); - error = TRUE; - } - - if (charlist[cli].composite && composite && (dirIx == 0)) { - sprintf(globmsg, "%s is a duplicate composite character name.\n", - charlist[cli].charname); - LogMsg(globmsg, LOGERROR, OK, TRUE); - error = TRUE; - } - - charlist[cli].derived = charlist[cli].derived || derived; - charlist[cli].transitional = charlist[cli].transitional || transitional; - charlist[cli].composite = charlist[cli].composite || composite; - - if (charlist[cli].derived && charlist[cli].composite) { - sprintf(globmsg, - "Character name %s was defined more than once as" - " a derived or composite character .\n", - charlist[cli].charname); - LogMsg(globmsg, LOGERROR, OK, TRUE); - error = TRUE; - } - - if ((strlen(fname) > 0) && STRNEQ(charlist[cli].filename, fname)) { - sprintf(globmsg, - "%s character has filename %s in character set and \n" - " filename %s in %s file.\n", - charlist[cli].charname, - charlist[cli].filename, fname, - charlist[cli].derived ? DERIVEDCHARFILENAME : COMPFILE); - LogMsg(globmsg, LOGERROR, OK, TRUE); - error = TRUE; - } - - return error; -} - -static void -swap(struct cl_elem *c1, struct cl_elem *c2) { - struct cl_elem temp; - - temp = *c1; - *c1 = *c2; - *c2 = temp; -} - -extern void -sortcharlist(boolean byfilename) -/*****************************************************************************/ -/* sort the charlist by character name */ -/*****************************************************************************/ -{ - indx gap, i, j; - - for (gap = clsize / 2; gap > 0; gap = gap / 2) - for (i = gap; i < clsize; i++) - for (j = i - gap; j >= 0; j = j - gap) { - if (!byfilename) { - if (strcmp(charlist[j].charname, charlist[j + gap].charname) < 0) - break; - } else if (strcmp(charlist[j].filename, charlist[j + gap].filename) < 0) - break; - - swap(&charlist[j], &charlist[j + gap]); - } -} - -/*****************************************************************************/ -/* Put entry for each character into charlist. */ -/*****************************************************************************/ -/*extern void -makecharlist(boolean release, boolean quiet, char *indir, indx dirix) - { - indx i; - - if (dirix == 0) - { - if (maxclist == 0) - { - charlist = (struct cl_elem *) AllocateMem(MAXCLIST, - sizeof(struct cl_elem), "character list"); - maxclist = MAXCLIST; - - for (i = 0; i < maxclist; i++) - charlist[i].inCharTable = charlist[i].inBezDir = FALSE; - - clsize = 0; - } - - readcharset(release); - } - - sortcharlist(FALSE); - if (dirix == 0) checkduplicates(); - readderived(release, dirix); - readcomposite(release, dirix); - checkcharlist(release, quiet, indir, dirix); - sortcharlist(TRUE); - checkfiledups(); - } - - -*/ -extern boolean -NameInCharList(char *fname) { - return (FileInCharList(fname) >= 0); -} - -/* -extern void -CopyCharListToTable() - { - indx i; - - for (i = 0; i < clsize; i++) - if ( !charlist[i].composite && - !charlist[i].derived && - !charlist[i].transitional && - charlist[i].inCharTable) - create_entry(charlist[i].charname, charlist[i].filename, UNINITWIDTH, - FALSE, 0, charlist[i].masters, charlist[i].hintDir); - } - -*/ - -extern void -CheckAllListInTable(boolean release) { - indx i; - boolean onemissing = FALSE; - - for (i = 0; i < clsize; i++) { - if (charlist[i].derived || charlist[i].composite || charlist[i].transitional || charlist[i].inBezDir) continue; - - sprintf(globmsg, - "Character: %s is in character set," - " but was not found in the\n %s directory.\n", - charlist[i].charname, bezdir); - LogMsg(globmsg, (release ? LOGERROR : WARNING), OK, TRUE); - onemissing = TRUE; - } - - if (release && onemissing) - LogMsg("BuildFont cannot continue with missing character(s).\n", - LOGERROR, NONFATALERROR, TRUE); -} - -extern boolean IsInFullCharset(char *bezName); - -extern boolean -CompareCharListToBez(char *fname, boolean release, indx dirix, boolean quiet) { - indx i = FileInCharList(fname); - char filename[MAXPATHLEN]; - - get_filename(filename, bezdir, fname); - if (i < 0) /* fname not found in charlist */ - { - if (release) { - if (!UsesSubset() || !IsInFullCharset(fname)) { - sprintf(globmsg, - "File name: %s in %s directory will not\n" - " be included in the font because it is not" - " in the character set.\n", - fname, bezdir); - - LogMsg(globmsg, WARNING, OK, TRUE); - } - } else { - /********************************************************************/ - /* Check if this is a directory since we already know it exists in */ - /* the bez directory. */ - /********************************************************************/ - if (FileExists(filename, TRUE)) { - if (dirix == 0) { - if (charsetexists) { - /* if subset: if charname "fname" is in layouts, - then do not issue this message. */ - if (!UsesSubset() || !IsInFullCharset(fname)) { - if (!quiet) { - sprintf(globmsg, - "Extra character file: %s in %s directory will\n" - " be included in the font.\n", - fname, bezdir); - LogMsg(globmsg, WARNING, OK, TRUE); - } - } - } - - AddCharListEntry(fname, fname, GetTotalInputDirs(), - GetHintsDir(), FALSE, FALSE, TRUE, FALSE); - sortcharlist(TRUE); - } - } - } - - return FALSE; - } - - if (charlist[i].composite) return FALSE; - - if (charlist[i].derived) { - sprintf(globmsg, - "File name: %s in %s directory\n" - " is the same as a derived file name.\n", - fname, bezdir); - LogMsg(globmsg, LOGERROR, OK, TRUE); - return TRUE; - } - - /**************************************************************************/ - /* don't worry about transitional */ - /**************************************************************************/ - if (!FileExists(filename, FALSE)) - return FALSE; /* Error msg will be issued in */ - /* CheckAllListInTable or checkcharlist. */ - charlist[i].inBezDir = TRUE; - return FALSE; -} - -extern void -ResetCharListBools(boolean firstTime, indx dirix) -/*****************************************************************************/ -/* This proc is called to compare the inBezDir and inCharTable booleans. */ -/* Its purpose is to ensure that only characters in every input directory */ -/* are put into the chartable. If a character is in the bez directory and */ -/* this is the first time thru then inCharTable will be set to true. */ -/* Subsequent calls must have both inBezDir and inCharTable true for */ -/* inCharTable to stay true. */ -/*****************************************************************************/ -{ - indx i; - - for (i = 0; i < clsize; i++) { - if (charlist[i].masters <= dirix) continue; - /* added for cube */ - if (charlist[i].inBezDir) { - if (!charlist[i].inCharTable && firstTime) - charlist[i].inCharTable = TRUE; - } else - charlist[i].inCharTable = FALSE; - - charlist[i].inBezDir = FALSE; - } -} - -extern void -FreeCharList() { - indx i; - for (i = 0; i < clsize; i++) { - if (charlist[i].filename != charlist[i].charname) { - if (charlist[i].charname) - UnallocateMem(charlist[i].charname); - } - - if (charlist[i].filename) - UnallocateMem(charlist[i].filename); - } - - UnallocateMem(charlist); - clsize = 0; -} diff --git a/c/autohint/autohintlib/source/bf/charlist.h b/c/autohint/autohintlib/source/bf/charlist.h deleted file mode 100644 index bc3d1214a..000000000 --- a/c/autohint/autohintlib/source/bf/charlist.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ - -extern void AddCharListEntry( - char *, char *, long, long, boolean, boolean, boolean, boolean); - -extern boolean CheckCharListEntry( - char *, char *, boolean, boolean, boolean, boolean, indx); - -extern boolean NameInCharList( - char *); - -extern indx FindCharListEntry( - char *); - -/* -extern void makecharlist( -boolean, boolean, char *, indx -);*/ - -extern void sortcharlist( - boolean); - -extern boolean CompareCharListToBez( - char *, boolean, indx, boolean); -/* -extern void CopyCharListToTable ( -void -);*/ - -extern void CheckAllListInTable( - boolean); - -extern void FreeCharList( - void); - -extern void ResetCharListBools( - boolean, indx); diff --git a/c/autohint/autohintlib/source/bf/charlistpriv.c b/c/autohint/autohintlib/source/bf/charlistpriv.c deleted file mode 100644 index f0a6e5fbf..000000000 --- a/c/autohint/autohintlib/source/bf/charlistpriv.c +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* This source file should contain any procedure(s) that are called - from AC. It should not contain calls to procedures implemented - in object files that are not bound into AC. */ - -#include "basic.h" -#include "bftoac.h" -#include "charlistpriv.h" - -long clsize = 0; -struct cl_elem *charlist = NULL; - -extern boolean ReadCharFileNames(fname, start) char *fname; -boolean *start; -{ - static indx i; - if (*start) { - i = 0; - *start = FALSE; - } - while (i < clsize) { - if (charlist[i].derived || charlist[i].composite) { - i++; - continue; - } - strcpy(fname, charlist[i].filename); - i++; - return TRUE; - } - return FALSE; -} diff --git a/c/autohint/autohintlib/source/bf/charlistpriv.h b/c/autohint/autohintlib/source/bf/charlistpriv.h deleted file mode 100644 index 745667ddd..000000000 --- a/c/autohint/autohintlib/source/bf/charlistpriv.h +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* The sole purpose of this interface is to define the types that are - needed by the two charlist*.c source files, but should not be - used outside them. The two source files were split so that just - the procedure(s) needed for AC were in one of them. */ - -typedef struct cl_elem { - char *charname; - char *filename; - boolean composite : 1, derived : 1, transitional : 1, - inCharTable : 1, inBezDir : 1; - short masters; /* number of masters for this char */ - short hintDir; /* which of the master dirs will be used for hints */ -} CL_ELEM; - -extern long clsize; -extern struct cl_elem *charlist; diff --git a/c/autohint/autohintlib/source/bf/charpath.c b/c/autohint/autohintlib/source/bf/charpath.c deleted file mode 100644 index 4e6c8d9fb..000000000 --- a/c/autohint/autohintlib/source/bf/charpath.c +++ /dev/null @@ -1,2341 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* charpath.c */ - -#include "machinedep.h" -#include "buildfont.h" -#include "bftoac.h" -#include "charpath.h" -#include "chartable.h" -#include "masterfont.h" -#include "opcodes.h" -#include "optable.h" -#include "hintfile.h" -#include "transitionalchars.h" - -extern double atan2(double, double); - -#define DEBUG_PCP 0 /* debug point closepath */ - -#define DMIN 50 /* device minimum (one-half of a device pixel) */ -#define MAINHINTS -1 -#define GROWBUFF 2048 /* Amount to grow output buffer, if necessary. */ -/* The following definitions are used when determining - if a hinting operator used the start, end, average or - flattened coordinate values. */ -/* Segments are numbered starting with 1. The "ghost" segment is 0. */ -#define STARTPT 0 -#define ENDPT 1 -#define AVERAGE 2 -#define CURVEBBOX 3 -#define FLATTEN 4 -#define GHOST 5 - -boolean flexexists; -extern boolean multiplemaster; -boolean cubeLibrary; -boolean bereallyQuiet = 1; -char *currentChar; /* name of the current char for error messages */ -extern boolean ReadCharFile(); - -#if !AC_C_LIB -static boolean firstMT; -#endif -static char *startbuff, **outbuff; -static short dirCount, byteCount, buffSize; -static PPathList pathlist = NULL; -static Cd *refPtArray = NULL; -static indx hintsdirIx; -static char outstr[100]; - -/* Prototypes */ -static void AddLine(indx, indx); -static boolean CheckFlexOK(indx); -static boolean ChangetoCurve(indx, indx); -static void CheckFlexValues(short *, indx, indx, boolean *, boolean *); -static void CheckForZeroLengthCP(void); -static void CheckHandVStem3(void); -static void CombinePaths(void); -static boolean CompareCharPaths(char *, boolean); -static void Ct(Cd, Cd, Cd, indx, short); -static boolean CurveBBox(indx, short, long, Fixed *); -static void FindHandVStem3(PHintElt *, indx, boolean *); -static void FreePathElements(indx, indx); -static void GetCoordFromType(short, CdPtr, indx, indx); -static long GetCPIx(indx, long); -static void GetEndPoint(indx, long, Fixed *, Fixed *); -static void GetEndPoints(indx, long, CdPtr, CdPtr); -static void GetFlexCoord(indx, indx, indx, CdPtr); -static void GetPathType(short, char *); -static short GetPointType(short, Fixed, long *); -static void GetRelPos(long, short, Fixed, CdPtr, CdPtr, Fixed *); -static void GetRelativePosition(Fixed, Fixed, Fixed, Fixed, Fixed, Fixed *); -static void Hvct(Cd, Cd, Cd, indx, short); -static void InconsistentPathType(char *, indx, short, short, indx); -static void InconsistentPointCount(char *, indx, int, int); -static void InsertHint(PHintElt, indx, short, short); -static void MtorDt(Cd, indx, short); -static void OptimizeCT(indx); -static void OptimizeMtorDt(indx, short *, boolean *, boolean *); -static void ReadHints(PHintElt, indx); -static int ReadandAssignHints(void); -static void ReadHorVStem3Values(indx, short, short, boolean *); -static void SetSbandWidth(char *, boolean, Transitions *, int); -static void Vhct(Cd, Cd, Cd, indx, short); -static void WriteFlex(indx); -static void WriteHints(indx); -static void WritePathElt(indx, indx, short, indx, short); -static void WriteSbandWidth(void); -static void WriteX(Fixed); -static void WriteY(Fixed); -static void WriteToBuffer(void); -static boolean ZeroLengthCP(indx, indx); - -#if AC_C_LIB -void GetMasterDirName(char *dirname, indx ix) { - if (dirname) - dirname[0] = '\0'; -} -#endif - -/* macros */ -#define FixShift (8) -#define IntToFix(i) ((long int)(i) << FixShift) -#define FRnd(x) ((long int)(((x) + (1 << 7)) & ~0xFFL)) -#define FTrunc8(x) ((long int)((x) >> 8)) -#define FIXED2FLOAT(x) ((float)((x) / 256.0)) -#define FixedToDouble(x) ((double)((x) / 256.0)) -#define Frac(x) ((x)&0xFFL) -#define FixOne (0x100L) -#define FixHalf (0x80L) -#define FixHalfMul(f) ((f) >> 1) -#define FixTwoMul(f) ((f) << 1) -#define TFMX(x) ((x)) -#define TFMY(y) (-(y)) -#define ITFMX(x) ((x)) -#define ITFMY(y) (-(y)) -#define WRTNUM(i) \ - { \ - sprintf(outstr, "%d ", (int)(i)); \ - WriteToBuffer(); \ - } -#define WriteStr(str) \ - { \ - sprintf(outstr, "%s ", (char *)str); \ - WriteToBuffer(); \ - } -#define WriteSubr(val) \ - { \ - sprintf(outstr, "%d subr ", val); \ - WriteToBuffer(); \ - } - -/* Checks if buffer needs to grow before writing out string. */ -static void WriteToBuffer() { - int len = (int)strlen(outstr); - - if ((byteCount + len) > buffSize) { - buffSize += GROWBUFF; -#if DOMEMCHECK - startbuff = (char *)memck_realloc(*outbuff, (buffSize * sizeof(char))); -#else - startbuff = (char *)ReallocateMem(*outbuff, - (unsigned)(buffSize * sizeof(char)), "file buffer"); -#endif - SetMaxBytes(buffSize); - *outbuff = startbuff; - startbuff += byteCount; - memset(startbuff, 0, GROWBUFF); - while (*startbuff == '\0') startbuff--; - startbuff++; - } - byteCount += len; - sprintf(startbuff, "%s", outstr); - startbuff += len; -} - -static void WriteX(x) - Fixed x; -{ - Fixed i = FRnd(x); - WRTNUM(FTrunc8(i)); -} - -static void WriteY(y) - Fixed y; -{ - Fixed i = FRnd(y); - WRTNUM(FTrunc8(i)); -} - -#define WriteCd(c) \ - { \ - WriteX(c.x); \ - WriteY(c.y); \ - } - -static void WriteOneHintVal(val) - Fixed val; -{ - if (Frac(val) == 0) - WRTNUM(FTrunc8(val)) - else { - WRTNUM(FTrunc8(FRnd(val * 100L))) - WriteStr("100 div "); - } -} - -/* Locates the first CP following the given path element. */ -static long GetCPIx(dirIx, pathIx) - indx dirIx; -long pathIx; -{ - indx ix; - - for (ix = pathIx; ix < path_entries; ix++) - if (pathlist[dirIx].path[ix].type == CP) - return ix; - sprintf(globmsg, "No closepath in character: %s.\n", currentChar); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - return (-1); -} - -/* Locates the first MT preceding the given path element. */ -static int GetMTIx(indx dirIx, indx pathIx) { - indx ix; - - for (ix = pathIx; ix >= 0; ix--) - if (pathlist[dirIx].path[ix].type == RMT) - return ix; - sprintf(globmsg, "No moveto in character: %s.\n", currentChar); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - return (-1); -} - -/* Locates the first MT SUCCEEDING the given path element. */ -static int GetNextMTIx(indx dirIx, indx pathIx) { - indx ix; - - for (ix = pathIx; ix < path_entries; ix++) - if (pathlist[dirIx].path[ix].type == RMT) - return ix; - return (-1); -} - -static void GetEndPoint(dirIx, pathIx, ptX, ptY) - indx dirIx; -long pathIx; -Fixed *ptX, *ptY; -{ - PCharPathElt pathElt = &pathlist[dirIx].path[pathIx]; - -retry: - switch (pathElt->type) { - case RMT: - case RDT: - *ptX = pathElt->x; - *ptY = pathElt->y; - break; - case RCT: - *ptX = pathElt->x3; - *ptY = pathElt->y3; - break; - case CP: - while (--pathIx >= 0) { - pathElt = &pathlist[dirIx].path[pathIx]; - if (pathElt->type == RMT) - goto retry; - } - sprintf(globmsg, "Bad character description file: %s.\n", currentChar); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - default: - sprintf(globmsg, "Illegal operator in character file: %s.\n", currentChar); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } -} - -static void GetEndPoints(dirIx, pathIx, start, end) - indx dirIx; -long pathIx; -Cd *start, *end; -{ - if (pathlist[dirIx].path[pathIx].type == RMT) { - long cpIx; - - GetEndPoint(dirIx, pathIx, &start->x, &start->y); - /* Get index for closepath associated with this moveto. */ - cpIx = GetCPIx(dirIx, pathIx + 1); - GetEndPoint(dirIx, cpIx - 1, &end->x, &end->y); - } else { - GetEndPoint(dirIx, pathIx - 1, &start->x, &start->y); - GetEndPoint(dirIx, pathIx, &end->x, &end->y); - } -} - -static void GetCoordFromType(short pathtype, CdPtr coord, - indx dirix, indx eltno) { - switch (pathtype) { - case RMT: - case RDT: - (*coord).x = FTrunc8(FRnd(pathlist[dirix].path[eltno].x)); - (*coord).y = FTrunc8(FRnd(pathlist[dirix].path[eltno].y)); - break; - case RCT: - (*coord).x = FTrunc8(FRnd(pathlist[dirix].path[eltno].x3)); - (*coord).y = FTrunc8(FRnd(pathlist[dirix].path[eltno].y3)); - break; - case CP: - GetCoordFromType(pathlist[dirix].path[eltno - 1].type, coord, dirix, eltno - 1); - break; - }; -} - -static void GetPathType(short pathtype, char *str) { - switch (pathtype) { - case RMT: - strcpy(str, "moveto"); - break; - case RDT: - strcpy(str, "lineto"); - break; - case RCT: - strcpy(str, "curveto"); - break; - case CP: - strcpy(str, "closepath"); - break; - default: - sprintf(globmsg, "Illegal path type: %d in character: %s.\n", pathtype, currentChar); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } -} - -static void FreePathElements(startix, stopix) - indx startix, - stopix; -{ - indx i, j; - - for (j = startix; j < stopix; j++) { - i = 0; -#if 0 - PHintElt hintElt, next; - if (pathlist[j].path != NULL) - { - /* Before we can free hint elements will need to know path_entries - value for char in each directory because this proc can be - called when characters are inconsistent. - */ - for (i = 0; i < path_entries; i++) - { - hintElt = pathlist[j].path[i].hints; - while (hintElt != NULL) - { - next = hintElt->next; -#if DOMEMCHECK - memck_free(hintElt); -#else - UnallocateMem(hintElt); -#endif - hintElt = next; - } - } - } -#endif -#if DOMEMCHECK - memck_free(pathlist[j].mainhints); - memck_free(pathlist[j].path); -#else - UnallocateMem(pathlist[j].mainhints); - UnallocateMem(pathlist[j].path); -#endif - } -} - -static void InconsistentPointCount(char *filename, indx ix, - int entries1, int entries2) { - char pathdir1[MAXPATHLEN], pathdir2[MAXPATHLEN]; - - GetMasterDirName(pathdir1, 0); - GetMasterDirName(pathdir2, ix); - sprintf(globmsg, "The character: %s will not be included in the font\n because the version in %s has a total of %d elements and\n the one in %s has %d elements.\n", filename, pathdir1, (int)entries1, pathdir2, (int)entries2); - LogMsg(globmsg, WARNING, OK, TRUE); -} - -static void InconsistentPathType(char *filename, indx ix, short type1, - short type2, indx eltno) { - char pathdir1[MAXPATHLEN], pathdir2[MAXPATHLEN]; - char typestr1[10], typestr2[10]; - Cd coord1, coord2; - - GetPathType(type1, typestr1); - GetPathType(type2, typestr2); - GetCoordFromType(type1, &coord1, 0, eltno); - GetCoordFromType(type2, &coord2, ix, eltno); - GetMasterDirName(pathdir1, 0); - GetMasterDirName(pathdir2, ix); - sprintf(globmsg, "The character: %s will not be included in the font\n because the version in %s has path type %s at coord: %d %d\n and the one in %s has type %s at coord %d %d.\n", - filename, pathdir1, typestr1, (int)coord1.x, (int)coord1.y, pathdir2, - typestr2, (int)coord2.x, (int)coord2.y); - LogMsg(globmsg, WARNING, OK, TRUE); -} - -/* Returns whether changing the line to a curve is successful. */ -static boolean ChangetoCurve(dirIx, pathIx) - indx dirIx, - pathIx; -{ - Cd start, end, ctl1, ctl2; - PCharPathElt pathElt = &pathlist[dirIx].path[pathIx]; - - if (pathElt->type == RCT) - return TRUE; - /* Use the 1/3 rule to convert a line to a curve, i.e. put the control points - 1/3 of the total distance from each end point. */ - GetEndPoints(dirIx, pathIx, &start, &end); - ctl1.x = FRnd((start.x * 2 + end.x + FixHalf) / 3); - ctl1.y = FRnd((start.y * 2 + end.y + FixHalf) / 3); - ctl2.x = FRnd((end.x * 2 + start.x + FixHalf) / 3); - ctl2.y = FRnd((end.y * 2 + start.y + FixHalf) / 3); - pathElt->type = RCT; - pathElt->x1 = ctl1.x; - pathElt->y1 = ctl1.y; - pathElt->x2 = ctl2.x; - pathElt->y2 = ctl2.y; - pathElt->x3 = end.x; - pathElt->y3 = end.y; - pathElt->rx1 = ctl1.x - start.x; - pathElt->ry1 = ctl1.y - start.y; - pathElt->rx2 = pathElt->x2 - pathElt->x1; - pathElt->ry2 = pathElt->y2 - pathElt->y1; - pathElt->rx3 = pathElt->x3 - pathElt->x2; - pathElt->ry3 = pathElt->y3 - pathElt->y2; - return TRUE; -} - -static boolean ZeroLengthCP(dirIx, pathIx) - indx dirIx, - pathIx; -{ - Cd startPt, endPt; - - GetEndPoints(dirIx, pathIx, &startPt, &endPt); - return (startPt.x == endPt.x && startPt.y == endPt.y); -} - -/* Subtracts or adds one unit from the segment at pathIx. */ -static void AddLine(dirIx, pathIx) - indx dirIx, - pathIx; -{ - Fixed fixTwo = IntToFix(2); - Fixed xoffset = 0, yoffset = 0; - Fixed xoffsetr = 0, yoffsetr = 0; - PCharPathElt start, end, thisone, nxtone; - char dirname[MAXPATHLEN]; - indx i, n; - - if (pathlist[dirIx].path[pathIx].type != RCT) { - if (!bereallyQuiet) { - GetMasterDirName(dirname, dirIx); - sprintf(globmsg, - "Please convert the point closepath in directory: %s, character: %s to a line closepath.\n", dirname, currentChar); - LogMsg(globmsg, WARNING, OK, TRUE); - } - return; - } - i = GetMTIx(dirIx, pathIx) + 1; - start = &pathlist[dirIx].path[i]; - end = &pathlist[dirIx].path[pathIx]; - /* Check control points to find out if x or y value should be adjusted - in order to get a smooth curve. */ - switch (start->type) { - case RDT: - if (!bereallyQuiet) { - GetMasterDirName(dirname, dirIx); - sprintf(globmsg, "Please convert the point closepath to a line closepath in directory: %s, character: %s.\n", dirname, currentChar); - LogMsg(globmsg, WARNING, OK, TRUE); - } - return; - break; - case RCT: - if ((ABS(start->x1 - end->x2) < fixTwo) && (ABS(start->x1 - pathlist[dirIx].path[i - 1].x) < fixTwo)) - yoffset = - (start->y1 < end->y2 && end->y2 > 0) || (start->y1 > end->y2 && end->y2 < 0) ? FixOne : -FixOne; - else if ((ABS(start->y1 - end->y2) < fixTwo) && (ABS(start->y1 - pathlist[dirIx].path[i - 1].y) < fixTwo)) - xoffset = - (start->x1 < end->x2 && end->x2 > 0) || (start->x1 > end->x2 && end->x2 < 0) ? FixOne : -FixOne; - else { - if (!bereallyQuiet) { - GetMasterDirName(dirname, dirIx); - sprintf(globmsg, "Could not modify point closepath in directory '%s', character: %s near (%ld, %ld).\n", dirname, currentChar, FTrunc8(end->x), FTrunc8(end->y)); - LogMsg(globmsg, WARNING, OK, TRUE); - } - return; - } - break; - default: - GetMasterDirName(dirname, dirIx); - sprintf(globmsg, "Bad character description file: %s/%s.\n", dirname, currentChar); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - - thisone = &(pathlist[dirIx].path[pathIx]); - thisone->x3 += xoffset; - xoffsetr = (xoffset == 0) ? 0 : ((thisone->rx3 < 0) ? FixOne : -FixOne); - thisone->rx3 += xoffsetr; - - thisone->y3 += yoffset; - yoffsetr = (yoffset == 0) ? 0 : ((thisone->ry3 < 0) ? FixOne : -FixOne); - thisone->ry3 += yoffsetr; - - /* Now, fix up the following MT's rx1, ry1 values - This fixes a LOOOONG-standing bug. renner Wed Jul 16 09:33:50 1997*/ - if ((n = GetNextMTIx(dirIx, pathIx)) > 0) { - nxtone = &(pathlist[dirIx].path[n]); - nxtone->rx += (-xoffsetr); - nxtone->ry += (-yoffsetr); - } -} - -#define PI 3.1415926535 -static void BestLine(PCharPathElt start, PCharPathElt end, Fixed *dx, Fixed *dy) { - double angle; - /* control point differences */ - double cx = FixedToDouble(end->x2 - end->x3); - double cy = FixedToDouble(end->y2 - end->y3); - - *dx = *dy = 0; - - if (cy == 0.0 && cx == 0.0) { -#if DEBUG_PCP - fprintf(OUTPUTBUFF, " cx=%f cy=%f ***\n", cx, cy); -#endif /*DEBUG_PCP*/ - sprintf(globmsg, "Unexpected tangent in character path: %s.\n", currentChar); - LogMsg(globmsg, WARNING, OK, TRUE); - return; - } - - angle = atan2(cy, cx); -#if DEBUG_PCP - fprintf(OUTPUTBUFF, " cx=%f cy=%f theta=%f %.0f deg\n", cx, cy, angle, angle / PI * 180.); -#endif /*DEBUG_PCP*/ - -#if FOUR_WAY - /* Judy's non-Cube code only moves vertically or horizontally. */ - /* This code produces similar results. */ - if (angle < (-PI * 0.75)) { - *dx = -FixOne; - } else if (angle < (-PI * 0.25)) { - *dy = -FixOne; - } else if (angle < (PI * 0.25)) { - *dx = FixOne; - } else if (angle < (PI * 0.75)) { - *dy = FixOne; - } else { - *dx = -FixOne; - } -#else /*FOUR_WAY*/ - - if (angle < (-PI * 0.875)) { - *dx = -FixOne; - } else if (angle < (-PI * 0.625)) { - *dy = -FixOne; - *dx = -FixOne; - } else if (angle < (-PI * 0.375)) { - *dy = -FixOne; - } else if (angle < (-PI * 0.125)) { - *dy = -FixOne; - *dx = FixOne; - } else if (angle < (PI * 0.125)) { - *dx = FixOne; - } else if (angle < (PI * 0.375)) { - *dx = FixOne; - *dy = FixOne; - } else if (angle < (PI * 0.625)) { - *dy = FixOne; - } else if (angle < (PI * 0.875)) { - *dy = FixOne; - *dx = -FixOne; - } else { - *dx = -FixOne; - } -#endif /*FOUR_WAY*/ -} - -/* CUBE VERSION 17-Apr-94 jvz */ -/* Curves: subtracts or adds one unit from the segment at pathIx. */ -/* Lines: flags the segment at pathIx to be removed later; CP follows it. */ -static void AddLineCube(indx dirIx, indx pathIx) { - /* Path element types have already been coordinated by ChangeToCurve. */ - /* Hints are only present in the hintsdirIx. */ - - if (pathlist[dirIx].path[pathIx].type == RDT) { - pathlist[dirIx].path[pathIx].remove = TRUE; - if (pathlist[dirIx].path[pathIx + 1].type != CP) { - sprintf(globmsg, "Expected CP in path: %s.\n", currentChar); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - - /* If there's another path in the character, we need to compensate */ - /* because CP does not update currentpoint. */ - - if (pathIx + 2 < path_entries) { - if (pathlist[dirIx].path[pathIx + 2].type == RMT) { - pathlist[dirIx].path[pathIx + 2].rx += pathlist[dirIx].path[pathIx].rx; - pathlist[dirIx].path[pathIx + 2].ry += pathlist[dirIx].path[pathIx].ry; - } else { - sprintf(globmsg, "Expected second RMT in path: %s.\n", currentChar); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - } - -#if DEBUG_PCP - if (dirIx == 0) - fprintf(OUTPUTBUFF, " RDT\n"); -#endif /*DEBUG_PCP*/ - - } else if (pathlist[dirIx].path[pathIx].type == RCT) { - Fixed dx = 0; - Fixed dy = 0; - PCharPathElt start; - PCharPathElt end; - indx mt; /* index of the moveto preceding this path */ - -#if DEBUG_PCP - if (dirIx == 0) - fprintf(OUTPUTBUFF, " RCT\n"); -#endif /*DEBUG_PCP*/ - - mt = GetMTIx(dirIx, pathIx); - start = &pathlist[dirIx].path[mt + 1]; - end = &pathlist[dirIx].path[pathIx]; - - /* find nearest grid point we can move to */ - BestLine(start, end, &dx, &dy); - -#if DEBUG_PCP - fprintf(OUTPUTBUFF, " dx %d dy %d\n", FTrunc8(dx), FTrunc8(dy)); -#endif /*DEBUG_PCP*/ - - /* note that moving rx2, ry2 will also move rx3, ry3 */ - pathlist[dirIx].path[pathIx].x2 += dx; - pathlist[dirIx].path[pathIx].x3 += dx; - pathlist[dirIx].path[pathIx].rx2 += dx; - - pathlist[dirIx].path[pathIx].y2 += dy; - pathlist[dirIx].path[pathIx].y3 += dy; - pathlist[dirIx].path[pathIx].ry2 += dy; - } else { - /* Not a RCT or RDT - error - unexpected path element type. */ - sprintf(globmsg, "Bad character description file: %s.\n", currentChar); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } -} - -/* - Look for zero length closepaths. If true then add a small - one unit line to each design. Because blending can cause - small arithmetic errors at each point in the path the - accumulation of such errors might cause the path to not end - up at the same point where it started. This can cause a sharp - angle segment that may cause spike problems in old rasterizers, - and in the qreducer (used for filling very large size characters). - The one unit line, which is drawn by the closepath, takes up the - slack for the arithmetic errors and avoids the spike problem. - */ -static void CheckForZeroLengthCP() { - indx ix, pathIx; - - for (ix = 0; ix < dirCount; ix++) { - for (pathIx = 0; pathIx < path_entries; pathIx++) { - if (pathlist[ix].path[pathIx].type == CP && ZeroLengthCP(ix, pathIx)) { - if (cubeLibrary) - AddLineCube(ix, pathIx - 1); - else - AddLine(ix, pathIx - 1); - } - } - } -} - -typedef struct path_names_ { - char dirnam[MAXPATHLEN]; - char fullfilepath[MAXPATHLEN]; -} Path_Name_; - -#if !IS_LIB -static Path_Name_ Path_Names[MAXDESIGNS]; -#else -static Path_Name_ Path_Names[1]; -#endif - -/* Checks that character paths for multiple masters have the same - number of points and in the same path order. If this isn't the - case the character is not included in the font. */ -static boolean CompareCharPaths(char *filename, boolean fortransitionals) { - indx dirix, ix, i; - long totalPathElt, minPathLen; - boolean ok = TRUE; - short type1, type2; - - totalPathElt = minPathLen = MAXINT; - if (pathlist == NULL) { -#if DOMEMCHECK - pathlist = (PPathList)memck_malloc(MAXDESIGNS * sizeof(PathList)); -#else - pathlist = (PPathList)AllocateMem( - (unsigned int)MAXDESIGNS /*dirCount*/, - sizeof(PathList), - "character path list"); -#endif - } - - for (dirix = 0; dirix < dirCount; dirix++) { -#if OLD - SetMasterDir(dirix); - SetReadFileName(filename); - setPrefix(bezdir); -#else - SetReadFileName(Path_Names[dirix].fullfilepath); -#endif - ResetMaxPathEntries(); - SetCurrPathList(&pathlist[dirix]); - path_entries = 0; - - /* read hints from special file if it exists */ - if (hintsdirIx == dirix) { - char hintFileName[MAXPATHLEN]; - sprintf(hintFileName, "%s/hints/%s", Path_Names[dirix].dirnam, filename); - if (FileExists(hintFileName, FALSE)) { - if (!ReadCharFile(TRUE, TRUE, FALSE, FALSE)) - return FALSE; -#if !AC_C_LIB - if (!ReadHintsFile(hintFileName, &pathlist[dirix])) -#endif - return FALSE; - - } else { - /* read char data and hints from bez file */ - if (!ReadCharFile(TRUE, TRUE, addHints, FALSE)) - return FALSE; - } - } else { - /* read char data only */ - if (!ReadCharFile(TRUE, TRUE, FALSE, FALSE)) - return FALSE; - } - - if (dirix == 0) - totalPathElt = path_entries; - else if (path_entries != totalPathElt) { - InconsistentPointCount(filename, dirix, totalPathElt, path_entries); - ok = FALSE; - } - minPathLen = NUMMIN(NUMMIN(path_entries, totalPathElt), minPathLen); - } - - for (dirix = 1; dirix < dirCount; dirix++) { - for (i = 0; i < minPathLen; i++) { - if ((type1 = pathlist[0].path[i].type) != (type2 = pathlist[dirix].path[i].type)) { - if ((type1 == RDT) && (type2 == RCT)) { /* Change this element in all previous directories to a curve. */ - ix = dirix - 1; - do { - ok = ok && ChangetoCurve(ix, i); - ix--; - } while (ix >= 0); - } else if ((type1 == RCT) && (type2 == RDT)) - ok = ok && ChangetoCurve(dirix, i); - else { - InconsistentPathType(filename, dirix, - pathlist[0].path[i].type, pathlist[dirix].path[i].type, i); - ok = FALSE; - /* skip to next subpath */ - while (++i < minPathLen && (pathlist[0].path[i].type != CP)) - ; - } - } - } - } - return ok; -} - -static void SetSbandWidth(char *charname, boolean fortransit, Transitions *trptr, int trgroupnum) { -#if !AC_C_LIB - short width; - Bbox bbox; -#endif - indx dirix; - - for (dirix = 0; dirix < dirCount; dirix++) { - if (fortransit) { - pathlist[dirix].sb = trptr->transitgrouparray[trgroupnum].assembled_sb[dirix]; - pathlist[dirix].width = trptr->transitgrouparray[trgroupnum].assembled_width[dirix]; - } else { -#if AC_C_LIB - pathlist[dirix].sb = 0; - pathlist[dirix].width = 1000; - -#else - GetWidthandBbox(charname, &width, &bbox, FALSE, dirix); - pathlist[dirix].sb = bbox.llx; - pathlist[dirix].width = width; -#endif - } - } -} - -static void WriteSbandWidth() { - short subrix, length, opcount = GetOperandCount(SBX); - indx ix, j, startix = 0; - boolean writeSubrOnce, sbsame = TRUE, wsame = TRUE; - - for (ix = 1; ix < dirCount; ix++) { - sbsame = sbsame && (pathlist[ix].sb == pathlist[ix - 1].sb); - wsame = wsame && (pathlist[ix].width == pathlist[ix - 1].width); - } - if (sbsame && wsame) { - sprintf(outstr, "%ld %d ", pathlist[0].sb, pathlist[0].width); - WriteToBuffer(); - } else if (sbsame) { - sprintf(outstr, "%ld ", pathlist[0].sb); - WriteToBuffer(); - for (j = 0; j < dirCount; j++) { - sprintf(outstr, "%d ", - (j == 0) ? pathlist[j].width : pathlist[j].width - pathlist[0].width); - WriteToBuffer(); - } - GetLengthandSubrIx(1, &length, &subrix); - WriteSubr(subrix); - } else if (wsame) { - for (j = 0; j < dirCount; j++) { - sprintf(outstr, "%ld ", - (j == 0) ? pathlist[j].sb : pathlist[j].sb - pathlist[0].sb); - WriteToBuffer(); - } - GetLengthandSubrIx(1, &length, &subrix); - WriteSubr(subrix); - sprintf(outstr, "%d ", pathlist[0].width); - WriteToBuffer(); - } else { - GetLengthandSubrIx(opcount, &length, &subrix); - if ((writeSubrOnce = (length == opcount))) { - sprintf(outstr, "%ld %d ", pathlist[0].sb, pathlist[0].width); - WriteToBuffer(); - length = startix = 1; - } - for (ix = 0; ix < opcount; ix += length) { - for (j = startix; j < dirCount; j++) { - sprintf(outstr, "%ld ", (ix == 0) ? (j == 0) ? pathlist[j].sb : pathlist[j].sb - pathlist[0].sb : (j == 0) ? (long int)pathlist[j].width : (long int)(pathlist[j].width - pathlist[0].width)); - WriteToBuffer(); - } - if (!writeSubrOnce || (ix == (opcount - 1))) - WriteSubr(subrix); - } - } - WriteStr("sbx\n"); -} - -static boolean CurveBBox(indx dirIx, short hinttype, long pathIx, Fixed *value) { - Cd startPt, endPt; - Fixed llx, lly, urx, ury, minval, maxval; - Fixed p1, p2, *minbx, *maxbx; - CharPathElt pathElt; - - *value = IntToFix(10000); - pathElt = pathlist[dirIx].path[pathIx]; - GetEndPoints(dirIx, pathIx, &startPt, &endPt); - switch (hinttype) { - case RB: - case RV + ESCVAL: - minval = TFMY(NUMMIN(startPt.y, endPt.y)); - maxval = TFMY(NUMMAX(startPt.y, endPt.y)); - p1 = TFMY(pathElt.y1); - p2 = TFMY(pathElt.y2); - minbx = &lly; - maxbx = &ury; - break; - case RY: - case RM + ESCVAL: - minval = TFMX(NUMMIN(startPt.x, endPt.x)); - maxval = TFMX(NUMMAX(startPt.x, endPt.x)); - p1 = TFMX(pathElt.x1); - p2 = TFMX(pathElt.x2); - minbx = &llx; - maxbx = &urx; - break; - default: - sprintf(globmsg, "Illegal hint type in character: %s.\n", currentChar); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - if (p1 - maxval >= FixOne || p2 - maxval >= FixOne || - p1 - minval <= FixOne || p2 - minval <= FixOne) { - /* Transform coordinates so I get the same value that AC would give. */ - FindCurveBBox(TFMX(startPt.x), TFMY(startPt.y), TFMX(pathElt.x1), TFMY(pathElt.y1), - TFMX(pathElt.x2), TFMY(pathElt.y2), TFMX(endPt.x), TFMY(endPt.y), - &llx, &lly, &urx, &ury); - if (*maxbx > maxval || minval > *minbx) { - if (minval - *minbx > *maxbx - maxval) - *value = (hinttype == RB || hinttype == RV + ESCVAL) ? ITFMY(*minbx) : ITFMX(*minbx); - else - *value = (hinttype == RB || hinttype == RV + ESCVAL) ? ITFMY(*maxbx) : ITFMX(*maxbx); - return TRUE; - } - } - return FALSE; -} -#if __CENTERLINE__ -static char *_HintType_(int typ) { - switch (typ) { - case GHOST: - return ("Ghost"); - break; - case AVERAGE: - return ("Average"); - break; - case CURVEBBOX: - return ("Curvebbox"); - break; - case ENDPT: - return ("Endpt"); - break; - case STARTPT: - return ("Startpt"); - break; - case FLATTEN: - return ("Flatten"); - break; - } - return ("Unknown"); -} -static char *_HintKind_(int hinttype) { - switch (hinttype) { - case RB: - return ("RB"); - break; - case RV + ESCVAL: - return ("RV"); - break; - case RY: - return ("RY"); - break; - case RM + ESCVAL: - return ("RM"); - break; - } - return ("??"); -} -static char *_elttype_(int indx) { - switch (pathlist[hintsdirIx].path[indx].type) { - case RMT: - return ("Moveto"); - break; - case RDT: - return ("Lineto"); - break; - case RCT: - return ("Curveto"); - break; - case CP: - return ("Closepath"); - break; - } - return ("Unknown"); -} - -#endif - -static boolean nearlyequal_(Fixed a, Fixed b, Fixed tolerance) { - return (ABS(a - b) <= tolerance); -} - -/* Returns whether the hint values are derived from the start, - average, end or flattened curve with an inflection point of - the specified path element. Since path element numbers in - character files start from one and the path array starts - from zero we need to subtract one from the path index. */ -static short GetPointType(short hinttype, Fixed value, long *pathEltIx) { - Cd startPt, endPt; - Fixed startval, endval, loc; - short pathtype; - boolean tryAgain = TRUE; - long pathIx = *pathEltIx - 1; - -#if __CENTERLINE__ - if (TRACE) { - fprintf(stderr, "Enter GetPointType: Hinttype=%s @(%.2f) curr patheltix=%d pathIx=%d <%s>", _HintKind_(hinttype), FIXED2FLOAT(value), *pathEltIx, pathIx, _elttype_(pathIx)); - } -#endif - -retry: - GetEndPoints(hintsdirIx, pathIx, &startPt, &endPt); - switch (hinttype) { - case RB: - case RV + ESCVAL: - startval = startPt.y; - endval = endPt.y; -#if __CENTERLINE__ - if (TRACE) fprintf(stderr, "Startval Y=%.2f EndVal Y=%.2f ", FIXED2FLOAT(startval), FIXED2FLOAT(endval)); -#endif - break; - case RY: - case RM + ESCVAL: - startval = startPt.x; - endval = endPt.x; -#if __CENTERLINE__ - if (TRACE) fprintf(stderr, "Startval X=%.2f EndVal X=%.2f ", FIXED2FLOAT(startval), FIXED2FLOAT(endval)); -#endif - break; - default: - sprintf(globmsg, "Illegal hint type in character: %s.\n", currentChar); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - - /* Check for exactly equal first, in case endval = startval + 1. jvz 1nov95 */ - /* Certain cases are still ambiguous. */ - - if (value == startval) { -#if __CENTERLINE__ - if (TRACE) fprintf(stderr, "==> StartPt\n"); -#endif - return STARTPT; - } else if (value == endval) { -#if __CENTERLINE__ - if (TRACE) fprintf(stderr, "==> EndPt\n"); -#endif - return ENDPT; - } else if (nearlyequal_(value, startval, FixOne)) { -#if __CENTERLINE__ - if (TRACE) fprintf(stderr, "==> ~StartPt\n"); -#endif - return STARTPT; - } else if (nearlyequal_(value, endval, FixOne)) { -#if __CENTERLINE__ - if (TRACE) fprintf(stderr, "==> ~EndPt\n"); -#endif - return ENDPT; - } else if (value == (loc = FixHalfMul(startval + endval)) || - nearlyequal_(value, loc, FixOne)) { -#if __CENTERLINE__ - if (TRACE) fprintf(stderr, "==> Average\n"); -#endif - return AVERAGE; - } - - pathtype = pathlist[hintsdirIx].path[pathIx].type; - if (tryAgain && (pathIx + 1 < path_entries) && (pathtype != CP)) { /* try looking at other end of line or curve */ - pathIx++; - *pathEltIx += 1; - tryAgain = FALSE; -#if __CENTERLINE__ - if (TRACE) fprintf(stderr, " (Retry w/PathEltix=%d) ", *pathEltIx); -#endif - goto retry; - } - if (!tryAgain) /* reset pathEltIx to original value */ { - *pathEltIx -= 1; -#if __CENTERLINE__ - if (TRACE) fprintf(stderr, " (reset PathEltix to %d) ", *pathEltIx); -#endif - } - if (CurveBBox(hintsdirIx, hinttype, *pathEltIx - 1, &loc) && - nearlyequal_(value, loc, FixOne)) { -#if __CENTERLINE__ - if (TRACE) fprintf(stderr, "==> Curvebbox\n"); -#endif - return CURVEBBOX; - } -#if __CENTERLINE__ - if (TRACE) fprintf(stderr, "==> Flatten fallout\n"); -#endif - return FLATTEN; -} - -static void GetRelPos(long pathIx, short hinttype, Fixed hintVal, - CdPtr startPt, CdPtr endPt, Fixed *val) { - Cd origStart, origEnd; - - GetEndPoints(hintsdirIx, pathIx, &origStart, &origEnd); - if (hinttype == RB || hinttype == (RV + ESCVAL)) - GetRelativePosition(endPt->y, startPt->y, origEnd.y, origStart.y, hintVal, val); - else - GetRelativePosition(endPt->x, startPt->x, origEnd.x, origStart.x, hintVal, val); -} - -/* Calculates the relative position of hintVal between its endpoints and - gets new hint value between currEnd and currStart. */ -static void GetRelativePosition(currEnd, currStart, end, start, hintVal, fixedRelValue) - Fixed currEnd, - currStart, end, start, hintVal, *fixedRelValue; -{ - float relVal; - - if ((end - start) == 0) - *fixedRelValue = (Fixed)LROUND((float)(hintVal - start) + currStart); - else { - relVal = (float)(hintVal - start) / (float)(end - start); - *fixedRelValue = (Fixed)LROUND(((currEnd - currStart) * relVal) + currStart); - } -} - -/* For each base design, excluding HintsDir, include the - hint information at the specified path element. type1 - and type2 indicates whether to use the start, end, avg., - curvebbox or flattened curve. If a curve is to be flattened - check if this is an "s" curve and use the inflection point. If not - then use the same relative position between the two endpoints as - in the main hints dir. - hinttype is either RB, RY, RM or RV. pathEltIx - is the index into the path array where the new hint should - be stored. pathIx is the index of the path segment used to - calculate this particular hint. */ -static void InsertHint(PHintElt currHintElt, indx pathEltIx, - short type1, short type2) { - indx ix, j; - Cd startPt, endPt; - PHintElt *hintElt, newEntry; - CharPathElt pathElt; - long pathIx; - short pathtype, hinttype = currHintElt->type; - Fixed *value, ghostVal, tempVal; - -#if __CENTERLINE__ - if (TRACE) { - fprintf(stderr, "InsertHint: "); - fprintf(stderr, "Type1=%s Type2=%s", _HintType_(type1), _HintType_(type2)); - fprintf(stderr, " PathEltIndex= "); - if (pathEltIx == MAINHINTS) { - fprintf(stderr, "MainHints "); - } else { - Fixed tx, ty; - fprintf(stderr, "%d ", pathEltIx); - if (type1 != GHOST) { - GetEndPoint(hintsdirIx, currHintElt->pathix1 - 1, &tx, &ty); - fprintf(stderr, "Start attached to (%.2f %.2f)", FIXED2FLOAT(tx), FIXED2FLOAT(ty)); - } - if (type2 != GHOST) { - GetEndPoint(hintsdirIx, currHintElt->pathix2 - 1, &tx, &ty); - fprintf(stderr, "End attached to (%.2f %.2f)", FIXED2FLOAT(tx), FIXED2FLOAT(ty)); - } - } - fprintf(stderr, "\n"); - } -#endif - - if (type1 == GHOST || type2 == GHOST) - /* ghostVal should be -20 or -21 */ - ghostVal = currHintElt->rightortop - currHintElt->leftorbot; - for (ix = 0; ix < dirCount; ix++) { - if (ix == hintsdirIx) - continue; -#if DOMEMCHECK - newEntry = (PHintElt)memck_malloc(sizeof(HintElt)); -#else - newEntry = (PHintElt)AllocateMem(1, sizeof(HintElt), "hint element"); -#endif - newEntry->type = hinttype; - hintElt = - (pathEltIx == MAINHINTS ? &pathlist[ix].mainhints : &pathlist[ix].path[pathEltIx].hints); - while (*hintElt != NULL && (*hintElt)->next != NULL) - hintElt = &(*hintElt)->next; - if (*hintElt == NULL) - *hintElt = newEntry; - else - (*hintElt)->next = newEntry; - for (j = 0; j < 2; j++) { - pathIx = (j == 0 ? currHintElt->pathix1 - 1 : currHintElt->pathix2 - 1); - pathtype = (j == 0 ? type1 : type2); - value = (j == 0 ? &newEntry->leftorbot : &newEntry->rightortop); - if (pathtype != GHOST) - GetEndPoints(ix, pathIx, &startPt, &endPt); - switch (pathtype) { - case AVERAGE: - *value = ((hinttype == RB || hinttype == (RV + ESCVAL)) ? FixHalfMul(startPt.y + endPt.y) : FixHalfMul(startPt.x + endPt.x)); - break; - case CURVEBBOX: - if (!CurveBBox(ix, hinttype, pathIx, value)) { - GetRelPos(pathIx, hinttype, - ((j == 0) ? currHintElt->leftorbot : currHintElt->rightortop), - &startPt, &endPt, &tempVal); - *value = FRnd(tempVal); - } - break; - case ENDPT: - *value = ((hinttype == RB || hinttype == (RV + ESCVAL)) ? endPt.y : endPt.x); - break; - case FLATTEN: - pathElt = pathlist[ix].path[pathIx]; - if (pathElt.type != RCT) { - sprintf(globmsg, "Malformed path list: %s, dir: %d, element: %ld != RCT.\n", - currentChar, ix, pathIx); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - if (!GetInflectionPoint(startPt.x, startPt.y, pathElt.x1, pathElt.y1, - pathElt.x2, pathElt.y2, pathElt.x3, pathElt.y3, value)) { /* no flat spot found */ - /* Get relative position of value in currHintElt. */ - GetRelPos(pathIx, hinttype, - ((j == 0) ? currHintElt->leftorbot : currHintElt->rightortop), - &startPt, &endPt, &tempVal); - *value = FRnd(tempVal); - } - break; - case GHOST: - if (j == 1) - *value = newEntry->leftorbot + ghostVal; - break; - case STARTPT: - *value = ((hinttype == RB || hinttype == (RV + ESCVAL)) ? startPt.y : startPt.x); - break; - default: - sprintf(globmsg, "Illegal point type in character: %s.\n", currentChar); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - /* Assign correct value for bottom band if first path element - is a ghost band. */ - if (j == 1 && type1 == GHOST) - newEntry->leftorbot = newEntry->rightortop - ghostVal; - } - } -} - -static void ReadHints(hintElt, pathEltIx) - PHintElt hintElt; -indx pathEltIx; -{ - PHintElt currElt = hintElt; - short pointtype1, pointtype2; - - while (currElt != NULL) { - if (currElt->pathix1 != 0) - pointtype1 = - GetPointType(currElt->type, currElt->leftorbot, &(currElt->pathix1)); - else - pointtype1 = GHOST; - if (currElt->pathix2 != 0) - pointtype2 = - GetPointType(currElt->type, currElt->rightortop, &(currElt->pathix2)); - else - pointtype2 = GHOST; - InsertHint(currElt, pathEltIx, pointtype1, pointtype2); - currElt = currElt->next; - } -} - -/* Reads hints from hints directory path list and assigns corresponding - hints to other designs. */ -static int ReadandAssignHints() { - indx ix; - - /* Check for main hints first, i.e. global to character. */ - if (pathlist[hintsdirIx].mainhints != NULL) - ReadHints(pathlist[hintsdirIx].mainhints, MAINHINTS); - /* Now check for local hint values. */ - for (ix = 0; ix < path_entries; ix++) { - if (pathlist[hintsdirIx].path == NULL) - return 1; - if (pathlist[hintsdirIx].path[ix].hints != NULL) - ReadHints(pathlist[hintsdirIx].path[ix].hints, ix); - } - return 0; -} - -static boolean DoubleCheckFlexVals(dirnum, eltix, hintdirnum) - indx dirnum, - eltix, hintdirnum; -{ - boolean vert = (pathlist[hintdirnum].path[eltix].x == pathlist[hintdirnum].path[eltix + 1].x3); - if (vert) { - return (pathlist[dirnum].path[eltix].x == pathlist[dirnum].path[eltix + 1].x3); - } else { - return (pathlist[dirnum].path[eltix].y == pathlist[dirnum].path[eltix + 1].y3); - } -} - -static boolean CheckFlexOK(ix) - indx ix; -{ - indx i; - boolean flexOK = pathlist[hintsdirIx].path[ix].isFlex; - PCharPathElt end; - char pathdir[MAXPATHLEN]; - - for (i = 0; i < dirCount; i++) { - if (i == hintsdirIx) continue; - if (flexOK && (!pathlist[i].path[ix].isFlex)) { - if (!DoubleCheckFlexVals(i, ix, hintsdirIx)) { - end = &pathlist[i].path[ix]; - GetMasterDirName(pathdir, i); - sprintf(globmsg, "Flex will not be included in character: %s in '%s' at element %d near (%ld, %ld) because the character does not have flex in each design.\n", currentChar, pathdir, (int)ix, FTrunc8(end->x), FTrunc8(end->y)); - LogMsg(globmsg, WARNING, OK, TRUE); - return FALSE; - } else { - pathlist[i].path[ix].isFlex = flexOK; - } - } - } - return flexOK; -} - -static void OptimizeCT(ix) - indx ix; -{ - short newtype; - boolean vhct = TRUE, hvct = TRUE; - indx i; - - for (i = 0; i < dirCount; i++) - if (pathlist[i].path[ix].rx1 != 0 || pathlist[i].path[ix].ry3 != 0) { - vhct = FALSE; - break; - } - for (i = 0; i < dirCount; i++) - if (pathlist[i].path[ix].ry1 != 0 || pathlist[i].path[ix].rx3 != 0) { - hvct = FALSE; - break; - } - if (vhct) - newtype = VHCT; - else if (hvct) - newtype = HVCT; - if (vhct || hvct) - for (i = 0; i < dirCount; i++) - pathlist[i].path[ix].type = newtype; -} - -static void MtorDt(Cd coord, indx startix, short length) { - if (length == 2) { - WriteCd(coord); - } else if (startix == 0) - WriteX(coord.x); - else - WriteY(coord.y); -} - -static void Hvct(Cd coord1, Cd coord2, Cd coord3, indx startix, short length) { - indx ix; - indx lastix = startix + length; - - for (ix = startix; ix < lastix; ix++) - switch (ix) { - case 0: - WriteX(coord1.x); - break; - case 1: - WriteX(coord2.x); - break; - case 2: - WriteY(coord2.y); - break; - case 3: - WriteY(coord3.y); - break; - default: - sprintf(globmsg, "Invalid index value: %d defined for curveto command1 in character: %s.\n", (int)ix, currentChar); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - break; - } -} - -static void Vhct(Cd coord1, Cd coord2, Cd coord3, indx startix, short length) { - indx ix; - indx lastix = startix + length; - - for (ix = startix; ix < lastix; ix++) - switch (ix) { - case 0: - WriteY(coord1.y); - break; - case 1: - WriteX(coord2.x); - break; - case 2: - WriteY(coord2.y); - break; - case 3: - WriteX(coord3.x); - break; - default: - sprintf(globmsg, "Invalid index value: %d defined for curveto command2 in character:%s.\n", (int)ix, currentChar); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - break; - } -} - -/* length can only be 1, 2, 3 or 6 */ -static void Ct(Cd coord1, Cd coord2, Cd coord3, indx startix, short length) { - indx ix; - indx lastix = startix + length; - - for (ix = startix; ix < lastix; ix++) - switch (ix) { - case 0: - WriteX(coord1.x); - break; - case 1: - WriteY(coord1.y); - break; - case 2: - WriteX(coord2.x); - break; - case 3: - WriteY(coord2.y); - break; - case 4: - WriteX(coord3.x); - break; - case 5: - WriteY(coord3.y); - break; - default: - sprintf(globmsg, "Invalid index value: %d defined for curveto command3 in character: %s.\n", (int)ix, currentChar); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - break; - } -} - -static void ReadHorVStem3Values(indx pathIx, short eltno, short hinttype, - boolean *errormsg) { - indx ix; - PHintElt *hintElt; - short count, newhinttype; - boolean ok = TRUE; - Fixed min, dmin, mid, dmid, max, dmax; - char dirname[MAXPATHLEN]; - - for (ix = 0; ix < dirCount; ix++) { - count = 1; - if (ix == hintsdirIx) - continue; - GetMasterDirName(dirname, ix); - hintElt = (pathIx == MAINHINTS ? &pathlist[ix].mainhints : &pathlist[ix].path[pathIx].hints); - /* Find specified hint element. */ - while (*hintElt != NULL && count != eltno) { - hintElt = &(*hintElt)->next; - count++; - } - /* Check that RM or RV type is in pairs of threes. */ - if (*hintElt == NULL || (*hintElt)->next == NULL || (*hintElt)->next->next == NULL) { - sprintf(globmsg, "Invalid format for hint operator: hstem3 or vstem3 in character: %s/%s.\n", dirname, currentChar); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - if ((*hintElt)->type != hinttype || (*hintElt)->next->type != hinttype || (*hintElt)->next->next->type != hinttype) { - sprintf(globmsg, "Invalid format for hint operator: hstem3 or vstem3 in character: %s in '%s'.\n", currentChar, dirname); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - min = (*hintElt)->leftorbot; - dmin = (*hintElt)->rightortop - min; - mid = (*hintElt)->next->leftorbot; - dmid = (*hintElt)->next->rightortop - mid; - max = (*hintElt)->next->next->leftorbot; - dmax = (*hintElt)->next->next->rightortop - max; - /* Check that counters are the same width and stems are the same width. */ - if (dmin != dmax || - (((mid + dmid / 2) - (min + dmin / 2)) != ((max + dmax / 2) - (mid + dmid / 2)))) { - ok = FALSE; - break; - } - } - if (!ok) { /* change RM's to RY's or RV's to RB's for this element in each directory */ - newhinttype = (hinttype == (RM + ESCVAL) ? RY : RB); - if (*errormsg) { - sprintf(globmsg, "Near miss for using operator: %s in character: %s in '%s'. (min=%ld..%ld[delta=%ld], mid=%ld..%ld[delta=%ld], max=%ld..%ld[delta=%ld])\n", - (hinttype == (RM + ESCVAL)) ? "vstem3" : "hstem3", - currentChar, dirname, - FTrunc8((*hintElt)->leftorbot), FTrunc8((*hintElt)->rightortop), FTrunc8((*hintElt)->rightortop - (*hintElt)->leftorbot), - FTrunc8((*hintElt)->next->leftorbot), FTrunc8((*hintElt)->next->rightortop), FTrunc8((*hintElt)->next->rightortop - (*hintElt)->next->leftorbot), - FTrunc8((*hintElt)->next->next->leftorbot), FTrunc8((*hintElt)->next->next->rightortop), FTrunc8((*hintElt)->next->next->rightortop - (*hintElt)->next->next->leftorbot)); - LogMsg(globmsg, WARNING, OK, TRUE); - *errormsg = FALSE; - } - for (ix = 0; ix < dirCount; ix++) { - count = 1; - hintElt = (pathIx == MAINHINTS ? &pathlist[ix].mainhints : &pathlist[ix].path[pathIx].hints); - /* Find specified hint element. */ - while (*hintElt != NULL && count != eltno) { - hintElt = &(*hintElt)->next; - count++; - } - /* Already checked that hintElt->next, etc. exists, - so don't need to do it again. */ - (*hintElt)->type = newhinttype; - (*hintElt)->next->type = newhinttype; - (*hintElt)->next->next->type = newhinttype; - } - } -} - -/* Go through each hint element and check that all rm's and rv's - meet the necessary criteria. */ -static void FindHandVStem3(hintElt, pathIx, errormsg) - PHintElt *hintElt; -indx pathIx; -boolean *errormsg; -{ - short count = 1; - - while (*hintElt != NULL) { - if ((*hintElt)->type == (RM + ESCVAL) || (*hintElt)->type == (RV + ESCVAL)) { - ReadHorVStem3Values(pathIx, count, (*hintElt)->type, errormsg); - /* RM's and RV's are in pairs of 3 */ - hintElt = &(*hintElt)->next->next->next; - count += 3; - } else { - hintElt = &(*hintElt)->next; - count++; - } - } -} - -static void CheckHandVStem3() { - indx ix; - boolean errormsg = TRUE; - - FindHandVStem3(&pathlist[hintsdirIx].mainhints, MAINHINTS, &errormsg); - for (ix = 0; ix < path_entries; ix++) - FindHandVStem3(&pathlist[hintsdirIx].path[ix].hints, ix, &errormsg); -} - -static void CheckFlexValues(short *operator, indx eltix, indx flexix, - boolean *xequal, boolean *yequal) { - indx ix; - Cd coord; - - *operator= RMT; - if (flexix < 2) return; - - *xequal = *yequal = TRUE; - for (ix = 1; ix < dirCount; ix++) - switch (flexix) { - case 2: - if ((coord.x = pathlist[ix].path[eltix].rx2) != pathlist[ix - 1].path[eltix].rx2) - *xequal = FALSE; - if ((coord.y = pathlist[ix].path[eltix].ry2) != pathlist[ix - 1].path[eltix].ry2) - *yequal = FALSE; - break; - case 3: - if ((coord.x = pathlist[ix].path[eltix].rx3) != pathlist[ix - 1].path[eltix].rx3) - *xequal = FALSE; - if ((coord.y = pathlist[ix].path[eltix].ry3) != pathlist[ix - 1].path[eltix].ry3) - *yequal = FALSE; - break; - case 4: - if ((coord.x = pathlist[ix].path[eltix + 1].rx1) != pathlist[ix - 1].path[eltix + 1].rx1) - *xequal = FALSE; - if ((coord.y = pathlist[ix].path[eltix + 1].ry1) != pathlist[ix - 1].path[eltix + 1].ry1) - *yequal = FALSE; - break; - case 5: - if ((coord.x = pathlist[ix].path[eltix + 1].rx2) != pathlist[ix - 1].path[eltix + 1].rx2) - *xequal = FALSE; - if ((coord.y = pathlist[ix].path[eltix + 1].ry2) != pathlist[ix - 1].path[eltix + 1].ry2) - *yequal = FALSE; - break; - case 6: - if ((coord.x = pathlist[ix].path[eltix + 1].rx3) != pathlist[ix - 1].path[eltix + 1].rx3) - *xequal = FALSE; - if ((coord.y = pathlist[ix].path[eltix + 1].ry3) != pathlist[ix - 1].path[eltix + 1].ry3) - *yequal = FALSE; - break; - case 7: - if ((coord.x = pathlist[ix].path[eltix + 1].x3) != pathlist[ix - 1].path[eltix + 1].x3) - *xequal = FALSE; - if ((coord.y = pathlist[ix].path[eltix + 1].y3) != pathlist[ix - 1].path[eltix + 1].y3) - *yequal = FALSE; - break; - } - if (!(*xequal) && !(*yequal)) - return; - - if (*xequal && (coord.x == 0)) { - *operator= VMT; - *xequal = FALSE; - } - if (*yequal && (coord.y == 0)) { - *operator= HMT; - *yequal = FALSE; - } -} - -static void GetFlexCoord(rmtCt, dirix, eltix, coord) - indx rmtCt, - dirix, eltix; -CdPtr coord; -{ - switch (rmtCt) { - case 0: - (*coord).x = refPtArray[dirix].x - pathlist[dirix].path[eltix].x; - (*coord).y = refPtArray[dirix].y - pathlist[dirix].path[eltix].y; - break; - case 1: - (*coord).x = pathlist[dirix].path[eltix].x1 - refPtArray[dirix].x; - (*coord).y = pathlist[dirix].path[eltix].y1 - refPtArray[dirix].y; - break; - case 2: - (*coord).x = pathlist[dirix].path[eltix].rx2; - (*coord).y = pathlist[dirix].path[eltix].ry2; - break; - case 3: - (*coord).x = pathlist[dirix].path[eltix].rx3; - (*coord).y = pathlist[dirix].path[eltix].ry3; - break; - case 4: - (*coord).x = pathlist[dirix].path[eltix + 1].rx1; - (*coord).y = pathlist[dirix].path[eltix + 1].ry1; - break; - case 5: - (*coord).x = pathlist[dirix].path[eltix + 1].rx2; - (*coord).y = pathlist[dirix].path[eltix + 1].ry2; - break; - case 6: - (*coord).x = pathlist[dirix].path[eltix + 1].rx3; - (*coord).y = pathlist[dirix].path[eltix + 1].ry3; - break; - case 7: - (*coord).x = pathlist[dirix].path[eltix + 1].x3; - (*coord).y = pathlist[dirix].path[eltix + 1].y3; - break; - } -} - -/* NOTE: Mathematical transformations are applied to the multi-master - data in order to decrease the computation during font execution. - See /user/foley/atm/blendfont1.910123 for the definition of this - transformation. This transformation is applied whenever charstring - data is written (i.e. sb and width, flex, hints, dt, ct, mt) AND - an OtherSubr 7 - 11 will be called. */ -static void WriteFlex(eltix) - indx eltix; -{ -#if !AC_C_LIB - boolean vert = (pathlist[hintsdirIx].path[eltix].x == pathlist[hintsdirIx].path[eltix + 1].x3); - Cd coord, coord0; /* array of reference points */ - boolean xsame, ysame, writeSubrOnce; - char operator[MAXOPLEN]; /* rmt, hmt, vmt */ - short optype; - indx ix, j, opix, startix; - short opcount, subrIx, length; - -#if DOMEMCHECK - refPtArray = (Cd *)memck_malloc(dirCount * sizeof(Cd)); -#else - refPtArray = (Cd *)AllocateMem(dirCount, sizeof(Cd), "reference point array"); -#endif - for (ix = 0; ix < dirCount; ix++) { - refPtArray[ix].x = (vert ? pathlist[ix].path[eltix].x : pathlist[ix].path[eltix].x3); - refPtArray[ix].y = (vert ? pathlist[ix].path[eltix].y3 : pathlist[ix].path[eltix].y); - } - WriteStr("1 subr\n"); - for (j = 0; j < 8; j++) { - if (j == 7) - WRTNUM(DMIN); - xsame = ysame = FALSE; - CheckFlexValues(&optype, eltix, j, &xsame, &ysame); - opcount = GetOperandCount(optype); - if ((xsame && !ysame) || (!xsame && ysame)) - GetLengthandSubrIx((opcount = 1), &length, &subrIx); - else - GetLengthandSubrIx(opcount, &length, &subrIx); - GetOperator(optype, operator); - GetFlexCoord(j, 0, eltix, &coord); - coord0.x = coord.x; - coord0.y = coord.y; - if (j == 7) { - if (!xsame && (optype == VMT)) - WriteX(coord.x); /* usually=0. cf bottom of "CheckFlexValues" */ - } - if (xsame && ysame) { - WriteCd(coord); - } else if (xsame) { - WriteX(coord.x); - if (optype != HMT) { - for (ix = 0; ix < dirCount; ix++) { - GetFlexCoord(j, ix, eltix, &coord); - WriteY((ix == 0 ? coord.y : coord.y - coord0.y)); - } - WriteSubr(subrIx); - } - } else if (ysame) { - if (optype != VMT) { - for (ix = 0; ix < dirCount; ix++) { - GetFlexCoord(j, ix, eltix, &coord); - WriteX((ix == 0 ? coord.x : coord.x - coord0.x)); - } - WriteSubr(subrIx); - } - WriteY(coord.y); - } else { - startix = 0; - if ((writeSubrOnce = (length == opcount))) { - if (optype == HMT) - WriteX(coord.x); - else if (optype == VMT) - WriteY(coord.y); - else - WriteCd(coord); - length = startix = 1; - } - for (opix = 0; opix < opcount; opix += length) { - for (ix = startix; ix < dirCount; ix++) { - GetFlexCoord(j, ix, eltix, &coord); - if (ix != 0) { - coord.x -= coord0.x; - coord.y -= coord0.y; - } - switch (optype) { - case HMT: - WriteX(coord.x); - break; - case VMT: - WriteY(coord.y); - break; - case RMT: - MtorDt(coord, opix, length); - break; - } - } - if (!writeSubrOnce || (opix == (opcount - 1))) - WriteSubr(subrIx); - } /* end of for opix */ - } /* end of last else clause */ - if (j != 7) { - sprintf(outstr, "%s 2 subr\n", operator); - WriteToBuffer(); - } - if (j == 7) { - if (!ysame && (optype == HMT)) - WriteY(coord.y); /* usually=0. cf bottom of "CheckFlexValues" */ - } - } /* end of j for loop */ - WriteStr("0 subr\n"); - flexexists = TRUE; -#if DOMEMCHECK - memck_free(refPtArray); -#else - UnallocateMem(refPtArray); -#endif - -#endif /* AC_C_LIB */ -} - -static void WriteHints(pathEltIx) - indx pathEltIx; -{ - indx ix, opix, startix; - short rmcount, rvcount, hinttype; - short opcount, subrIx, length; - PHintElt *hintArray; - boolean lbsame, rtsame, writeSubrOnce; - - /* hintArray contains the pointers to the beginning of the linked list of hints for - each design at pathEltIx. */ -#if DOMEMCHECK - hintArray = (PHintElt *)memck_malloc(dirCount * sizeof(HintElt *)); -#else - hintArray = (PHintElt *)AllocateMem(dirCount, sizeof(HintElt *), "hint element array"); -#endif - /* Initialize hint array. */ - for (ix = 0; ix < dirCount; ix++) - hintArray[ix] = - (pathEltIx == MAINHINTS ? pathlist[ix].mainhints : pathlist[ix].path[pathEltIx].hints); - if (pathEltIx != MAINHINTS) - WriteStr("beginsubr snc\n"); - rmcount = rvcount = 0; - while (hintArray[0] != NULL) { - startix = 0; - hinttype = hintArray[hintsdirIx]->type; - for (ix = 0; ix < dirCount; ix++) { - hintArray[ix]->rightortop -= hintArray[ix]->leftorbot; /* relativize */ - if ((hinttype == RY || hinttype == (RM + ESCVAL)) && !cubeLibrary) - /* if it is a cube library, sidebearings are considered to be zero */ - /* for normal fonts, translate vstem hints left by sidebearing */ - hintArray[ix]->leftorbot -= IntToFix(pathlist[ix].sb); - } - lbsame = rtsame = TRUE; - for (ix = 1; ix < dirCount; ix++) { - if (hintArray[ix]->leftorbot != hintArray[ix - 1]->leftorbot) - lbsame = FALSE; - if (hintArray[ix]->rightortop != hintArray[ix - 1]->rightortop) - rtsame = FALSE; - } - if (lbsame && rtsame) { - WriteOneHintVal(hintArray[0]->leftorbot); - WriteOneHintVal(hintArray[0]->rightortop); - } else if (lbsame) { - WriteOneHintVal(hintArray[0]->leftorbot); - for (ix = 0; ix < dirCount; ix++) - WriteOneHintVal((ix == 0 ? hintArray[ix]->rightortop : hintArray[ix]->rightortop - hintArray[0]->rightortop)); - GetLengthandSubrIx(1, &length, &subrIx); - WriteSubr(subrIx); - } else if (rtsame) { - for (ix = 0; ix < dirCount; ix++) - WriteOneHintVal((ix == 0 ? hintArray[ix]->leftorbot : hintArray[ix]->leftorbot - hintArray[0]->leftorbot)); - GetLengthandSubrIx(1, &length, &subrIx); - WriteSubr(subrIx); - WriteOneHintVal(hintArray[0]->rightortop); - } else { - opcount = GetOperandCount(hinttype); - GetLengthandSubrIx(opcount, &length, &subrIx); - if ((writeSubrOnce = (length == opcount))) { - WriteOneHintVal(hintArray[0]->leftorbot); - WriteOneHintVal(hintArray[0]->rightortop); - length = startix = 1; - } - for (opix = 0; opix < opcount; opix += length) { - for (ix = startix; ix < dirCount; ix++) { - if (opix == 0) - WriteOneHintVal((ix == 0 ? hintArray[ix]->leftorbot : hintArray[ix]->leftorbot - hintArray[0]->leftorbot)); - else - WriteOneHintVal((ix == 0 ? hintArray[ix]->rightortop : hintArray[ix]->rightortop - hintArray[0]->rightortop)); - } - if (!writeSubrOnce || (opix == (opcount - 1))) - WriteSubr(subrIx); - } - } - switch (hinttype) { - case RB: - WriteStr("rb\n"); - break; - case RV + ESCVAL: - if (++rvcount == 3) { - rvcount = 0; - WriteStr("rv\n"); - } - break; - case RY: - WriteStr("ry\n"); - break; - case RM + ESCVAL: - if (++rmcount == 3) { - rmcount = 0; - WriteStr("rm\n"); - } - break; - default: - sprintf(globmsg, "Illegal hint type: %d in character: %s.\n", hinttype, currentChar); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - for (ix = 0; ix < dirCount; ix++) - hintArray[ix] = (hintArray[ix]->next == NULL) ? NULL : hintArray[ix]->next; - } /* end of while */ - if (pathEltIx != MAINHINTS) - WriteStr("endsubr enc\nnewcolors\n"); -#if DOMEMCHECK - memck_free(hintArray); -#else - UnallocateMem(hintArray); -#endif -} - -static void WritePathElt(indx dirIx, indx eltIx, short pathType, - indx startix, short length) { - Cd c1, c2, c3; - PCharPathElt path, path0; - - path = &pathlist[dirIx].path[eltIx]; - path0 = &pathlist[0].path[eltIx]; - - switch (pathType) { - case HDT: - case HMT: - WriteX((dirIx == 0 ? path->rx : path->rx - path0->rx)); - break; - case VDT: - case VMT: - WriteY((dirIx == 0 ? path->ry : path->ry - path0->ry)); - break; - case RDT: - case RMT: - c1.x = (dirIx == 0 ? path->rx : path->rx - path0->rx); - c1.y = (dirIx == 0 ? path->ry : path->ry - path0->ry); - MtorDt(c1, startix, length); - break; - case HVCT: - case VHCT: - case RCT: - if (dirIx == 0) { - c1.x = path->rx1; - c1.y = path->ry1; - c2.x = path->rx2; - c2.y = path->ry2; - c3.x = path->rx3; - c3.y = path->ry3; - } else { - c1.x = path->rx1 - path0->rx1; - c1.y = path->ry1 - path0->ry1; - c2.x = path->rx2 - path0->rx2; - c2.y = path->ry2 - path0->ry2; - c3.x = path->rx3 - path0->rx3; - c3.y = path->ry3 - path0->ry3; - } - if (pathType == RCT) - Ct(c1, c2, c3, startix, length); - else if (pathType == HVCT) - Hvct(c1, c2, c3, startix, length); - else - Vhct(c1, c2, c3, startix, length); - break; - case CP: - break; - default: { - sprintf(globmsg, "Illegal path operator %d found in character: %s.\n", - (int)pathType, currentChar); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - } -} - -static void OptimizeMtorDt(eltix, op, xequal, yequal) - indx eltix; -short *op; -boolean *xequal, *yequal; -{ - indx ix; - - *xequal = *yequal = TRUE; - for (ix = 1; ix < dirCount; ix++) { - *xequal = *xequal && - (pathlist[ix].path[eltix].rx == pathlist[ix - 1].path[eltix].rx); - *yequal = *yequal && - (pathlist[ix].path[eltix].ry == pathlist[ix - 1].path[eltix].ry); - } - if (*xequal && pathlist[0].path[eltix].rx == 0) { - *op = (*op == RMT) ? VMT : VDT; - *xequal = FALSE; - } else if (*yequal && pathlist[0].path[eltix].ry == 0) { - *op = (*op == RMT) ? HMT : HDT; - *yequal = FALSE; - } -} - -static boolean CoordsEqual(indx dir1, indx dir2, indx opIx, indx eltIx, short op) { - PCharPathElt path1 = &pathlist[dir1].path[eltIx], path2 = &pathlist[dir2].path[eltIx]; - char dirname[MAXPATHLEN]; - - switch (opIx) { - case 0: - if (op == RCT || op == HVCT) - return (path1->rx1 == path2->rx1); - else /* op == VHCT */ - return (path1->ry1 == path2->ry1); - break; - case 1: - if (op == RCT) - return (path1->ry1 == path2->ry1); - else - return (path1->rx2 == path2->rx2); - break; - case 2: - if (op == RCT) - return (path1->rx2 == path2->rx2); - else - return (path1->ry2 == path2->ry2); - break; - case 3: - if (op == RCT) - return (path1->ry2 == path2->ry2); - else if (op == HVCT) - return (path1->ry3 == path2->ry3); - else /* op == VHCT */ - return (path1->rx3 == path2->rx3); - break; - case 4: - return (path1->rx3 == path2->rx3); - break; - case 5: - return (path1->ry3 == path2->ry3); - break; - default: - GetMasterDirName(dirname, dir1); - sprintf(globmsg, "Invalid index value: %d defined for curveto command4 in character: %s. Op=%d, dir=%s near (%ld %ld).\n", (int)opIx, currentChar, (int)op, dirname, FTrunc8(path1->x), FTrunc8(path1->y)); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - break; - } - - return 0; -} - -/* Checks if path element values are the same for the RCT, HVCT and VHCT - operators in each master directory between operands startIx to - startIx + length. Returns TRUE if they are the same and FALSE otherwise. */ -static boolean SamePathValues(indx eltIx, short op, indx startIx, short length) { - indx ix, dirIx; - /* PCharPathElt path0 = &pathlist[0].path[eltIx]; */ - boolean same = TRUE; - - for (ix = 0; ix < length; ix++) { - for (dirIx = 1; dirIx < dirCount; dirIx++) - if (!(same = same && CoordsEqual(dirIx, 0, startIx, eltIx, op))) - return FALSE; - startIx++; - } - return TRUE; -} - -/* Takes multiple path descriptions for the same character name and - combines them into a single path description using new subroutine - calls 7 - 11. */ -static void CombinePaths() { -#if !AC_C_LIB - indx ix, eltix, opix, startIx, dirIx; - short length, subrIx, opcount, op; - char operator[MAXOPLEN]; - boolean xequal, yequal; - - if (!cubeLibrary) - WriteSbandWidth(); - if (addHints && (pathlist[hintsdirIx].mainhints != NULL)) - WriteHints(MAINHINTS); - WriteStr("sc\n"); - firstMT = TRUE; - for (eltix = 0; eltix < path_entries; eltix++) { - /* A RDT may be tagged 'remove' because it is followed by a point CP. */ - /* See AddLineCube(). */ - if (pathlist[0].path[eltix].remove) - continue; - - xequal = yequal = FALSE; - if (addHints && (pathlist[hintsdirIx].path[eltix].hints != NULL)) - WriteHints(eltix); - switch (pathlist[0].path[eltix].type) { - case RMT: - if (firstMT && !cubeLibrary) /* translate by sidebearing value */ - /* don't want this for cube */ - for (ix = 0; ix < dirCount; ix++) - pathlist[ix].path[eltix].rx -= IntToFix(pathlist[ix].sb); - firstMT = FALSE; - case RDT: - case CP: - break; - case RCT: - if (CheckFlexOK(eltix)) { - WriteFlex(eltix); - /* Since we know the next element is a flexed curve and - has been written out we skip it. */ - eltix++; - continue; - } - /* Try to use optimized operators. */ - if ((pathlist[0].path[eltix].rx1 == 0 && pathlist[0].path[eltix].ry3 == 0) || (pathlist[0].path[eltix].ry1 == 0 && pathlist[0].path[eltix].rx3 == 0)) - OptimizeCT(eltix); - break; - default: - sprintf(globmsg, "Unknown operator in character: %s.\n", currentChar); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - op = pathlist[0].path[eltix].type; - if (op != RCT && op != HVCT && op != VHCT && op != CP) - /* Try to use optimized operators. */ - OptimizeMtorDt(eltix, &op, &xequal, &yequal); - startIx = 0; - opcount = GetOperandCount(op); - GetLengthandSubrIx(opcount, &length, &subrIx); - if (xequal && yequal) { - WritePathElt(0, eltix, op, 0, opcount); - } else if (xequal) { - WriteX(pathlist[0].path[eltix].rx); - if (op != HMT && op != HDT) { - for (ix = 0; ix < dirCount; ix++) - WriteY(((ix == 0) ? pathlist[ix].path[eltix].ry : pathlist[ix].path[eltix].ry - pathlist[0].path[eltix].ry)); - GetLengthandSubrIx(1, &length, &subrIx); - WriteSubr(subrIx); - } - } else if (yequal) { - if (op != VMT && op != VDT) { - for (ix = 0; ix < dirCount; ix++) - WriteX(((ix == 0) ? pathlist[ix].path[eltix].rx : pathlist[ix].path[eltix].rx - pathlist[0].path[eltix].rx)); - GetLengthandSubrIx(1, &length, &subrIx); - WriteSubr(subrIx); - } - WriteY(pathlist[0].path[eltix].ry); - } else - for (opix = 0; opix < opcount; opix += length) { - WritePathElt(0, eltix, op, opix, length); - startIx = opix; - if (op == RCT || op == HVCT || op == VHCT) - if (SamePathValues(eltix, op, startIx, length)) - continue; - for (ix = 0; ix < length; ix++) { - for (dirIx = 1; dirIx < dirCount; dirIx++) - WritePathElt(dirIx, eltix, op, startIx, 1); - startIx++; - } - if (subrIx >= 0 && op != CP) - WriteSubr(subrIx); - } /* end of for opix */ - GetOperator(op, operator); - WriteStr(operator); - } /* end of for eltix */ - WriteStr("ed\n"); -#endif /* AC_C_LIB */ -} - -/* Returns number of operands for the given operator. */ -extern short GetOperandCount(short op) { - short count; - - if (op < ESCVAL) { - switch (op) { - case CP: - case HDT: - case HMT: - case VDT: - case VMT: - count = 1; - break; - case RMT: - case RDT: - case RB: - case RY: - case SBX: - count = 2; - break; - case HVCT: - case VHCT: - count = 4; - break; - case RCT: - count = 6; - break; - default: - sprintf(globmsg, "Unknown operator in character: %s.\n", currentChar); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - break; - } - } else { /* handle escape operators */ - switch (op - ESCVAL) { - case RM: - case RV: - count = 2; - break; - } - } - return count; -} - -/* Returns the subr number to use for a given operator in subrIx and - checks that the argument length of each subr call does not - exceed the font interpreter stack limit. */ -extern void GetLengthandSubrIx(short opcount, short *length, short *subrIx) { - if (((opcount * dirCount) > FONTSTKLIMIT) && opcount != 1) - if ((opcount / 2 * dirCount) > FONTSTKLIMIT) - if ((2 * dirCount) > FONTSTKLIMIT) - *length = 1; - else - *length = 2; - else - *length = opcount / 2; - else - *length = opcount; - if (((*length) * dirCount) > FONTSTKLIMIT) { - sprintf(globmsg, "Font stack limit exceeded for character: %s.\n", currentChar); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - if (!cubeLibrary) { - switch (*length) { - case 1: - *subrIx = 7; - break; - case 2: - *subrIx = 8; - break; - case 3: - *subrIx = 9; - break; - case 4: - *subrIx = 10; - break; - case 6: - *subrIx = 11; - break; - default: - sprintf(globmsg, "Illegal operand length for character: %s.\n", currentChar); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - break; - } - } else { /* CUBE */ - switch (dirCount) { - case 2: - switch (*length) { - case 1: - *subrIx = 7; - break; - case 2: - *subrIx = 8; - break; - case 3: - *subrIx = 9; - break; - case 4: - *subrIx = 10; - break; - case 6: - *subrIx = 11; - break; - default: - sprintf(globmsg, "Illegal operand length for character: %s.\n", currentChar); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - break; - } - break; - - case 4: - switch (*length) { - case 1: - *subrIx = 12; - break; - case 2: - *subrIx = 13; - break; - case 3: - *subrIx = 14; - break; - case 4: - *subrIx = 15; - break; - default: - sprintf(globmsg, "Illegal operand length for character: %s.\n", currentChar); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - break; - } - break; - - case 8: - switch (*length) { - case 1: - *subrIx = 16; - break; - case 2: - *subrIx = 17; - break; - default: - sprintf(globmsg, "Illegal operand length for character: %s.\n", currentChar); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - break; - } - break; - - case 16: - switch (*length) { - case 1: - *subrIx = 18; - break; - default: - sprintf(globmsg, "Illegal operand length for character: %s.\n", currentChar); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - break; - } - break; - - default: - LogMsg("Illegal dirCount.\n", LOGERROR, NONFATALERROR, TRUE); - break; - } - } -} - -/********** - Normal MM fonts have their dimensionality wired into the subrs. - That is, the contents of subr 7-11 are computed on a per-font basis. - Cube fonts can be of 1-4 dimensions on a per-character basis. - But there are only a few possible combinations of these numbers - because we are limited by the stack size: - - dimensions arguments values subr# - 1 1 2 7 - 1 2 4 8 - 1 3 6 9 - 1 4 8 10 - 1 6 12 11 - 2 1 4 12 - 2 2 8 13 - 2 3 12 14 - 2 4 16 15 - 3 1 8 16 - 3 2 16 17 - 4 1 16 18 - - *************/ - -extern void SetHintsDir(dirIx) - indx dirIx; -{ - hintsdirIx = dirIx; -} - -extern int GetHintsDir(void) { - return hintsdirIx; -} - -#if 0 -extern boolean MergeCharPaths(outbuffer, charname, filename, - fortransit, tr, trgroupnum) char **outbuffer, - *charname, *filename; -boolean fortransit; -Transitions *tr; -int trgroupnum; -{ - boolean ok; - int i, ix; - - byteCount = 1; - buffSize = GetMaxBytes(); - outbuff = outbuffer; - startbuff = *outbuffer; - memset(startbuff, 0, buffSize); - currentChar = charname; - -#if DEBUG_PCP - fprintf(OUTPUTBUFF, "start character %s\n", charname); -#endif - - if (!fortransit) { - dirCount = GetTotalInputDirs(); - for (i = 0; i < dirCount; i++) { - GetMasterDirName(Path_Names[i].dirnam, i); - sprintf(Path_Names[i].fullfilepath, "%s/%s/%s", - Path_Names[i].dirnam, BEZDIR, filename); - } - } else { - i = GetNumAxes(); - switch (i) { - case 1: - dirCount = 2; - break; - case 2: - dirCount = 4; - break; - case 3: - dirCount = 8; - break; - case 4: - dirCount = 16; - break; - default: - dirCount = 0; - break; - } - for (i = 0; i < dirCount; i++) { - strcpy(Path_Names[i].fullfilepath, tr->transitgrouparray[trgroupnum].assembledfilename[i]); - ix = strindex(Path_Names[i].fullfilepath, "/"); - strncpy(Path_Names[i].dirnam, Path_Names[i].fullfilepath, ix); - Path_Names[i].dirnam[ix] = '\0'; - } - } - - if (ok = CompareCharPaths(filename, fortransit)) { - CheckForZeroLengthCP(); - SetSbandWidth(charname, fortransit, tr, trgroupnum); - if (addHints && hintsdirIx >= 0 && path_entries > 0) { - if (ReadandAssignHints()) { - sprintf(globmsg, "Path problem in ReadAndAssignHints, character %s.\n", charname); - LogMsg(globmsg, LOGERROR, FATALERROR, TRUE); - } - CheckHandVStem3(); - } - CombinePaths(); - } - FreePathElements(0, dirCount); - return ok; -} -#endif diff --git a/c/autohint/autohintlib/source/bf/charpath.h b/c/autohint/autohintlib/source/bf/charpath.h deleted file mode 100644 index 9d8f9d8d2..000000000 --- a/c/autohint/autohintlib/source/bf/charpath.h +++ /dev/null @@ -1,56 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* charpath.h */ - -#ifndef CHARPATH_H -#define CHARPATH_H - -typedef struct _t_hintelt { - struct _t_hintelt *next; - short int type; /* RB, RY, RM, RV */ - Fixed leftorbot, rightortop; - long pathix1, pathix2; -} HintElt, *PHintElt; - -typedef struct _t_charpathelt { - short int type; /* RMT, RDT, RCT, CP */ - /* the following fields must be cleared in charpathpriv.c/CheckPath */ - boolean isFlex : 1, sol : 1, eol : 1, remove : 1; - int unused : 12; - PHintElt hints; - Fixed x, y, x1, y1, x2, y2, x3, y3; /* absolute coordinates */ - long rx, ry, rx1, ry1, rx2, ry2, rx3, ry3; /* relative coordinates */ -} CharPathElt, *PCharPathElt; - -typedef struct _t_pathlist { - PCharPathElt path; - PHintElt mainhints; - long sb; - short width; -} PathList, *PPathList; - -extern long path_entries; /* number of elements in a character path */ -extern boolean addHints; /* whether to include hints in the font */ - -extern PCharPathElt AppendCharPathElement(int); - -extern boolean CheckCharPath(char *, char *); - -extern short GetOperandCount(short); - -extern void GetLengthandSubrIx(short, short *, short *); - -extern void ResetMaxPathEntries(void); - -extern void SetCurrPathList(PPathList); - -extern void SetHintsDir(indx); - -extern int GetHintsDir(void); - -extern void SetHintsElt(short, CdPtr, long, long, boolean); - -extern void SetNoHints(void); - -#endif /*CHARPATH_H*/ diff --git a/c/autohint/autohintlib/source/bf/charpathpriv.c b/c/autohint/autohintlib/source/bf/charpathpriv.c deleted file mode 100644 index e14e44db6..000000000 --- a/c/autohint/autohintlib/source/bf/charpathpriv.c +++ /dev/null @@ -1,121 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* This source file should contain any procedure(s) that are called - from AC. It should not contain calls to procedures implemented - in object files that are not bound into AC. */ - -#include "buildfont.h" -#include "bftoac.h" -#include "charpath.h" - -#define MAXPATHELT 100 /* initial maximum number of path elements */ - -static long maxPathEntries = 0; -static PPathList currPathList = NULL; -long path_entries; -boolean addHints = TRUE; - -static void CheckPath( - void); - -static void CheckPath() { - if (currPathList->path == NULL) { -#if DOMEMCHECK - currPathList->path = (CharPathElt *)memck_malloc((unsigned int)maxPathEntries * sizeof(CharPathElt)); -#else - currPathList->path = (CharPathElt *)AllocateMem((unsigned int)maxPathEntries, sizeof(CharPathElt), "path element array"); -#endif - } - if (path_entries >= maxPathEntries) { - int i; - - maxPathEntries += MAXPATHELT; -#if DOMEMCHECK - currPathList->path = (PCharPathElt)memck_realloc(currPathList->path, (maxPathEntries * sizeof(CharPathElt))); -#else - currPathList->path = - (PCharPathElt)ReallocateMem((char *)currPathList->path, - maxPathEntries * sizeof(CharPathElt), "path element array"); -#endif - /* Initialize certain fields in CharPathElt, since realloc'ed memory */ - /* may be non-zero. */ - for (i = path_entries; i < maxPathEntries; i++) { - currPathList->path[i].hints = NULL; - currPathList->path[i].isFlex = FALSE; - currPathList->path[i].sol = FALSE; - currPathList->path[i].eol = FALSE; - currPathList->path[i].remove = FALSE; - } - } -} - -extern PCharPathElt AppendCharPathElement(int pathtype) { - CheckPath(); - currPathList->path[path_entries].type = pathtype; - path_entries++; - return (&currPathList->path[path_entries - 1]); -} - -/* Called from CompareCharPaths when a new character is being read. */ -extern void ResetMaxPathEntries() { - maxPathEntries = MAXPATHELT; -} - -extern void SetCurrPathList(plist) - PPathList plist; -{ - currPathList = plist; -} - -extern void SetHintsElt(short hinttype, CdPtr coord, long elt1, long elt2, boolean mainhints) { - PHintElt *hintEntry; - PHintElt lastHintEntry = NULL; - - if (!addHints) - return; - if (mainhints) /* define main hints for character */ - hintEntry = &currPathList->mainhints; - else { - CheckPath(); - hintEntry = &currPathList->path[path_entries].hints; - } -#if DOMEMCHECK - lastHintEntry = (PHintElt)memck_malloc(sizeof(HintElt)); -#else - lastHintEntry = (PHintElt)AllocateMem(1, sizeof(HintElt), "hint element"); -#endif - lastHintEntry->type = hinttype; - lastHintEntry->leftorbot = coord->x; - lastHintEntry->rightortop = coord->y; /* absolute coordinates */ - lastHintEntry->pathix1 = elt1; - lastHintEntry->pathix2 = elt2; - while (*hintEntry != NULL && (*hintEntry)->next != NULL) - hintEntry = &(*hintEntry)->next; - if (*hintEntry == NULL) - *hintEntry = lastHintEntry; - else - (*hintEntry)->next = lastHintEntry; -} - -/* Called when character file contains hinting operators, but - not the path element information needed for making blended - fonts. */ -extern void SetNoHints() { - addHints = FALSE; -} - -/* According to Bill Paxton the offset locking commands should - be replaced by hint substitution and is not necessary to - use for blended fonts. This means characters that should - have these commands may not look as good on Classic LW's. */ -/* -extern void SetOffsetLocking(locktype) -char *locktype; -{ - if (STREQ(locktype, "sol")) - currPathList[path_entries-1].sol = TRUE; - else - currPathList[path_entries-1].eol = TRUE; -} -*/ diff --git a/c/autohint/autohintlib/source/bf/chartable.h b/c/autohint/autohintlib/source/bf/chartable.h deleted file mode 100644 index 217f38cb9..000000000 --- a/c/autohint/autohintlib/source/bf/chartable.h +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -#include "buildfont.h" -#include "transitionalchars.h" - -/* Called when making an AFM file. */ - -extern void WriteCharMetrics(FILE *, indx); - -extern indx create_entry(char *name, - char *filename, - short width, - boolean derived, - indx dirix, - short masters, - short hintDir); - -extern long setnoncomps(void); - -extern void AddCCtoTable(char *, BboxPtr, BboxPtr, short, indx); - -extern void AddTransitionaltoTable(char *charname, Transitions *tr); - -extern void SetupCharTable(void); - -/* free strings allocated for char_table */ -extern void FreeCharTab(char *); - -extern void sortchartab(boolean); - -extern void GetWidthandBbox(char *, short *, BboxPtr, boolean, indx); - -/* Returns whether the given character is in the char set and has -a bez file. */ -extern boolean CharExists(char *); - -/* Check that a bez file has been seen for the given file name */ -extern boolean CharFileExists(char *); - -extern void set_char_width(char *, long, short *, indx); - -extern long writechars(boolean, char **, long *, boolean, boolean); - -extern long writesubrs(long *); - -extern long getCapDY(char *, boolean, indx); - -extern void writefontbbox(char *); - -extern void WriteBaseDesignBBox(FILE *, indx); - -extern long CharNameCost(void); - -extern void SetCharEncoding(boolean, boolean); diff --git a/c/autohint/autohintlib/source/bf/cryptdefs.h b/c/autohint/autohintlib/source/bf/cryptdefs.h deleted file mode 100644 index 1da6eb40a..000000000 --- a/c/autohint/autohintlib/source/bf/cryptdefs.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* cryptdefs.h -Original Version: Linda Gass January 4, 1987 -Edit History: -Linda Gass: Fri Jul 17 15:16:59 1987 -Linda Weinert: 3/10/87 - introduce ifndef -End Edit History. -*/ - -#include "basic.h" - -#define MAXINT32 0x7fffffffL - -#define BIN 0L -#define HEX 1L - -#define OTHER 0 -#define EEXEC 1 -#define FONTPASSWORD 2 - -#define INLEN -1L - -extern long DoContEncrypt( - char *, FILE *, boolean, long); - -extern long ContEncrypt(char *indata, FILE *outstream, boolean fileinput, long incount, boolean dblenc); - -extern short DoInitEncrypt( - FILE *, short, long, long, boolean); - -extern long DoEncrypt( - char *, FILE *, boolean, long, short, long, long, boolean, boolean); - -extern long ContDecrypt( - char *, char *, boolean, boolean, long, unsigned long); - -extern unsigned long ReadDecFile( - FILE *, char *, char *, boolean, long, unsigned long, short); - -extern void SetLenIV( - short); diff --git a/c/autohint/autohintlib/source/bf/cryptprocs.c b/c/autohint/autohintlib/source/bf/cryptprocs.c deleted file mode 100644 index 6ee4651c5..000000000 --- a/c/autohint/autohintlib/source/bf/cryptprocs.c +++ /dev/null @@ -1,447 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ - -#include "buildfont.h" -#include "cryptdefs.h" -#include "machinedep.h" - -#define C1e 1069928045L -#define C2e 226908351L -#define C1o 902381661L -#define C2o 341529579L -#define keye 121201L -#define keyo 11586L -#define keyf 85294471L -#define keyc 6492394L - -#define MAXLENIV 4 - -/* Globals used outside this source file */ -short lenIV = 4; - -/* Globals used by encryption routines. */ -static long C1, C2, key, lineLength, lineCount; -static unsigned long innerrndnum, outerrndnum; -static char hexmap[] = "0123456789abcdef"; -static int outerlenIV = 4; - -/* Globals used by decryption routines. */ -static long dec1, dec2, inchars; -static unsigned long randno; -static short decrypttype; - -/* Globals used by both encryption and decryption routines. */ -static long format; - -/* Prototypes */ - -static char *InputEnc( - char *, boolean, unsigned long *); - -static void InitEncrypt( - FILE *, boolean); - -static unsigned long DoDecrypt( - FILE *, char *, boolean, long, boolean, unsigned long, short, long, boolean); - -static void SetCryptGlobs( - int, long, boolean, long *, long *, long *); - -#define InitRnum(r, s) \ - { r = (unsigned long)s; } -#define Rnum8(r) \ - ((unsigned long)(r = (((r * C1) + C2) & 0x3fffffff) >> 8) & 0xFF) -#define Encrypt(r, clear, cipher) \ - r = ((unsigned long)((cipher = ((clear) ^ (r >> 8)) & 0xFF) + r) * C1 + C2) - -#define DoublyEncrypt(r0, r1, clear, cipher) \ - r0 = ((unsigned long)((cipher = ((clear) ^ (r0 >> 8)) & 0xFF) + r0) * C1 + C2); \ - r1 = ((unsigned long)((cipher = ((cipher) ^ (r1 >> 8)) & 0xFF) + r1) * C1 + C2); - -#define Decrypt(r, clear, cipher) \ - clear = (unsigned char)((cipher) ^ (r >> 8)) & 0xFF; \ - r = (unsigned long)((cipher) + r) * dec1 + dec2 - -#define OutputEnc(ch, stm) \ - if (format == BIN) \ - (void)putc(ch, stm); \ - else { \ - (void)putc(hexmap[(ch >> 4) & 0xF], stm); \ - (void)putc(hexmap[ch & 0xF], stm); \ - if (--lineCount <= 0) { \ - (void)putc('\n', stm); \ - lineCount = lineLength / 2; \ - } \ - } - -#define get_char(ch, stream, filein) \ - if (filein) \ - ch = (long)getc((FILE *)stream); \ - else \ - ch = (long)*stm++; \ - inchars++; - -static void SetCryptGlobs(int crypttype, long formattype, boolean chardata, long *c1, long *c2, long *k) { - format = formattype; - switch (crypttype) { - case EEXEC: - *c1 = C1e; - *c2 = C2e; - *k = (chardata ? keyc : keye); - return; - break; - case OTHER: - *c1 = C1o; - *c2 = C2o; - *k = keyo; - return; - break; - case FONTPASSWORD: - *c1 = C1o; - *c2 = C2o; - *k = keyf; - return; - break; - } - LogMsg("Invalid crypt params.\n", LOGERROR, NONFATALERROR, TRUE); -} - -static char *InputEnc(char *stm, boolean fileinput, unsigned long *cipher) { - register long c1, c2; - - get_char(c1, stm, fileinput); - if (format == BIN) { - *cipher = c1; - return (stm); - } - while (c1 <= ' ') { - if (c1 == EOF) { - *cipher = EOF; - return stm; - } - if (decrypttype == OTHER) { - get_char(c1, stm, fileinput); - } else - break; - } - get_char(c2, stm, fileinput); - while (c2 <= ' ') { - if (c2 == EOF) { - *cipher = EOF; - return stm; - } - if (decrypttype == OTHER) { - get_char(c2, stm, fileinput); - } else - break; - } - *cipher = ((c1 <= '9' ? c1 : c1 + 9) & 0xF) << 4 | ((c2 <= '9' ? c2 : c2 + 9) & 0xF); - return (stm); -} - -static char *InputPlain(stm, fileinput, clear) char *stm; -boolean fileinput; -unsigned long *clear; -{ - register long c1; - - get_char(c1, stm, fileinput); - *clear = c1; - return (stm); -} - -void SetLenIV(short len) { - lenIV = len; -} - -/* innerrndnum is a global and represents the random seed for the inner level - of double encryption. outerrndnum is the random seed for the outer level - or single encryption. This procedure generates random bytes - and ensures that the first random byte is not a whitespace character - and that at least one of the random bytes is not one of the - ASCII hexadecimal character codes. - The PS interpreter depends on this when decrypting and uses - this info to decide whether data is binary or hex encrypted. */ -static void InitEncrypt(FILE *outstream, boolean dblenc) { - register indx j; - boolean ok = FALSE; - unsigned long randomseed, clear, cipher, origouterrndnum; - time_t tm; - short keylen = (dblenc ? lenIV : outerlenIV); - char initVec[MAXLENIV]; - - get_time(&tm); - InitRnum(randomseed, (unsigned long)tm); - origouterrndnum = outerrndnum; - while (!ok) { - InitRnum(innerrndnum, key); - if (!dblenc) { /* {}'s needed for enclosing macro call. */ - InitRnum(outerrndnum, key); - } else - outerrndnum = origouterrndnum; - for (j = 0; j < keylen; j++) { - clear = Rnum8(randomseed); - if (dblenc) - Encrypt(innerrndnum, clear, cipher); - else - Encrypt(outerrndnum, clear, cipher); - if (j == 0 && (cipher == ' ' || cipher == '\t' || cipher == '\n' || cipher == '\r')) - break; - if ((cipher < '0' || cipher > '9') && (cipher < 'A' || cipher > 'F') && (cipher < 'a' || cipher > 'f')) - ok = TRUE; - if (dblenc) - Encrypt(outerrndnum, cipher, cipher); - initVec[j] = (char)(cipher & 0xFF); - } - } - lineCount = lineLength / 2; - for (j = 0; j < keylen; j++) - OutputEnc(initVec[j], outstream); -} /* InitEncrypt */ - -/* innerrndnum and outerrndnum are globals */ -extern long ContEncrypt(char *indata, FILE *outstream, boolean fileinput, long incount, boolean dblenc) { - unsigned long clear; - long encchars = 0; - - while (TRUE) { - if (fileinput) { - clear = (unsigned long)getc((FILE *)indata); - if (clear == (unsigned long)EOF) - break; - } else { - if (encchars == incount) - break; - clear = *indata++; - } - encchars++; -#ifdef ENCRYPTOUTPUT - if (dblenc) { - unsigned long cipher; - /* {}'s needed for enclosing macro call. */ - DoublyEncrypt(innerrndnum, outerrndnum, clear, cipher); - } else - Encrypt(outerrndnum, clear, cipher); - OutputEnc(((char)cipher), outstream); -#else - putc((char)clear, outstream); -#endif - } - if (fileerror(outstream)) - return (-1); - return (encchars); -} /* ContEncrypt */ - -short DoInitEncrypt(FILE *outstream, short enctype, long formattype, long linelen, boolean chardata) { - lineLength = linelen; - SetCryptGlobs(enctype, formattype, chardata, &C1, &C2, &key); - InitEncrypt(outstream, FALSE); - return (0); -} /* DoInitEncrypt */ - -/* returns the number of characters encrypted and written */ -extern long DoContEncrypt(char *indata, FILE *outstream, boolean fileinput, long incount) { - unsigned long enccount; - FILE *instream = (FILE *)indata; - - if (fileinput) - clearerr(instream); - else if (incount == INLEN) - incount = (long)strlen(indata); - clearerr(outstream); - enccount = ContEncrypt(indata, outstream, fileinput, incount, FALSE); - if ((fileinput && fileerror(instream)) || fileerror(outstream)) - return (-1); - else - return (enccount); -} /* DoContEncrypt */ - -/* Returns the number of characters encrypted and written. Returns -1 if - * an error occurred while reading or writing. The incount argument is used - * only if we are encrypting characters from memory. - */ -long DoEncrypt(char *indata, FILE *outstream, boolean fileinput, long incount, short enctype, long formattype, long linelen, - boolean chardata, boolean dblenc) { - unsigned long enccount; - FILE *instream = (FILE *)indata; - lineLength = linelen; - SetCryptGlobs(enctype, formattype, chardata, &C1, &C2, &key); - if (fileinput) - clearerr(instream); - clearerr(outstream); - InitEncrypt(outstream, dblenc); - enccount = ContEncrypt(indata, outstream, fileinput, incount, dblenc); - /* if (format==HEX && lineLength!=MAXINT && lineCount outcount) - return (-1); - *outdata++ = clear; - } - clearchars++; - } - /* Check for possible file errors. */ - if ((fileoutput && fileerror(outstream)) || - (fileinput && fileerror(instream))) - return (-1); - return (clearchars); -} - -static unsigned long DoDecrypt(FILE *instream, char *outdata, boolean fileinput, /* whether input is from file or memory */ - long incount, boolean fileoutput, /* whether output is to file or memory */ - unsigned long outcount, short dectype, /* the type of decryption */ - long formattype, boolean chardata) - -{ - unsigned long cipher, seed, clearchars = 0; - unsigned char clear; - FILE *outstream = (FILE *)outdata; - char *currPtr = (char *)instream; - int j; - short keylen = (chardata ? lenIV : outerlenIV); - - inchars = 0; - decrypttype = dectype; - SetCryptGlobs(dectype, formattype, chardata, &dec1, &dec2, (long *)&seed); - if (fileinput) - clearerr(instream); - if (fileoutput) - clearerr(outstream); - InitRnum(randno, seed); - for (j = 0; j < keylen; j++) { - currPtr = InputEnc(currPtr, fileinput, &cipher); - /* Check for empty file. */ - if (cipher == (unsigned long)EOF) - return (0); - Decrypt(randno, clear, cipher); - } - while (fileinput || (inchars < incount)) { - currPtr = InputEnc(currPtr, fileinput, &cipher); - if (cipher == (unsigned long)EOF) - break; - - Decrypt(randno, clear, cipher); - if (fileoutput) - (void)putc(clear, (FILE *)outdata); - else { - if (clearchars > outcount) - return (-1); - *outdata++ = clear; - } - clearchars++; - } - /* Since we are using getc and putc, check for file errors. */ - if (fileoutput) - if (fileerror(((FILE *)outdata))) - return (-1); - if (fileinput) - if (fileerror(instream)) - return (-1); - return (clearchars); -} /* DoDecrypt */ - -static unsigned long DoRead(FILE *instream, char *outdata, boolean fileinput, /* whether input is from file or memory */ - long incount, boolean fileoutput, /* whether output is to file or memory */ - unsigned long outcount) - -{ - unsigned long clear; - unsigned long clearchars = 0; - FILE *outstream = (FILE *)outdata; - char *currPtr = (char *)instream; - - inchars = 0; - if (fileinput) - clearerr(instream); - if (fileoutput) - clearerr(outstream); - - while (fileinput || (inchars < incount)) { - currPtr = InputPlain(currPtr, fileinput, &clear); - if (clear == (unsigned long)EOF) - break; - - if (fileoutput) - (void)putc(clear, (FILE *)outdata); - else { - if (clearchars > outcount) - return (-1); - *outdata++ = (char)(clear & 0xFF); - } - clearchars++; - } - /* Since we are using getc and putc, check for file errors. */ - if (fileoutput) - if (fileerror(((FILE *)outdata))) - return (-1); - if (fileinput) - if (fileerror(instream)) - return (-1); - return (clearchars); -} /* DoRead */ - -unsigned long ReadDecFile(FILE *instream, char *filename, char *outbuffer, - boolean fileinput /* whether input is from file or memory */, long incount, unsigned long outcount, - short dectype /* the type of decryption */) { - unsigned long cc; - boolean decrypt = 1; - char c; - - if (fileinput) { - c = getc(instream); - ungetc(c, instream); - } else - c = *((char *)instream); - - if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'f') || (c >= 'A' && c <= 'F')) - decrypt = 1; - else - decrypt = 0; - - if (decrypt) - cc = DoDecrypt(instream, outbuffer, fileinput, incount, FALSE, outcount, dectype, HEX, FALSE); - else - cc = DoRead(instream, outbuffer, fileinput, incount, FALSE, outcount); - - switch (cc) { - case -1: - sprintf(globmsg, "A file error occurred in the %s file.\n", filename); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - break; - } - return (cc); -} diff --git a/c/autohint/autohintlib/source/bf/derivedchars.h b/c/autohint/autohintlib/source/bf/derivedchars.h deleted file mode 100644 index 88f188fff..000000000 --- a/c/autohint/autohintlib/source/bf/derivedchars.h +++ /dev/null @@ -1,23 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* derivedchars.h */ - -#ifndef DERIVEDCHARS_H -#define DERIVEDCHARS_H - -#define DERIVEDCHARFILENAME "derivedchars" - -extern void free_derivedtables( - boolean, indx); - -extern char **make_derivedchars( - boolean, short *, indx); - -extern void readderived( - boolean, indx); - -extern void CheckDerivedFileSizes( - int, int); - -#endif diff --git a/c/autohint/autohintlib/source/bf/fileops.c b/c/autohint/autohintlib/source/bf/fileops.c deleted file mode 100644 index b560c83d4..000000000 --- a/c/autohint/autohintlib/source/bf/fileops.c +++ /dev/null @@ -1,553 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ - -#include "buildfont.h" -#include "afmcharsetdefs.h" -#include "cryptdefs.h" -#include "fipublic.h" -#include "machinedep.h" -#include "charpath.h" - -#define BAKSUFFIX ".BAK" - -static char charsetDir[MAXPATHLEN]; -static char charsetname[MAXPATHLEN]; -static char charsetPath[MAXPATHLEN]; -static char subsetPath[MAXPATHLEN]; -static char subsetname[MAXPATHLEN]; -static char working_dir[MAXPATHLEN]; /* name of directory where bf was invoked*/ -static short total_inputdirs = 1; /* number of input directories */ -static long MaxBytes; -char globmsg[MAXMSGLEN + 1]; /* used to format messages */ -static CharsetParser charsetParser; -static char charsetLayout[MAXPATHLEN]; -static char initialWorkingDir[MAXPATHLEN]; -static int initialWorkingDirLength; - -#if IS_LIB -typedef void *(*AC_MEMMANAGEFUNCPTR)(void *ctxptr, void *old, unsigned long size); -extern AC_MEMMANAGEFUNCPTR AC_memmanageFuncPtr; -extern void *AC_memmanageCtxPtr; -#endif - -#include "memcheck.h" - -typedef struct -{ - int lo; - int hi; -} SubsetData; - -extern boolean multiplemaster; /* from buildfont.c */ - -extern short strindex(s, t) /* return index of t in s, -1 if none */ - char *s, - *t; -{ - indx i, n; - - n = (indx)strlen(t); - for (i = 0; s[i] != '\0'; i++) - if (!strncmp(s + i, t, n)) - return i; - return -1; -} - -char *AllocateMem(unsigned int nelem, unsigned int elsize, const char *description) { -#if IS_LIB - char *ptr = (char *)AC_memmanageFuncPtr(AC_memmanageCtxPtr, NULL, nelem * elsize); - if (NULL != ptr) - memset((void *)ptr, 0x0, nelem * elsize); -#else - char *ptr = (char *)calloc(nelem, elsize); -#endif - if (ptr == NULL) { - sprintf(globmsg, "Cannot allocate %d bytes of memory for %s.\n", - (int)(nelem * elsize), description); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - return (ptr); -} - -char *ReallocateMem(char *ptr, unsigned int size, const char *description) { -#if IS_LIB - char *newptr = (char *)AC_memmanageFuncPtr(AC_memmanageCtxPtr, (void *)ptr, size); -#else - char *newptr = (char *)realloc(ptr, size); -#endif - if (newptr == NULL) { - sprintf(globmsg, "Cannot allocate %d bytes of memory for %s.\n", - (int)size, description); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - return (newptr); -} - -void UnallocateMem(void *ptr) { -#if IS_LIB - AC_memmanageFuncPtr(AC_memmanageCtxPtr, (void *)ptr, 0); -#else - if (ptr != NULL) { - free((char *)ptr); - ptr = NULL; - } -#endif -} - -extern unsigned long CheckFileBufferLen(buffer, filename) char **buffer, *filename; -{ - long filelen; - - filelen = ACGetFileSize(filename); - if (filelen > MaxBytes) { /* renner Tue Sep 11 14:59:37 1990 */ -#if 0 - fprintf(stderr, "Calling realloc: %ld vs %ld\n", filelen, MaxBytes); - fflush(stderr); -#endif - MaxBytes = filelen + 5; -#if DOMEMCHECK - *buffer = (char *)memck_realloc(*buffer, (MaxBytes * sizeof(char))); -#else - *buffer = (char *)ReallocateMem(*buffer, (unsigned)(MaxBytes * sizeof(char)), "file buffer"); -#endif - } - return filelen; -} - -/* ACOpenFile tries to open a file with the access attribute - specified. If fopen fails an error message is printed - and the program exits if severity = FATAL. */ -extern FILE *ACOpenFile(char *filename, char *access, short severity) { - FILE *stream; - char dirname[MAXPATHLEN]; - - stream = fopen(filename, access); - if (stream == NULL) { - GetInputDirName(dirname, ""); - switch (severity) { - case (OPENERROR): - sprintf(globmsg, "The %s file does not exist or is not accessible (currentdir='%s').\n", filename, dirname); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - break; - case (OPENWARN): - sprintf(globmsg, "The %s file does not exist or is not accessible (currentdir='%s').\n", filename, dirname); - LogMsg(globmsg, WARNING, OK, TRUE); - break; - default: - break; - } - } - return (stream); -} - -extern void FileNameLenOK(filename) char *filename; -{ - if (strlen(filename) >= MAXFILENAME) { - sprintf(globmsg, "File name: %s exceeds max allowable length of %d.\n", - filename, (int)MAXFILENAME); - LogMsg(globmsg, LOGERROR, FATALERROR, TRUE); - } -} - -extern void CharNameLenOK(charname) char *charname; -{ - if (strlen(charname) >= MAXCHARNAME) { - sprintf(globmsg, - "Character name: %s exceeds maximum allowable length of %d.\n", - charname, (int)MAXCHARNAME); - LogMsg(globmsg, LOGERROR, FATALERROR, TRUE); - } -} - -extern void PathNameLenOK(pathname) char *pathname; -{ - if (strlen(pathname) >= MAXPATHLEN) { - sprintf(globmsg, - "File name: %s exceeds maximum allowable length of %d.\n", - pathname, (int)MAXPATHLEN); - LogMsg(globmsg, LOGERROR, FATALERROR, TRUE); - } -} - -extern boolean BAKFile(filename) char *filename; -{ - short length = (short)strlen(filename); - if (length <= 4) return FALSE; - if (!strcmp(&filename[length - 4], BAKSUFFIX)) - return TRUE; - return FALSE; -} - -extern long GetMaxBytes() { - return MaxBytes; -} - -extern void SetMaxBytes(value) long value; -{ - MaxBytes = value; -} - -/* Sets the global variable charsetDir. */ -extern void set_charsetdir(dirname) char *dirname; -{ - strcpy(charsetDir, dirname); -} - -extern void getcharsetname(csname) char *csname; -{ - strcpy(csname, charsetname); -} - -void SetCharsetParser(char *fileTypeString) { - if (fileTypeString == NULL) - charsetParser = bf_CHARSET_STANDARD; - else if (STREQ(fileTypeString, "CID")) - charsetParser = bf_CHARSET_CID; - else - charsetParser = bf_CHARSET_STANDARD; -} - -CharsetParser -GetCharsetParser() { - return charsetParser; -} - -void SetCharsetLayout(char *fontinfoString) { - strcpy(charsetLayout, (fontinfoString == NULL) - ? BF_STD_LAYOUT - : fontinfoString); -} - -char * -GetCharsetLayout() { - return charsetLayout; -} - -#define INCREMENT 3 -static SubsetData *subsetdata = NULL; -static int allocation = INCREMENT; -static int allocated = 0; -static boolean usesSubset = FALSE; - -boolean -UsesSubset(void) { - return usesSubset; -} - -void SetSubsetName(char *name) { - strcpy(subsetname, name); -#if DOMEMCHECK - subsetdata = (SubsetData *)memck_malloc(INCREMENT * sizeof(SubsetData)); -#else - subsetdata = (SubsetData *)AllocateMem(INCREMENT, sizeof(SubsetData), "SetSubsetName"); -#endif - usesSubset = TRUE; -} - -char * -GetSubsetName(void) { - return (subsetname); -} - -char * -GetSubsetPath(void) { - return (subsetPath); -} - -void LoadSubsetData(void) { - FILE *fp = ACOpenFile(subsetPath, "r", OPENERROR); - int lo; - int hi; - int scanned; - - while ((scanned = fscanf(fp, "%d-%d", &lo, &hi)) > 0) { - if (scanned == 1) - subsetdata[allocated].lo = subsetdata[allocated].hi = lo; - else { - subsetdata[allocated].lo = lo; - subsetdata[allocated].hi = hi; - } - - if (++allocated >= allocation) { - allocation += INCREMENT; -#if DOMEMCHECK - subsetdata = (SubsetData *)memck_realloc(subsetdata, (allocation * sizeof(SubsetData))); -#else - subsetdata = (SubsetData *)ReallocateMem((char *)subsetdata, - allocation * sizeof(SubsetData), "LoadSubsetData"); -#endif - } - } - - fclose(fp); -} - -boolean -InSubsetData(int cid) { - int i; - - for (i = 0; i < allocated; i++) { - if ((cid >= subsetdata[i].lo) && (cid <= subsetdata[i].hi)) - return TRUE; - } - - return FALSE; -} - -/*****************************************************************************/ -/* Returns the name of the character set file. If the filename exists on */ -/* the current directory use that file, otherwise, preface it with the */ -/* character set directory name. */ -/*****************************************************************************/ -void setcharsetname(boolean release, char *csname, char *baseFontPath) { - char *filename; - long i; - char delimit[2]; - - charsetname[0] = csname[0] = '\0'; - - filename = GetFntInfo("CharacterSet", !release); - if (filename == NULL) { - LogMsg("CharacterSet keyword not found in fontinfo file.\n", - WARNING, OK, TRUE); - return; - } - - if (baseFontPath != NULL) { - sprintf(charsetname, "%s%s", baseFontPath, filename); - sprintf(subsetPath, "%s%s", baseFontPath, subsetname); - } else { - sprintf(charsetname, "%s", filename); - sprintf(subsetPath, "%s", subsetname); - } - - if (!CFileExists(charsetname, FALSE)) { - get_filedelimit(delimit); - if (((i = (long)strlen(charsetDir)) == 0) || (charsetDir[i - 1] == delimit[0])) - delimit[0] = '\0'; - - if (charsetParser == bf_CHARSET_CID) { - sprintf(charsetname, "%s%s%s%s%s%s%s", - charsetDir, delimit, - filename, delimit, - BF_LAYOUTS, delimit, - charsetLayout); - } else - sprintf(charsetname, "%s%s%s", charsetDir, delimit, filename); - } - - if (!CFileExists(subsetPath, FALSE)) { - get_filedelimit(delimit); - if (((i = (long)strlen(charsetDir)) == 0) || (charsetDir[i - 1] == delimit[0])) - delimit[0] = '\0'; - - if (charsetParser == bf_CHARSET_CID) { - sprintf(subsetPath, "%s%s%s%s%s%s%s", - charsetDir, delimit, - filename, delimit, - BF_SUBSETS, delimit, - subsetname); - } else - sprintf(subsetPath, "%s%s%s", charsetDir, delimit, subsetname); - } - -#if DOMEMCHECK - memck_free(filename); -#else - UnallocateMem(filename); -#endif - PathNameLenOK(charsetname); - strcpy(csname, charsetname); - strcpy(charsetPath, charsetname); -} - -extern void get_working_dir(dirname) char *dirname; -{ - strcpy(dirname, working_dir); -} - -extern void init_working_dir() { - GetFullPathname(working_dir, 0, MININT); - strcpy(initialWorkingDir, working_dir); - initialWorkingDirLength = (int)strlen(initialWorkingDir); -} - -extern void set_working_dir() { - set_current_dir(working_dir); -} - -extern char *GetFItoAFMCharSetName() { - char *filename; - - if (strlen(charsetDir) == 0) - return NULL; -#if DOMEMCHECK - filename = memck_malloc((strlen(charsetDir) + strlen(AFMCHARSETTABLE) + 2) * sizeof(char)); -#else - filename = AllocateMem((unsigned int)(strlen(charsetDir) + strlen(AFMCHARSETTABLE) + 2), - sizeof(char), "AFM charset filename"); -#endif - get_filename(filename, charsetDir, AFMCHARSETTABLE); - return filename; -} - -extern short GetTotalInputDirs() { - return total_inputdirs; -} - -extern void SetTotalInputDirs(short total) { - total_inputdirs = total; -} - -/* insures that the meaningful data in the buffer is terminated - * by an end of line marker and the null terminator for a string. */ -extern long ACReadFile(textptr, fd, filename, filelength) char *textptr; -FILE *fd; -char *filename; -long filelength; -{ - long cc; - - cc = ReadDecFile( - fd, filename, textptr, TRUE, MAXINT, (unsigned long)(filelength), - OTHER); - fclose(fd); - if (textptr[cc - 1] != NL || textptr[cc - 1] != '\r') - textptr[cc++] = NL; - textptr[cc] = '\0'; - return ((long)cc); -} /* ACReadFile */ - -boolean -IsHintRowMatch(char *hintDirName, char *rowDirName) { - char fontDirName[MAXPATHLEN]; - int fontDirLength; - - /**************************************************************************/ - /* It is necessary to concatenate the hintDirName and rowDirName when */ - /* doing comparisons because each of these may involve multiple path */ - /* components: a/b and x/y/z -> a/b/x/y/z */ - /**************************************************************************/ - sprintf(fontDirName, "%s/%s/", hintDirName, rowDirName); - fontDirLength = (int)strlen(fontDirName); - return ((initialWorkingDirLength >= fontDirLength) && - (strcmp(initialWorkingDir + initialWorkingDirLength - fontDirLength, - fontDirName) == 0)); -} - -boolean -IsInFullCharset(char *bezName) { - FILE *charsetFile; - char line[501]; - char hintDirName[128]; - char rowDirName[128]; - char cname[128]; - - if ((charsetFile = ACOpenFile(charsetPath, "r", OPENOK)) == NULL) - return FALSE; - while (fgets(line, 500, charsetFile) != NULL) { - switch (charsetParser) { - case bf_CHARSET_CID: - if ((sscanf(line, "%*d%s%s%s", hintDirName, rowDirName, cname) == 3) && - IsHintRowMatch(hintDirName, rowDirName) && - (STREQ(cname, bezName))) { - fclose(charsetFile); - return TRUE; - } - break; - case bf_CHARSET_STANDARD: - default: - if ((sscanf(line, "%s", cname) == 1) && - (STREQ(cname, bezName))) { - fclose(charsetFile); - return TRUE; - } - break; - } - } - - fclose(charsetFile); - return FALSE; -} - -/*****************************************************************************/ -/* ReadNames is used for reading each successive character name from the */ -/* character set file. It returns next free location for characters. */ -/*****************************************************************************/ -extern char * -ReadNames(char *cname, char *filename, long *masters, long *hintDir, - FILE *stream) { -#ifdef IS_GGL - /* This should never be called with the GGL */ - return NULL; -#else - int total_assigns; - char line[501]; - static char *result; - int done = 0; - int cid; - char hintDirName[128]; - char rowDirName[128]; - /* char fontDirName[256]; */ - /* int workingDirLength; */ - /* int fontDirLength; */ - - while (!done && ((result = fgets(line, 500, stream)) != NULL)) { - switch (charsetParser) { - case bf_CHARSET_CID: - total_assigns = sscanf(line, "%d%s%s%s", - &cid, hintDirName, rowDirName, cname); - if (total_assigns == 4) { - if (IsHintRowMatch(hintDirName, rowDirName)) { - if (subsetdata) { - if (InSubsetData(cid)) { - strcpy(filename, cname); - *masters = GetTotalInputDirs(); - *hintDir = GetHintsDir(); - done = 1; - } else - done = 0; - } else { - strcpy(filename, cname); - *masters = GetTotalInputDirs(); - *hintDir = GetHintsDir(); - done = 1; - } - } - } - break; - - case bf_CHARSET_STANDARD: - default: - total_assigns = sscanf(line, " %s %s %ld %ld", - cname, filename, masters, hintDir); - if (total_assigns >= 1) { - CharNameLenOK(cname); - - if (total_assigns == 1) strcpy(filename, cname); - - if (multiplemaster) { - FileNameLenOK(filename); - - if (total_assigns < 3) *masters = GetTotalInputDirs(); - - if (total_assigns < 4) - *hintDir = GetHintsDir(); - else - --*hintDir; /* hintDir is zero-origin */ - } else { - strcpy(filename, cname); - *masters = 1; - *hintDir = 0; - } - - done = 1; - } - break; - } - } - - return result; -#endif -} diff --git a/c/autohint/autohintlib/source/bf/filookup.c b/c/autohint/autohintlib/source/bf/filookup.c deleted file mode 100644 index 3f97e5e93..000000000 --- a/c/autohint/autohintlib/source/bf/filookup.c +++ /dev/null @@ -1,1365 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ - -/* filookup.c - looks up keywords in the fontinfo file and returns the value. */ - -#include "buildfont.h" -#include "filookup.h" -#include "fipriv.h" -#include "fipublic.h" -#include "machinedep.h" -#include "masterfont.h" -#ifdef ACLIB_EXPORTS -#include "ac.h" -#endif -#if SUN -#include -#endif -#define EOS "" -#define NOMATCH -1 -#define MAXFONTNAME 30 /* max length of the FontName = 36 chars PS */ - /* name length max due to LW ROM bug - 7 */ - /* chars for Mac coordinating + 1 for null */ - /* terminator */ - -#define DEFAULTOVRSHTPTSIZE 9.51 /* Default overshoot point size. */ - -static const char *keywordtab[KWTABLESIZE]; -static boolean tab_initialized = FALSE; -static FINODE finode; -static FIPTR fiptr = &finode; -static char endNotice[] = "EndNotice"; -static char endDirs[] = "EndDirs"; -static char endInstance[] = "EndInstances"; -static char endVectors[] = "EndVectors"; -static char fifilename[MAXPATHLEN]; - -static short lookup( - char *); - -static char *search_for_key( - char *, FILE *); - -static void make_error_return( - short, char *, char *, char *, char *); - -static void make_normal_return( - char *, boolean); - -static void append_normal_return( - char *); - -static void check_for_int( - char *, char *); - -static void check_for_intormatrix( - char *, char *); - -static void check_for_num( - char *, char *); - -static void check_for_string( - char *, char *); - -static void check_for_boolean( - char *, char *); - -static void check_for_matrix( - char *, char *, boolean); - -static void check_PS_comment( - char *); - -static void checkovershootvalue( - char *, boolean, boolean); - -static boolean checkovershoots( - void); - -static char *get_middle_lines( - char *, char *, boolean); - -static char *get_keyword_value( - char *, char *); - -static void init_kw_tab( - void); - -static char *get_base_font_path( - void); - -static char *GetHVStems( - char *, boolean); - -static void CheckStemSnap( - char *); - -#ifdef SUN -static boolean valueOK = TRUE; -#endif - -void fiptrfree(FIPTR ptr) { -#if DOMEMCHECK - memck_free(ptr->value_string); -#else - UnallocateMem(ptr->value_string); -#endif -} - -/* Look up the keyword parameter in the table to get the index */ -static short lookup(key) char *key; -{ - indx kwindex; - - for (kwindex = 0; kwindex < KWTABLESIZE; kwindex++) - if (STREQ(key, keywordtab[kwindex])) - return (kwindex); - return (NOMATCH); -} - -/* This proc reads through the given file searching for a line - with its first word the same as key. If it finds such a - line it returns it. */ -static char *search_for_key(key, file) char *key; -FILE *file; -{ - char *line; - char linekey[LINELEN + 1]; -#if DOMEMCHECK - line = memck_malloc((unsigned)LINELEN * sizeof(char)); -#else - line = AllocateMem((unsigned)LINELEN, sizeof(char), "font info buffer"); -#endif - while (fgets(line, LINELEN, file) != NULL) { - if (sscanf(line, " %s", linekey) < 1) - continue; - if (STREQ(key, linekey)) - return (line); - } -#if DOMEMCHECK - memck_free(line); -#else - UnallocateMem(line); -#endif - return (NULL); -} - -/* make_error_return concatenates the error_msgs - strings together into the string return value and - assigns the exit status in the return value structure, as well */ -static void make_error_return(short exit_status, char *error_msg1, char *error_msg2, char *error_msg3, char *error_msg4) { - short msg1_len = (short)strlen(error_msg1); - short msg2_len = (short)strlen(error_msg2); - short msg3_len = (short)strlen(error_msg3); - short msg4_len = (short)strlen(error_msg4); - -#if DOMEMCHECK - memck_free(fiptr->value_string); -#else - UnallocateMem(fiptr->value_string); -#endif - fiptr->value_string = AllocateMem((unsigned)(msg1_len + msg2_len + msg3_len + msg4_len + 1), sizeof(char), "fontinfo return value"); - sprintf(fiptr->value_string, "%s%s%s%s", - error_msg1, error_msg2, error_msg3, error_msg4); - fiptr->exit_status = exit_status; -} - -/* make_normal_return copies the string argument into the - * the return value string and assigns the normal return - * exit status. The caller should free the arg.*/ -static void make_normal_return(char *arg, boolean arg_is_string) { -#if DOMEMCHECK - fiptr->value_string = memck_malloc((unsigned)(strlen(arg) + 1) * sizeof(char)); -#else - fiptr->value_string = AllocateMem((unsigned)(strlen(arg) + 1), sizeof(char), - "fontinfo return"); -#endif - strcpy(fiptr->value_string, arg); - fiptr->exit_status = NORMAL_RETURN; - fiptr->value_is_string = arg_is_string; -} - -/* - * append_normal_return appends the string argument at the end of - * the return value string and assigns the normal return - * exit status. The caller should free the arg, if necessary. */ -static void append_normal_return(arg) char *arg; -{ - char *temp; - - if (fiptr->value_string == NULL) { -#if DOMEMCHECK - fiptr->value_string = memck_malloc((unsigned)(strlen(arg) + 1) * sizeof(char)); -#else - fiptr->value_string = AllocateMem((unsigned)(strlen(arg) + 1), - sizeof(char), "fontinfo return"); -#endif - strcpy(fiptr->value_string, arg); - } else { - temp = fiptr->value_string; -#if DOMEMCHECK - fiptr->value_string = memck_malloc((strlen(temp) + strlen(arg) + 1) * sizeof(char)); -#else - fiptr->value_string = AllocateMem((unsigned)(strlen(temp) + strlen(arg) + 1), sizeof(char), - "fontinfo return"); -#endif - strcat(fiptr->value_string, temp); - strcat(fiptr->value_string, arg); -#if DOMEMCHECK - memck_free(temp); -#else - UnallocateMem(temp); -#endif - } - fiptr->exit_status = NORMAL_RETURN; - fiptr->value_is_string = FALSE; -} - -/* If lineargs is an int, put the int to the value string. - Otherwise, put an error message to the value string. */ -static void check_for_int(key, lineargs) char *key, *lineargs; -{ - indx i, j; - float f; - - i = sscanf(lineargs, " %f", &f); - if (i == 1) { - j = (short)f; - if ((float)j == f) { - sprintf(lineargs, "%d", j); - make_normal_return(lineargs, FALSE); - return; - } - } - sprintf(globmsg, "integer expected on same line of %s file as keyword ", fifilename); - make_error_return(ERROR_RETURN, globmsg, key, "\n instead of ", lineargs); -} - -/* Checks whether lineargs is an int or matrix then calls the - appropriate procedure. */ -static void check_for_intormatrix(key, lineargs) char *key, *lineargs; -{ - char *lb = (char *)strchr(lineargs, '['); - - if (lb == 0) /* must be an integer */ - check_for_int(key, lineargs); - else - check_for_matrix(key, lineargs, FALSE); -} - -/* If lineargs is a decimal number, put the decimal number to - the value string. Otherwise, put an error message to the - value string. */ -static void check_for_num(key, lineargs) char *key, *lineargs; -{ - short i; - float f; - - i = sscanf(lineargs, " %g", &f); - if (i != 1) { - sprintf(globmsg, - "floating point number expected on same line of %s file as ", fifilename); - make_error_return(ERROR_RETURN, globmsg, key, "\n instead of ", lineargs); - } else { - sprintf(lineargs, "%g", f); - make_normal_return(lineargs, FALSE); - } -} - -/* If lineargs is a string in PostScript format (i.e., enclosed in - * parentheses), put the string to the value string. - * Otherwise, put an error message into the value string. */ -static void check_for_string(key, lineargs) char *key, *lineargs; -{ - char *lp, *rp; - - lp = (char *)strchr(lineargs, '('); - rp = (char *)strrchr(lineargs, ')'); - if ((lp == 0) || (rp == 0) || (lp > rp) || (strspn(rp + 1, " \n\r\t\f\v") != strlen(rp + 1))) { - sprintf(globmsg, - "parenthesized string expected on same line of %s file as ", fifilename); - make_error_return(ERROR_RETURN, globmsg, key, "\n instead of ", lineargs); - return; - } - rp[0] = '\0'; /* trash character after ) to put in string terminator */ - make_normal_return(lp + 1, TRUE); -} - -int misspace(int c) { - if (c == ' ' || c == '\n' || c == '\r' || c == '\t') - return 1; - return 0; -} - -int misdigit(int c) { - return c >= '0' && c <= '9'; -} - -/* If lineargs is a boolean, put the boolean to the value string. - * Otherwise, put an error message to the value string. */ -static void check_for_boolean(key, lineargs) char *key, *lineargs; -{ - indx i; - - for (i = 0; (misspace(lineargs[i])); i++) { - } - if (!strncmp(&lineargs[i], "false", 5)) - make_normal_return("false", FALSE); - else if (!strncmp(&lineargs[i], "true", 4)) - make_normal_return("true", FALSE); - else { - sprintf(globmsg, - "boolean value expected on the same line of %s file as ", fifilename); - make_error_return(ERROR_RETURN, globmsg, key, "\n instead of ", lineargs); - } -} - -/* - If lineargs is a PostScript format matrix (enclosed in square - brackets) put the matrix to the value string. Otherwise, put - an error message to the value string. */ -static void check_for_matrix(char *key, char *lineargs, boolean append) { - char *lb, *rb; - lb = (char *)strchr(lineargs, '['); - rb = (char *)strrchr(lineargs, ']'); - if ((lb == 0) || (rb == 0) || (lb > rb)) { - sprintf(globmsg, "matrix enclosed by square brackets expected on line of\n %s file with ", fifilename); - make_error_return(ERROR_RETURN, globmsg, key, "\n instead of ", lineargs); - return; - } - rb[1] = '\0'; /* trash character after ] to put in string terminator */ - if (!append) - make_normal_return(lb, FALSE); - else - append_normal_return(lb); -} - -/* - * If line is a PostScript comment, put it in the value string - * Otherwise, put an error message in the value string. */ -static void check_PS_comment(line) char *line; -{ - if (BLANK(line)) - return; - if (!COMMENT(line)) - make_error_return(ERROR_RETURN, fifilename, - " file should contain line in PostScript comment form\n instead of ", - line, EOS); - else - append_normal_return(line); -} - -/* This proc reads all of the lines in the fifile, looking for the - * beginkey line. Once that is found, it starts appending - * the lines which follow up to the line that - * matches the param, endkey. If matrix is true then it - * checks that the line is a matrix before appending otherwise - * it checks that the line is a comment. */ -static char *get_middle_lines(char *beginkey, char *endkey, boolean matrix) { - FILE *fifile; - char *line, linekey[LINELEN], linebuf[LINELEN + 1]; - char fname[MAXPATHLEN]; - char *bfp; - - fifile = ACOpenFile(fifilename, "r", OPENOK); - if (fifile == NULL) - return (NULL); - - line = search_for_key(beginkey, fifile); - if (line == NULL) { - bfp = get_base_font_path(); - /* extract line with matching keyword, if any, from the base font - * directory's file */ - if (bfp == NULL) - return (NULL); - sprintf(fname, "%s%s", bfp, fifilename); - fifile = ACOpenFile(fname, "r", OPENOK); - if (fifile == NULL) - return (NULL); - line = search_for_key(beginkey, fifile); - } - while (fgets(linebuf, LINELEN, fifile) != NULL) { - if (sscanf(linebuf, " %s", linekey) < 1) - continue; - if (STRNEQ(endkey, linekey)) - if (!matrix) - check_PS_comment(linebuf); - else - check_for_matrix(beginkey, linebuf, TRUE); - else { - fclose(fifile); - return (line); - } - } - fclose(fifile); -#if DOMEMCHECK - memck_free(line); -#else - UnallocateMem(line); -#endif - return (NULL); -} - -/* Gets a line that has the keyword and returns the remainder of - the line. */ -static char *get_keyword_value(key, dirpath) char *key; -char *dirpath; -{ - FILE *fifile; - char *line, *lineargs; - char fname[MAXPATHLEN]; - - sprintf(fname, "%s%s", dirpath, fifilename); - fifile = ACOpenFile(fname, "r", OPENERROR); - line = search_for_key(key, fifile); - if (line == NULL) { - fclose(fifile); - return (NULL); - } -#if DOMEMCHECK - lineargs = memck_malloc((unsigned)LINELEN * sizeof(char)); -#else - lineargs = AllocateMem((unsigned)LINELEN, sizeof(char), "fontinfo buffer"); -#endif - strcpy(lineargs, line + strindex(line, key) + strlen(key)); - fclose(fifile); -#if DOMEMCHECK - memck_free(line); -#else - UnallocateMem(line); -#endif - return (lineargs); -} - -static void init_kw_tab() { - if (tab_initialized) - return; - tab_initialized = TRUE; - /* These are the keywords actually used on the Mac */ - keywordtab[ADOBECOPYRIGHT] = "AdobeCopyright"; - keywordtab[BASEFONTPATH] = "BaseFontPath"; - keywordtab[CHARACTERSET] = "CharacterSet"; - keywordtab[CHARACTERSETFILETYPE] = "CharacterSetFileType"; - keywordtab[CHARACTERSETLAYOUT] = "CharacterSetLayout"; - keywordtab[COMPOSITES] = "Composites"; - keywordtab[COPYRIGHTNOTICE] = "CopyrightNotice"; - keywordtab[CUBELIBRARY] = "CubeLibrary"; - keywordtab[DOMINANTH] = "DominantH"; - keywordtab[DOMINANTV] = "DominantV"; - keywordtab[ENCODING] = "Encoding"; - keywordtab[FAMILYBLUESPATH] = "FamilyBluesPath"; - keywordtab[FAMILYNAME] = "FamilyName"; - keywordtab[FONTMATRIX] = "FontMatrix"; - keywordtab[FONTNAME] = "FontName"; - keywordtab[FORCEBOLD] = "ForceBold"; - keywordtab[FULLNAME] = "FullName"; - keywordtab[ISFIXEDPITCH] = "isFixedPitch"; - keywordtab[ITALICANGLE] = "ItalicAngle"; - keywordtab[PCFILENAMEPREFIX] = "PCFileNamePrefix"; - keywordtab[SCALEPERCENT] = "ScalePercent"; - keywordtab[STEMSNAPH] = "StemSnapH"; - keywordtab[STEMSNAPV] = "StemSnapV"; - keywordtab[SYNTHETICBASE] = "SyntheticBase"; - keywordtab[TRADEMARK] = "Trademark"; - keywordtab[UNDERLINEPOSITION] = "UnderlinePosition"; - keywordtab[UNDERLINETHICKNESS] = "UnderlineThickness"; - keywordtab[WEIGHT] = "Weight"; - keywordtab[VERSION] = "version"; - - /* These are the keywords used only for blending, coloring or - blackbox backward compatibility */ - keywordtab[APPLEFONDID] = "AppleFONDID"; - keywordtab[APPLENAME] = "AppleName"; - keywordtab[ASCENT] = "Ascent"; - keywordtab[ASCENTDESCENTPATH] = "AscentDescentPath"; - keywordtab[ASCHEIGHT] = "AscenderHeight"; - keywordtab[ASCOVERSHOOT] = "AscenderOvershoot"; - keywordtab[AUXHSTEMS] = "AuxHStems"; - keywordtab[AUXVSTEMS] = "AuxVStems"; - keywordtab[AXISLABELS1] = "AxisLabels1"; - keywordtab[AXISLABELS2] = "AxisLabels2"; - keywordtab[AXISLABELS3] = "AxisLabels3"; - keywordtab[AXISLABELS4] = "AxisLabels4"; - keywordtab[AXISMAP1] = "AxisMap1"; - keywordtab[AXISMAP2] = "AxisMap2"; - keywordtab[AXISMAP3] = "AxisMap3"; - keywordtab[AXISMAP4] = "AxisMap4"; - keywordtab[AXISTYPE1] = "AxisType1"; - keywordtab[AXISTYPE2] = "AxisType2"; - keywordtab[AXISTYPE3] = "AxisType3"; - keywordtab[AXISTYPE4] = "AxisType4"; - keywordtab[BASELINEYCOORD] = "BaselineYCoord"; - keywordtab[BASELINEOVERSHOOT] = "BaselineOvershoot"; - keywordtab[BASELINE5] = "Baseline5"; - keywordtab[BASELINE5OVERSHOOT] = "Baseline5Overshoot"; - keywordtab[BASELINE6] = "Baseline6"; - keywordtab[BASELINE6OVERSHOOT] = "Baseline6Overshoot"; - keywordtab[BITSIZES75] = "BitSizes75"; - keywordtab[BITSIZES96] = "BitSizes96"; - keywordtab[CAPHEIGHT] = "CapHeight"; - keywordtab[CAPOVERSHOOT] = "CapOvershoot"; - keywordtab[DESCENT] = "Descent"; - keywordtab[DESCHEIGHT] = "DescenderHeight"; - keywordtab[DESCOVERSHOOT] = "DescenderOvershoot"; - keywordtab[FIGHEIGHT] = "FigHeight"; - keywordtab[FIGOVERSHOOT] = "FigOvershoot"; - keywordtab[FLEXEXISTS] = "FlexExists"; - keywordtab[FLEXOK] = "FlexOK"; - keywordtab[FLEXSTRICT] = "FlexStrict"; - keywordtab[FONTVENDOR] = "FontVendor"; - keywordtab[FORCEBOLDTHRESHOLD] = "ForceBoldThreshold"; - keywordtab[HINTSDIR] = "HintsDir"; - keywordtab[HCOUNTERCHARS] = "HCounterChars"; - keywordtab[HEIGHT5] = "Height5"; - keywordtab[HEIGHT5OVERSHOOT] = "Height5Overshoot"; - keywordtab[HEIGHT6] = "Height6"; - keywordtab[HEIGHT6OVERSHOOT] = "Height6Overshoot"; - keywordtab[PRIMARYINSTANCES] = "PrimaryInstances"; - keywordtab[LCHEIGHT] = "LcHeight"; - keywordtab[LCOVERSHOOT] = "LcOvershoot"; - keywordtab[MASTERDESIGNPOSITIONS] = "MasterDesignPositions"; - keywordtab[MASTERDIRS] = "MasterDirs"; - keywordtab[MSMENUNAME] = "MSMenuName"; - keywordtab[MSWEIGHT] = "MSWeight"; - keywordtab[NCEXISTS] = "NCExists"; - keywordtab[NUMAXES] = "NumAxes"; - keywordtab[ORDINALBASELINE] = "OrdinalBaseline"; - keywordtab[ORDINALOVERSHOOT] = "OrdinalOvershoot"; - keywordtab[ORIGEMSQUAREUNITS] = "OrigEmSqUnits"; - keywordtab[OVERSHOOTPTSIZE] = "OvershootPtsize"; - keywordtab[PAINTTYPE] = "PaintType"; - keywordtab[PGFONTIDNAME] = "PGFontID"; - keywordtab[PHANTOMVECTORS] = "PhantomVectors"; - keywordtab[PI] = "Pi"; - keywordtab[POLYCONDITIONPROC] = "PolyConditionProc"; - keywordtab[POLYCONDITIONTYPE] = "PolyConditionType"; - keywordtab[POLYFLEX] = "PolyFlex"; - keywordtab[POLYFONT] = "PolyFont"; - keywordtab[PRIMOGENITALFONTNAME] = "PrimogenitalFontName"; - keywordtab[SERIF] = "Serif"; - keywordtab[SOURCE] = "Source"; - keywordtab[REGULARINSTANCE] = "RegularInstance"; - keywordtab[RNDSTEMUP] = "RndStemUp"; - keywordtab[STROKEWIDTH] = "StrokeWidth"; - keywordtab[STROKEWIDTHHEAVY] = "StrokeWidthHeavy"; - keywordtab[STYLEBOLD] = "StyleBold"; - keywordtab[STYLECONDENSED] = "StyleCondensed"; - keywordtab[STYLEEXTENDED] = "StyleExtended"; - keywordtab[SUPERIORBASELINE] = "SuperiorBaseline"; - keywordtab[SUPERIOROVERSHOOT] = "SuperiorOvershoot"; - keywordtab[VCOUNTERCHARS] = "VCounterChars"; - keywordtab[VENDORSFONTID] = "VendorsFontID"; - keywordtab[VPMENUNAME] = "VPMenuName"; - keywordtab[VPSTYLE] = "VPStyle"; - keywordtab[VPTYPEFACEID] = "VPTypefaceID"; - keywordtab[BLUEFUZZ] = "BlueFuzz"; - keywordtab[ZONETHRESHOLD] = "ZoneThreshold"; - - keywordtab[LANGUAGEGROUP] = "LanguageGroup"; -} - -/* filookup will lookup the keyword in the fontinfo file. - If the keyword is found and has the proper type, its value - will be written to the returned value string. If the - keyword is optional and not found, a message to that effect - is returned in the value string. Otherwise, an error message - will be written to the returned value string. -*/ -extern FIPTR filookup(char *keyword, boolean optional) { - short kwindex; - char *fs; - char *bfp = NULL; - - init_kw_tab(); - kwindex = lookup(keyword); - if (kwindex == NOMATCH) { - if ((keyword != NULL) && (keyword[0] != '\0')) { - make_error_return(ERROR_RETURN, - fifilename, " file does not recognize keyword ", keyword, "."); - } else { - make_error_return((optional) ? OPTIONAL_NOT_FOUND : ERROR_RETURN, - fifilename, " empty keyword. ", EOS, EOS); - } - return (fiptr); - } - /* extract line with matching keyword, if any, from the file */ - fs = get_keyword_value(keyword, ""); - if (fs == NULL) { - bfp = get_base_font_path(); - /* extract line with matching keyword, if any, from the base font - * directory's file */ - if (bfp != NULL) - fs = get_keyword_value(keyword, bfp); - } - if (fs == NULL) { - if (optional) { - fiptr->exit_status = OPTIONAL_NOT_FOUND; - fiptr->value_string = NULL; - return (fiptr); - } else { - make_error_return(ERROR_RETURN, - fifilename, " file does not contain keyword ", keyword, "."); - return (fiptr); - } - } - - if (fiptr->value_string != NULL) { -#if DOMEMCHECK - memck_free(fiptr->value_string); -#else - UnallocateMem(fiptr->value_string); -#endif - } - - switch (kwindex) { - case APPLENAME: - case AXISTYPE1: - case AXISTYPE2: - case AXISTYPE3: - case AXISTYPE4: - case FONTVENDOR: - case BITSIZES75: - case BITSIZES96: - case HINTSDIR: - case HCOUNTERCHARS: - case MSMENUNAME: - case POLYCONDITIONPROC: - case PRIMOGENITALFONTNAME: - case SOURCE: - case VCOUNTERCHARS: - case VENDORSFONTID: - case VPMENUNAME: - case VPSTYLE: - case ADOBECOPYRIGHT: - case ASCENTDESCENTPATH: - case BASEFONTPATH: - case CHARACTERSET: - case CHARACTERSETFILETYPE: - case CHARACTERSETLAYOUT: - case ENCODING: - case FAMILYBLUESPATH: - case FAMILYNAME: - case FONTNAME: - case FULLNAME: - case PCFILENAMEPREFIX: - case TRADEMARK: - case VERSION: - case WEIGHT: - check_for_string(keyword, fs); - break; - case COMPOSITES: - case CUBELIBRARY: - case ISFIXEDPITCH: - case SYNTHETICBASE: - case FLEXSTRICT: - case FLEXOK: - case FLEXEXISTS: - case FORCEBOLD: - case NCEXISTS: - case PI: - case SERIF: - case RNDSTEMUP: - check_for_boolean(keyword, fs); - break; - case ASCENT: - case DESCENT: - case FORCEBOLDTHRESHOLD: - case ITALICANGLE: - case SCALEPERCENT: - case UNDERLINEPOSITION: - case UNDERLINETHICKNESS: - case ORIGEMSQUAREUNITS: - case OVERSHOOTPTSIZE: - case STROKEWIDTH: - case STROKEWIDTHHEAVY: - case BLUEFUZZ: - case ZONETHRESHOLD: - check_for_num(keyword, fs); - break; - case MASTERDIRS: - fs = get_middle_lines(keyword, endDirs, FALSE); - if (fs == NULL) - make_error_return(ERROR_RETURN, - "Could not find keyword ", endDirs, " in file ", fifilename); - break; - case COPYRIGHTNOTICE: - fs = get_middle_lines(keyword, endNotice, FALSE); - if (fs == NULL) - make_error_return(ERROR_RETURN, - "No EndNotice line found in ", fifilename, " file.", EOS); - break; - case APPLEFONDID: - case ASCHEIGHT: - case ASCOVERSHOOT: - case BASELINEYCOORD: - case BASELINEOVERSHOOT: - case BASELINE5: - case BASELINE5OVERSHOOT: - case BASELINE6: - case BASELINE6OVERSHOOT: - case CAPHEIGHT: - case CAPOVERSHOOT: - case DESCHEIGHT: - case DESCOVERSHOOT: - case FIGHEIGHT: - case FIGOVERSHOOT: - case HEIGHT5: - case HEIGHT5OVERSHOOT: - case HEIGHT6: - case HEIGHT6OVERSHOOT: - case LCHEIGHT: - case LCOVERSHOOT: - case MSWEIGHT: - case NUMAXES: - case ORDINALBASELINE: - case ORDINALOVERSHOOT: - case PAINTTYPE: - case PGFONTIDNAME: - case POLYCONDITIONTYPE: - case POLYFONT: - case SUPERIORBASELINE: - case SUPERIOROVERSHOOT: - case VPTYPEFACEID: - case LANGUAGEGROUP: - check_for_int(keyword, fs); - break; - case AUXHSTEMS: - case AUXVSTEMS: - case AXISLABELS1: - case AXISLABELS2: - case AXISLABELS3: - case AXISLABELS4: - case AXISMAP1: - case AXISMAP2: - case AXISMAP3: - case AXISMAP4: - case MASTERDESIGNPOSITIONS: - case POLYFLEX: - case REGULARINSTANCE: - case STYLEBOLD: - case STYLECONDENSED: - case STYLEEXTENDED: - case FONTMATRIX: - case STEMSNAPH: - case STEMSNAPV: - check_for_matrix(keyword, fs, FALSE); - break; - case DOMINANTH: - case DOMINANTV: - check_for_intormatrix(keyword, fs); - break; - case PHANTOMVECTORS: - fs = get_middle_lines(keyword, endVectors, TRUE); - if (fs == NULL) - make_error_return(ERROR_RETURN, - "Could not find keyword ", endVectors, " in file ", fifilename); - break; - case PRIMARYINSTANCES: - fs = get_middle_lines(keyword, endInstance, TRUE); - if (fs == NULL) - make_error_return(ERROR_RETURN, - "Could not find keyword ", endInstance, " in file ", fifilename); - break; - default: - make_error_return(ERROR_RETURN, - keyword, " is not a known ", fifilename, " file keyword."); - break; - } - -#if DOMEMCHECK - memck_free(fs); -#else - UnallocateMem(fs); -#endif - return (fiptr); -} - -/* Sets the file name from which to get font info to a non-default - name. */ -extern void SetFntInfoFileName(filename) char *filename; -{ - strcpy(fifilename, filename); -} - -/* Sets the file name from which to get font info to the default - name. */ -extern void ResetFntInfoFileName(void) { - strcpy(fifilename, FIFILENAME); -} - -/* Looks up the value of the specified keyword in the fontinfo - file. If the keyword doesn't exist and this is an optional - key, returns a NULL. Otherwise, returns the value string. */ -extern char *GetFntInfo(char *keyword, boolean optional) { - FIPTR fptr; - char *returnstring = NULL; - -#ifdef ACLIB_EXPORTS - if (featurefiledata != NULL) { - int i; - - for (i = 0; i < featurefilesize; i++) { - if (featurefiledata[i].key && !strcmp(featurefiledata[i].key, keyword)) { -#if DOMEMCHECK - returnstring = memck_malloc((strlen(featurefiledata[i].value) + 1) * sizeof(char)); -#else - returnstring = (char *)AllocateMem((unsigned)strlen(featurefiledata[i].value) + 1, sizeof(char), "GetFntInfo return str"); -#endif - strcpy(returnstring, featurefiledata[i].value); - return returnstring; - } - } - - if (optional) { - return NULL; - } else { - sprintf(globmsg, "ERROR: Fontinfo: Couldn't find fontinfo for %s\n", keyword); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - } else { -#endif - - fptr = filookup(keyword, optional); - switch (fptr->exit_status) { - case NORMAL_RETURN: -#if DOMEMCHECK - returnstring = memck_malloc((strlen(fptr->value_string) + 1) * sizeof(char)); -#else - returnstring = AllocateMem((unsigned)strlen(fptr->value_string) + 1, sizeof(char), - "return string for fontinfo"); -#endif - strcpy(returnstring, fptr->value_string); -#if DOMEMCHECK - memck_free(fptr->value_string); -#else - UnallocateMem(fptr->value_string); -#endif - break; - case OPTIONAL_NOT_FOUND: - returnstring = NULL; -#if DOMEMCHECK - memck_free(fptr->value_string); -#else - UnallocateMem(fptr->value_string); -#endif - break; - case ERROR_RETURN: - sprintf(globmsg, "%s\n", fptr->value_string); -#if DOMEMCHECK - memck_free(fptr->value_string); -#else - UnallocateMem(fptr->value_string); -#endif - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - break; - default: -#if DOMEMCHECK - memck_free(fptr->value_string); -#else - UnallocateMem(fptr->value_string); -#endif - LogMsg("Unknown exit status from fontinfo lookup.\n", - LOGERROR, NONFATALERROR, TRUE); - break; - } - return (returnstring); -#ifdef ACLIB_EXPORTS - } -#endif - return NULL; -} - -/* This proc looks up an integer fontinfo value and returns: - 1) the integer value found for the keyword - 2) MAXINT if the keyword was not found - In case of an error, cleanup is called, which never returns - */ - -extern int GetFIInt(char *keyword, boolean optional) { - FIPTR fptr; - int temp; - - fptr = filookup(keyword, optional); - switch (fptr->exit_status) { - case NORMAL_RETURN: - sscanf(fptr->value_string, "%d", &temp); -#if DOMEMCHECK - memck_free(fptr->value_string); -#else - UnallocateMem(fptr->value_string); -#endif - return (temp); - break; - case OPTIONAL_NOT_FOUND: - if (optional) { -#if DOMEMCHECK - memck_free(fptr->value_string); -#else - UnallocateMem(fptr->value_string); -#endif - return (MAXINT); - } - /* fall through intentionally */ - case ERROR_RETURN: - sprintf(globmsg, "%s\n", fptr->value_string); -#if DOMEMCHECK - memck_free(fptr->value_string); -#else - UnallocateMem(fptr->value_string); -#endif - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - default: -#if DOMEMCHECK - memck_free(fptr->value_string); -#else - UnallocateMem(fptr->value_string); -#endif - LogMsg("Unknown exit status from fontinfo lookup.\n", - LOGERROR, NONFATALERROR, TRUE); - } - return (MAXINT); -} - -/* FreeFontInfo frees the memory associated with the pointer ptr. - This is to reclaim the storage allocated in GetFntInfo. */ -extern void FreeFontInfo(char *ptr) { -#if DOMEMCHECK - memck_free(ptr); -#else - UnallocateMem(ptr); -#endif -} - -/* Appends Aux{H,V}Stems which is optional to StemSnap{H,V} respectively. */ -static char *GetHVStems(char *kw, boolean optional) { - char *fistr1, *fistr2, *newfistr; - char *end, *start; - - fistr1 = GetFntInfo(((STREQ(kw, "AuxHStems")) ? "StemSnapH" : "StemSnapV"), optional); - fistr2 = GetFntInfo(kw, ACOPTIONAL); - if (fistr2 == NULL) return fistr1; - if (fistr1 == NULL) return fistr2; - /* Merge two arrays. */ -#if DOMEMCHECK - newfistr = memck_malloc((strlen(fistr1) + strlen(fistr2) + 1) * sizeof(char)); -#else - newfistr = AllocateMem( - (unsigned)(strlen(fistr1) + strlen(fistr2) + 1), sizeof(char), "Aux stem value"); -#endif - end = (char *)strrchr(fistr1, ']'); - end[0] = '\0'; - start = (char *)strchr(fistr2, '['); - start[0] = ' '; - sprintf(newfistr, "%s%s", fistr1, fistr2); -#if DOMEMCHECK - memck_free(fistr1); -#else - UnallocateMem(fistr1); -#endif -#if DOMEMCHECK - memck_free(fistr2); -#else - UnallocateMem(fistr2); -#endif - return newfistr; -} - -/* This procedure parses the various fontinfo file stem keywords: - StemSnap{H,V}, Dominant{H,V} and Aux{H,V}Stems. If Aux{H,V}Stems - is specified then the StemSnap{H,V} values are automatically - added to the stem array. ParseIntStems guarantees that stem values - are unique and in ascending order. - If blendstr is NULL it means we just want the values from the - current font directory and not for all input directories - (e.g., for a multi-master font). - */ -extern void ParseIntStems(char *kw, boolean optional, long maxstems, int *stems, long *pnum, char *blendstr) { - char c; - char *line; - int val, cnt, i, ix, j, temp, targetCnt = -1, total = 0; - boolean singleint = FALSE; - short dirCount = (blendstr == NULL ? 1 : GetTotalInputDirs()); - char *initline; - - *pnum = 0; - for (ix = 0; ix < dirCount; ix++) { - cnt = 0; - if (blendstr != NULL) - SetMasterDir(ix); - if (STREQ(kw, "AuxHStems") || STREQ(kw, "AuxVStems")) - initline = GetHVStems(kw, optional); - else - initline = GetFntInfo(kw, optional); - if (initline == NULL) { - if (targetCnt > 0) { - sprintf(globmsg, "The keyword: %s does not have the same number of values\n in each master design.\n", kw); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } else - continue; /* optional keyword not found */ - } - line = initline; - /* Check for single integer instead of matrix. */ - if ((strlen(line) != 0) && (strchr(line, '[') == 0)) { - singleint = TRUE; - goto numlst; - } - while (TRUE) { - c = *line++; - switch (c) { - case 0: - *pnum = 0; -#if DOMEMCHECK - memck_free(initline); -#else - UnallocateMem(initline); -#endif - return; - case '[': - goto numlst; - default: - break; - } - } - numlst: - while (*line != ']') { - while (misspace(*line)) line++; /* skip past any blanks */ - if (sscanf(line, " %d", &val) < 1) break; - if (total >= maxstems) { - sprintf(globmsg, "Cannot have more than %d values in fontinfo file array: \n %s\n", (int)maxstems, initline); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - if (val < 1) { - sprintf(globmsg, "Cannot have a value < 1 in fontinfo file array: \n %s\n", line); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - stems[total++] = val; - cnt++; - if (singleint) break; - while (misdigit(*line)) line++; /* skip past the number */ - } - /* insure they are in order */ - for (i = *pnum; i < total; i++) - for (j = i + 1; j < total; j++) - if (stems[i] > stems[j]) { - temp = stems[i]; - stems[i] = stems[j]; - stems[j] = temp; - } - /* insure they are unique - note: complaint for too many might precede - guarantee of uniqueness */ - for (i = *pnum; i < total - 1; i++) - if (stems[i] == stems[i + 1]) { - for (j = (i + 2); j < total; j++) - stems[j - 1] = stems[j]; - total--; - cnt--; - } - if (ix > 0 && (cnt != targetCnt)) { -#if DOMEMCHECK - memck_free(initline); -#else - UnallocateMem(initline); -#endif - sprintf(globmsg, "The keyword: %s does not have the same number of values\n in each master design.\n", kw); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - targetCnt = cnt; - *pnum += cnt; -#if DOMEMCHECK - memck_free(initline); -#else - UnallocateMem(initline); -#endif - } /* end of for loop */ - if (blendstr == NULL || total == 0) - return; - /* Write array of blended snap values to blendstr to be put in - Blend dict of Private dictionary. */ - WriteBlendedArray(stems, total, cnt, blendstr); - /* Reset pnum so just the first set of snap values is written - in the top level Private dictionary. */ - *pnum = cnt; -} - -/* This proc checks for the existence of StemSnap{H,V}. If it is - specified in the fontinfo file then it checks that the corresponding - Dominant{H,V} value (if it exists) is also in the StemSnap array. - If it is not an error message is issued. Also checks that if there - are more than two values in the StemSnap{H,V} arrays then there must - be two values in the Dominant{H,V} arrays. */ -static void CheckStemSnap(direction) char *direction; -{ - int stems[MAXSTEMSNAP]; - long stemcnt, dominantVal = MAXINT, domValCnt = 0; - char key[15]; - indx ix; - - key[0] = '\0'; - sprintf(key, "Dominant%s", direction); - ParseIntStems(key, ACOPTIONAL, (long)MAXDOMINANTSTEMS, stems, &stemcnt, NULL); - if (stemcnt > 0) { - dominantVal = stems[0]; - domValCnt = stemcnt; - } - sprintf(key, "StemSnap%s", direction); - ParseIntStems(key, ACOPTIONAL, (long)MAXSTEMSNAP, stems, &stemcnt, NULL); - if (stemcnt <= 0) - return; - if (dominantVal == MAXINT) { - sprintf(globmsg, "A StemSnap%s array is specified, but a Dominant%s value\n is not defined. This may cause stem width problems.\n", direction, direction); - LogMsg(globmsg, WARNING, OK, TRUE); - return; - } - if ((stemcnt > 2) && (domValCnt != MAXDOMINANTSTEMS)) { - sprintf(globmsg, "There must be two values in the Dominant{H,V} arrays if there are\n more than two values in the StemSnap{H,V} arrays in the %s file.\n", FIFILENAME); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - for (ix = 0; ix < stemcnt; ix++) - if (dominantVal == stems[ix]) - return; - sprintf(globmsg, "The Dominant%s value: %ld must be included in\n the StemSnap%s array in the %s file.\n", direction, dominantVal, direction, FIFILENAME); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); -} - -extern void -CheckRequiredKWs(void) -/*****************************************************************************/ -/* This proc attempts to test for required fontinfo keywords early in the */ -/* running of buildfont, rather than have the lack of one of them cause */ -/* buildfont to blow up just as it goes to assemble the font. It can only */ -/* check a subset of the keywords that potentially will be required, since */ -/* whether coloring keywords are required is data dependent. FontName, */ -/* version and CharacterSet entries are tested early enough elsewhere. */ -/*****************************************************************************/ -{ - char *s; -/* int stems[MAXDOMINANTSTEMS]; - long stemcnt, bands; */ -#ifdef SUN - float overshootptsize = (float)DEFAULTOVRSHTPTSIZE; -#endif - s = GetFntInfo("FontName", MANDATORY); - if (strlen(s) >= MAXFONTNAME) { - sprintf(globmsg, "FontName in %s exceeds max length of %d.\n", - fifilename, (int)(MAXFONTNAME - 1)); -#if DOMEMCHECK - memck_free(s); -#else - UnallocateMem(s); -#endif - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } -#if DOMEMCHECK - memck_free(s); -#else - UnallocateMem(s); -#endif - s = GetFntInfo("Encoding", - scalinghints || (GetCharsetParser() == bf_CHARSET_CID)); -#if DOMEMCHECK - memck_free(s); -#else - UnallocateMem(s); -#endif - s = GetFntInfo("AdobeCopyright", scalinghints); -#if DOMEMCHECK - memck_free(s); -#else - UnallocateMem(s); -#endif - s = GetFntInfo("FullName", scalinghints); -#if DOMEMCHECK - memck_free(s); -#else - UnallocateMem(s); -#endif - s = GetFntInfo("FamilyName", scalinghints); -#if DOMEMCHECK - memck_free(s); -#else - UnallocateMem(s); -#endif - s = GetFntInfo("Weight", scalinghints); -#if DOMEMCHECK - memck_free(s); -#else - UnallocateMem(s); -#endif - s = GetFntInfo("isFixedPitch", scalinghints); -#if DOMEMCHECK - memck_free(s); -#else - UnallocateMem(s); -#endif - s = GetFntInfo("UnderlinePosition", scalinghints); -#if DOMEMCHECK - memck_free(s); -#else - UnallocateMem(s); -#endif - s = GetFntInfo("UnderlineThickness", scalinghints); -#if DOMEMCHECK - memck_free(s); -#else - UnallocateMem(s); -#endif - s = GetFntInfo("Trademark", ACOPTIONAL); -#if DOMEMCHECK - memck_free(s); -#else - UnallocateMem(s); -#endif - s = GetFntInfo("Composites", ACOPTIONAL); -#if DOMEMCHECK - memck_free(s); -#else - UnallocateMem(s); -#endif - s = GetFntInfo("ScalePercent", ACOPTIONAL); -#if DOMEMCHECK - memck_free(s); -#else - UnallocateMem(s); -#endif - -#ifdef SUN - if (scalinghints) { - SetFntInfoFileName(SCALEDHINTSINFO); - s = GetFntInfo("OrigEmSqUnits", MANDATORY); -#if DOMEMCHECK - memck_free(s); -#else - UnallocateMem(s); -#endif - } - s = GetFntInfo("FlexOK", ACOPTIONAL); -#if DOMEMCHECK - memck_free(s); -#else - UnallocateMem(s); -#endif - s = GetFntInfo("RndStemUp", ACOPTIONAL); -#if DOMEMCHECK - memck_free(s); -#else - UnallocateMem(s); -#endif - s = GetFntInfo("HCounterChars", ACOPTIONAL); -#if DOMEMCHECK - memck_free(s); -#else - UnallocateMem(s); -#endif - s = GetFntInfo("VCounterChars", ACOPTIONAL); -#if DOMEMCHECK - memck_free(s); -#else - UnallocateMem(s); -#endif - ParseIntStems("DominantV", MANDATORY, (long)MAXDOMINANTSTEMS, stems, - &stemcnt, NULL); - ParseIntStems("DominantH", ACOPTIONAL, (long)MAXDOMINANTSTEMS, stems, - &stemcnt, NULL); - CheckStemSnap("H"); - CheckStemSnap("V"); - - bands = build_bands(); - if (scalinghints || (bands == 0)) { - ResetFntInfoFileName(); - return; - } - if ((s = GetFntInfo("OvershootPtsize", ACOPTIONAL)) != NULL) - overshootptsize = atof(s) - 0.49; - if (checkbandwidths(overshootptsize, TRUE) || - checkbandwidths(overshootptsize, FALSE) || - checkbandspacing() || !checkovershoots()) - LogMsg( - "Can't continue because of problem with " - "alignment zones in fontinfo file.\n", - LOGERROR, NONFATALERROR, TRUE); -#endif -} - -#ifdef SUN - -static checkovershootvalue(keyword, optional, positive) char *keyword; -boolean optional, positive; -{ - int value; - - if ((value = GetFIInt(keyword, optional)) != MAXINT) { - if (positive) { - if (value < 0) { - sprintf(globmsg, "The keyword %s has a value of %d.\n It should be greater than or equal to 0.\n", keyword, value); - LogMsg(globmsg, LOGERROR, OK, TRUE); - valueOK = FALSE; - } - } else if (value > 0) { - sprintf(globmsg, "The keyword %s has a value of %d.\n It should be less than or equal to 0.\n", keyword, value); - LogMsg(globmsg, LOGERROR, OK, TRUE); - valueOK = FALSE; - } - } -} - -/* Returns TRUE if all values have the correct sign i.e. positive or negative. */ -static boolean checkovershoots() { - valueOK = TRUE; - checkovershootvalue("BaselineOvershoot", MANDATORY, FALSE); - checkovershootvalue("CapOvershoot", MANDATORY, TRUE); - checkovershootvalue("LcOvershoot", ACOPTIONAL, TRUE); - checkovershootvalue("FigOvershoot", ACOPTIONAL, TRUE); - checkovershootvalue("SuperiorOvershoot", ACOPTIONAL, FALSE); - checkovershootvalue("OrdinalOvershoot", ACOPTIONAL, FALSE); - checkovershootvalue("AscenderOvershoot", ACOPTIONAL, TRUE); - checkovershootvalue("DescenderOvershoot", ACOPTIONAL, FALSE); - checkovershootvalue("Baseline5Overshoot", ACOPTIONAL, FALSE); - checkovershootvalue("Baseline6Overshoot", ACOPTIONAL, FALSE); - checkovershootvalue("Height5Overshoot", ACOPTIONAL, TRUE); - checkovershootvalue("Height6Overshoot", ACOPTIONAL, TRUE); - return valueOK; -} - -#endif - -/* - * get_base_font_path reads the BaseFontPath entry out of this - * directory's fontinfo, if any, and returns the base font path name, - * which is guaranteed to end in a delimiter */ -static char * -get_base_font_path() { - char *line = get_keyword_value("BaseFontPath", EOS); - char *bfp; - char *lp, *rp; - char name[MAXPATHLEN]; - int bfp_len; - int i; - - if (line == NULL) - return (NULL); -#if DOMEMCHECK - bfp = memck_malloc((strlen(line) + 3) * sizeof(char)); -#else - bfp = AllocateMem((unsigned)(strlen(line) + 3), - sizeof(char), "font info buffer"); -#endif - i = sscanf(line, "%s", bfp); - if (i != 1) - return (NULL); - lp = (char *)strchr(bfp, '('); - rp = (char *)strrchr(bfp, ')'); - if ((lp == 0) || (rp == 0) || (rp < lp)) - return (NULL); - bfp_len = (int)(rp - lp - 1); - strncpy(line, lp + 1, bfp_len); - line[bfp_len] = '\0'; - line = CheckBFPath(line); - get_filename(name, line, ""); /* Adds appropriate delimiter. */ - strcpy(line, name); -#if DOMEMCHECK - memck_free(bfp); -#else - UnallocateMem(bfp); -#endif - return (line); -} diff --git a/c/autohint/autohintlib/source/bf/filookup.h b/c/autohint/autohintlib/source/bf/filookup.h deleted file mode 100644 index 3e7cd9f62..000000000 --- a/c/autohint/autohintlib/source/bf/filookup.h +++ /dev/null @@ -1,151 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ - -/*****************************************************************************/ -/* Header file for fontinfo lookup program */ -/*****************************************************************************/ - -/*****************************************/ -/* These keywords are used for colored */ -/* and uncolored, Mac and Sun versions */ -/*****************************************/ -#define ADOBECOPYRIGHT 0 -#define ASCENT 1 + ADOBECOPYRIGHT -#define ASCENTDESCENTPATH 1 + ASCENT -#define BASEFONTPATH 1 + ASCENTDESCENTPATH -#define CHARACTERSET 1 + BASEFONTPATH -#define CHARACTERSETFILETYPE 1 + CHARACTERSET -#define CHARACTERSETLAYOUT 1 + CHARACTERSETFILETYPE -#define COMPOSITES 1 + CHARACTERSETLAYOUT -#define COPYRIGHTNOTICE 1 + COMPOSITES -#define CUBELIBRARY 1 + COPYRIGHTNOTICE -#define DESCENT 1 + CUBELIBRARY -#define DOMINANTH 1 + DESCENT -#define DOMINANTV 1 + DOMINANTH -#define ENCODING 1 + DOMINANTV -#define FAMILYBLUESPATH 1 + ENCODING -#define FAMILYNAME 1 + FAMILYBLUESPATH -#define FONTMATRIX 1 + FAMILYNAME -#define FONTNAME 1 + FONTMATRIX -#define FULLNAME 1 + FONTNAME -#define ISFIXEDPITCH 1 + FULLNAME -#define ITALICANGLE 1 + ISFIXEDPITCH -#define PCFILENAMEPREFIX 1 + ITALICANGLE -#define RNDSTEMUP 1 + PCFILENAMEPREFIX -#define SCALEPERCENT 1 + RNDSTEMUP -#define STEMSNAPH 1 + SCALEPERCENT -#define STEMSNAPV 1 + STEMSNAPH -#define SYNTHETICBASE 1 + STEMSNAPV -#define TRADEMARK 1 + SYNTHETICBASE -#define UNDERLINEPOSITION 1 + TRADEMARK -#define UNDERLINETHICKNESS 1 + UNDERLINEPOSITION -#define VERSION 1 + UNDERLINETHICKNESS -#define WEIGHT 1 + VERSION - -/*****************************************/ -/* These keywords are used just for */ -/* coloring... */ -/*****************************************/ - -#define ASCHEIGHT 1 + WEIGHT -#define ASCOVERSHOOT 1 + ASCHEIGHT -#define AUXHSTEMS 1 + ASCOVERSHOOT -#define AUXVSTEMS 1 + AUXHSTEMS -#define BASELINE5 1 + AUXVSTEMS -#define BASELINE5OVERSHOOT 1 + BASELINE5 -#define BASELINE6 1 + BASELINE5OVERSHOOT -#define BASELINE6OVERSHOOT 1 + BASELINE6 -#define BASELINEYCOORD 1 + BASELINE6OVERSHOOT -#define BASELINEOVERSHOOT 1 + BASELINEYCOORD -#define CAPHEIGHT 1 + BASELINEOVERSHOOT -#define CAPOVERSHOOT 1 + CAPHEIGHT -#define DESCHEIGHT 1 + CAPOVERSHOOT -#define DESCOVERSHOOT 1 + DESCHEIGHT -#define FIGHEIGHT 1 + DESCOVERSHOOT -#define FIGOVERSHOOT 1 + FIGHEIGHT -#define FLEXEXISTS 1 + FIGOVERSHOOT -#define FLEXOK 1 + FLEXEXISTS -#define FORCEBOLD 1 + FLEXOK -#define HCOUNTERCHARS 1 + FORCEBOLD -#define HEIGHT5 1 + HCOUNTERCHARS -#define HEIGHT5OVERSHOOT 1 + HEIGHT5 -#define HEIGHT6 1 + HEIGHT5OVERSHOOT -#define HEIGHT6OVERSHOOT 1 + HEIGHT6 -#define LCHEIGHT 1 + HEIGHT6OVERSHOOT -#define LCOVERSHOOT 1 + LCHEIGHT -#define ORDINALBASELINE 1 + LCOVERSHOOT -#define ORDINALOVERSHOOT 1 + ORDINALBASELINE -#define ORIGEMSQUAREUNITS 1 + ORDINALOVERSHOOT -#define OVERSHOOTPTSIZE 1 + ORIGEMSQUAREUNITS -#define SUPERIORBASELINE 1 + OVERSHOOTPTSIZE -#define SUPERIOROVERSHOOT 1 + SUPERIORBASELINE -#define ZONETHRESHOLD 1 + SUPERIOROVERSHOOT -#define BLUEFUZZ 1 + ZONETHRESHOLD -#define FLEXSTRICT 1 + BLUEFUZZ - -/*****************************************/ -/* These keywords are for compatibility */ -/* with the blackbox (old code) world... */ -/*****************************************/ -#define APPLEFONDID 1 + FLEXSTRICT -#define APPLENAME 1 + APPLEFONDID -#define BITSIZES75 1 + APPLENAME -#define BITSIZES96 1 + BITSIZES75 -#define FONTVENDOR 1 + BITSIZES96 -#define MSMENUNAME 1 + FONTVENDOR -#define MSWEIGHT 1 + MSMENUNAME -#define NCEXISTS 1 + MSWEIGHT -#define PAINTTYPE 1 + NCEXISTS -#define PGFONTIDNAME 1 + PAINTTYPE -#define PRIMOGENITALFONTNAME 1 + PGFONTIDNAME -#define PI 1 + PRIMOGENITALFONTNAME -#define POLYCONDITIONPROC 1 + PI -#define POLYCONDITIONTYPE 1 + POLYCONDITIONPROC -#define POLYFLEX 1 + POLYCONDITIONTYPE -#define POLYFONT 1 + POLYFLEX -#define SERIF 1 + POLYFONT -#define SOURCE 1 + SERIF -#define STROKEWIDTH 1 + SOURCE -#define STROKEWIDTHHEAVY 1 + STROKEWIDTH -#define VCOUNTERCHARS 1 + STROKEWIDTHHEAVY -#define VENDORSFONTID 1 + VCOUNTERCHARS -#define VPMENUNAME 1 + VENDORSFONTID -#define VPSTYLE 1 + VPMENUNAME -#define VPTYPEFACEID 1 + VPSTYLE - -/*****************************************/ -/* These keywords are just used for */ -/* multiple master fonts... */ -/*****************************************/ -#define AXISLABELS1 1 + VPTYPEFACEID -#define AXISLABELS2 1 + AXISLABELS1 -#define AXISLABELS3 1 + AXISLABELS2 -#define AXISLABELS4 1 + AXISLABELS3 -#define AXISMAP1 1 + AXISLABELS4 -#define AXISMAP2 1 + AXISMAP1 -#define AXISMAP3 1 + AXISMAP2 -#define AXISMAP4 1 + AXISMAP3 -#define AXISTYPE1 1 + AXISMAP4 -#define AXISTYPE2 1 + AXISTYPE1 -#define AXISTYPE3 1 + AXISTYPE2 -#define AXISTYPE4 1 + AXISTYPE3 -#define FORCEBOLDTHRESHOLD 1 + AXISTYPE4 -#define HINTSDIR 1 + FORCEBOLDTHRESHOLD -#define MASTERDESIGNPOSITIONS 1 + HINTSDIR -#define MASTERDIRS 1 + MASTERDESIGNPOSITIONS -#define NUMAXES 1 + MASTERDIRS -#define PHANTOMVECTORS 1 + NUMAXES -#define PRIMARYINSTANCES 1 + PHANTOMVECTORS -#define REGULARINSTANCE 1 + PRIMARYINSTANCES -#define STYLEBOLD 1 + REGULARINSTANCE -#define STYLECONDENSED 1 + STYLEBOLD -#define STYLEEXTENDED 1 + STYLECONDENSED - -/* additionals */ -#define LANGUAGEGROUP 1 + STYLEEXTENDED - -#define KWTABLESIZE 1 + LANGUAGEGROUP - -#define MAXOVERSHOOTBANDS 6 -#define MAXUNDERSHOOTBANDS 6 -#define MAXBANDPAIRS (MAXOVERSHOOTBANDS + MAXUNDERSHOOTBANDS) diff --git a/c/autohint/autohintlib/source/bf/fipriv.h b/c/autohint/autohintlib/source/bf/fipriv.h deleted file mode 100644 index 1e7fcb319..000000000 --- a/c/autohint/autohintlib/source/bf/fipriv.h +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* These procedures are private between filookup.c and fiblues.c. */ - -#include "fipublic.h" - -#ifndef FIPRIVATE_H -#define FIPRIVATE_H - -/* Builds the undershoot and overshoot band arrays. */ -extern int build_bands( - void); - -/* looks up specified keyword in fontinfo file. */ -extern FIPTR filookup( - char *, boolean); - -/* Frees the value string associated with fiptr. */ -extern void fiptrfree( - FIPTR); - -/* These procs check that band widths and band spacing are within limits. */ -extern boolean checkbandwidths( - float, boolean); - -extern boolean checkbandspacing( - void); - -extern void WriteBlendedArray( - int *, int, int, char *); - -#endif /*FIPRIVATE_H*/ diff --git a/c/autohint/autohintlib/source/bf/fipublic.h b/c/autohint/autohintlib/source/bf/fipublic.h deleted file mode 100644 index da3380685..000000000 --- a/c/autohint/autohintlib/source/bf/fipublic.h +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* This interface is for C-program callers of the font info lookup - * proc. The caller of filookup is responsible for also calling - * fiptrfree to get rid of the storage returned. */ - -#ifndef FIPUBLIC_H -#define FIPUBLIC_H - -#include "basic.h" - -#define NORMAL_RETURN 0 -#define OPTIONAL_NOT_FOUND 1 -#define ERROR_RETURN 2 -#define LINELEN 200 -#define ACOPTIONAL 1 -#define MANDATORY 0 - -#define DEFAULTBLUEFUZZ FixOne /* Default value used by PS interpreter and Adobe's fonts */ - /* to extend the range of alignment zones. */ -#define MAXDOMINANTSTEMS 2 -#define MAXSTEMSNAP 12 -#define MMFINAME "mmfontinfo" -#define FIFILENAME "fontinfo" - -typedef struct fontinfo { - short exit_status; /* NORMAL_RETURN = 0 - normal return => */ - /* keyword found and argument ok, */ - /* value_string has value */ - /* OPTIONAL_NOT_FOUND = 1 */ - /* keyword not found, but optional => */ - /* value_string empty */ - /* ERROR_RETURN = 2 - error return => keyword not found or argument - bad, */ - /* value_string has error msg describing problem */ - short value_is_string; /* 0 means false */ - char *value_string; -} FINODE, *FIPTR; - -/* FreeFontInfo frees the memory associated with the pointer ptr. - This is to reclaim the storage allocated in GetFntInfo. */ -extern void FreeFontInfo( - char *); - -/* Looks up the value of the specified keyword in the fontinfo - file. If the keyword doesn't exist and this is an optional - key, returns a NULL. Otherwise, returns the value string. */ -extern char *GetFntInfo( - char *, boolean); - -/* returns MAXINT if optional and not found */ -extern int GetFIInt( - char *, boolean); - -extern void SetFntInfoFileName( - char *); - -extern void ResetFntInfoFileName( - void); - -/* get_private_blues formats the BlueValue-related data in the - fontinfo file for use in the Private dictionary. */ - -extern char *get_private_blues( - boolean); - -/* get_blended_blues formats the BlueValue-related data for - multiple master fonts. */ -extern char *get_blended_blues( - boolean, boolean); - -/* This proc attempts to test for required fontinfo keywords - early in the running of buildfont, rather than have the lack - of one of them cause buildfont to blow up just as it goes - to assemble the font. */ - -extern void CheckRequiredKWs( - void); - -extern void ParseIntStems( - char *, boolean, long, int *, long *, char *); - -#endif /*FIPUBLIC_H*/ diff --git a/c/autohint/autohintlib/source/bf/hintfile.h b/c/autohint/autohintlib/source/bf/hintfile.h deleted file mode 100644 index ddc20954b..000000000 --- a/c/autohint/autohintlib/source/bf/hintfile.h +++ /dev/null @@ -1,5 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ - -extern boolean ReadHintsFile(char *inFileName, PPathList path); -extern void RegisterBezHandlers(void); diff --git a/c/autohint/autohintlib/source/bf/illtobez.c b/c/autohint/autohintlib/source/bf/illtobez.c deleted file mode 100644 index 5fb18c5e5..000000000 --- a/c/autohint/autohintlib/source/bf/illtobez.c +++ /dev/null @@ -1,924 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* Converts Adobe illustrator files to bezier font editor format files */ -/* history: */ -/* JLee - Mar 19, 1987 include debugging flag */ -/* JLee - May 29, 1987 include scale factor */ -/* JLee - June 3, 1987 include -d option */ -/* JLee - October 19, 1987 extract width info from file */ -/* JLee - November 5, 1987 fix bug in initialize_widths */ - -#include "buildfont.h" -#include "bftoac.h" -#include "cryptdefs.h" -#include "fipublic.h" -#include "machinedep.h" - -#define MAXPOINTS 1500 -# -#define WIDTH(s) strindex(s, "%%Note:width") != -1 -#define ENDPROLOG(s) strindex(s, "%%EndProlog") != -1 -#define BEGINSETUP(s) strindex(s, "%%BeginSetup") != -1 -#define ENDSETUP(s) strindex(s, "%%EndSetup") != -1 -#define TRAILER(s) strindex(s, "%%Trailer") != -1 -#define NEWSTROKECOLOR 'G' -#define NEWFILLCOLOR 'g' -#define MOVETO 'm' -#define SMOOTHCURVETO 'c' -#define CORNERCURVETO 'C' -#define SMOOTHLINETO 'l' -#define CORNERLINETO 'L' -#define SMOOTHCOPY 'v' -#define CORNERCOPY 'V' -#define SMOOTHROLL 'y' -#define CORNERROLL 'Y' -#define FILL 'F' -#define FILLANDSTROKE 'B' -#define CLOSEANDFILL 'f' -#define CLOSEANDSTROKE 's' -#define CLOSEANDFILLANDSTROKE 'b' -#define STROKE 'S' -#define CLOSEANDNOPAINT 'n' -#define NOPAINT 'N' -#define MTINDEX 0 -#define LTINDEX 1 -#define CTINDEX 2 -#define BEZLINESIZE 64 - -typedef struct path_element { - Cd coord; - short tag; -} path_element; - -typedef struct char_width { - char name[MAXCHARNAME]; - short width; -} char_width; - -/* Globals */ -static boolean firstpath; /* 1st path in this character */ -static boolean width_found; /* width comment in ill. file */ -static boolean err; /* whether error occurred during conversion */ -static boolean printmsg; /* whether to print Converting msg */ -static boolean release; /* indicates release version */ -static indx np; /* number of points in path */ -static indx widthcnt; /* number of character widths */ -static long dict_entries; -static float scale; /* scale factor */ -static char_width *widthtab = NULL; -static path_element *path = NULL, *final_path = NULL; -static char tmpnm[sizeof(TEMPFILE) + sizeof(bezdir) + 3]; -static short convertedchars; - -extern void ConvertInputDirFiles(const char *dirname, tConvertfunc convertproc); - -static void illcleanup( - void); - -static boolean initialize_widths( - void); - -static void process_width( - FILE *, const char *, boolean); - -static void write_widths_file( - boolean); - -static boolean width_error( - const char *); - -static void toomanypoints( - const char *); - -static void convert( - FILE *, FILE *, const char *, const char *); - -static void do_path( - boolean, FILE *, const char *); - -static long findarea( - CdPtr, CdPtr, CdPtr); - -static boolean directionIsCW( - void); - -static void relative( - FILE *); - -#if ILLDEBUG -static dump_path( - boolean); -#endif - -static void illcleanup() { -#if DOMEMCHECK - memck_free(widthtab); - memck_free(path); - memck_free(final_path); -#else - UnallocateMem(widthtab); - UnallocateMem(path); - UnallocateMem(final_path); -#endif -} - -static boolean initialize_widths() { - FILE *wfile; - boolean widths_exist = FALSE; - long temp; - indx ix; - long cnt, maxChars = MAXCHARS; - char line[MAXLINE + 1]; /* input buffer */ - -#if DOMEMCHECK - widthtab = (struct char_width *)memck_malloc(maxChars * sizeof(char_width)); -#else - widthtab = (struct char_width *)AllocateMem(maxChars, sizeof(char_width), - "width table"); -#endif - for (ix = 0; ix < maxChars; ix++) - widthtab[ix].width = UNINITWIDTH; - widthcnt = dict_entries = 0; - if ((widths_exist = CFileExists(WIDTHSFILENAME, FALSE))) { - wfile = ACOpenFile(WIDTHSFILENAME, "r", OPENERROR); - while (fgets(line, MAXLINE, wfile) != NULL) { - if ((COMMENT(line)) || (BLANK(line))) - continue; - if ((ix = strindex(line, "/")) == -1) - continue; /* no character name on this line */ - if (widthcnt >= maxChars) { - maxChars += 100; -#if DOMEMCHECK - widthtab = (struct char_width *)memck_realloc(widthtab, (maxChars * sizeof(struct char_width))); -#else - widthtab = (struct char_width *)ReallocateMem( - (char *)widthtab, (unsigned)(maxChars * sizeof(struct char_width)), "width table"); -#endif - for (ix = maxChars - 100; ix < maxChars; ix++) - widthtab[ix].width = UNINITWIDTH; - } - cnt = sscanf(&line[ix + 1], " %s %ld WDef", widthtab[widthcnt].name, &temp); - if (cnt != 2) { - fclose(wfile); - sprintf(globmsg, "%s file line: %s cannot be parsed.\n It should have the format: / WDef", - WIDTHSFILENAME, line); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - CharNameLenOK(widthtab[widthcnt].name); - widthtab[widthcnt].width = (short)temp; - widthcnt++; - } - fclose(wfile); - } - return (widths_exist); -} - -static void process_width(FILE *infile, const char *name, boolean seen_width) { - indx n, ix; - long width, cnt; - float real_width, junk; - char line[MAXLINE + 1]; /* input buffer */ - - boolean char_exists = FALSE, done = FALSE; - - /* read width information */ - fgets(line, MAXLINE, infile); - cnt = sscanf(line, " %f %f", &real_width, &junk); - if (cnt != 2) { - fclose(infile); - sprintf(globmsg, "Width specified for %s character cannot be parsed.\n", name); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - /* skip past next "end of path" operator */ - while ((!done) && (fgets(line, MAXLINE, infile) != NULL)) { - n = (indx)strlen(line); - switch (line[n - 2]) /* the illustrator operator */ - { - case CLOSEANDNOPAINT: - case NOPAINT: - done = TRUE; - break; - case CLOSEANDSTROKE: - case STROKE: - case FILL: - case FILLANDSTROKE: - case CLOSEANDFILL: - case CLOSEANDFILLANDSTROKE: - sprintf(globmsg, "Width filled or stroked in %s character.\n", name); - LogMsg(globmsg, WARNING, OK, TRUE); - done = TRUE; - break; - } - } - width = SCALEDRTOL(real_width, scale); - width_found = TRUE; - /* Check if there is already an entry for this char. */ - for (ix = 0; ix < widthcnt; ix++) { - if (!strcmp(name, widthtab[ix].name)) { - if (widthtab[ix].width != width) { - if (seen_width) { - sprintf(globmsg, "2 different widths specified in %s character.\n", name); - LogMsg(globmsg, WARNING, OK, TRUE); - } - if ((widthtab[ix].width != UNINITWIDTH) || (seen_width)) { - sprintf(globmsg, "Width updated for %s character (old: %d, new: %ld).\n", name, (int)widthtab[ix].width, width); - LogMsg(globmsg, INFO, OK, FALSE); - } - widthtab[ix].width = (short)width; - } - char_exists = TRUE; - break; - } - } - if (!char_exists) { - strcpy(widthtab[widthcnt].name, name); - widthtab[widthcnt].width = (short)width; - widthcnt++; - } -} - -static void write_widths_file(boolean widths_exist) { - FILE *wfile; - indx i; - - if (widthcnt == 0) { - sprintf(globmsg, "No %s file written, because no widths were found.\n", - WIDTHSFILENAME); - LogMsg(globmsg, INFO, OK, FALSE); - return; - } - /* if widths.ps file already exists rename it to widths.ps.BAK */ - if (widths_exist) { - char backname[MAXFILENAME]; - - sprintf(backname, "%s.BAK", WIDTHSFILENAME); - RenameFile(WIDTHSFILENAME, backname); - } - wfile = ACOpenFile(TEMPFILE, "w", OPENERROR); - fprintf(wfile, "%d dict dup begin\n", (int)NUMMAX(widthcnt, dict_entries)); - for (i = 0; i < widthcnt; i++) { - fprintf(wfile, "/%s %d WDef\n", widthtab[i].name, - (int)widthtab[i].width); - } - fprintf(wfile, "end\n"); - fclose(wfile); - RenameFile(TEMPFILE, WIDTHSFILENAME); -} - -/* This procedure is called if a width comment is not found - while converting a font illustrator file */ -static boolean width_error(const char *name) { - indx ix; - - /* Check if width is already in width data structure */ - for (ix = 0; ix < widthcnt; ix++) { - if (!strcmp(name, widthtab[ix].name)) { - sprintf(globmsg, "No width in %s character description, using\nwidth of %d from %s file.\n", widthtab[ix].name, (int)widthtab[ix].width, WIDTHSFILENAME); - LogMsg(globmsg, INFO, OK, FALSE); - return (FALSE); - } - } - if (release) { - sprintf(globmsg, "No width was specified for the %s character.\n", name); - LogMsg(globmsg, LOGERROR, OK, TRUE); - return (TRUE); - } else { - sprintf(globmsg, - "No width was specified for the %s character.\n The default width of %d will be used.\n", - name, DEFAULTWIDTH); - LogMsg(globmsg, WARNING, OK, TRUE); - strcpy(widthtab[widthcnt].name, name); - widthtab[widthcnt].width = DEFAULTWIDTH; - widthcnt++; - return (FALSE); - } -} - -static void toomanypoints(const char *name) { - sprintf(globmsg, "%s character description has too many points (maximum is %d).\n", name, (int)MAXPOINTS); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); -} - -static void convert(FILE *infile, FILE *outfile, const char *charname, const char *filename) { - float color = 0.0; - float temp1, temp2, temp3, temp4, temp5, temp6; - indx n; - long cnt; - boolean white, seen_width = FALSE, seen_trailer = FALSE; - char op, line[MAXLINE + 1]; /* input buffer */ - - /* Skip prolog and script setup sections */ - while (fgets(line, MAXLINE, infile) != NULL) { - if (ENDPROLOG(line)) - break; - } - while (fgets(line, MAXLINE, infile) != NULL) { - if (BLANK(line)) - continue; - else - break; - } - if (BEGINSETUP(line)) - /* assume you will have an EndSetup and won't reach end of file */ - while (fgets(line, MAXLINE, infile) != NULL) { - if (ENDSETUP(line)) - break; /* EndSetup will be treated as comment below */ - } - np = 0; - do { - if (WIDTH(line)) { - process_width(infile, charname, seen_width); - seen_width = TRUE; - continue; - } - if (TRAILER(line)) { - if (np != 0) { - sprintf(globmsg, "Incomplete path at end of script section of %s character.\n", filename); - LogMsg(globmsg, WARNING, OK, TRUE); - } - seen_trailer = TRUE; - break; - } - if (COMMENT(line)) - continue; - n = (indx)strlen(line); - if (n < 2) { - sprintf(globmsg, "%s character description contains the invalid line:\n %s.\n", filename, line); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - switch (op = line[n - 2]) /* the illustrator operator */ - { - case CLOSEANDNOPAINT: - case NOPAINT: - case CLOSEANDSTROKE: - case STROKE: - case FILLANDSTROKE: - case CLOSEANDFILLANDSTROKE: - sprintf(globmsg, "%d point path with paint operator %c ignored in %s character.\n", np, op, filename); - LogMsg(globmsg, WARNING, OK, TRUE); - np = 0; - continue; - /* NOTREACHED */ - break; - case CLOSEANDFILL: - if (np > 2) { - if ((path[0].coord.x != path[np - 1].coord.x) || - (path[0].coord.y != path[np - 1].coord.y)) { - sprintf(globmsg, "%d point path in %s character is not closed. It will be ignored.\n", np, filename); - LogMsg(globmsg, WARNING, OK, TRUE); - np = 0; - continue; - } - } - case FILL: - if (np > 2) { - white = (color > 0.5); - do_path(white, outfile, filename); - } else { - sprintf(globmsg, "%d point filled path ignored in %s character.\n", - np, filename); - LogMsg(globmsg, WARNING, OK, TRUE); - np = 0; - continue; - } - np = 0; - break; - case NEWFILLCOLOR: - cnt = sscanf(line, " %f", &color); - if (cnt != 1) { - sprintf(globmsg, "Color specified for %s character cannot be parsed.\n", filename); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - break; - case MOVETO: - if (np != 0) { - sprintf(globmsg, "%d point path not ended before moveto in %s character.\n %s", np, filename, line); - LogMsg(globmsg, WARNING, OK, TRUE); - } - cnt = sscanf(line, " %f %f", &temp1, &temp2); - if (cnt != 2) { - sprintf(globmsg, "Moveto for %s character cannot be parsed.\n %s", filename, line); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - path[np].coord.x = SCALEDRTOL(temp1, scale); - path[np].coord.y = SCALEDRTOL(temp2, scale); - path[np].tag = MTINDEX; - np = 1; - break; - case SMOOTHLINETO: - case CORNERLINETO: - cnt = sscanf(line, " %f %f", &temp1, &temp2); - if (cnt != 2) { - sprintf(globmsg, "Lineto for %s character cannot be parsed.\n %s", filename, line); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - if (np >= MAXPOINTS) - toomanypoints(filename); - path[np].coord.x = SCALEDRTOL(temp1, scale); - path[np].coord.y = SCALEDRTOL(temp2, scale); - path[np].tag = LTINDEX; - np++; - break; - case SMOOTHCURVETO: - case CORNERCURVETO: - cnt = sscanf(line, " %f %f %f %f %f %f", - &temp1, &temp2, &temp3, &temp4, &temp5, &temp6); - if (cnt != 6) { - sprintf(globmsg, "Curveto for %s character cannot be parsed.\n %s", filename, line); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - if (np > (MAXPOINTS - 3)) - toomanypoints(filename); - path[np].coord.x = SCALEDRTOL(temp1, scale); - path[np].coord.y = SCALEDRTOL(temp2, scale); - path[np + 1].coord.x = SCALEDRTOL(temp3, scale); - path[np + 1].coord.y = SCALEDRTOL(temp4, scale); - path[np + 2].coord.x = SCALEDRTOL(temp5, scale); - path[np + 2].coord.y = SCALEDRTOL(temp6, scale); - path[np].tag = path[np + 1].tag = path[np + 2].tag = CTINDEX; - np += 3; - break; - case SMOOTHCOPY: /* x0 y0 x1 y1 2 copy curveto */ - case CORNERCOPY: - cnt = sscanf(line, " %f %f %f %f", &temp1, &temp2, &temp3, &temp4); - if (cnt != 4) { - sprintf(globmsg, "Curveto for%s character cannot be parsed.\n %s", filename, line); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - if (np > (MAXPOINTS - 3)) - toomanypoints(filename); - path[np].coord = path[np - 1].coord; - path[np + 1].coord.x = SCALEDRTOL(temp1, scale); - path[np + 1].coord.y = SCALEDRTOL(temp2, scale); - path[np + 2].coord.x = SCALEDRTOL(temp3, scale); - path[np + 2].coord.y = SCALEDRTOL(temp4, scale); - path[np].tag = path[np + 1].tag = path[np + 2].tag = CTINDEX; - np += 3; - break; - case SMOOTHROLL: - case CORNERROLL: - cnt = sscanf(line, " %f %f %f %f", &temp1, &temp2, &temp3, &temp4); - if (cnt != 4) { - sprintf(globmsg, "Curveto for %s character cannot be parsed.\n %s", filename, line); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - if (np > (MAXPOINTS - 3)) - toomanypoints(filename); - path[np].coord.x = SCALEDRTOL(temp1, scale); - path[np].coord.y = SCALEDRTOL(temp2, scale); - path[np + 2].coord.x = path[np + 1].coord.x = SCALEDRTOL(temp3, scale); - path[np + 2].coord.y = path[np + 1].coord.y = SCALEDRTOL(temp4, scale); - path[np].tag = path[np + 1].tag = path[np + 2].tag = CTINDEX; - np += 3; - break; - } /* switch */ - } while (fgets(line, MAXLINE, infile) != NULL); - if (!seen_trailer) { - sprintf(globmsg, "No \"%%TRAILER\" line in file for %s character\n - file probably truncated.\n", filename); - LogMsg(globmsg, WARNING, OK, TRUE); - } -} /* end convert */ - -static void do_path(boolean white, FILE *outfile, const char *name) { - indx n, elem; - path_element *p, *fp; - long tag; - boolean cw, reverse; - boolean open = ((path[0].coord.x != path[np - 1].coord.x) || - (path[0].coord.y != path[np - 1].coord.y)); - - cw = directionIsCW(); -#if ILLDEBUG - fprintf(OUTPUTBUFF, "%s\n", (white ? "WHITE" : "BLACK")); -#endif - reverse = ((white && !cw) || (!white && cw)); - if (reverse) /* reverse path direction */ - { - n = np; - p = &path[np - 1]; - - /* Start at end with a moveto and adjust tags going backwards. */ - tag = p->tag; - p->tag = MTINDEX; - p--; - n--; -#if ILLDEBUG - fprintf(OUTPUTBUFF, "Reversing %d point path in character %s.\n", np, name); -#endif - - while (n > 0) { - switch (tag) { - case CTINDEX: - p -= 2; - tag = p->tag; - p->tag = CTINDEX; - p--; - n -= 3; - break; - - case LTINDEX: - tag = p->tag; - p->tag = LTINDEX; - p--; - n--; - break; - - case MTINDEX: - fprintf(OUTPUTBUFF, "Moveto on reverse in character %s.\n", name); - cleanup(NONFATALERROR); - break; - } - } - -#if ILLDEBUG - dump_path(reverse); - fprintf(OUTPUTBUFF, "Path before restarting, np=%d\n", np); -#endif - - /* If last point is a Lineto, replace it with a closepath. If there are - no Lineto's, add a closepath at the end. Otherwise, find some Lineto, - replace it with a closepath and rearrange the path so that the - closepath is at the end. */ - elem = np - 1; - if (!open) { - if (path[0].tag != LTINDEX) { - p = &path[np - 1]; - for (n = np - 1; n >= 0; n--, p--) { - if (p->tag == LTINDEX) { - elem = n - 1; - np--; - break; - } - } - } else - np--; - } - - p = &path[elem]; - fp = &final_path[0]; - fp->tag = MTINDEX; - - if (p->tag == MTINDEX) { - fp->coord = p->coord; - fp++; - p--; - } else { - fp->coord = path[elem + 1].coord; - fp++; - } - - for (n = 1; n < np; n++) { /* copies from path [elem] or path[elem-1] to path[0] */ - *fp = *p; - fp++; - p--; - if (--elem < 0) { /* resets p to copy from path[np-1] to path[elem] */ - p = &path[np - 1]; - elem = np - 1; - } - } - } else /* dump as is -- do not reverse direction */ - { -#if ILLDEBUG - fprintf(OUTPUTBUFF, "No reverse\n"); - dump_path(reverse); -#endif - /* If last point is a Lineto, replace it with a closepath. If there are - no Lineto's, add a closepath at the end. Otherwise, find some Lineto, - replace it with a closepath and rearrange the path so that the - closepath is at the end. */ - elem = 0; - if (!open) { - if (path[np - 1].tag != LTINDEX) { - p = &path[0]; - for (n = 0; n < np; n++, p++) { - if (p->tag == LTINDEX) { - elem = n + 1; - np--; - break; - } - } - } else { - np--; - } - } - p = &path[elem]; - fp = &final_path[0]; - fp->tag = MTINDEX; - if (p->tag == MTINDEX) { - fp->coord = p->coord; - p++; - } else { - fp->coord = path[elem - 1].coord; - } - fp++; - for (n = 1; n < np; n++) { /* copies from path[elem] or path[elem+1] to path[np] */ - *fp = *p; - fp++; - p++; - if (++elem >= np) { /* resets to copy from path[0] to path[elem] */ - p = &path[0]; - elem = 0; - } - } - } - relative(outfile); -} /* end do_path */ - -static long findarea(CdPtr p1, CdPtr p2, CdPtr sp) { - long v1x, v1y, v2x, v2y; - - v1x = p1->x - sp->x; - v1y = p1->y - sp->y; - v2x = p2->x - sp->x; - v2y = p2->y - sp->y; - /* Cross product = area of parallelogram defined by vectors v1 & v2. */ - return ((v1x * v2y) - (v2x * v1y)); -} - -static boolean directionIsCW() { - path_element *p = path; - long area, n; - Cd c1, c2, old_point, sp; - - area = 0; - n = np; - /* Initialize the stationary point about which the area is computed */ - sp = p->coord; - /* Traverse list of points, accumulating total area. */ - while (n > 0) { - switch (p->tag) { - case MTINDEX: - n--; - break; - case LTINDEX: - area += findarea(&old_point, &p->coord, &sp); - n--; - break; - case CTINDEX: - c1 = p->coord; - p++; - c2 = p->coord; - p++; - area = area + findarea(&old_point, &c1, &sp) + findarea(&c1, &c2, &sp) + findarea(&c2, &p->coord, &sp); - n -= 3; - break; - } - old_point = p->coord; - p++; - } - return (area < 0.0); -} /* direction */ - -/* Convert to relative format */ - -static void relative(FILE *outfile) { - path_element *p, *p1, *p2; - long i, dx, dy; -#if ILLDEBUG - static char op[3] = {'M', 'L', 'C'}; -#endif - static Cd cp; /* current position */ - static char buff[500]; - - p = &final_path[0]; - i = np; -#if ILLDEBUG - fprintf(OUTPUTBUFF, "Path before relativising,np=%d\n", np); - while (i > 0) { - if (p->tag == CTINDEX) { - fprintf(OUTPUTBUFF, "%ld %ld ", p->coord.x, p->coord.y); - p++; - fprintf(OUTPUTBUFF, "%ld %ld ", p->coord.x, p->coord.y); - p++; - fprintf(OUTPUTBUFF, "%ld %ld %c\n", p->coord.x, p->coord.y, op[p->tag]); - p++; - i -= 3; - } else { - fprintf(OUTPUTBUFF, "%ld %ld %c\n", p->coord.x, p->coord.y, op[p->tag]); - p++; - i--; - } - } -#endif - p = &final_path[0]; - i = np; - while (i > 0) { - switch (p->tag) { - case MTINDEX: - if (firstpath) { - sprintf(buff, "%ld %ld rmt\n", p->coord.x, p->coord.y); - (void)DoContEncrypt(buff, outfile, FALSE, INLEN); - firstpath = FALSE; - } else { - dy = p->coord.y - cp.y; - if ((dx = p->coord.x - cp.x) == 0) { - sprintf(buff, "%ld vmt\n", dy); - (void)DoContEncrypt(buff, outfile, FALSE, INLEN); - } else if (dy == 0) { - sprintf(buff, "%ld hmt\n", dx); - (void)DoContEncrypt(buff, outfile, FALSE, INLEN); - } else { - sprintf(buff, "%ld %ld rmt\n", dx, dy); - (void)DoContEncrypt(buff, outfile, FALSE, INLEN); - } - } - cp = p->coord; - p++; - i--; - break; - case LTINDEX: - dy = p->coord.y - cp.y; - if ((dx = p->coord.x - cp.x) == 0) { - sprintf(buff, "%ld vdt\n", dy); - (void)DoContEncrypt(buff, outfile, FALSE, INLEN); - } else if (dy == 0) { - sprintf(buff, "%ld hdt\n", dx); - (void)DoContEncrypt(buff, outfile, FALSE, INLEN); - } else { - sprintf(buff, "%ld %ld rdt\n", dx, dy); - (void)DoContEncrypt(buff, outfile, FALSE, INLEN); - } - cp = p->coord; - p++; - i--; - break; - case CTINDEX: - p1 = p + 1; - p2 = p + 2; - - if (((dx = (p->coord.x - cp.x)) == 0) && (p2->coord.y == p1->coord.y)) /* vhct */ - { - sprintf(buff, "%ld %ld %ld %ld vhct\n", - p->coord.y - cp.y, p1->coord.x - p->coord.x, - p1->coord.y - p->coord.y, p2->coord.x - p1->coord.x); - (void)DoContEncrypt(buff, outfile, FALSE, INLEN); - } else if (((dy = (p->coord.y - cp.y)) == 0) && (p2->coord.x == p1->coord.x)) /* hvct */ - { - sprintf(buff, "%ld %ld %ld %ld hvct\n", - dx, p1->coord.x - p->coord.x, - p1->coord.y - p->coord.y, p2->coord.y - p1->coord.y); - (void)DoContEncrypt(buff, outfile, FALSE, INLEN); - } else /* rct */ - { - sprintf(buff, "%ld %ld ", dx, dy); - (void)DoContEncrypt(buff, outfile, FALSE, INLEN); - sprintf(buff, "%ld %ld ", p1->coord.x - p->coord.x, p1->coord.y - p->coord.y); - (void)DoContEncrypt(buff, outfile, FALSE, INLEN); - sprintf(buff, "%ld %ld rct\n", p2->coord.x - p1->coord.x, p2->coord.y - p1->coord.y); - (void)DoContEncrypt(buff, outfile, FALSE, INLEN); - } - cp = p2->coord; - p += 3; - i -= 3; - break; - } - } - (void)DoContEncrypt("cp\n", outfile, FALSE, INLEN); /* closepath */ -} /* end relative */ - -#if ILLDEBUG -static dump_path(boolean reverse) { - static char op[3] = {'M', 'L', 'C'}; - long n; - path_element *p; - - n = np; - if (reverse) { - /* Dump path after reversal. */ - fprintf(OUTPUTBUFF, "Dump of reversed path\n"); - p = &path[np - 1]; - while (n > 0) { - if (p->tag == CTINDEX) { - fprintf(OUTPUTBUFF, "%-10.3d %-10.3d", p->coord.x, p->coord.y); - p--; - fprintf(OUTPUTBUFF, "%-10.3d %-10.3d", p->coord.x, p->coord.y); - p--; - fprintf(OUTPUTBUFF, "%-10.3d %-10.3d %c\n", p->coord.x, p->coord.y, op[p->tag]); - p--; - n -= 3; - } else { - fprintf(OUTPUTBUFF, "%-10.3d %-10.3d %c\n", p->coord.x, p->coord.y, op[p->tag]); - p--; - n--; - } - } - } else { - fprintf(OUTPUTBUFF, "Dump of unreversed path\n"); - p = path; - while (n > 0) { - if (p->tag == CTINDEX) { - fprintf(OUTPUTBUFF, "%-10.3d %-10.3d", p->coord.x, p->coord.y); - p++; - fprintf(OUTPUTBUFF, "%-10.3d %-10.3d", p->coord.x, p->coord.y); - p++; - fprintf(OUTPUTBUFF, "%-10.3d %-10.3d %c\n", p->coord.x, p->coord.y, op[p->tag]); - p++; - n -= 3; - } else { - fprintf(OUTPUTBUFF, "%-10.3d %-10.3d %c\n", p->coord.x, p->coord.y, op[p->tag]); - p++; - n--; - } - } - } -} - -#endif - -void convert_illcharfile(const char *charname, const char *filename) { - FILE *infile, *outfile; - char inname[MAXPATHLEN], outname[MAXPATHLEN]; - - firstpath = TRUE; - width_found = FALSE; - get_filename(inname, ILLDIR, filename); - get_filename(outname, bezdir, filename); - - infile = ACOpenFile(inname, "r", OPENWARN); - if (infile == NULL) return; - outfile = ACOpenFile(tmpnm, "w", OPENERROR); - DoInitEncrypt(outfile, OTHER, HEX, (long)BEZLINESIZE, FALSE); - WriteStart(outfile, charname); - convert(infile, outfile, charname, filename); - (void)DoContEncrypt("ed\n", outfile, FALSE, INLEN); - if (!width_found) - err = err || width_error(charname); - fclose(infile); - fclose(outfile); - RenameFile(tmpnm, outname); - if (printmsg) { - LogMsg("Converting Adobe Illustrator(R) files ...", - INFO, OK, FALSE); - printmsg = FALSE; - } - convertedchars++; -} - -extern void set_scale(float *newscale) { - float temp; - long cnt; - char *fontinfostr; - - *newscale = 1; - fontinfostr = GetFntInfo("ScalePercent", ACOPTIONAL); - if (fontinfostr == NULL) - return; - cnt = sscanf(fontinfostr, " %f", &temp); - if (cnt != 1) { - sprintf(globmsg, "ScalePercent line of fontinfo file invalid.\n"); -#if DOMEMCHECK - memck_free(fontinfostr); -#else - UnallocateMem(fontinfostr); -#endif - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } -#if DOMEMCHECK - memck_free(fontinfostr); -#else - UnallocateMem(fontinfostr); -#endif - *newscale = temp / (float)100; -} - -void convert_illfiles(boolean rel) { - boolean widths_exist; - boolean result = TRUE; - - release = rel; - printmsg = TRUE; - illcleanup(); /* just in case last caller exited with error */ - widths_exist = initialize_widths(); - set_scale(&scale); - get_filename(tmpnm, bezdir, TEMPFILE); - -#if DOMEMCHECK - path = (struct path_element *)memck_malloc(MAXPOINTS * sizeof(path_element)); - final_path = (struct path_element *)memck_malloc(MAXPOINTS * sizeof(path_element)); -#else - path = (struct path_element *)AllocateMem(MAXPOINTS, sizeof(path_element), - "path structure"); - final_path = (struct path_element *)AllocateMem(MAXPOINTS, sizeof(path_element), "final path structure"); -#endif - convertedchars = 0; -#if SUN - ConvertCharFiles(ILLDIR, release, scale, convert_illcharfile); -#elif WIN32 - ConvertCharFiles(ILLDIR, release, scale, convert_illcharfile); -#else - ConvertInputDirFiles(ILLDIR, convert_illcharfile); -#endif - if (convertedchars > 0) { - sprintf(globmsg, " %d files converted.\n", (int)convertedchars); - LogMsg(globmsg, INFO, OK, FALSE); - if (scale != 1.0) { - sprintf(globmsg, "Widths in the original %s file were not scaled.\n", WIDTHSFILENAME); - LogMsg(globmsg, WARNING, OK, TRUE); - } - } - if (err || !result) - cleanup(NONFATALERROR); - write_widths_file(widths_exist); - illcleanup(); -} diff --git a/c/autohint/autohintlib/source/bf/machinedep.c b/c/autohint/autohintlib/source/bf/machinedep.c deleted file mode 100644 index 6d7fcd740..000000000 --- a/c/autohint/autohintlib/source/bf/machinedep.c +++ /dev/null @@ -1,616 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* machinedep.c - -history: - -JLee April 8, 1988 - -Judy Lee: Wed Jul 6 17:55:30 1988 -End Edit History -*/ -#include /* Needed only for _O_RDWR definition */ -#include - -#include -#include -#ifdef WIN32 -#include -#else -#include -#endif -#include - -#include -extern char *ctime(); - -#ifdef WIN32 -#include -/* as of Visual Studi 2005, the POSIX names are deprecated; need to use -Windows specific names instead. -*/ -#include -#define chdir _chdir -#define mkdir _mkdir -#define getcwd _getcwd - -#include -#define access _access -#else -#include /* for access(), lockf() */ -#endif - -#include "ac.h" -#include "fipublic.h" -#include "machinedep.h" - -#define CURRENTID "CurrentID" -#define MAXID "MaxID" -#define MAXUNIQUEID 16777215L /* 2^24 - 1 */ -#define BUFFERSZ 512 /* buffer size used by unique id file */ -#define MAXIDFILELEN 100 /* maximum length of line in unique id file */ - -static char ibmfilename[] = "ibmprinterfont.unprot"; -static char uniqueIDFile[MAXPATHLEN]; -static short warncnt = 0; -#if defined(__MWERKS__) -static char Delimiter[] = "/"; -#elif defined(WIN32) -static char Delimiter[] = "\\"; -#else -static char Delimiter[] = "/"; -#endif - -static int (*errorproc)(short); /* proc to be called from LogMsg if error occurs */ - -/* used for cacheing of log messages */ -static char lastLogStr[MAXMSGLEN + 1] = ""; -static short lastLogLevel = -1; -static boolean lastLogPrefix; -static int logCount = 0; - -static void LogMsg1(char *str, short level, short code, boolean prefix); - -short WarnCount() { - return warncnt; -} - -void ResetWarnCount() { - warncnt = 0; -} - -#ifdef IS_LIB -#define Write(s) \ - { \ - if (libReportCB != NULL) libReportCB(s); \ - } -#define WriteWarnorErr(f, s) \ - { \ - if (libErrorReportCB != NULL) libErrorReportCB(s); \ - } -#else -#define Write(s) -#define WriteWarnorErr(f, s) -#endif - -void set_errorproc(userproc) int (*userproc)(short); -{ - errorproc = userproc; -} - -/* called by LogMsg and when exiting (tidyup) */ -void FlushLogMsg(void) { - /* if message happened exactly 2 times, don't treat it specially */ - if (logCount == 1) { - LogMsg1(lastLogStr, lastLogLevel, OK, lastLogPrefix); - } else if (logCount > 1) { - char newStr[MAXMSGLEN]; - sprintf(newStr, "The last message (%.20s...) repeated %d more times.\n", - lastLogStr, logCount); - LogMsg1(newStr, lastLogLevel, OK, TRUE); - } - logCount = 0; -} - -void LogMsg( - char *str, /* message string */ - short level, /* error, warning, info */ - short code, /* exit value - if !OK, this proc will not return */ - boolean prefix /* prefix message with LOGERROR: or WARNING:, as appropriate */) { - /* changed handling of this to be more friendly (?) jvz */ - if (strlen(str) > MAXMSGLEN) { - LogMsg1("The following message was truncated.\n", WARNING, OK, TRUE); - ++warncnt; - } - if (level == WARNING) - ++warncnt; - if (!strcmp(str, lastLogStr) && level == lastLogLevel) { - ++logCount; /* same message */ - } else { /* new message */ - if (logCount) /* messages pending */ - FlushLogMsg(); - LogMsg1(str, level, code, prefix); /* won't return if LOGERROR */ - strncpy(lastLogStr, str, MAXMSGLEN); - lastLogLevel = level; - lastLogPrefix = prefix; - } -} - -static void LogMsg1(char *str, short level, short code, boolean prefix) { - switch (level) { - case INFO: - Write(str); - break; - case WARNING: - if (prefix) - WriteWarnorErr(stderr, "WARNING: "); - WriteWarnorErr(stderr, str); - break; - case LOGERROR: - if (prefix) - WriteWarnorErr(stderr, "ERROR: "); - WriteWarnorErr(stderr, str); - break; - default: - WriteWarnorErr(stderr, "ERROR - log level not recognized: "); - WriteWarnorErr(stderr, str); - break; - } - if (level == LOGERROR && (code == NONFATALERROR || code == FATALERROR)) { - (*errorproc)(code); - } -} - -void getidfilename(str) char *str; -{ - strcpy(str, uniqueIDFile); -} - -void set_uniqueIDFile(str) char *str; -{ - strcpy(uniqueIDFile, str); -} - -static char afmfilename[] = "AFM"; -static char macfilename[] = "macprinterfont.unprot"; - -void get_filename(char *name, char *str, const char *basename) { - sprintf(name, "%s%s%s", str, Delimiter, basename); -} - -void get_afm_filename(name) char *name; -{ - strcpy(name, afmfilename); -} - -void get_ibm_fontname(ibmfontname) char *ibmfontname; -{ - strcpy(ibmfontname, ibmfilename); -} - -void get_mac_fontname(macfontname) char *macfontname; -{ - strcpy(macfontname, macfilename); -} - -void get_time(time_t *value) { - time(value); -} - -void get_datetime(datetimestr) char *datetimestr; -{ - time_t secs; - - get_time(&secs); - strncpy(datetimestr, ctime(&secs), 24); - /* skip the 24th character, which is a newline */ - datetimestr[24] = '\0'; -} - -/* Sets the current directory to the one specified. */ -void set_current_dir(current_dir) char *current_dir; -{ - if ((chdir(current_dir)) != 0) { - sprintf(globmsg, "Unable to cd to directory: '%s'.\n", current_dir); - LogMsg(globmsg, WARNING, OK, TRUE); - } -} - -void get_current_dir(char *currdir) { - (void)getcwd(currdir, MAXPATHLEN); -} - -/* Returns true if the given file exists, is not a directory - and user has read permission, otherwise it returns FALSE. */ -boolean FileExists(const char *filename, short errormsg) { - struct stat stbuff; - int filedesc; - - if ((strlen(filename) == 0) && !errormsg) - return FALSE; - /* Check if this file exists and if it is a directory. */ - if (stat(filename, &stbuff) == -1) { - if (errormsg) { - sprintf(globmsg, "The %s file does not exist, but is required.\n", filename); - LogMsg(globmsg, LOGERROR, OK, TRUE); - } - return FALSE; - } - if ((stbuff.st_mode & S_IFMT) == S_IFDIR) { - if (errormsg) { - sprintf(globmsg, "%s is a directory not a file.\n", filename); - LogMsg(globmsg, LOGERROR, OK, TRUE); - } - return FALSE; - } else - - /* Check for read permission. */ - if ((filedesc = access(filename, R_OK)) == -1) { - if (errormsg) { - sprintf(globmsg, "The %s file is not accessible.\n", filename); - LogMsg(globmsg, LOGERROR, OK, TRUE); - } - return FALSE; - } - - return TRUE; -} - -boolean CFileExists(const char *filename, short errormsg) { - return FileExists(filename, errormsg); -} - -boolean DirExists(char *dirname, boolean absolute, boolean create, boolean errormsg) { -#ifndef WIN32 -#pragma unused(absolute) -#endif - long int access_denied = access(dirname, F_OK); - - if (access_denied) { - if (errno == EACCES) { - sprintf(globmsg, "The %s directory cannot be accessed.\n", dirname); - LogMsg(globmsg, LOGERROR, OK, TRUE); - return FALSE; - } else { - if (errormsg) { - sprintf(globmsg, "The %s directory does not exist.", dirname); - LogMsg(globmsg, create ? WARNING : LOGERROR, OK, TRUE); - } - if (!create) { - if (errormsg) - LogMsg("\n", LOGERROR, OK, FALSE); - return FALSE; - } - if (errormsg) - LogMsg(" It will be created for you.\n", WARNING, OK, FALSE); - { -#ifdef WIN32 - int result = mkdir(dirname); -#else - int result = mkdir(dirname, 00775); -#endif - - if (result) { - sprintf(globmsg, "Can't create the %s directory.\n", dirname); - LogMsg(globmsg, LOGERROR, OK, TRUE); - return FALSE; - } - } /* end local block for mkdir */ - } - } - return TRUE; -} - -/* Returns the full name of the input directory. */ -void GetInputDirName(name, suffix) char *name; -char *suffix; -{ - char currdir[MAXPATHLEN]; - - getcwd(currdir, MAXPATHLEN); - sprintf(name, "%s%s%s", currdir, Delimiter, suffix); -} - -unsigned long ACGetFileSize(filename) char *filename; -{ - struct stat filestat; - - if ((stat(filename, &filestat)) < 0) return (0); -#ifdef CW80 - return ((unsigned long)filestat.st_mtime); -#else - return ((unsigned long)filestat.st_size); -#endif -} - -void RenameFile(oldName, newName) char *oldName, *newName; -{ - if (FileExists(newName, FALSE)) { - if (remove(newName)) { - sprintf(globmsg, "Could not remove file: %s for renaming (%d).\n", newName, errno); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - } - if (rename(oldName, newName)) { - sprintf(globmsg, "Could not rename file: %s to: %s (%d).\n", oldName, newName, errno); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } -} - -void MoveDerivedFile(filename, basedir, fromDir, toDir) char *filename, *basedir, *fromDir, *toDir; -{ - char fromname[MAXPATHLEN], toname[MAXPATHLEN]; - - if (basedir == NULL) { - get_filename(fromname, fromDir, filename); - get_filename(toname, toDir, filename); - } else { - sprintf(fromname, "%s%s%s%s", basedir, fromDir, Delimiter, filename); - sprintf(toname, "%s%s%s%s", basedir, toDir, Delimiter, filename); - } - RenameFile(fromname, toname); -} - -void AppendFile(start, end) char *start, *end; -{ - FILE *file1, *file2; - char buffer[200]; - file2 = ACOpenFile(end, "r", OPENOK); - if (file2 == NULL) - return; - file1 = ACOpenFile(start, "a", OPENWARN); - while (fgets(buffer, 200, file2) != NULL) - fputs(buffer, file1); - fclose(file1); - fclose(file2); -} - -/* Converts :'s to /'s. Colon's before the first alphabetic - character are converted to ../ */ -char *CheckBFPath(baseFontPath) char *baseFontPath; -{ - char *uponelevel = "../"; - char *startpath, *oldsp; - char newpath[MAXPATHLEN]; - short length; - - newpath[0] = '\0'; - if (strchr(baseFontPath, *Delimiter) == NULL) { - if (*baseFontPath == *Delimiter) - LogMsg( - "BaseFontPath keyword in fontinfo file must indicate a relative path name.\n", - LOGERROR, NONFATALERROR, TRUE); - return baseFontPath; - } - - /* Find number of colons at the start of the path */ - switch (length = (short)strspn(baseFontPath, Delimiter)) { - case (0): - break; - case (1): - LogMsg( - "BaseFontPath keyword in fontinfo file must indicate a relative path name.\n", - LOGERROR, NONFATALERROR, TRUE); - break; - default: - /* first two colons => up one, any subsequent single colon => up one */ - for (startpath = baseFontPath + 1; - startpath < baseFontPath + length; startpath++) - if (*startpath == *Delimiter) - strcat(newpath, uponelevel); - break; - } - - length = (short)strlen(startpath); - /* replace all colons by slashes in remainder of input string - - Note: this does not handle > 1 colon embedded in the middle of - a Mac path name correctly */ - for (oldsp = startpath; startpath < oldsp + length; startpath++) - if (*startpath == *Delimiter) - *startpath = *Delimiter; -#if DOMEMCHECK - startpath = memck_malloc((strlen(newpath) + length + 1) * sizeof(char)); -#else - startpath = AllocateMem(((unsigned int)strlen(newpath)) + length + 1, sizeof(char), - "return string for CheckBFPath"); -#endif - strcpy(startpath, newpath); - strcat(startpath, oldsp); -#if DOMEMCHECK - memck_free(baseFontPath); -#else - UnallocateMem(baseFontPath); -#endif - return startpath; -} - -/* Dummy procedures */ - -void CreateResourceFile(filename) char *filename; -{ -#ifndef WIN32 -#pragma unused(filename) -#endif -} - -/* Returns full pathname of current working directory. */ -void GetFullPathname(char *dirname, short vRefNum, long dirID) { -#ifndef WIN32 -#pragma unused(vRefNum) -#pragma unused(dirID) -#endif - getcwd(dirname, MAXPATHLEN); - /* Append unix delimiter. */ - strcat(dirname, Delimiter); -} - -/* Creates a file called .BFLOCK or .ACLOCK in the current directory. - If checkexists is TRUE this proc will check if .BFLOCK or .ACLOCK exists - before creating it. If it does exist an error message will - be displayed and buildfont will exit. - The .BFLOCK file is used to indicate that buildfont is currently - being run in the directory. The .ACLOCK file is used to indicate - that AC is currently being run in the directory. */ -boolean createlockfile(fileToOpen, baseFontPath) char *fileToOpen; -char *baseFontPath; /* for error msg only; cd has been done */ -{ - FILE *bf; - - if (CFileExists(BFFILE, FALSE)) { - sprintf(globmsg, "BuildFont is already running in the %s directory.\n", - (strlen(baseFontPath)) ? baseFontPath : "current"); - LogMsg(globmsg, LOGERROR, OK, TRUE); - return FALSE; - } - if (CFileExists(ACFILE, FALSE)) { - sprintf(globmsg, "AC is already running in the %s directory.\n", - (strlen(baseFontPath)) ? baseFontPath : "current"); - LogMsg(globmsg, LOGERROR, OK, TRUE); - return FALSE; - } - bf = ACOpenFile(fileToOpen, "w", OPENOK); - if (bf == NULL) { - sprintf(globmsg, - "Cannot open the %s%s file.\n", baseFontPath, fileToOpen); - LogMsg(globmsg, LOGERROR, OK, TRUE); - return FALSE; - } - fclose(bf); - return TRUE; -} - -void SetMacFileType(filename, filetype) char *filename; -char *filetype; -{ -#ifndef WIN32 -#pragma unused(filename) -#pragma unused(filetype) -#endif -} - -void closefiles() { -#ifndef IS_LIB - Write("Warning: closefiles unimplemented\n"); -#endif - /* register int counter, bad_ones = 0; -*/ - /* leave open stdin, stdout, stderr and console */ - /*for (counter = 4; counter < _NFILE; counter++) - if (fclose(&_file[counter])) - bad_ones++; - */ -} - -void get_filedelimit(delimit) char *delimit; -{ - strcpy(delimit, Delimiter); -} - -/* -extern get_afm_filename(char *name) -{ - char fontname[MAXFILENAME]; - - get_mac_fontname(fontname); - sprintf(name, "%s%s", fontname, ".AFM"); - FileNameLenOK(name); -} - -extern get_ibm_fontname(ibmfontname) -char *ibmfontname; -{ - char *fontinfostr; - - if ((fontinfostr = GetFntInfo("PCFileNamePrefix", ACOPTIONAL)) == NULL) - strcpy(ibmfontname, ibmfilename); - else - { - if (strlen(fontinfostr) != 5) - { - sprintf(globmsg, "PCFileNamePrefix in the %s file must be exactly 5 characters.\n", FIFILENAME); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - strcpy(ibmfontname, fontinfostr); - strcat(ibmfontname, "___.PFB"); - FreeFontInfo(fontinfostr); - } -} - -extern get_mac_fontname(macfontname) -char *macfontname; -{ - char *fontinfostr, *fontname; - - fontinfostr = GetFntInfo("FontName", MANDATORY); - fontname = printer_filename(fontinfostr); - strcpy(macfontname, fontname); - FreeFontInfo(fontinfostr); - UnallocateMem(fontname); -} - -extern get_time(value) -long *value; -{ - GetDateTime(value); -} - -extern get_datetime(char *datetimestr) -{ - long secs; - char datestr[25], timestr[25]; - - get_time(&secs); - IUDateString(secs, abbrevDate, datestr); - IUTimeString(secs, TRUE, timestr); - sprintf(datetimestr, "%p %p", datestr, timestr); -} -*/ -/* copies from one path ref num to another - can be different forks of same file */ - -char *MakeTempName(char *dirprefix, char *fileprefix) { -#ifndef WIN32 -#pragma unused(dirprefix) -#pragma unused(fileprefix) -#endif - return NULL; -} - -int AutoCrit(char *filenameparam, char *goo) { -#ifndef WIN32 -#pragma unused(filenameparam) -#pragma unused(goo) -#endif - return 0; -} - -int bf_alphasort(const void *f1, const void *f2) { - struct direct **mf1, **mf2; - mf1 = (struct direct **)f1; - mf2 = (struct direct **)f2; - return strcmp((*mf1)->d_name, (*mf2)->d_name); -} - -#if defined(_MSC_VER) && (_MSC_VER < 1800) -float roundf(float x) { - float val = (float)((x < 0) ? (ceil((x)-0.5)) : (floor((x) + 0.5))); - return val; -} -#endif - -unsigned char *CtoPstr(char *filename) { - int i, length = (int)strlen(filename); - for (i = length; i > 0; i--) - filename[i] = filename[i - 1]; - filename[0] = length; - return (unsigned char *)filename; -} - -char *PtoCstr(unsigned char *filename) { - int i, length = filename[0]; - for (i = 0; i < length; i++) - filename[i] = filename[i + 1]; - filename[i] = '\0'; - - return (char *)filename; -} diff --git a/c/autohint/autohintlib/source/bf/machinedep.h b/c/autohint/autohintlib/source/bf/machinedep.h deleted file mode 100644 index 357c99585..000000000 --- a/c/autohint/autohintlib/source/bf/machinedep.h +++ /dev/null @@ -1,148 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* machinedep.h - defines machine dependent procedures used by - buildfont. - -history: - -Judy Lee: Mon Jul 18 14:13:03 1988 -End Edit History -*/ - -#include "basic.h" - -#ifndef MACHINEDEP_H -#define MACHINEDEP_H - -#if WIN32 -#include -#include -#else -#include -#endif - -#define fileeof(p) feof(p) -#define fileerror(p) ferror(p) - -#define ACFILE ".ACLOCK" /* zero length file to indicate that AC */ - /* is running in current directory. */ - -#define BFFILE ".BFLOCK" /* zero length file to indicate that buildfont */ - /* is running in current directory. */ - -extern void FlushLogMsg(void); - -extern boolean createlockfile( - char *, char *); - -extern void set_errorproc(int (*)(short)); - -extern void closefiles( - void); - -extern void get_filedelimit( - char *); - -extern void get_time(time_t *); - -/* Gets the date and time. */ -extern void get_datetime( - char *); - -/* delimits str with / or : */ -extern void get_filename( - char *, char *, const char *); - -/* Returns name of AFM file. */ -extern void get_afm_filename( - char *); - -/* Returns name of IBM printer file. */ -extern void get_ibm_fontname( - char *); - -/* Returns name of Mac printer file. */ -extern void get_mac_fontname( - char *); - -/* Returns the full path name given ref num and dirID. - If dirID is MININT then it returns the pathname of - the current working directory. On UNIX it always - returns the current working directory. */ -extern void GetFullPathname( - char *, short, long); - -extern char *CheckBFPath( - char *); - -extern void GetInputDirName( - char *, char *); - -extern unsigned long ACGetFileSize( - char *); - -/* Checks if the character set directory exists. */ -extern boolean DirExists( - char *, boolean, boolean, boolean); - -/* Checks for the existence of the specified file. */ -extern boolean FileExists( - const char *, short); - -/* Checks for the existence of the specified file. */ -extern boolean CFileExists( - const char *, short); - -extern void MoveDerivedFile( - char *, char *, char *, char *); - -/* Creates the resource file for the Macintosh downloadable printer font. */ -extern void CreateResourceFile( - char *); - -extern void RenameFile( - char *, char *); - -extern void set_current_dir( - char *); - -extern void get_current_dir( - char *); - -extern void SetMacFileType( - char *, char *); - -extern void ScanBezFiles( - boolean, indx, boolean); - -extern void ScanDirFiles( - boolean, char *); - -extern void AppendFile( - char *, char *); - -extern char *MakeTempName( - char *, char *); - -extern int AutoCrit( - char *, char *); - -public -procedure FlushLogFiles(); -public -procedure OpenLogFiles(); -typedef int (*includeFile)(struct direct *); -typedef int (*sortFn)(const void *, const void *); - -extern char *GetPathName( - char *); - -extern int bf_alphasort(const void *f1, const void *f2); - -#if defined(_MSC_VER) && (_MSC_VER < 1800) -public -float roundf(float x); -#endif - -#endif /*MACHINEDEP_H*/ diff --git a/c/autohint/autohintlib/source/bf/masterfont.h b/c/autohint/autohintlib/source/bf/masterfont.h deleted file mode 100644 index 8c9548fef..000000000 --- a/c/autohint/autohintlib/source/bf/masterfont.h +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* masterfont.h */ - -#ifndef MASTERFONT_H -#define MASTERFONT_H - -#define MAXDESIGNS 16 /* maximum number of base designs for a multiple master font. */ - -extern void BlendIntArray( - int *, int, int, char *); - -extern void BlendFltArray( - float *, int, int, char *); - -/* Returns the default weight value for this directory. */ -extern float DefaultWeightForDir( - int); - -extern void DefaultWeightVector( - char *); - -extern void FreeDirEntries( - void); - -extern void GetMasterDirName( - char *, indx); - -extern int GetMasterDirIx( - char *); - -extern short GetMasterFontList( - char *); - -extern int InteriorDesignsExist( - void); - -extern void PrintInputDirNames( - void); - -extern void SetDefaultWeightVector( - void); - -extern void SetMasterDir( - indx); - -extern int TotalWtVecs( - void); - -extern void WritePhantomIntercepts( - FILE *); - -#endif /*MASTERFONT_H*/ diff --git a/c/autohint/autohintlib/source/bf/masterfontpriv.h b/c/autohint/autohintlib/source/bf/masterfontpriv.h deleted file mode 100644 index e40c44f1e..000000000 --- a/c/autohint/autohintlib/source/bf/masterfontpriv.h +++ /dev/null @@ -1,14 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -#ifndef MASTERFONTPRIV_H -#define MASTERFONTPRIV_H - -typedef struct _MasterDesignPosit { - char *MasterDirName; - float posit[4]; -} MasterDesignPosit; - -extern void GetMasterDesignPositions(MasterDesignPosit **MDP, int *nummast, int *numaxes); - -#endif /* MASTERFONTPRIV_H */ diff --git a/c/autohint/autohintlib/source/bf/opcodes.h b/c/autohint/autohintlib/source/bf/opcodes.h deleted file mode 100644 index 7dab4defb..000000000 --- a/c/autohint/autohintlib/source/bf/opcodes.h +++ /dev/null @@ -1,183 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* opcodes for PS operators */ -/* The assignment of mnemonics to constants in this file has two purposes: - 1) establish the value of encoded operators that are put in the - CharString of a character. This purpose requires that the values - of such operators must correspond to the values in fontbuild.c in - the PS interpreter. - 2) provide an index into a lookup table for buildfont's use. - Thus, some of the mnemonics are never put in a CharString, but - are here just so the table lookup is possible. For such operators, - the values don't matter as long as they don't conflict with any of - the PS interpreter values. */ - -/* Thu May 12 22:56:28 PDT 1994 jvz SETWV, COMPOSE */ - -#define COURIERB 0 -/* y COURIERB - Courier coloring */ -#define RB 1 -/* y dy RB -- add horizontal coloring pair at y and y+dy */ -#define COMPOSE 2 -/* subr# COMPOSE -- draw a library element. Pops only one arg from stack. */ -#define RY 3 -/* x dx RY -- add vertical coloring pair at x and x+dx */ -#define VMT 4 -/* dy VMT -- equivalent to 0 dy RMT */ -#define RDT 5 -/* dx dy RDT -- relative lineto */ -#define HDT 6 -/* dx HDT -- equivalent to dx 0 RDT */ -#define VDT 7 -/* dy VDT -- equivalent to 0 dy RDT */ -#define RCT 8 -/* dx1 dy1 dx2 dy2 dx3 dy3 RCT -- relative curveto */ -#define CP 9 -/* closepath */ -#define DOSUB 10 -/* i DOSUB -- execute Subrs[i] */ -#define RET 11 -/* RET -- return from DOSUB call */ -#define ESC 12 -/* escape - see special operators below */ -#define SBX 13 -/* SBX */ -#define ED 14 -/* end of a character */ -#define MT 15 -/* x y MT - non-relative - Courier and some space chars only */ -#define DT 16 -/* x y DT - non-relative - Courier only */ -#define CT 17 -/* x1 y1 x2 y2 x3 y3 CT - non-relative - Courier only */ -#define OMIN 18 /* MIN is a macro in THINK C */ - /* a b MIN -> (min(a,b)) */ -#define ST 19 -/* ST -- stroke (graphics state operator) */ -#define NP 20 -/* NP - Courier newpath */ -#define RMT 21 -/* dx dy RMT -- relative moveto */ -#define HMT 22 -/* dx HMT -- equivalent to dx 0 RMT */ -#define SLC 23 -/* i SLC -- setlinecap (graphics state operator) */ -#define MUL 24 -/* a b MUL -> (a*b) */ -#define STKWDTH 25 -/* font constant for strokewidth */ -#define BSLN 26 -/* font constant for baseline */ -#define CPHGHT 27 -/* font constant for cap height */ -#define BOVER 28 -/* font constant for baseline overshoot */ -#define XHGHT 29 -/* font constant for xheight */ -#define VHCT 30 -/* dy1 dx2 dy2 dx3 VHCT -- equivalent to 0 dy1 dx2 dy2 dx3 0 RCT */ -#define HVCT 31 -/* dx1 dx2 dy2 dy3 HVCT -- equivalent to dx1 0 dx2 dy2 0 dy3 RCT */ - -/* the operators above can be used in the charstring and thus evaluated - by the PS interpreter. The following operators never are placed in - the charstring, but are found in bez files. */ - -#define SNC 38 -/* start new colors */ -#define ENC 39 -/* end new colors */ -#define SC 40 -/* start character */ -#define FLX 41 -/* flex => translated to a 0 DOSUB in CharString */ -#define SOL 42 -/* start of loop = subpath => translated to FL CharString op */ -#define EOL 43 -/* end of loop = subpath => translated to FL CharString op */ -#define ID 44 -/* path id number */ - -/* escape operators - all of these can go into the charstrings */ -#define FL 0 -/* FL -- flip switch for "offset locking" - e.g. insuring > 0 pixel - separation between two paths of an i */ -#define RM 1 -/* x0 dx0 x1 dx1 x2 dx2 RM -- add 3 equal spaced vertical coloring pairs */ -#define RV 2 -/* y0 dy0 y1 dy1 y2 dy2 RV -- add 3 equal spaced horizontal coloring pairs */ -#define FI 3 -/* FI -- fill (graphics state operator) */ -#define ARC 4 -/* cx cy r a1 a2 ARC - Courier only */ -#define SLW 5 -/* w SLW -- setlinewidth (graphics state operator) */ -#define CC 6 -/* asb dx dy ccode acode CC -- composite character definition */ -#define SB 7 -/* */ -#define SSPC 8 -/* llx lly urx ury SSPC -- start self painting character - Courier only */ -#define ESPC 9 -/* ESPC -- end self painting character - Courier only */ -#define ADD 10 -/*a b ADD -> (a+b) */ -#define SUB 11 -/* a b SUB -> (a-b) */ -#define DIV 12 -/* a b DIV -> (a / b), used when need a non-integer value */ -#define OMAX 13 /* MAX is a macro in THINK C */ - /* a b MAX -> (max(a,b)) */ -#define NEG 14 -/* a NEG -> (-a) */ -#define IFGTADD 15 -/* a b c d IFGTADD -> (b > c)? (a+d) : (a) */ -#define DO 16 -/* a1 ... an n i DO -- - push an on PS stack; - ... - push a1 on PS stack; - begin systemdict; - begin fontdict; - execute OtherSubrs[i]; - end; - end; - */ -#define POP 17 -/* pop a number from top of PS stack and push it on fontbuild stack - used in communicating with OtherSubrs */ -#define DSCND 18 -/* font constant for descender */ -#define SETWV 19 -/* set weight vector */ -#define OVRSHT 20 -/* font constant for overshoot */ -#define SLJ 21 -/* i SLJ -- setlinejoin (graphics state operator) */ -#define XOVR 22 -/* font constant for xheight overshoot */ -#define CAPOVR 23 -/* font constant for cap overshoot */ -#define AOVR 24 -/* font constant for ascender overshoot */ -#define HLFSW 25 -/* font constant for half strokewidth */ -#define ROUNDSW 26 -/* w RNDSW -> (RoundSW(w)) -- round stroke width */ -#define ARCN 27 -/* cx cy r a1 a2 ARCN - Courier only */ -#define EXCH 28 -/* a b EXCH -> b a */ -#define INDEX 29 -/* an ... a0 i INDX -> an ... a0 ai */ -#define CRB 30 -/* y dy CRB - Courier rb */ -#define CRY 31 -/* x dx CRY - Courier ry */ -#define PUSHCP 32 -/* PUSHCP -> cx cy -- push the current position onto font stack - (graphics state operator) */ -#define POPCP 33 -/* cx cy POPCP -- set current position from font stack - (graphics state operator) */ diff --git a/c/autohint/autohintlib/source/bf/optable.c b/c/autohint/autohintlib/source/bf/optable.c deleted file mode 100644 index 2a2e7fb1c..000000000 --- a/c/autohint/autohintlib/source/bf/optable.c +++ /dev/null @@ -1,160 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* optable.c - initializes table of known PostScript operators. */ - -#include "buildfont.h" -#include "machinedep.h" -#include "opcodes.h" -#include "optable.h" - -/* This defines an element of the table used to translate ASCII operand - names to the binary encoded equivalents. */ -typedef struct op_element { - short encoding; - char operator[MAXOPLEN]; -} op_element; - -#ifdef SUN -#define KNOWNOPSIZE 32 -#else -#define KNOWNOPSIZE 18 -#endif - -static struct op_element *op_table = NULL; - -/* Globals used outside this module. */ -#ifdef SUN -char beginsubr[10], endsubr[8], preflx[7], newcolors[10]; -#endif - -extern void init_ops() { - indx ix = 0; - - op_table = (struct op_element *)AllocateMem(KNOWNOPSIZE, sizeof(struct op_element), "operator table"); - /* The table is initialized in the following strange way to make it - difficult to find out what the secret font operators are by looking at - the object code for this source. Anyone with a debugger can look at the - operators once they have been initialized, however. It would make sense - to only have this initialization done once when buildfont is first - started, but now it is done once per font processed. - - The operator strings need to be left justified and null terminated. - - Not all of the operators from opcodes.h are initialized here; in - particular, some that seemed to be needed just for Courier were ignored. - - Operators for which the encoding value has been incremented by ESCVAL must - be preceded by an escape when written to the output charstring. */ -#ifdef SUN - sprintf(op_table[ix].operator, "%c%c%c%c", 'r', 'b', '\0', '\0'); - op_table[ix++].encoding = RB; - sprintf(op_table[ix].operator, "%c%c%c%c", 'r', 'y', '\0', '\0'); - op_table[ix++].encoding = RY; - sprintf(op_table[ix].operator, "%c%c%c%c", 's', 'u', 'b', 'r'); - op_table[ix++].encoding = DOSUB; -#endif - sprintf(op_table[ix].operator, "%c%c%c%c", 'v', 'm', 't', '\0'); - op_table[ix++].encoding = VMT; - sprintf(op_table[ix].operator, "%c%c%c%c", 'r', 'd', 't', '\0'); - op_table[ix++].encoding = RDT; - sprintf(op_table[ix].operator, "%c%c%c%c", 'h', 'd', 't', '\0'); - op_table[ix++].encoding = HDT; - sprintf(op_table[ix].operator, "%c%c%c%c", 'v', 'd', 't', '\0'); - op_table[ix++].encoding = VDT; - sprintf(op_table[ix].operator, "%c%c%c%c", 'r', 'c', 't', '\0'); - op_table[ix++].encoding = RCT; - sprintf(op_table[ix].operator, "%c%c%c%c", 'c', 'p', '\0', '\0'); - op_table[ix++].encoding = CP; - sprintf(op_table[ix].operator, "%c%c%c%c", 'r', 'e', 't', '\0'); - op_table[ix++].encoding = RET; - sprintf(op_table[ix].operator, "%c%c%c%c", 'e', 's', 'c', '\0'); - op_table[ix++].encoding = ESC; - sprintf(op_table[ix].operator, "%c%c%c%c", 's', 'b', 'x', '\0'); - op_table[ix++].encoding = SBX; - sprintf(op_table[ix].operator, "%c%c%c%c", 'e', 'd', '\0', '\0'); - op_table[ix++].encoding = ED; - sprintf(op_table[ix].operator, "%c%c%c%c", 'm', 't', '\0', '\0'); - op_table[ix++].encoding = MT; - sprintf(op_table[ix].operator, "%c%c%c%c", 'r', 'm', 't', '\0'); - op_table[ix++].encoding = RMT; - sprintf(op_table[ix].operator, "%c%c%c%c", 'h', 'm', 't', '\0'); - op_table[ix++].encoding = HMT; - sprintf(op_table[ix].operator, "%c%c%c%c", 'v', 'h', 'c', 't'); - op_table[ix++].encoding = VHCT; - sprintf(op_table[ix].operator, "%c%c%c%c", 'h', 'v', 'c', 't'); - op_table[ix++].encoding = HVCT; - /* special non-charstring operators start here */ - sprintf(op_table[ix].operator, "%c%c%c%c", 's', 'c', '\0', '\0'); - op_table[ix++].encoding = SC; - sprintf(op_table[ix].operator, "%c%c%c%c", 'i', 'd', '\0', '\0'); - op_table[ix++].encoding = ID; -#ifdef SUN - sprintf(op_table[ix].operator, "%c%c%c%c", 's', 'n', 'c', '\0'); - op_table[ix++].encoding = SNC; - sprintf(op_table[ix].operator, "%c%c%c%c", 'e', 'n', 'c', '\0'); - op_table[ix++].encoding = ENC; - sprintf(op_table[ix].operator, "%c%c%c%c", 'f', 'l', 'x', '\0'); - op_table[ix++].encoding = FLX; - sprintf(op_table[ix].operator, "%c%c%c%c", 's', 'o', 'l', '\0'); - op_table[ix++].encoding = SOL; - sprintf(op_table[ix].operator, "%c%c%c%c", 'e', 'o', 'l', '\0'); - op_table[ix++].encoding = EOL; -#endif - /* escape operators start here */ - sprintf(op_table[ix].operator, "%c%c%c%c", 'c', 'c', '\0', '\0'); - op_table[ix++].encoding = CC + ESCVAL; -#ifdef SUN - sprintf(op_table[ix].operator, "%c%c%c%c", 'f', 'l', '\0', '\0'); - op_table[ix++].encoding = FL + ESCVAL; - sprintf(op_table[ix].operator, "%c%c%c%c", 'r', 'm', '\0', '\0'); - op_table[ix++].encoding = RM + ESCVAL; - sprintf(op_table[ix].operator, "%c%c%c%c", 'r', 'v', '\0', '\0'); - op_table[ix++].encoding = RV + ESCVAL; - sprintf(op_table[ix].operator, "%c%c%c%c", 'd', 'i', 'v', '\0'); - op_table[ix++].encoding = DIV + ESCVAL; - sprintf(op_table[ix].operator, "%c%c%c%c", 'd', 'o', '\0', '\0'); - op_table[ix++].encoding = DO + ESCVAL; - sprintf(op_table[ix].operator, "%c%c%c%c", 'p', 'o', 'p', 'n'); - op_table[ix++].encoding = POP + ESCVAL; -#endif - - if (ix > KNOWNOPSIZE) { - LogMsg("Initialization of op table failed.\n", - LOGERROR, NONFATALERROR, TRUE); - } - /* These are treated as a special case for no particularly good reason - other than that they are longer than will fit in the above table */ -#ifdef SUN - sprintf(beginsubr, "%s%c%c%c%c", "begin", 's', 'u', 'b', 'r'); - - sprintf(endsubr, "%s%c%c%c%c", "end", 's', 'u', 'b', 'r'); - sprintf(preflx, "%s%c%c%c", "pre", 'f', 'l', 'x'); - sprintf(newcolors, "%s%c%c%c%c%c%c", "new", 'c', 'o', 'l', 'o', 'r', 's'); -#endif -} - -void GetOperator(short encoding, char *operator) { - indx ix; - - for (ix = 0; ix < KNOWNOPSIZE; ix++) - if (encoding == op_table[ix].encoding) { - strcpy(operator, op_table[ix].operator); - return; - } - sprintf(globmsg, "The opcode: %d is invalid.\n", (int)encoding); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); -} - -/* Checks if the operator passed in is a recognized PS operator. - If it is the associated opcode is returned. */ -extern short op_known(operator) char *operator; - -{ - indx ix; - - for (ix = 0; ix < KNOWNOPSIZE; ix++) - if (STREQ(op_table[ix].operator, operator)) - return op_table[ix].encoding; - return MININT; /* Unknown operator */ -} diff --git a/c/autohint/autohintlib/source/bf/optable.h b/c/autohint/autohintlib/source/bf/optable.h deleted file mode 100644 index 69436f6f2..000000000 --- a/c/autohint/autohintlib/source/bf/optable.h +++ /dev/null @@ -1,22 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ - -#define ESCVAL 100 -#define MAXOPLEN 5 - -#ifdef SUN -extern char beginsubr[10], endsubr[8], preflx[7], newcolors[10]; -#endif - -extern void GetOperator( - short, char*); - -extern short op_known( - char*); - -extern void init_ops( - void); - -extern void freeoptable( - void); diff --git a/c/autohint/autohintlib/source/bf/rawPStobez.c b/c/autohint/autohintlib/source/bf/rawPStobez.c deleted file mode 100644 index 1cc162116..000000000 --- a/c/autohint/autohintlib/source/bf/rawPStobez.c +++ /dev/null @@ -1,310 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -/* rawPStobez.c - converts character description files in raw - PostScript format to relativized bez format. The only - operators allowed are moveto, lineto, curveto and closepath. - This program assumes that the rawPS files are located in a - directory named chars and stores the converted and encrypted - files with the same name in a directory named bez. - -history: - -Judy Lee: Tue Jun 14 17:33:13 1988 -End Edit History - -*/ -#include "buildfont.h" -#include "bftoac.h" -#include "cryptdefs.h" -#include "machinedep.h" - -#define MOVETO ((!strcmp(token, "moveto"))) -#define LINETO ((!strcmp(token, "lineto"))) -#define CURVETO ((!strcmp(token, "curveto"))) -#define CLOSEPATH ((!strcmp(token, "closepath"))) -#define END ((!strcmp(token, "ed"))) -#define START ((!strcmp(token, "sc"))) - -#define SSIZE 20 /* operand stack size */ - -#if !IS_LIB -static long oprnd_stk[SSIZE]; -static short count; -static short convertedchars; -static boolean printmsg; -static long dx, dy; -static char tempname[MAXFILENAME]; -static Cd p1, p2, p3, currPt; -static float scale; /* scale factor for each character. */ -#endif -static char outstr[MAXLINE]; /* contains string to be encrypted */ - -static void errmsg( - char *, char *, FILE *, FILE *); - -static short nextline( - FILE *); - -static char *ReadrawPSFile( - FILE *, char *, char *); - -static void SetCd( - Cd, CdPtr); - -static void putonstk( - long, char *); - -static void mt( - void); - -static void dt( - void); - -static void ct( - void); - -#ifdef OLDFUNCTIONS - -static errmsg(str, name, infile, outfile) char *str, *name; -FILE *infile, *outfile; -{ - fclose(infile); - fclose(outfile); - sprintf(globmsg, "%s in %s file does not have the correct number of operands.\n This file was not converted.\n", str, name); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); -} - -static short nextline(infile) - FILE *infile; -{ - register short c; - - while (TRUE) { - c = getc(infile); - if (c == NL || c == '\r' || c == EOF) - return (c); - } -} - -static char *ReadrawPSFile(stream, tokenPtr, filename) - FILE *stream; -char *tokenPtr, *filename; -{ - register short c; - - /* Skip all white space */ - while (TRUE) { - c = getc(stream); - if (c == '%') - c = nextline(stream); - if (c == EOF) - return (NULL); - if (!isspace(c)) { - *tokenPtr = c; - tokenPtr++; - break; - } - } - while (TRUE) { - c = getc(stream); - if (c == '%') - c = nextline(stream); - if (c == EOF) { - sprintf(globmsg, "Unexpected end of file found in %s directory \n character description: %s.\n", RAWPSDIR, filename); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - if (isspace(c)) - break; - *tokenPtr = c; - tokenPtr++; - } - *tokenPtr = '\0'; - return tokenPtr; -} - -static SetCd(a, b) - Cd a; -CdPtr b; -{ - b->x = a.x; - b->y = a.y; -} - -static putonstk(number, charname) long number; -char *charname; -{ - if (count >= SSIZE) { - sprintf(globmsg, - "Maximum stack size exceeded when converting %s file %s.\n", - RAWPSDIR, charname); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - oprnd_stk[count] = number; - count = count + 1; -} - -static mt() { - count = count - 1; - p1.y = oprnd_stk[count--]; - p1.x = oprnd_stk[count]; - dx = SCALEDRTOL((p1.x - currPt.x), scale); - dy = SCALEDRTOL((p1.y - currPt.y), scale); - if (dx == 0) - sprintf(outstr, "%ld %c%c%c\n", dy, 'v', 'm', 't'); - else if (dy == 0) - sprintf(outstr, "%ld %c%c%c\n", dx, 'h', 'm', 't'); - else - sprintf(outstr, "%ld %ld %c%c%c\n", dx, dy, 'r', 'm', 't'); - SetCd(p1, &currPt); -} - -static dt() { - count = count - 1; - p1.y = oprnd_stk[count--]; - p1.x = oprnd_stk[count]; - dx = SCALEDRTOL((p1.x - currPt.x), scale); - dy = SCALEDRTOL((p1.y - currPt.y), scale); - if (dx == 0) - sprintf(outstr, "%ld %c%c%c\n", dy, 'v', 'd', 't'); - else if (dy == 0) - sprintf(outstr, "%ld %c%c%c\n", dx, 'h', 'd', 't'); - else - sprintf(outstr, "%ld %ld %c%c%c\n", dx, dy, 'r', 'd', 't'); - SetCd(p1, &currPt); -} - -static ct() { - count = count - 1; - p3.y = oprnd_stk[count--]; - p3.x = oprnd_stk[count--]; - p2.y = oprnd_stk[count--]; - p2.x = oprnd_stk[count--]; - p1.y = oprnd_stk[count--]; - p1.x = oprnd_stk[count]; - if ((currPt.x == p1.x) && (p3.y == p2.y)) /* vhct */ - sprintf(outstr, "%ld %ld %ld %ld %c%c%c%c\n", - SCALEDRTOL((p1.y - currPt.y), scale), SCALEDRTOL((p2.x - p1.x), scale), - SCALEDRTOL((p2.y - p1.y), scale), SCALEDRTOL((p3.x - p2.x), scale), - 'v', 'h', 'c', 't'); - else if ((currPt.y == p1.y) && (p3.x == p2.x)) /* hvct */ - sprintf(outstr, "%ld %ld %ld %ld %c%c%c%c\n", - SCALEDRTOL((p1.x - currPt.x), scale), SCALEDRTOL((p2.x - p1.x), scale), - SCALEDRTOL((p2.y - p1.y), scale), SCALEDRTOL((p3.y - p2.y), scale), - 'h', 'v', 'c', 't'); - else /* rct */ - sprintf(outstr, "%ld %ld %ld %ld %ld %ld %c%c%c\n", - SCALEDRTOL((p1.x - currPt.x), scale), SCALEDRTOL((p1.y - currPt.y), scale), - SCALEDRTOL((p2.x - p1.x), scale), SCALEDRTOL((p2.y - p1.y), scale), - SCALEDRTOL((p3.x - p2.x), scale), SCALEDRTOL((p3.y - p2.y), scale), - 'r', 'c', 't'); - SetCd(p3, &currPt); -} - -extern void convert_PScharfile(const char *charname, const char *filename) { - FILE *infile, *outfile; - char token[50]; - long number; - char inname[MAXPATHLEN], outname[MAXPATHLEN]; - - get_filename(inname, RAWPSDIR, filename); - get_filename(outname, bezdir, filename); - infile = ACOpenFile(inname, "r", OPENWARN); - if (infile == NULL) - return; - outfile = ACOpenFile(tempname, "w", OPENERROR); - DoInitEncrypt(outfile, OTHER, HEX, MAXINT32, FALSE); - WriteStart(outfile, charname); - count = 0; - currPt.x = 0; - currPt.y = 0; - while (ReadrawPSFile(infile, token, inname) != NULL) { - if (sscanf(token, " %ld", &number) == 1) { - putonstk(number, charname); - continue; - } else /* must be a string */ - { - if (START) - continue; - if (END) - break; - if (CLOSEPATH) { - (void)DoContEncrypt("cp\n", outfile, FALSE, INLEN); - continue; - } else if (MOVETO) - if (count != 2) - errmsg("moveto", inname, infile, outfile); - else - mt(); - else if (LINETO) - if (count != 2) - errmsg("lineto", inname, infile, outfile); - else - dt(); - else if (CURVETO) - if (count != 6) - errmsg("curveto", inname, infile, outfile); - else - ct(); - else /* Unrecognized operator */ - { - fclose(infile); - fclose(outfile); - unlink(tempname); - sprintf(globmsg, "Unknown operator: %s in character description: %s.\n", token, inname); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - count = 0; - (void)DoContEncrypt(outstr, outfile, FALSE, INLEN); - } - } - (void)DoContEncrypt("ed\n", outfile, FALSE, INLEN); - fclose(infile); - fclose(outfile); - RenameFile(tempname, outname); - if (printmsg) { - LogMsg("Converting PostScript(R) language files ...", - INFO, OK, FALSE); - printmsg = FALSE; - } - convertedchars++; -} - -extern convert_rawPSfiles(release) - boolean release; -{ - boolean result = TRUE; - - /* initialize globals in this source file */ - count = convertedchars = 0; - printmsg = TRUE; - set_scale(&scale); - - get_filename(tempname, bezdir, TEMPFILE); -#if SUN - result = ConvertCharFiles( - RAWPSDIR, release, scale, convert_PScharfile); -#elif WIN32 - result = ConvertCharFiles( - RAWPSDIR, release, scale, convert_PScharfile); -#else - ConvertInputDirFiles(RAWPSDIR, convert_PScharfile); -#endif - if (convertedchars > 0) { - sprintf(globmsg, " %d files converted.\n", (int)convertedchars); - LogMsg(globmsg, INFO, OK, FALSE); - if (scale != 1.0) { - sprintf(globmsg, "Widths in the original %s file were not scaled.\n", WIDTHSFILENAME); - LogMsg(globmsg, WARNING, OK, TRUE); - } - } - if (!result) cleanup(NONFATALERROR); -} - -#endif - -int WriteStart(FILE *outfile, const char *name) { - sprintf(outstr, "%%%s\nsc\n", name); - (void)DoContEncrypt(outstr, outfile, FALSE, INLEN); - return 0; -} diff --git a/c/autohint/autohintlib/source/bf/transitionalchars.h b/c/autohint/autohintlib/source/bf/transitionalchars.h deleted file mode 100644 index 4fa94dffd..000000000 --- a/c/autohint/autohintlib/source/bf/transitionalchars.h +++ /dev/null @@ -1,63 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/***********************************************************************/ -#ifndef TRANSITIONALCHARS_H -#define TRANSITIONALCHARS_H - -#include "masterfontpriv.h" - -#define TRANSITIONALCHARFILENAME "transitionalchars" - -typedef float Ary4[4]; - -typedef struct _Transitions { - char *charname; - short numtransitiongroups; - struct _TransitGroup *transitgrouparray; /* ARRAY */ -} Transitions; - -typedef struct _TransitGroup { - char **assembledfilename; /* ARRAY : one filename for each "corner" */ - int *assembled_width; /* array */ - int *assembled_sb; /* array */ - Bbox bbx; /* not of the assembled file, but the super-bbox of all elts */ - int subrindex; /* subroutine-index the _Merged_ assembledfilename's charpaths */ - short numentries; - short hintindex; /* which elt entry is -the- source for hints for this group */ - struct _TransitElt *transiteltarray; /* ARRAY */ - Ary4 minval, maxval; /* sorted min/max of group's fromval/toval entries */ -} TransitionGroup; - -typedef struct _tt_pathlist *PTPathList; - -typedef struct _TransitElt { - char *from_filename, *to_filename; - short from_width, to_width; - short from_sb, to_sb; - Bbox from_bbx, to_bbx; - PTPathList from_pathlist, to_pathlist; /* opaque */ - unsigned from_ishintdir : 1, /* else "to" is hintdir for this pair */ - defaultbehavior : 1, /* else, range is in fromval/toval */ - from_isanchored : 1, /* if "from" is at a corner */ - to_isanchored : 1; /* if "to" is at a corner */ - Ary4 fromposit, toposit; /* position of the masters in cartesian space */ - Ary4 fromval, toval; /* cartesian coords where the masters should be utilized */ -} TransitElt; - -extern void ReadTransitional( - boolean); - -extern void PreReadTransitional(); - -extern void CopyTransitionalToTable(); - -extern void AssembleTransitionals(); - -extern char **TransitionalCharsHintList( - boolean, short *, indx); - -extern void Free_TransitionalList(); - -extern void GetMastDesPosInfo(MasterDesignPosit **MDPptr, int *NumMast, int *NumAxes); - -#endif /* TRANSITIONALCHARS_H */ diff --git a/c/autohint/autohintlib/source/public/ac/ac_C_lib.h b/c/autohint/autohintlib/source/public/ac/ac_C_lib.h deleted file mode 100644 index 65846be6b..000000000 --- a/c/autohint/autohintlib/source/public/ac/ac_C_lib.h +++ /dev/null @@ -1,127 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ - -/* The following ifdef block is the standard way of creating macros which make exporting -// from a DLL simpler. All files within this DLL are compiled with the ACLIB_API -// symbol defined on the command line. this symbol should not be defined on any project -// that uses this DLL. This way any other project whose source files include this file see -// ACLIB_API functions as being imported from a DLL, wheras this DLL sees symbols -// defined with this macro as being exported. -*/ -#ifndef AC_C_LIB_H_ -#define AC_C_LIB_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifdef AC_C_LIB_EXPORTS - -#if WIN32 -#define ACLIB_API __declspec(dllexport) -#else - -#if __MWERKS__ -#define ACLIB_API __declspec(export) -#elif __GNUC__ && __MACH__ -#define ACLIB_API __attribute__((visibility("default"))) -#endif - -#endif - -#else -#define ACLIB_API -#endif - -enum { - AC_Success, - AC_FontinfoParseFail, - AC_FatalError, - AC_MemoryError, - AC_UnknownError, - AC_DestBuffOfloError, - AC_InvalidParameterError -}; - -ACLIB_API const char *AC_getVersion(void); - -typedef void *(*AC_MEMMANAGEFUNCPTR)(void *ctxptr, void *old, unsigned long size); - -/* - * Function: AC_SetMemManager - **************************** -If this is supplied, then the AC lib will call this function foor all memory allocations. -Else is it will use the std C lib alloc/malloc/free. -*/ -ACLIB_API void AC_SetMemManager(void *ctxptr, AC_MEMMANAGEFUNCPTR func); - -/* - * Function: AC_SetReportCB - **************************** -If this is supplied and verbose is set to true, then the AC lib will write (many!) text status messages to this file. -If verbose is set false, then only error messages are written. -*/ -typedef void (*AC_REPORTFUNCPTR)(char *msg); -extern AC_REPORTFUNCPTR libReportCB; /* global log function which is supplied by the following */ -extern AC_REPORTFUNCPTR libErrorReportCB; /* global error log function which is supplied by the following */ - -ACLIB_API void AC_SetReportCB(AC_REPORTFUNCPTR reportCB, int verbose); - -/* Global for reporting log messages. */ - -/* - * Function: AC_SetReportStemsCB - **************************** -If this is called , then the AC lib will write all the stem widths it encounters. -Note that the callabcks should not dispose of the glyphName memory; that belongs to the AC lib. -It should be copied immediately - it may may last past the return of the calback. -*/ - -extern unsigned int allstems; /* if false, then stems defined by curves are xcluded from the reporting */ -typedef void (*AC_REPORTSTEMPTR)(long int top, long int bottom, char *glyphName); - -extern AC_REPORTSTEMPTR addHStemCB; -extern AC_REPORTSTEMPTR addVStemCB; -ACLIB_API void AC_SetReportStemsCB(AC_REPORTSTEMPTR hstemCB, AC_REPORTSTEMPTR vstemCB, unsigned int allStems); - -/* - * Function: AC_SetReportZonesCB - **************************** -If this is called , then the AC lib will write all the aligment zones it encounters. -Note that the callabcks should not dispose of the glyphName memory; that belongs to the AC lib. -It should be copied immediately - it may may last past the return of the calback. -*/ -typedef void (*AC_REPORTZONEPTR)(long int top, long int bottom, char *glyphName); -extern AC_REPORTZONEPTR addCharExtremesCB; -extern AC_REPORTZONEPTR addStemExtremesCB; -ACLIB_API void AC_SetReportZonesCB(AC_REPORTZONEPTR charCB, AC_REPORTZONEPTR stemCB); - -typedef void (*AC_RETRYPTR)(void); -extern AC_RETRYPTR reportRetryCB; - -/* - * Function: AutoColorString - **************************** - * This function takes srcbezdata, a pointer to null terminated C-string containing data in the bez - * format (see bez spec) and fontinfo, a pointer to null terminated C-string containing fontinfo - * for the bez glyph. Hint information is added to the bez data and returned to the caller through the - * buffer dstbezdata. dstbezdata must be allocated before the call and a pointer to its length passed - * as *length. If the space allocated is insufficient for the target bezdata, an error will be returned - * and *length will be set to the desired size. - */ -ACLIB_API int AutoColorString(const char *srcbezdata, const char *fontinfo, char *dstbezdata, int *length, int allowEdit, int allowHintSub, int roundCoords, int debug); - -/* - * Function: AC_initCallGlobals - **************************** - * This function must be called before calling AC_initCallGlobals in the case where - * the program is switching between any of the auto-hinting and stem reportign modes - * while running. - */ - -ACLIB_API void AC_initCallGlobals(void); - -#ifdef __cplusplus -} -#endif -#endif /* AC_C_LIB_H_ */ diff --git a/c/autohint/autohintlib/source/public/ac/memcheck.h b/c/autohint/autohintlib/source/public/ac/memcheck.h deleted file mode 100644 index 2952dbae3..000000000 --- a/c/autohint/autohintlib/source/public/ac/memcheck.h +++ /dev/null @@ -1,88 +0,0 @@ -#ifndef MEMCHECK_H -#define MEMCHECK_H - -#if DOMEMCHECK - -#if defined(MACINTOSH) || defined(macintosh) || defined(OSX) || defined(__MWERKS__) -#define SINGEXPORT __declspec(export) -#define SINGSTDCALL -#define SINGCALLBACK -#endif - -#if WIN32 -#define SINGEXPORT __declspec(dllexport) -#define SINGSTDCALL __stdcall -#define SINGCALLBACK __cdecl -#endif - -#ifndef SINGLIB_CDECL -#define SINGLIB_CDECL SINGCALLBACK -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -typedef enum e_MemCheck_MemStore { - memck_store_default = 0, /* default - calls OS-provided malloc() directly */ - memck_store_app, /* for mem want to keep for the app's life */ - memck_store_maxMemStore /* must be the last */ -} MemCheck_MemStore; - -SINGEXPORT void *memck_mallocinternal( - int size, - MemCheck_MemStore index, - char *filename, - int lineno); - -SINGEXPORT void *memck_callocinternal( - int count, - int size, - MemCheck_MemStore index, - char *filename, - int lineno); - -SINGEXPORT void memck_freeinternal( - void *ptr, - char *filename, - int lineno); - -SINGEXPORT void *memck_reallocinternal( - void *ptr, - int size, - char *filename, - int lineno); - -/* PUBLIC */ -SINGEXPORT int memck_PrintAllAllocFreeCalls; - -SINGEXPORT int memck_Startup(char *logfilePathname); /* returns non-0 if failure */ - -/* PUBLIC - Use these macros instead of calling the *alloc/free functions above */ - -#define memck_malloc(x) memck_mallocinternal((x), memck_store_app, __FILE__, __LINE__) -#define memck_calloc(count, size) memck_callocinternal((count), (size), memck_store_app, __FILE__, __LINE__) - -#define memck_free(x) memck_freeinternal((x), __FILE__, __LINE__) -#define memck_realloc(ptr, size) memck_reallocinternal((ptr), (size), __FILE__, __LINE__) - -#define memck_os_malloc(x) memck_mallocinternal((x), memck_store_default, __FILE__, __LINE__) -#define memck_os_calloc(count, size) memck_callocinternal((count), (size), memck_store_default, __FILE__, __LINE__) - -/* PUBLIC */ -SINGEXPORT void memck_ResetMemLeakDetection(void); - -/* PUBLIC */ -SINGEXPORT void memck_CheckMemLeaks(void); /* print allocations, and call memck_ResetMemLeakDetection */ - -/* PUBLIC */ -SINGEXPORT void memck_Shutdown(void); - -#ifdef __cplusplus -} -#endif - -#endif /* DOMEMCHECK */ - -#endif /* MEMCHECK_H */ diff --git a/c/autohint/autohintlib/source/public/extras/numtypes.h b/c/autohint/autohintlib/source/public/extras/numtypes.h deleted file mode 100644 index 078321ac3..000000000 --- a/c/autohint/autohintlib/source/public/extras/numtypes.h +++ /dev/null @@ -1,169 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ - -#ifndef _NUMTYPES_H -#define _NUMTYPES_H - -#include - -/***********************************************************************/ -/* GUIDELINES FOR SELECTION OF TYPE */ -/* */ -/* The following types give best performance because implicit */ -/* conversion does not take place. So, use them if at all possible. */ -/* Types are show in order of decreasing preference. The dependable */ -/* domain for each type is show enclosed in []. */ -/* */ -/* IntX */ -/* CardX */ -/* ByteX8 whenever there is NO mandated requirement for signed */ -/* or unsigned values [0, 127]. */ -/***********************************************************************/ - -/***********************************************************************/ -/* The present file assumes: */ -/* */ -/* char: 8 bits */ -/* short: 16 bits */ -/* long: 32 bits */ -/* */ -/* This assumption is currently true for Sun, PC, and Mac environments.*/ -/* When this assumption is no longer true, #ifdef the code accordingly */ -/* and change this comment. */ -/***********************************************************************/ - -/***********************************************************************/ -/* The following numeric types guarantee the number of bits: neither */ -/* more or less than specified. Use these ONLY when you actually must */ -/* have the number of bits specified. If you need a minimum of a */ -/* certain number of bits, use types from the IntX.../CardX... group. */ -/***********************************************************************/ - -typedef int32_t Fixed; - -typedef int32_t Int32; -#define MAX_INT32 ((Int32)0x7FFFFFFF) -#define MIN_INT32 ((Int32)0x80000000) - -typedef uint32_t Card32; -#define MAX_CARD32 ((Card32)0xFFFFFFFF) - -typedef int16_t Int16; -#define MAX_INT16 ((Int16)0x7FFF) -#define MIN_INT16 ((Int16)0x8000) - -typedef uint16_t Card16; -#define MAX_CARD16 ((Card16)0xFFFF) - -typedef int8_t Int8; -#define MAX_INT8 ((Int8)0x7F) -#define MIN_INT8 ((Int8)0x80) - -typedef uint8_t Card8; -#define MAX_CARD8 ((Card8)0xFF) - -typedef uint8_t Byte8; - -/***********************************************************************/ -/* The following numeric types guarantee at least the number of bits */ -/* indicated. Use these when a specific size is not required, but */ -/* a minimum size is. Note that IntX/CardX are guaranteed to be at */ -/* least 16 bits, but can be set (for testing purposes) to either */ -/* 16 or 32 bit sizes by defining FORCE_INT_BITS to the compiler. */ -/***********************************************************************/ - -#if defined(FORCE16BITS) -#define FORCE_INT_BITS 16 -#elif defined(FORCE32BITS) -#define FORCE_INT_BITS 32 -#endif - -/***********************************/ -/* Optimize for performance... */ -/***********************************/ -#if FORCE_INT_BITS == 32 - -typedef Int32 IntX; -#define MAX_INTX MAX_INT32 -#define MIN_INTX MIN_INT32 -typedef Card32 CardX; -#define MAX_CARDX MAX_CARD32 - -#elif FORCE_INT_BITS == 16 - -typedef Int16 IntX; -#define MAX_INTX MAX_INT16 -#define MIN_INTX MIN_INT16 -typedef Card16 CardX; -#define MAX_CARDX MAX_CARD16 -#define MAX_CARDX MAX_CARD16 - -#else - -typedef int IntX; -#define MAX_INTX ((IntX)((1 << (sizeof(IntX) * 8 - 1)) - 1)) -#define MIN_INTX ((IntX)(1 << (sizeof(IntX) * 8 - 1))) -typedef unsigned CardX; -#define MAX_CARDX ((CardX)(MAX_INTX | MIN_INTX)) -#endif - -/***********************************/ -/* Optimize for space... */ -/***********************************/ -typedef long IntX32; -#define MAX_INTX32 MAX_INT32 -#define MIN_INTX32 MIN_INT32 - -typedef unsigned long CardX32; -#define MAX_CARDX32 MAX_CARD32 - -typedef short IntX16; -#define MAX_INTX16 MAX_INT16 -#define MIN_INTX16 MIN_INT16 - -typedef unsigned short CardX16; -#define MAX_CARDX16 MAX_CARD16 - -typedef signed char IntX8; -#define MAX_INTX8 MAX_INT8 -#define MIN_INTX8 MIN_INT8 - -typedef unsigned char CardX8; -#define MAX_CARDX8 MAX_CARD8 - -typedef char ByteX8; -/* MAX_BYTEX8 and MIN_BYTEX8 are omitted because it is not known */ -/* whether if a ByteX8 (char) is signed or unsigned. */ - -/***********************************************************************/ -/* Use this type for use with variables connected with system calls. */ -/***********************************************************************/ -typedef int IntN; -#define MAX_INTN ((IntN)((1 << (sizeof(IntN) * 8 - 1)) - 1)) -#define MIN_INTN ((IntN)(1 << (sizeof(IntN) * 8 - 1))) - -typedef unsigned CardN; -#define MAX_CARDN ((CardN)(MAX_INTN | MIN_INTN)) - -typedef short ShortN; -typedef unsigned short ShortCardN; -typedef long LongN; -typedef unsigned long LongCardN; -typedef float FloatN; -typedef double DoubleN; - -/***********************************************************************/ -/* Use these macros with scanf and printf. */ -/***********************************************************************/ -#define FMT_32 "l" -#define FMT_16 "h" - -#if FORCE_INT_BITS == 32 -#define FMT_X FMT_32 -#elif FORCE_INT_BITS == 16 -#define FMT_X FMT_16 -#endif - -#define FMT_N "" - -#endif /*_NUMTYPES_H*/ diff --git a/c/autohint/autohintlib/source/public/extras/pubtypes.h b/c/autohint/autohintlib/source/public/extras/pubtypes.h deleted file mode 100644 index 4bc3b8172..000000000 --- a/c/autohint/autohintlib/source/public/extras/pubtypes.h +++ /dev/null @@ -1,203 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ - -#ifndef _PUBTYPES_H -#define _PUBTYPES_H - -/***********************************************************************/ -/* THIS FILE IS PROVIDED FOR BACKWARD COMPATIBILITY ONLY!!! */ -/* Its use for new programs is not recommended because it contains */ -/* constructs that have been demonstrated to cause integration */ -/* problems. */ -/***********************************************************************/ - -/***********************************************************************/ -/* Numeric definitions */ -/***********************************************************************/ -#include "numtypes.h" - -typedef Int16 *PInt16; -typedef Int32 *PInt32; -typedef Card8 *PCard8; -typedef Card16 *PCard16; -typedef Card32 *PCard32; - -#define MAXInt32 MAX_INT32 -#define MINInt32 MIN_INT32 - -typedef Int32 integer; -#define MAXinteger MAX_INT32 -#define MINinteger MIN_INT32 -#ifdef __MWERKS__ -typedef CardX boolean; -#endif -typedef Card16 cardinal; -typedef Card32 longcardinal; - -#define MAXCard32 MAX_CARD32 -#define MAXlongcardinal MAX_CARD32 -#define MAXunsignedinteger MAX_CARD32 -#define MAXCard16 MAX_CARD16 -#define MAXcardinal MAX_CARD16 -#define MAXCard8 MAX_CARD8 - -/***********************************************************************/ -/* Other definitions */ -/***********************************************************************/ -#ifndef VAXC -#define readonly -#define exitNormal 1 -#define exitError 2 -#else -#define exitNormal 0 -#define exitError 1 -#endif - -#define _inline -#define _priv extern - -/***********************************/ -/* Control Constructs */ -/***********************************/ -#define until(x) while (!(x)) -#define endswitch default:; - -/***********************************/ -/* Inline Functions */ -/***********************************/ -#ifndef ABS -#define ABS(x) ((x) < 0 ? -(x) : (x)) -#endif -#ifndef MIN -#define MIN(a, b) ((a) < (b) ? (a) : (b)) -#endif -#ifndef MAX -#define MAX(a, b) ((a) > (b) ? (a) : (b)) -#endif - -/***********************************/ -/* Declarative Sugar */ -/***********************************/ -#define forward extern - -#if WINATM && !defined(MAKEPUB) -#define private -#else -#define private static -#endif - -#define public -/*#define global extern*/ - -#define procedure void - -#ifndef true -#define true 1 -#define false 0 -#endif - -typedef integer (*PIntProc)(); - -/***********************************/ -/* Canonical type for sizes of */ -/* things -- will change to size_t */ -/* when we are completely */ -/* converted to ANSI conventions. */ -/***********************************/ -typedef long int ps_size_t; - -/***********************************/ -/* Bit fields */ -/***********************************/ -#ifndef BitField -#define BitField unsigned -#endif - -/***********************************/ -/* Reals and Fixed point */ -/***********************************/ -typedef float real; -typedef real *Preal; -typedef double longreal; -typedef Fixed *PFixed; - -/***********************************/ -/* Coordinates */ -/***********************************/ -typedef real ACComponent; - -typedef struct _t_RCd { - ACComponent x, y; -} RCd, *PRCd; - -typedef struct _t_FCd { - Fixed x, y; -} FCd, *PFCd; - -/***********************************/ -/* Characters and strings */ -/***********************************/ -typedef unsigned char character; -typedef character *string; -typedef character *charptr; - -#ifdef NUL -#undef NUL -#endif -#define NUL '\0' - -/***********************************/ -/* Generic Pointers */ -/***********************************/ -#ifndef NULL -#define NULL 0 -#endif - -#ifdef NIL -#undef NIL -#endif -#define NIL NULL - -#ifndef __MWERKS__ -typedef Card32 GenericID; /* Generic ID for contexts, */ - /* spaces, name cache, etc. */ - /* Opaque type used in public */ - /* interfaces */ - -#endif - -#if 0 -#define BitsInGenericIndex 10 -#define BitsInGenericGeneration (32 - BitsInGenericIndex) - -#define MAXGenericIDIndex ((Card32)((1 << BitsInGenericIndex) - 1)) -#define MAXGenericIDGeneration ((Card32)((1 << BitsInGenericGeneration) - 1)) - -typedef union { /* Representation of GenericID */ - struct { - BitField index:BitsInGenericIndex; - /* Reusable component */ - BitField generation:BitsInGenericGeneration; - /* Non-reusable component */ - } id; - GenericID stamp; /* Unique combined id (index, */ - /* generation) */ -} GenericIDRec; -#endif - -/***********************************************************************/ -/* Following is the standard opaque handle for a stream. This is all */ -/* that most clients should need. The concrete data structure is */ -/* defined in stream.h. */ -/***********************************************************************/ -typedef struct _t_StmRec *Stm; - -typedef struct _t_StringList { - integer numStrings; - integer refCnt; - string str[1]; - /* Space for additional strings */ - /* is malloc'ed starting here */ -} StringList, *PStringList; - -#endif /*_PUBTYPES_H*/ diff --git a/c/autohint/autohintlib/source/public/mac/types.h b/c/autohint/autohintlib/source/public/mac/types.h deleted file mode 100644 index ec1ddc78f..000000000 --- a/c/autohint/autohintlib/source/public/mac/types.h +++ /dev/null @@ -1,99 +0,0 @@ -/* @(#)types.h 2.32 94/08/18 SMI; from UCB 7.1 6/4/86 */ - -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ - -#ifndef __sys_types_h -#define __sys_types_h - -/* - * Basic system types. - */ - -#include "stdtypes.h" /* ANSI & POSIX types */ - -#ifndef _POSIX_SOURCE -#include "sysmacros.h" - -#define physadr physadr_t -#define quad quad_t - -typedef unsigned char u_char; -typedef unsigned short u_short; -typedef unsigned int u_int; -typedef unsigned long u_long; -typedef unsigned short ushort; /* System V compatibility */ -typedef unsigned int uint; /* System V compatibility */ -#endif /*!_POSIX_SOURCE*/ - -#ifdef vax -typedef struct _physadr_t { - int r[1]; -} * physadr_t; -typedef struct label_t { - int val[14]; -} label_t; -#endif -#ifdef mc68000 -typedef struct _physadr_t { - short r[1]; -} * physadr_t; -typedef struct label_t { - int val[13]; -} label_t; -#endif -#ifdef i386 -typedef struct _physadr_t { - short r[1]; -} * physadr_t; -typedef struct label_t { - int val[8]; -} label_t; -#endif -typedef struct _quad_t { - long val[2]; -} quad_t; -typedef long daddr_t; -typedef char* caddr_t; -/*typedef unsigned long ino_t; -typedef short dev_t; -typedef long off_t; -typedef unsigned short uid_t; -typedef unsigned short gid_t;*/ -typedef long key_t; -typedef char* addr_t; - -#ifndef _POSIX_SOURCE - -#define NBBY 8 /* number of bits in a byte */ -/* - * Select uses bit masks of file descriptors in longs. - * These macros manipulate such bit fields (the filesystem macros use chars). - * FD_SETSIZE may be defined by the user, but the default here - * should be >= NOFILE (param.h). - */ -#ifndef FD_SETSIZE -#ifdef SUNDBE -#define FD_SETSIZE 2048 -#else -#define FD_SETSIZE 256 -#endif /* SUNDBE */ -#endif - -typedef long fd_mask; -#define NFDBITS (sizeof(fd_mask) * NBBY) /* bits per mask */ -#ifndef howmany -#define howmany(x, y) (((x) + ((y)-1)) / (y)) -#endif - -typedef struct fd_set { - fd_mask fds_bits[howmany(FD_SETSIZE, NFDBITS)]; -} fd_set; - -#define FD_SET(n, p) ((p)->fds_bits[(n) / NFDBITS] |= (1 << ((n) % NFDBITS))) -#define FD_CLR(n, p) ((p)->fds_bits[(n) / NFDBITS] &= ~(1 << ((n) % NFDBITS))) -#define FD_ISSET(n, p) ((p)->fds_bits[(n) / NFDBITS] & (1 << ((n) % NFDBITS))) -#define FD_ZERO(p) memset((p), 0, sizeof(*(p))) - -#endif /* !_POSIX_SOURCE */ -#endif /* !__sys_types_h */ diff --git a/c/autohint/autohintlib/source/public/winextras/dir.h b/c/autohint/autohintlib/source/public/winextras/dir.h deleted file mode 100644 index 018b9914e..000000000 --- a/c/autohint/autohintlib/source/public/winextras/dir.h +++ /dev/null @@ -1,69 +0,0 @@ -/* @(#)dir.h 2.11 88/08/19 SMI */ - -/* - * Filesystem-independent directory information. - * Directory entry structures are of variable length. - * Each directory entry is a struct direct containing its file number, the - * offset of the next entry (a cookie interpretable only the filesystem - * type that generated it), the length of the entry, and the length of the - * name contained in the entry. These are followed by the name. The - * entire entry is padded with null bytes to a 4 byte boundary. All names - * are guaranteed null terminated. The maximum length of a name in a - * directory is MAXNAMLEN, plus a null byte. - * Note: this file is present only for backwards compatibility. It is superseded - * by the files /usr/include/dirent.h and /usr/include/sys/dirent.h. It will - * disappear in a future major release. - */ - -#ifndef _sys_dir_h -#define _sys_dir_h - -#define MAXNAMLEN 255 - -struct direct { - off_t d_off; /* offset of next disk directory entry */ - unsigned long d_fileno; /* file number of entry */ - unsigned short d_reclen; /* length of this record */ - unsigned short d_namlen; /* length of string in d_name */ - char d_name[MAXNAMLEN + 1]; /* name (up to MAXNAMLEN + 1) */ -}; - -/* - * The macro DIRSIZ(dp) gives the minimum amount of space required to represent - * a directory entry. For any directory entry dp->d_reclen >= DIRSIZ(dp). - * Specific filesystem typesm may use this macro to construct the value - * for d_reclen. - */ -#undef DIRSIZ -#define DIRSIZ(dp) \ - (((sizeof(struct direct) - (MAXNAMLEN + 1) + ((dp)->d_namlen + 1)) + 3) & ~3) - -#ifndef KERNEL -#define d_ino d_fileno /* compatability */ - -/* - * Definitions for library routines operating on directories. - */ -#ifdef WIN32 -typedef struct _dirdesc { - int dd_fd; /* file descriptor */ - long dd_loc; /* buf offset of entry from last readddir() */ - long dd_size; /* amount of valid data in buffer */ - long dd_bsize; /* amount of entries read at a time */ - long dd_off; /* Current offset in dir (for telldir) */ - char *dd_buf; /* directory data buffer */ -} DIR; - -#ifndef NULL -#define NULL 0 -#endif -extern DIR *opendir(); -extern struct direct *readdir(); -extern long telldir(); -extern void seekdir(); -#define rewinddir(dirp) seekdir((dirp), (long)0) -extern int closedir(); -#endif /*WIN32*/ -#endif - -#endif /*!_sys_dir_h*/ diff --git a/c/autohint/autohintlib/source/public/winextras/file.h b/c/autohint/autohintlib/source/public/winextras/file.h deleted file mode 100644 index 475f18e5e..000000000 --- a/c/autohint/autohintlib/source/public/winextras/file.h +++ /dev/null @@ -1,97 +0,0 @@ -/* @(#)file.h 2.20 91/06/18 SMI; from UCB 7.1 6/4/86 */ - -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ - -#ifndef __sys_file_h -#define __sys_file_h - -#ifdef __MWERKS__ -#include "types.h" -#else -#include -#endif - -#ifdef KERNEL -/* - * Descriptor table entry. - * One for each kernel object. - */ -struct file { - int f_flag; /* see below */ - short f_type; /* descriptor type */ - short f_count; /* reference count */ - short f_msgcount; /* references from message queue */ - struct fileops { - int (*fo_rw)(); - int (*fo_ioctl)(); - int (*fo_select)(); - int (*fo_close)(); - } * f_ops; - caddr_t f_data; /* ptr to file specific struct (vnode/socket) */ - off_t f_offset; - struct ucred *f_cred; /* credentials of user who opened file */ -}; - -struct file *file, *fileNFILE; -int nfile; -struct file *getf(); -struct file *falloc(); -#endif /*KERNEL*/ - -#include "fcntl.h" - -/* - * bits to save after an open. The no delay bits mean "don't wait for - * carrier at open" in all cases. Sys5 & POSIX save the no delay bits, - * using them to also mean "don't block on reads"; BSD has you reset it - * with an fcntl() if you want the "don't block on reads" behavior. - */ -#define FMASK (FREAD | FWRITE | FAPPEND | FSYNC | FNBIO | FNONBIO) -#define FCNTLCANT (FREAD | FWRITE | FMARK | FDEFER | FSHLOCK | FEXLOCK | FSETBLK) - -/* - * User definitions. - */ - -/* - * Flock call. - */ -#define LOCK_SH 1 /* shared lock */ -#define LOCK_EX 2 /* exclusive lock */ -#define LOCK_NB 4 /* don't block when locking */ -#define LOCK_UN 8 /* unlock */ - -/* - * Access call. Also maintained in unistd.h - */ -#define F_OK 0 /* does file exist */ -#define X_OK 1 /* is it executable by caller */ -#define W_OK 2 /* writable by caller */ -#define R_OK 4 /* readable by caller */ - -/* - * Lseek call. Also maintained in 5include/stdio.h and sys/unistd.h as SEEK_* - */ -#define L_SET 0 /* absolute offset */ -#define L_INCR 1 /* relative to current offset */ -#define L_XTND 2 /* relative to end of file */ -#define LB_SET 3 /* abs. block offset */ -#define LB_INCR 4 /* rel. block offset */ -#define LB_XTND 5 /* block offset rel. to end */ - -#ifdef KERNEL -#define GETF(fp, fd) \ - { \ - if ((fd) < 0 || (fd) > u.u_lastfile || \ - ((fp) = u.u_ofile[fd]) == NULL) { \ - u.u_error = EBADF; \ - return; \ - } \ - } - -#define DTYPE_VNODE 1 /* file */ -#define DTYPE_SOCKET 2 /* communications endpoint */ -#endif /*KERNEL*/ - -#endif /* !__sys_file_h */ diff --git a/c/autohint/autohintlib/source/public/winextras/stdtypes.h b/c/autohint/autohintlib/source/public/winextras/stdtypes.h deleted file mode 100644 index b72ba1e79..000000000 --- a/c/autohint/autohintlib/source/public/winextras/stdtypes.h +++ /dev/null @@ -1,36 +0,0 @@ -/* @(#)stdtypes.h 1.6 90/01/04 SMI */ - -/* - * Suppose you have an ANSI C or POSIX thingy that needs a typedef - * for thingy_t. Put it here and include this file wherever you - * define the thingy. This is used so that we don't have size_t in - * N (N > 1) different places and so that we don't have to have - * types.h included all the time and so that we can include this in - * the lint libs instead of termios.h which conflicts with ioctl.h. - */ -#ifndef __sys_stdtypes_h -#define __sys_stdtypes_h - -#ifndef __MWERKS__ - -typedef int sigset_t; /* signal mask - may change */ - -typedef unsigned int speed_t; /* tty speeds */ -typedef unsigned long tcflag_t; /* tty line disc modes */ -typedef unsigned char cc_t; /* tty control char */ -typedef int pid_t; /* process id */ - -typedef unsigned short mode_t; /* file mode bits */ -typedef short nlink_t; /* links to a file */ - -typedef long clock_t; /* units=ticks (typically 60/sec) */ -typedef long time_t; /* value = secs since epoch */ - -typedef int size_t; /* ??? */ -typedef int ptrdiff_t; /* result of subtracting two pointers */ - -typedef unsigned short wchar_t; /* big enough for biggest char set */ - -#endif - -#endif /* !__sys_stdtypes_h */ diff --git a/c/autohint/autohintlib/source/public/winextras/sysmacros.h b/c/autohint/autohintlib/source/public/winextras/sysmacros.h deleted file mode 100644 index 30c6cb8b4..000000000 --- a/c/autohint/autohintlib/source/public/winextras/sysmacros.h +++ /dev/null @@ -1,19 +0,0 @@ -/* @(#)sysmacros.h 1.4 88/08/19 SMI */ - -/* - * Major/minor device constructing/busting macros. - */ - -#ifndef _sys_sysmacros_h -#define _sys_sysmacros_h - -/* major part of a device */ -#define major(x) ((int)(((unsigned)(x) >> 8) & 0377)) - -/* minor part of a device */ -#define minor(x) ((int)((x)&0377)) - -/* make a device number */ -#define makedev(x, y) ((dev_t)(((x) << 8) | (y))) - -#endif /*!_sys_sysmacros_h*/ diff --git a/c/autohint/autohintlib/source/public/winextras/unistd.h b/c/autohint/autohintlib/source/public/winextras/unistd.h deleted file mode 100644 index 3a9ca18b1..000000000 --- a/c/autohint/autohintlib/source/public/winextras/unistd.h +++ /dev/null @@ -1,121 +0,0 @@ -/* @(#)unistd.h 1.12 89/10/04 SMI; from S5R3 1.5 */ - -#ifndef __sys_unistd_h -#define __sys_unistd_h - -/* WARNING: _SC_CLK_TCK and sysconf() are also defined/declared in . */ -#define _SC_ARG_MAX 1 /* space for argv & envp */ -#define _SC_CHILD_MAX 2 /* maximum children per process??? */ -#define _SC_CLK_TCK 3 /* clock ticks/sec */ -#define _SC_NGROUPS_MAX 4 /* number of groups if multple supp. */ -#define _SC_OPEN_MAX 5 /* max open files per process */ -#define _SC_JOB_CONTROL 6 /* do we have job control */ -#define _SC_SAVED_IDS 7 /* do we have saved uid/gids */ -#define _SC_VERSION 8 /* POSIX version supported */ - -#define _POSIX_JOB_CONTROL 1 -#define _POSIX_SAVED_IDS 1 -#define _POSIX_VERSION 198808 - -#define _PC_LINK_MAX 1 /* max links to file/dir */ -#define _PC_MAX_CANON 2 /* max line length */ -#define _PC_MAX_INPUT 3 /* max "packet" to a tty device */ -#define _PC_NAME_MAX 4 /* max pathname component length */ -#define _PC_PATH_MAX 5 /* max pathname length */ -#define _PC_PIPE_BUF 6 /* size of a pipe */ -#define _PC_CHOWN_RESTRICTED 7 /* can we give away files */ -#define _PC_NO_TRUNC 8 /* trunc or error on >NAME_MAX */ -#define _PC_VDISABLE 9 /* best char to shut off tty c_cc */ -#define _PC_LAST 9 /* highest value of any _PC_* */ - -#define STDIN_FILENO 0 -#define STDOUT_FILENO 1 -#define STDERR_FILENO 2 - -#ifndef NULL -#define NULL 0 -#endif - -#ifndef _POSIX_SOURCE -/* - * SVID lockf() requests - */ -#define F_ULOCK 0 /* Unlock a previously locked region */ -#define F_LOCK 1 /* Lock a region for exclusive use */ -#define F_TLOCK 2 /* Test and lock a region for exclusive use */ -#define F_TEST 3 /* Test a region for other processes locks */ - -/* Path names: */ -#define GF_PATH "/etc/group" -#define PF_PATH "/etc/passwd" - -#endif /*!_POSIX_SOURCE*/ - -/* - * lseek & access args - * - * SEEK_* have to track L_* in sys/file.h & SEEK_* in 5include/stdio.h - * ?_OK have to track ?_OK in sys/file.h - */ -#ifndef SEEK_SET -#define SEEK_SET 0 /* Set file pointer to "offset" */ -#define SEEK_CUR 1 /* Set file pointer to current plus "offset" */ -#define SEEK_END 2 /* Set file pointer to EOF plus "offset" */ -#endif - -#define F_OK 0 /* does file exist */ -#define X_OK 1 /* is it executable by caller */ -#define W_OK 2 /* is it writable by caller */ -#define R_OK 4 /* is it readable by caller */ - -#if !defined(KERNEL) - -#ifdef __MWERKS__ -#include "types.h" -#else -#include -#endif - -/* extern void _exit(int status );*/ -extern int access(/* char *path, int amode */); -extern unsigned alarm(/* unsigned secs */); -extern int chdir(/* char *path */); -extern int chmod(/* char *path, mode_t mode */); -extern int chown(/* char *path, uid_t owner, gid_t group */); -extern int close(/* int fildes */); -extern char *ctermid(/* char *s */); -extern char *cuserid(/* char *s */); -extern int dup(/* int fildes */); -extern int dup2(/* int fildes, int fildes2 */); -#ifndef CW80 -extern int execl(/* char *path, ... */); -extern int execle(/* char *path, ... */); -extern int execlp(/* char *file, ... */); -extern int execv(/* char *path, char *argv[] */); -extern int execve(/* char *path, char *argv[], char *envp[] */); -extern int execvp(/* char *file, char *argv[] */); -#endif -extern long fpathconf(/* int fd, int name */); -extern char *getcwd(/* char *buf, int size */); -extern int getgroups(/* int gidsetsize, gid_t grouplist[] */); -extern char *getlogin(/* void */); -extern int isatty(/* int fildes */); -extern int link(/* char *path1, char *path2 */); -extern off_t lseek(/* int fildes, off_t offset, int whence */); -extern long pathconf(/* char *path, int name */); -extern int pause(/* void */); -extern int pipe(/* int fildes[2] */); -extern int read(/* int fildes, char *buf, unsigned int nbyte */); -extern int rmdir(/* char *path */); -extern int setgid(/* gid_t gid */); -extern int setpgid(/* pid_t pid, pid_t pgid */); -extern int setuid(/* uid_t uid */); -extern unsigned sleep(/* unsigned int seconds */); -extern long sysconf(/* int name */); -extern int tcsetpgrp(/* int fildes, pid_t pgrp_id */); -extern char *ttyname(/* int fildes */); -/* extern int unlink(const char *path );*/ -extern int write(/* int fildes, char *buf, unsigned int nbyte */); - -#endif /* !KERNEL */ -#endif /* !__sys_unistd_h */ diff --git a/c/autohint/build/linux/gcc/BuildAll.sh b/c/autohint/build/linux/gcc/BuildAll.sh deleted file mode 100755 index b243af8f5..000000000 --- a/c/autohint/build/linux/gcc/BuildAll.sh +++ /dev/null @@ -1,30 +0,0 @@ -#! /bin/sh -set -e -set -x - -target=autohintexe -curdir=$(pwd) - -if [ -z "$1" ] || [ "$1" = "release" ] -then - cd release - make - cd "$curdir" - cp -dR ../../../exe/linux/release/$target ../../../../build_all -elif [ "$1" = "debug" ] -then - cd debug - make - cd "$curdir" - cp -dR ../../../exe/linux/debug/$target ../../../../build_all -elif [ "$1" = "clean" ] -then - cd release - make "$1" - cd "$curdir" - cd debug - make "$1" - cd "$curdir" -else - echo "Build target must be 'release', 'debug', 'clean', or simply omitted (same as 'release')" -fi diff --git a/c/autohint/build/linux/gcc/debug/Makefile b/c/autohint/build/linux/gcc/debug/Makefile deleted file mode 100644 index d0612bb52..000000000 --- a/c/autohint/build/linux/gcc/debug/Makefile +++ /dev/null @@ -1,42 +0,0 @@ -######################################################################### -# # -# Copyright 1997-2014 Adobe Systems Incorporated. # -# All rights reserved. # -# # -######################################################################### - -# Configuration -CONFIG = debug -ROOT_DIR = ../../../.. -OBJECT_DIR = . -LIB_DIR = $(ROOT_DIR)/autohintlib/lib/$(PLATFORM)/$(CONFIG) - -CFLAGS = $(STD_OPTS) -I$(ROOT_DIR)/autohintlib/source/public/ac \ - -I$(ROOT_DIR)/autohintlib/source/public/extras \ - -I$(ROOT_DIR)/autohintlib/source/ac \ - -I$(ROOT_DIR)/autohintlib/source/bf \ - -DEXECUTABLE=1 -g - -# Program -PRG_SRCS = $(SRC_DIR)/main.c -PRG_OBJS = main.o -PRG_LIBS = $(LIB_DIR)/autohintlib.a -PRG_TARGET = $(EXE_DIR)/autohintexe - -# Build targets -TARGETS = $(PRG_TARGET) - -# Standard definitions -include ../../../../config/linux/gcc/gcc.mak - -# program rule is in gcc.mak - -# Lib rule - $(LIB_DIR)/autohintlib.a: - cd $(ROOT_DIR)/autohintlib/build/$(PLATFORM)/$(COMPILER)/$(CONFIG); $(MAKE) clean; $(MAKE); - - -# Object rules -main.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/main.c -o $@ - diff --git a/c/autohint/build/linux/gcc/release/Makefile b/c/autohint/build/linux/gcc/release/Makefile deleted file mode 100644 index 563088604..000000000 --- a/c/autohint/build/linux/gcc/release/Makefile +++ /dev/null @@ -1,42 +0,0 @@ -######################################################################### -# # -# Copyright 1997-2014 Adobe Systems Incorporated. # -# All rights reserved. # -# # -######################################################################### - -# Configuration -CONFIG = release -ROOT_DIR = ../../../.. -OBJECT_DIR = . -LIB_DIR = $(ROOT_DIR)/autohintlib/lib/$(PLATFORM)/$(CONFIG) - -CFLAGS = $(STD_OPTS) -I$(ROOT_DIR)/autohintlib/source/public/ac \ - -I$(ROOT_DIR)/autohintlib/source/public/extras \ - -I$(ROOT_DIR)/autohintlib/source/ac \ - -I$(ROOT_DIR)/autohintlib/source/bf \ - -DEXECUTABLE=1 - -# Program -PRG_SRCS = $(SRC_DIR)/main.c -PRG_OBJS = main.o -PRG_LIBS = $(LIB_DIR)/autohintlib.a -PRG_TARGET = $(EXE_DIR)/autohintexe - -# Build targets -TARGETS = $(PRG_TARGET) - -# Standard definitions -include ../../../../config/linux/gcc/gcc.mak - -# program rule is in gcc.mak - -# Lib rule - $(LIB_DIR)/autohintlib.a: - cd $(ROOT_DIR)/autohintlib/build/$(PLATFORM)/$(COMPILER)/$(CONFIG); $(MAKE) clean; $(MAKE); - - -# Object rules -main.o: - $(CC) $(CFLAGS) -c $(SRC_DIR)/main.c -o $@ - diff --git a/c/autohint/build/osx/xcode4/BuildAll.sh b/c/autohint/build/osx/xcode4/BuildAll.sh deleted file mode 100755 index ba5fcb9e1..000000000 --- a/c/autohint/build/osx/xcode4/BuildAll.sh +++ /dev/null @@ -1,22 +0,0 @@ -#! /bin/sh -set -e -set -x - -target=autohintexe - -if [ -z "$1" ] || [ "$1" = "release" ] -then - xcodebuild -target BuildAll -project $target.xcodeproj -configuration Release - cp ../../../exe/osx/release/$target ../../../../build_all - ls ../../../build -elif [ "$1" = "debug" ] -then - xcodebuild -target BuildAll -project $target.xcodeproj -configuration Debug - cp ../../../exe/osx/debug/$target ../../../../build_all -elif [ "$1" = "clean" ] -then - xcodebuild -target BuildAll -project $target.xcodeproj -configuration Debug "$1" - xcodebuild -target BuildAll -project $target.xcodeproj -configuration Release "$1" -else - echo "Build target must be 'release', 'debug', 'clean', or simply omitted (same as 'release')" -fi diff --git a/c/autohint/build/osx/xcode4/autohintexe.xcodeproj/project.pbxproj b/c/autohint/build/osx/xcode4/autohintexe.xcodeproj/project.pbxproj deleted file mode 100644 index 960060bfe..000000000 --- a/c/autohint/build/osx/xcode4/autohintexe.xcodeproj/project.pbxproj +++ /dev/null @@ -1,370 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXAggregateTarget section */ - BDD0854714E47AC700F0FC0D /* BuildAll */ = { - isa = PBXAggregateTarget; - buildConfigurationList = BDD0855C14E47B0900F0FC0D /* Build configuration list for PBXAggregateTarget "BuildAll" */; - buildPhases = ( - ); - dependencies = ( - FF99806E1B3D5E000020B466 /* PBXTargetDependency */, - BDD0854D14E47AD500F0FC0D /* PBXTargetDependency */, - ); - name = BuildAll; - productName = BuildAll; - }; -/* End PBXAggregateTarget section */ - -/* Begin PBXBuildFile section */ - BB2B3E751B3CFAF600641593 /* libautohintlib.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 56AE0BAD1A633B80000ECBEE /* libautohintlib.a */; }; - BD5BF4170D9AD1F80015F645 /* main.c in Sources */ = {isa = PBXBuildFile; fileRef = BD5BF4160D9AD1F80015F645 /* main.c */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - 56AE0BAC1A633B80000ECBEE /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = BD5BF4440D9AD3C80015F645 /* autohintlib.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = D2AAC046055464E500DB518D; - remoteInfo = autohintlib; - }; - BDD0854C14E47AD500F0FC0D /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 08FB7793FE84155DC02AAC07 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 8DD76FA90486AB0100D96B5E; - remoteInfo = autohintexe; - }; - FF99806D1B3D5E000020B466 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = BD5BF4440D9AD3C80015F645 /* autohintlib.xcodeproj */; - proxyType = 1; - remoteGlobalIDString = D2AAC045055464E500DB518D; - remoteInfo = autohintlib; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXFileReference section */ - 56AE0BA71A633867000ECBEE /* libautohintlib.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libautohintlib.a; path = "../../../../../../../../../Library/Developer/Xcode/DerivedData/autohintexe-aqaujhwuqqtoouhccdzyzjbhhmcb/Build/Products/Debug/libautohintlib.a"; sourceTree = ""; }; - BD5BF40F0D9AD0A50015F645 /* debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = debug.xcconfig; path = ../../../config/xcconfig/debug.xcconfig; sourceTree = SOURCE_ROOT; }; - BD5BF4100D9AD0A50015F645 /* release.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = release.xcconfig; path = ../../../config/xcconfig/release.xcconfig; sourceTree = SOURCE_ROOT; }; - BD5BF4130D9AD0DB0015F645 /* ac_C_lib.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ac_C_lib.h; path = ../../../autohintlib/source/public/ac/ac_C_lib.h; sourceTree = SOURCE_ROOT; }; - BD5BF4160D9AD1F80015F645 /* main.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = main.c; path = ../../../source/main.c; sourceTree = SOURCE_ROOT; }; - BD5BF4180D9AD2120015F645 /* autohintexe */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = autohintexe; sourceTree = BUILT_PRODUCTS_DIR; }; - BD5BF4200D9AD3230015F645 /* buildfont.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = buildfont.h; path = ../../../autohintlib/source/bf/buildfont.h; sourceTree = SOURCE_ROOT; }; - BD5BF4330D9AD3490015F645 /* ../../../autohintlib/source/public/extras/numtypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ../../../autohintlib/source/public/extras/numtypes.h; sourceTree = ""; }; - BD5BF4340D9AD3490015F645 /* ../../../autohintlib/source/public/extras/pubtypes.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ../../../autohintlib/source/public/extras/pubtypes.h; sourceTree = ""; }; - BD5BF4360D9AD3630015F645 /* bftoac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = bftoac.h; path = ../../../autohintlib/source/bf/bftoac.h; sourceTree = SOURCE_ROOT; }; - BD5BF4370D9AD36B0015F645 /* machinedep.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = machinedep.h; path = ../../../autohintlib/source/bf/machinedep.h; sourceTree = SOURCE_ROOT; }; - BD5BF4390D9AD37D0015F645 /* memcheck.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = memcheck.h; path = ../../../autohintlib/source/public/ac/memcheck.h; sourceTree = SOURCE_ROOT; }; - BD5BF4440D9AD3C80015F645 /* autohintlib.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = autohintlib.xcodeproj; path = ../../../autohintlib/build/osx/xcode4/autohintlib.xcodeproj; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 8DD76FAD0486AB0100D96B5E /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - BB2B3E751B3CFAF600641593 /* libautohintlib.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 08FB7794FE84155DC02AAC07 /* autohintexe */ = { - isa = PBXGroup; - children = ( - 56AE0BA71A633867000ECBEE /* libautohintlib.a */, - BD5BF4440D9AD3C80015F645 /* autohintlib.xcodeproj */, - BD5BF4080D9AD0760015F645 /* xcconfig */, - BD5BF4090D9AD0830015F645 /* Headers */, - 08FB7795FE84155DC02AAC07 /* Source */, - C6A0FF2B0290797F04C91782 /* Documentation */, - 1AB674ADFE9D54B511CA2CBB /* Products */, - ); - name = autohintexe; - sourceTree = ""; - }; - 08FB7795FE84155DC02AAC07 /* Source */ = { - isa = PBXGroup; - children = ( - BD5BF4160D9AD1F80015F645 /* main.c */, - ); - name = Source; - sourceTree = ""; - }; - 1AB674ADFE9D54B511CA2CBB /* Products */ = { - isa = PBXGroup; - children = ( - BD5BF4180D9AD2120015F645 /* autohintexe */, - ); - name = Products; - sourceTree = ""; - }; - 56AE0BA91A633B7F000ECBEE /* Products */ = { - isa = PBXGroup; - children = ( - 56AE0BAD1A633B80000ECBEE /* libautohintlib.a */, - ); - name = Products; - sourceTree = ""; - }; - BD5BF4080D9AD0760015F645 /* xcconfig */ = { - isa = PBXGroup; - children = ( - BD5BF40F0D9AD0A50015F645 /* debug.xcconfig */, - BD5BF4100D9AD0A50015F645 /* release.xcconfig */, - ); - name = xcconfig; - sourceTree = ""; - }; - BD5BF4090D9AD0830015F645 /* Headers */ = { - isa = PBXGroup; - children = ( - BD5BF4130D9AD0DB0015F645 /* ac_C_lib.h */, - BD5BF4390D9AD37D0015F645 /* memcheck.h */, - BD5BF4200D9AD3230015F645 /* buildfont.h */, - BD5BF4360D9AD3630015F645 /* bftoac.h */, - BD5BF4370D9AD36B0015F645 /* machinedep.h */, - BD5BF4320D9AD3490015F645 /* extras */, - ); - name = Headers; - sourceTree = ""; - }; - BD5BF4320D9AD3490015F645 /* extras */ = { - isa = PBXGroup; - children = ( - BD5BF4330D9AD3490015F645 /* ../../../autohintlib/source/public/extras/numtypes.h */, - BD5BF4340D9AD3490015F645 /* ../../../autohintlib/source/public/extras/pubtypes.h */, - ); - name = extras; - path = ../../../source/public/extras; - sourceTree = SOURCE_ROOT; - }; - C6A0FF2B0290797F04C91782 /* Documentation */ = { - isa = PBXGroup; - children = ( - ); - name = Documentation; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 8DD76FA90486AB0100D96B5E /* autohintexe */ = { - isa = PBXNativeTarget; - buildConfigurationList = 1DEB928508733DD80010E9CD /* Build configuration list for PBXNativeTarget "autohintexe" */; - buildPhases = ( - 8DD76FAB0486AB0100D96B5E /* Sources */, - 8DD76FAD0486AB0100D96B5E /* Frameworks */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = autohintexe; - productInstallPath = "$(HOME)/bin"; - productName = autohintexe; - productReference = BD5BF4180D9AD2120015F645 /* autohintexe */; - productType = "com.apple.product-type.tool"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 08FB7793FE84155DC02AAC07 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0460; - }; - buildConfigurationList = 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "autohintexe" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 1; - knownRegions = ( - English, - Japanese, - French, - German, - ); - mainGroup = 08FB7794FE84155DC02AAC07 /* autohintexe */; - projectDirPath = ""; - projectReferences = ( - { - ProductGroup = 56AE0BA91A633B7F000ECBEE /* Products */; - ProjectRef = BD5BF4440D9AD3C80015F645 /* autohintlib.xcodeproj */; - }, - ); - projectRoot = ""; - targets = ( - 8DD76FA90486AB0100D96B5E /* autohintexe */, - BDD0854714E47AC700F0FC0D /* BuildAll */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXReferenceProxy section */ - 56AE0BAD1A633B80000ECBEE /* libautohintlib.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libautohintlib.a; - remoteRef = 56AE0BAC1A633B80000ECBEE /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; -/* End PBXReferenceProxy section */ - -/* Begin PBXSourcesBuildPhase section */ - 8DD76FAB0486AB0100D96B5E /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - BD5BF4170D9AD1F80015F645 /* main.c in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - BDD0854D14E47AD500F0FC0D /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 8DD76FA90486AB0100D96B5E /* autohintexe */; - targetProxy = BDD0854C14E47AD500F0FC0D /* PBXContainerItemProxy */; - }; - FF99806E1B3D5E000020B466 /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - name = autohintlib; - targetProxy = FF99806D1B3D5E000020B466 /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin XCBuildConfiguration section */ - 1DEB928608733DD80010E9CD /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = BD5BF40F0D9AD0A50015F645 /* debug.xcconfig */; - buildSettings = { - GCC_PREPROCESSOR_DEFINITIONS = ( - "EXECUTABLE=1", - "$(inherited)", - ); - HEADER_SEARCH_PATHS = ( - ../../../autohintlib/source/ac, - ../../../autohintlib/source/bf, - ../../../autohintlib/source/public/extras, - ../../../autohintlib/source/public/ac, - ); - }; - name = Debug; - }; - 1DEB928708733DD80010E9CD /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = BD5BF4100D9AD0A50015F645 /* release.xcconfig */; - buildSettings = { - GCC_PREPROCESSOR_DEFINITIONS = ( - "EXECUTABLE=1", - "$(inherited)", - ); - HEADER_SEARCH_PATHS = ( - ../../../autohintlib/source/ac, - ../../../autohintlib/source/bf, - ../../../autohintlib/source/public/extras, - ../../../autohintlib/source/public/ac, - ); - }; - name = Release; - }; - 1DEB928A08733DD80010E9CD /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = BD5BF40F0D9AD0A50015F645 /* debug.xcconfig */; - buildSettings = { - GCC_PREPROCESSOR_DEFINITIONS = ( - "EXECUTABLE=1", - "$(inherited)", - ); - HEADER_SEARCH_PATHS = ( - ../../../autohintlib/source/ac, - ../../../autohintlib/source/bf, - ../../../autohintlib/source/public/extras, - ../../../autohintlib/source/public/ac, - "$(SDKROOT)/usr/include", - "$(SDKROOT)/usr/include/sys", - "../../../../public/include_files/sfnt_tables/**", - ); - PRODUCT_NAME = autohintexe; - }; - name = Debug; - }; - 1DEB928B08733DD80010E9CD /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = BD5BF4100D9AD0A50015F645 /* release.xcconfig */; - buildSettings = { - GCC_PREPROCESSOR_DEFINITIONS = ( - "EXECUTABLE=1", - "$(inherited)", - ); - HEADER_SEARCH_PATHS = ( - ../../../autohintlib/source/ac, - ../../../autohintlib/source/bf, - ../../../autohintlib/source/public/extras, - ../../../autohintlib/source/public/ac, - "$(SDKROOT)/usr/include", - "$(SDKROOT)/usr/include/sys", - "../../../../public/include_files/sfnt_tables/**", - ); - PRODUCT_NAME = autohintexe; - }; - name = Release; - }; - BDD0854814E47AC700F0FC0D /* Debug */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = BD5BF40F0D9AD0A50015F645 /* debug.xcconfig */; - buildSettings = { - }; - name = Debug; - }; - BDD0854914E47AC700F0FC0D /* Release */ = { - isa = XCBuildConfiguration; - baseConfigurationReference = BD5BF4100D9AD0A50015F645 /* release.xcconfig */; - buildSettings = { - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 1DEB928508733DD80010E9CD /* Build configuration list for PBXNativeTarget "autohintexe" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 1DEB928608733DD80010E9CD /* Debug */, - 1DEB928708733DD80010E9CD /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 1DEB928908733DD80010E9CD /* Build configuration list for PBXProject "autohintexe" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 1DEB928A08733DD80010E9CD /* Debug */, - 1DEB928B08733DD80010E9CD /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - BDD0855C14E47B0900F0FC0D /* Build configuration list for PBXAggregateTarget "BuildAll" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - BDD0854814E47AC700F0FC0D /* Debug */, - BDD0854914E47AC700F0FC0D /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 08FB7793FE84155DC02AAC07 /* Project object */; -} diff --git a/c/autohint/build/win/visualstudio/BuildAll.cmd b/c/autohint/build/win/visualstudio/BuildAll.cmd deleted file mode 100755 index e5810fe4c..000000000 --- a/c/autohint/build/win/visualstudio/BuildAll.cmd +++ /dev/null @@ -1,37 +0,0 @@ -@echo off -cd %~dp0 -setlocal enabledelayedexpansion -set targetProgram=autohint - -set do_release=0 -set do_target=0 - -if "%1"=="" set do_release=1 - -if "%1"=="release" set do_release=1 - -if %do_release%==1 ( - set buildConfig=Build - msbuild /target:!buildConfig! /p:configuration=Release %~dp0%targetProgram%.sln - set do_target=1 -) - -if "%1"=="debug" ( - set buildConfig=Build - msbuild /target:!buildConfig! /p:configuration=Debug %~dp0%targetProgram%.sln - set do_target=1 -) - -if %do_target%==1 ( - copy /Y ..\..\..\exe\win\release\%targetProgram%exe.exe ..\..\..\..\build_all -) - -if "%1"=="clean" ( - set buildConfig=Clean - msbuild /target:!buildConfig! /p:configuration=Debug %~dp0%targetProgram%.sln - msbuild /target:!buildConfig! /p:configuration=Release %~dp0%targetProgram%.sln - set do_target=1 -) -if %do_target%==0 ( - echo "Build target must be 'release', 'debug', 'clean', or simply omitted (same as 'release')" -) diff --git a/c/autohint/build/win/visualstudio/autohint.sln b/c/autohint/build/win/visualstudio/autohint.sln deleted file mode 100755 index 6830d6460..000000000 --- a/c/autohint/build/win/visualstudio/autohint.sln +++ /dev/null @@ -1,33 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.27703.2047 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "autohintexe", "autohintexe.vcxproj", "{72B7761C-7DAA-4729-9722-81CCE9550E12}" - ProjectSection(ProjectDependencies) = postProject - {FDCEB06E-D2E3-4916-9208-3C70703BFB27} = {FDCEB06E-D2E3-4916-9208-3C70703BFB27} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "autohintlib", "..\..\..\autohintlib\build\win\visualstudio\autohintlib.vcxproj", "{FDCEB06E-D2E3-4916-9208-3C70703BFB27}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x86 = Debug|x86 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {72B7761C-7DAA-4729-9722-81CCE9550E12}.Debug|x86.ActiveCfg = Debug|Win32 - {72B7761C-7DAA-4729-9722-81CCE9550E12}.Debug|x86.Build.0 = Debug|Win32 - {72B7761C-7DAA-4729-9722-81CCE9550E12}.Release|x86.ActiveCfg = Release|Win32 - {72B7761C-7DAA-4729-9722-81CCE9550E12}.Release|x86.Build.0 = Release|Win32 - {FDCEB06E-D2E3-4916-9208-3C70703BFB27}.Debug|x86.ActiveCfg = Debug|Win32 - {FDCEB06E-D2E3-4916-9208-3C70703BFB27}.Debug|x86.Build.0 = Debug|Win32 - {FDCEB06E-D2E3-4916-9208-3C70703BFB27}.Release|x86.ActiveCfg = Release|Win32 - {FDCEB06E-D2E3-4916-9208-3C70703BFB27}.Release|x86.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {8A4DAFD0-AB40-4310-A2A3-A0EA88C87AA7} - EndGlobalSection -EndGlobal diff --git a/c/autohint/build/win/visualstudio/autohintexe.vcxproj b/c/autohint/build/win/visualstudio/autohintexe.vcxproj deleted file mode 100755 index b9578191a..000000000 --- a/c/autohint/build/win/visualstudio/autohintexe.vcxproj +++ /dev/null @@ -1,109 +0,0 @@ - - - - - Debug - Win32 - - - Release - Win32 - - - - {72B7761C-7DAA-4729-9722-81CCE9550E12} - autohintexe - 10.0.17134.0 - - - - Application - MultiByte - $(DefaultPlatformToolset) - - - Application - MultiByte - $(DefaultPlatformToolset) - - - - - - - - - - - - - <_ProjectFileVersion>10.0.30319.1 - ..\..\..\exe\win\debug\ - $(Configuration)\ - true - ..\..\..\exe\win\release\ - $(Configuration)\ - false - $(ProjectName) - $(ProjectName) - - - - Disabled - ..\..\..\autohintlib\source\ac;..\..\..\autohintlib\source\public\ac;..\..\..\autohintlib\source\bf\;..\..\..\autohintlib\source\public\extras;..\..\..\autohintlib\source\public\winextras;%(AdditionalIncludeDirectories) - WIN32;_DEBUG;_CONSOLE;EXECUTABLE=1;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) - MultiThreadedDebug - - - Level3 - EditAndContinue - - - autohintlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetName)$(TargetExt) - ..\..\..\autohintlib\lib\win\debug;%(AdditionalLibraryDirectories) - true - Console - MachineX86 - - - - - MaxSpeed - ..\..\..\autohintlib\source\ac;..\..\..\autohintlib\source\public\ac;..\..\..\autohintlib\source\bf\;..\..\..\autohintlib\source\public\extras;..\..\..\autohintlib\source\public\winextras;%(AdditionalIncludeDirectories) - WIN32;NDEBUG;_CONSOLE;EXECUTABLE=1;_CRT_SECURE_NO_DEPRECATE;%(PreprocessorDefinitions) - MultiThreaded - - - Level3 - ProgramDatabase - - - autohintlib.lib;%(AdditionalDependencies) - $(OutDir)$(TargetName)$(TargetExt) - ..\..\..\autohintlib\lib\win\release;%(AdditionalLibraryDirectories) - false - Console - MachineX86 - - - - - - - - - - - - - - - - {fdceb06e-d2e3-4916-9208-3c70703bfb27} - - - - - - diff --git a/c/autohint/config/linux/gcc/gcc.mak b/c/autohint/config/linux/gcc/gcc.mak deleted file mode 100755 index d69c47916..000000000 --- a/c/autohint/config/linux/gcc/gcc.mak +++ /dev/null @@ -1,55 +0,0 @@ -######################################################################### -# # -# Copyright 2014 Adobe Systems Incorporated. # -# All rights reserved. # -# # -######################################################################### - -# Make definitions for Linux platform (i86) - -# Configuration -PLATFORM = linux -HARDWARE = i86 -COMPILER = gcc -SYS_LIBS = -lm -XFLAGS = -m32 - -# Directories (relative to build directory) -CT_LIB_DIR = $(ROOT_DIR)/../public/lib/lib/$(PLATFORM)/$(CONFIG) -EXE_DIR = $(ROOT_DIR)/exe/$(PLATFORM)/$(CONFIG) -SRC_DIR = $(ROOT_DIR)/source - - -STD_OPTS = $(XFLAGS) \ - -I$(ROOT_DIR)/../public/lib/api \ - -I$(ROOT_DIR)/../public/lib/resource \ - $(SYS_INCLUDES) -ifneq ($(strip $(OSX)),) # In order to test under Mac OSX, define OSX in the user environment. - STD_OPTS += -DOSX=1 -endif - - -default: $(TARGETS) - -$(PRG_TARGET): $(PRG_OBJS) $(PRG_LIBS) $(PRG_SRCS) $(PRG_INCLUDES) - mkdir -p $(EXE_DIR) - $(CC) $(CFLAGS) -o $@ $(PRG_OBJS) $(PRG_LIBS) $(SYS_LIBS) - -clean: - if [ "$(LIB_OBJS)" ]; then \ - rm -f $(LIB_OBJS); \ - fi - - if [ "$(PRG_OBJS)" ]; then \ - rm -f $(PRG_OBJS); \ - fi - - if [ "$(PRG_LIBS)" ]; then \ - rm -f $(PRG_LIBS); \ - fi - - if [ "$(PRG_TARGET)" ]; then \ - rm -f $(PRG_TARGET); \ - fi - - diff --git a/c/autohint/config/xcconfig/common.xcconfig b/c/autohint/config/xcconfig/common.xcconfig deleted file mode 100644 index 2c50eb837..000000000 --- a/c/autohint/config/xcconfig/common.xcconfig +++ /dev/null @@ -1,16 +0,0 @@ -ARCHS = $(ARCHS_STANDARD_32_BIT) -PREBINDING = NO -GCC_C_LANGUAGE_STANDARD = compiler-default -GCC_ENABLE_CPP_RTTI = NO -GCC_SHORT_ENUMS = NO -GCC_PRECOMPILE_PREFIX_HEADER = YES -GCC_WARN_ABOUT_RETURN_TYPE = YES -GCC_WARN_UNKNOWN_PRAGMAS = YES -GCC_WARN_FOUR_CHARACTER_CONSTANTS = YES -GCC_WARN_SIGN_COMPARE = YES -OTHER_CFLAGS = -fno-inline -GCC_MODEL_TUNING = G5 -SDKROOT = macosx -MACOSX_DEPLOYMENT_TARGET = 10.8 -ONLY_ACTIVE_ARCH = YES; -GCC_PREPROCESSOR_DEFINITIONS = OSX=1 OS=os_osx diff --git a/c/autohint/config/xcconfig/debug.xcconfig b/c/autohint/config/xcconfig/debug.xcconfig deleted file mode 100644 index 2bd232ccf..000000000 --- a/c/autohint/config/xcconfig/debug.xcconfig +++ /dev/null @@ -1,11 +0,0 @@ -#include "common.xcconfig" -ZERO_LINK = no -UNSTRIPPED_PRODUCT = YES -COPY_PHASE_STRIP = NO -GCC_GENERATE_DEBUGGING_SYMBOLS = YES -GCC_DEBUGGING_SYMBOLS = full -GCC_OPTIMIZATION_LEVEL = 0 -GCC_ENABLE_FIX_AND_CONTINUE = NO -GCC_DYNAMIC_NO_PIC = NO -CONFIGURATION_BUILD_DIR = ../../../exe/osx/debug/ -HEADER_SEARCH_PATHS = $(SDKROOT)/usr/include ../../../sfnt_includes diff --git a/c/autohint/config/xcconfig/release.xcconfig b/c/autohint/config/xcconfig/release.xcconfig deleted file mode 100644 index 293f46b39..000000000 --- a/c/autohint/config/xcconfig/release.xcconfig +++ /dev/null @@ -1,5 +0,0 @@ -#include "common.xcconfig" -GCC_GENERATE_DEBUGGING_SYMBOLS = NO -GCC_OPTIMIZATION_LEVEL = s -CONFIGURATION_BUILD_DIR = ../../../exe/osx/release/ -HEADER_SEARCH_PATHS = $(SDKROOT)/usr/include ../../../sfnt_includes diff --git a/c/autohint/doc/AC.doc b/c/autohint/doc/AC.doc deleted file mode 100644 index abfdfc7be..000000000 --- a/c/autohint/doc/AC.doc +++ /dev/null @@ -1,205 +0,0 @@ -AC - Automatic Coloring (Hinting) - -Background ----------- - -AC was written by Bill Paxton over eight years ago. Originally, it -was integrated with the font editor, FE, but Bill extracted the -hinting code so it could run independently and would be easier to -maintain. - -Input ------ - -AC reads a character outline in encrypted bez file format. The fontinfo -file is also read to get alignment zone information, the list of H,V counter -characters, the list of auxiliary H,V stem values, and whether or not flex -can be added to a character. - -As the bez file is read a doubly linked-list is created that contains the -path element information, e.g. coordinates, path type (moveto, curveto...), -etc. - -Setup ------ - -The following initial setup and error checking is done after a character -is read: - -a. Calculate the character bounding box to find the minimum and maximum -x, y values. Supposedly, the very minimum hinting a character will get -is its bounding box values. - -b. Check for duplicate subpaths. - -c. Check for consecutive movetos and only keep the last one. - -d. Check that the path ends with a single closepath and that there are -matching movetos and closepaths. - -e. Initialize the value of the largest vertical and horizontal stem -value allowed. The largest vertical stem value is the larger of 86.25 -and the largest value in the auxiliary V stem array. The largest -horizontal stem value is the larger of 86.25 and the largest value in -the auxiliary H stem array. - -f. If flex is allowed add flex to the character. The current flex -algorithm is very lax and flex can occur where you least expect it. -Almost anything that conforms to page 72 of the black book is flexed. -However, the last line on page 72 says the flex height must be 20 units -or less and this should really say 10 units or less. - -g. Check for smooth curves. If the direction arms tangent to the curve -is between 0 and 30 degrees the points are forced to be colinear. - -h. If there is a sharp angle, greater than 140 degrees, the angle will -be blunted by adding another point. There's a comment that says as of -version 2.21 this blunting will not occur. - -i. Count and save number of subpaths for each path element. - -Hinting -------- - -Generate possible hstem and vstem values. These values are saved as a -linked list (the coloring segment list) in the path element data structure. -There are four segment lists, one for top, bottom, left, and right segments. -The basic progression is: path -> segments -> values -> hints, where a -segment is a horizontal or vertical feature, a value is a pair of -segments (top and bottom or left and right) that is assigned a priority -based on the length and width of a stem, and hints are non-overlapping -pairs with the highest priority. - -Generating {H,V}Stems - -The path element is traversed and possible coordinates are added to the -segment list. The x or y coordinate is saved depending on if it's a -top/bottom or left/right segment and the minimum and maximum extent for a -vertical or horizontal segment. These coordinates are included in the list: -a) the coords of horizontal/vertical lines, b) if this is a curve find the -bends (bend angle must be 135 degrees or less to be included); -don't add a curve's coordinate if the point is not at an extreme and is -going in the same direction as the previous path, c) add points at -extremes, d) add bands for s-curves or where an inflection point occurs, -e) checks are made to see if the curve is in a blue zone and a coordinate -added at the appropriate place. - -Compact the coloring segment lists by removing any pairs that are -completely contained in another. Filter out bogus bend segments and -report any near misses to the horizontal alignment zones. - -Evaluating Stems - -Form all top and bottom, left and right pairs from segment list and -generate ghost pairs for horizontal segments in alignment zones. -A priority value is assigned to each pair. The value is a function -of the length of the segments, the length of any overlap, and the -distance apart. A higher priority value means it is a likely candidate -to be included in the hints and this is given to pairs that are closer -together, longer in length, and have a clean overlap. All pairs with -0 priority are discarded. - -Report any near misses (1 or 2 units) to the values in the H or V stems -array. - -Pruning Values - -Prune non-relevant stem pairs and keep the best of any overlapping pairs. -This is done by looking at the priority values. - -Finding the Best Values - -After pruning, the best pair is found for each top, bottom or left, right -segment using the priority values. Pairs that are at the same location -and are "similar" enough are merged by replacing the lower priority pair -with the higher priority pair. - -The pairs are again checked for near misses (1 or 2 units) to the -values in the H or V stems array, but this time the information is -saved in an array. If fixing these pairs is allowed the pairs saved -in the array are changed to match the value it was "close" to in the -H or V stem array. - -Check to see if H or V counter hints (hstem3, vstem3) should be used -instead of hstem or vstem. - -Create the main hints that are included at the beginning of a character. -These are created by picking, in order of priority, from the segment -lists. - -If no good hints are found use bounding box hints. - -Shuffling Subpaths ------------------- - -The character's subpaths are reordered so that the hints will not need -to change constantly because it is jumping from one subpath to another. -Kanji characters had the most problems with this which caused huge -files to be created. - -Hint Substitution ------------------ - -Remove "flares" from the segment list. Flares usually occur at the top -of a serif where a hint is added at an endpoint, but it's not at the -extreme and there is another endpoint very nearby. This causes a blip -at the top of the serif at low resolutions. Flares are not removed if -they are in an overshoot band. - -Copy hints to earlier elements in the path, if possible, so hint -substitution can start sooner. - -Don't allow hint substitution at short elements, so remove any if -they exist. Short is considered less than 6 units. - -Go through path element looking for pairs. If this pair is compatible -with the currently active hints then add it otherwise start hint -substitution. - -Special Cases -------------- - -When generating stems a procedure is called to allow lines that are not -completely horizontal or vertical to be included in the coloring -segment list. This was specifically included because the serifs of -ITCGaramond Ultra have points that are not quite horizontal according -to the comment int he program. When generating hstem values the threshold -is <= 2 for delta y and >= 25 for delta x. The reverse is true when -generating vstem values. - -There are many thresholds used when evaluating stems, pruning, and -finding the best values. The thresholds used throughout the program are -just "best guesses" according to Bill Paxton. There are various comments -in the code explaining why some of these thresholds were changed and -specifically for which fonts. - -The following characters attempt to have H counter hints added. - - "element", "equivalence", "notelement", "divide" - -in addition to any characters listed in the HCounterChars keyword of -the fontinfo file. - -The following characters attempt to have V counter hints added. - - "m", "M", "T", "ellipsis" - -in addition to any characters listed in the VCounterChars keyword of -the fontinfo file. - -There used to be a special set of characters that received dotsection -hints. This was to handle hinting on older PS interpreters that could -not perform hint replacement. This feature has been commented out of -the current version of AC. - -AC uses a 24.8 Fixed type number rather than the more widely used 16.16. - -Output ------- - -AC writes out a file in encrypted bez file format that includes -the hinting information. Along with each hint it writes a comment -that specifies which path element was used to create this hint. -This comment is used by BuildFont for hinting multiple master -fonts. - diff --git a/c/autohint/doc/bezfileformat.txt b/c/autohint/doc/bezfileformat.txt deleted file mode 100644 index 72c036034..000000000 --- a/c/autohint/doc/bezfileformat.txt +++ /dev/null @@ -1,36 +0,0 @@ - - PROPOSAL FOR BEZIER FILE FORMATS (revised) - -The Standard Bezier format is an encrypted file consisting of the following -operators: - (width) -- character width (* this may be added at a later date) - sc -- start of character outline - rmt -- relative move, same as T1 rmoveto operator) - vmt -- relative move, same as T1 vmoveto operator) - hmt -- relative move, same as T1 hmoveto operator) - rdt -- relative line/draw, same as T1 rlineto operator) - vdt -- relative line/draw, same as T1 vlineto operator) - hdt -- relative line/draw, same as T1 hlineto operator)) - rct -- optimized relative curve, same as T1 rrcurveto operator) - vhct -- optimized relative curve, same as T1 vhcurveto operator) - hvct -- optimized relative curve, same as T1 hvcurveto operator)) - cp -- end of sub-path, same as T1 closepath operator) - ed -- end of character outline, sa,e as T1 endchar operator. - preflx1 -- marks start of flex op, expressed a s T1 path ops - preflx2 -- marks end of flex op - flx -- flex op. - beginsubr snc -- marks start of new block of hint values - endsubr encnewcolors -- marks end of hint values - rb -- horizontal stem hint - ry -- vertical stem hint - rm -- vertical counter hints - rv -- horiztonal counter hints - div -- same PostScript div operator. - - -Notes: -The preflx1/ preflx2 sequence provides the same info as the flex -sequence; the difference is that the preflx1/preflx2 sequence provides -the argument values needed for building a Type1 string while the flex -sequence is simply the 6 rcurveto points. Both sequences are always -provided. diff --git a/c/autohint/source/main.c b/c/autohint/source/main.c deleted file mode 100644 index dd6729d16..000000000 --- a/c/autohint/source/main.c +++ /dev/null @@ -1,516 +0,0 @@ -/* Copyright 2014 Adobe Systems Incorporated (http://www.adobe.com/). All Rights Reserved. -This software is licensed as OpenSource, under the Apache License, Version 2.0. This license is available at: http://opensource.org/licenses/Apache-2.0. */ -/* main.c */ - -#include -#include "ac.h" -#include "machinedep.h" - -#ifdef WIN32 -#include -#include -#else -#include -#include -#endif - -const char *C_ProgramVersion = "1.65240"; -const char *reportExt = ".rpt"; -const char *dfltExt = ".new"; -char *bezName = NULL; -char *fileSuffix = NULL; -FILE *reportFile = NULL; - -boolean verbose = TRUE; /* if TRUE don't number of characters processed. */ - -boolean scalinghints = FALSE; - -/* EXECUTABLE defined means it is being compiled as a command-line tool; -if not defined, it is being compiled as a Python module. -*/ -#ifndef EXECUTABLE -extern jmp_buf aclibmark; -#endif - -#if ALLOWCSOUTPUT -boolean charstringoutput = FALSE; -static void read_char_widths(void); -#endif - -#if !WIN32 -extern int unlink(const char *); -#endif - -static void openReportFile(char *name, char *fSuffix); - -static void printVersions(void) { - fprintf(OUTPUTBUFF, "C program version %s. lib version %s.\n", C_ProgramVersion, AC_getVersion()); -} - -static void printUsage(void) { - fprintf(OUTPUTBUFF, "Usage: autohintexe [-u] [-h]\n"); - fprintf(OUTPUTBUFF, " autohintexe -f [-e] [-n] [-q] [-s ] [-ra] [-rs] -a] [ ... ]\n"); - printVersions(); -} - -static void printHelp(void) { - printUsage(); - fprintf(OUTPUTBUFF, " -u usage\n"); - fprintf(OUTPUTBUFF, " -h help message\n"); - fprintf(OUTPUTBUFF, " -e do not edit (change) the paths when hinting\n"); - fprintf(OUTPUTBUFF, " -n no multiple layers of coloring\n"); - fprintf(OUTPUTBUFF, " -q quiet\n"); - fprintf(OUTPUTBUFF, " -f path to font info file\n"); - fprintf(OUTPUTBUFF, " -i This can be used instead of the -f parameter for data input \n"); - fprintf(OUTPUTBUFF, " [name2]..[nameN] paths to glyph bez files\n"); - fprintf(OUTPUTBUFF, " -b the last argument is bez data instead of a file name and the result will go to stdOut\n"); - fprintf(OUTPUTBUFF, " -s Write output data to 'file name' + 'suffix', rather\n"); - fprintf(OUTPUTBUFF, " than writing it to the same file name as the input file.\n"); - fprintf(OUTPUTBUFF, " -ra Write alignment zones data. Does not hint or change glyph. Default extension is '.rpt'\n"); - fprintf(OUTPUTBUFF, " -rs Write stem widths data. Does not hint or change glyph. Default extension is '.rpt'\n"); - fprintf(OUTPUTBUFF, " -a Modifies -ra and -rs: Includes stems between curved lines: default is to omit these.\n"); - fprintf(OUTPUTBUFF, " -v print versions.\n"); -} - -static int main_cleanup(short code) { - closefiles(); - if (code != AC_Success) - exit(code); - - return 0; -} - -static void charZoneCB(Fixed top, Fixed bottom, char *glyphName) { - if (reportFile) - fprintf(reportFile, "charZone %s top %f bottom %f\n", glyphName, top / 256.0, bottom / 256.0); -} - -static void stemZoneCB(Fixed top, Fixed bottom, char *glyphName) { - if (reportFile) - fprintf(reportFile, "stemZone %s top %f bottom %f\n", glyphName, top / 256.0, bottom / 256.0); -} - -static void hstemCB(Fixed top, Fixed bottom, char *glyphName) { - if (reportFile) - fprintf(reportFile, "HStem %s top %f bottom %f\n", glyphName, top / 256.0, bottom / 256.0); -} - -static void vstemCB(Fixed right, Fixed left, char *glyphName) { - if (reportFile) - fprintf(reportFile, "VStem %s right %f left %f\n", glyphName, right / 256.0, left / 256.0); -} - -static void reportCB(char *msg) { - fprintf(OUTPUTBUFF, "%s", msg); - fprintf(OUTPUTBUFF, "\n"); -} - -static void reportRetry(void) { - if (reportFile != NULL) { - fclose(reportFile); - openReportFile(bezName, fileSuffix); - } -} - -static char *getFileData(char *name) { - char *data; - - struct stat filestat; - if ((stat(name, &filestat)) < 0) { - fprintf(OUTPUTBUFF, "Error. Could not open file '%s'. Please check that it exists and is not write-protected.\n", name); - main_cleanup(FATALERROR); - } - - if (filestat.st_size == 0) { - fprintf(OUTPUTBUFF, "Error. File '%s' has zero size.\n", name); - main_cleanup(FATALERROR); - } - - data = malloc(filestat.st_size + 1); - if (data == NULL) { - fprintf(OUTPUTBUFF, "Error. Could not allcoate memory for contents of file %s.\n", name); - main_cleanup(FATALERROR); - } else { - size_t fileSize = 0; - FILE *fp = fopen(name, "r"); - if (fp == NULL) { - fprintf(OUTPUTBUFF, "Error. Could not open file '%s'. Please check that it exists and is not write-protected.\n", name); - main_cleanup(FATALERROR); - } - fileSize = fread(data, 1, filestat.st_size, fp); - data[fileSize] = 0; - fclose(fp); - } - return data; -} - -static void writeFileData(char *name, char *output, char *fSuffix) { - size_t fileSize; - FILE *fp; - size_t nameSize = 1 + strlen(name); - char *savedName; - int usedNewName = 0; - - if ((fSuffix != NULL) && (fSuffix[0] != '\0')) { - nameSize += strlen(fSuffix); - savedName = malloc(nameSize); - savedName[0] = '\0'; - strcat(savedName, name); - strcat(savedName, fSuffix); - usedNewName = 1; - } else - savedName = malloc(nameSize); - - fp = fopen(savedName, "w"); - fileSize = fwrite(output, 1, strlen(output), fp); - fclose(fp); - - if (usedNewName) - free(savedName); -} - -static void openReportFile(char *name, char *fSuffix) { - size_t nameSize = 1 + strlen(name); - char *savedName; - int usedNewName = 0; - - if ((fSuffix != NULL) && (fSuffix[0] != '\0')) { - nameSize += strlen(fSuffix); - savedName = malloc(nameSize); - savedName[0] = '\0'; - strcat(savedName, name); - strcat(savedName, fSuffix); - usedNewName = 1; - } else - savedName = malloc(nameSize); - - reportFile = fopen(savedName, "w"); - - if (usedNewName) - free(savedName); -} - -static void closeReportFile(void) { - if (reportFile != NULL) - fclose(reportFile); -} - -int main(int argc, char *argv[]) { - /* See the discussion in the function definition for: - autohintlib:control.c:Blues() - private procedure Blues() - */ - - int allowEdit, roundCoords, allowHintSub, fixStems, debug, badParam; - boolean argumentIsBezData = false; - char *fontInfoFileName = NULL; /* font info file name, or suffix of environment variable holding the fontfino string. */ - char *fontinfo = NULL; /* the string of fontinfo data */ - int firstFileNameIndex = -1; /* arg index for first bez file name, or suffix of environment variable holding the bez string. */ - - register char *current_arg; - short total_files = 0; - int result, argi; - - badParam = fixStems = debug = doAligns = doStems = allstems = FALSE; - allowEdit = allowHintSub = roundCoords = TRUE; - fileSuffix = (char *)dfltExt; - - /* read in options */ - argi = 0; - while (++argi < argc) { - current_arg = argv[argi]; - - if (current_arg[0] == '\0') { - continue; - } else if (current_arg[0] != '-') { - if (firstFileNameIndex == -1) { - firstFileNameIndex = argi; - } - total_files++; - continue; - } else if (firstFileNameIndex != -1) { - fprintf(OUTPUTBUFF, "Error. Illegal command line. \"-\" option found after first file name.\n"); - exit(1); - } - - switch (current_arg[1]) { - case '\0': - badParam = TRUE; - break; - case 'u': - printUsage(); -#ifdef EXECUTABLE - exit(0); -#else - longjmp(aclibmark, 1); -#endif - break; - case 'h': - printHelp(); -#ifdef EXECUTABLE - exit(0); -#else - longjmp(aclibmark, 1); -#endif - break; - case 'e': - allowEdit = FALSE; - case 'd': - roundCoords = FALSE; - break; - case 'b': - argumentIsBezData = true; - break; - case 'f': - if (fontinfo != NULL) { - fprintf(OUTPUTBUFF, "Error. Illegal command line. \"-f\" can’t be used together with the \"-i\" command.\n"); - exit(1); - } - fontInfoFileName = argv[++argi]; - if ((fontInfoFileName[0] == '\0') || (fontInfoFileName[0] == '-')) { - fprintf(OUTPUTBUFF, "Error. Illegal command line. \"-f\" option must be followed by a file name.\n"); - exit(1); - } - fontinfo = getFileData(fontInfoFileName); - break; - case 'i': - if (fontinfo != NULL) { - fprintf(OUTPUTBUFF, "Error. Illegal command line. \"-i\" can’t be used together with the \"-f\" command.\n"); - exit(1); - } - fontinfo = argv[++argi]; - if ((fontinfo[0] == '\0') || (fontinfo[0] == '-')) { - fprintf(OUTPUTBUFF, "Error. Illegal command line. \"-i\" option must be followed by a font info string.\n"); - exit(1); - } - break; - case 's': - fileSuffix = argv[++argi]; - if ((fileSuffix[0] == '\0') || (fileSuffix[0] == '-')) { - fprintf(OUTPUTBUFF, "Error. Illegal command line. \"-s\" option must be followed by a string, and the string must not begin with '-'.\n"); - exit(1); - } - break; - case 'n': - allowHintSub = FALSE; - break; - case 'q': - verbose = FALSE; - break; - case 'D': - debug = TRUE; - break; - case 'F': - fixStems = TRUE; - break; - case 'a': - allstems = 1; - break; - - case 'r': - allowEdit = allowHintSub = FALSE; - fileSuffix = (char *)reportExt; - switch (current_arg[2]) { - case 'a': - reportRetryCB = reportRetry; - addCharExtremesCB = charZoneCB; - addStemExtremesCB = stemZoneCB; - doAligns = 1; - - addHStemCB = NULL; - addVStemCB = NULL; - doStems = 0; - break; - case 's': - reportRetryCB = reportRetry; - addHStemCB = hstemCB; - addVStemCB = vstemCB; - doStems = 1; - - addCharExtremesCB = NULL; - addStemExtremesCB = NULL; - doAligns = 0; - break; - default: - fprintf(OUTPUTBUFF, "Error. %s is an invalid parameter.\n", current_arg); - badParam = TRUE; - break; - } - break; - case 'v': - printVersions(); - exit(0); - break; - break; -#if ALLOWCSOUTPUT - case 'C': - charstringoutput = TRUE; - break; -#endif - default: - fprintf(OUTPUTBUFF, "Error. %s is an invalid parameter.\n", current_arg); - badParam = TRUE; - break; - } - } - - if (firstFileNameIndex == -1) { - fprintf(OUTPUTBUFF, "Error. Illegal command line. Must provide bez file name.\n"); - badParam = TRUE; - } - if (fontInfoFileName == NULL) { - fprintf(OUTPUTBUFF, "Error. Illegal command line. Must provide font info file name.\n"); - badParam = TRUE; - } - - if (badParam) -#ifdef EXECUTABLE - exit(NONFATALERROR); -#else - longjmp(aclibmark, -1); -#endif - -#if ALLOWCSOUTPUT - if (charstringoutput) - read_char_widths(); -#endif - - AC_SetReportCB(reportCB, verbose); - argi = firstFileNameIndex - 1; - while (++argi < argc) { - char *bezdata; - char *output; - size_t outputsize = 0; - bezName = argv[argi]; - if (!argumentIsBezData) { - bezdata = getFileData(bezName); - } else { - bezdata = bezName; - } - outputsize = 4 * strlen(bezdata); - output = malloc(outputsize); - - if (!argumentIsBezData && (doAligns || doStems)) { - openReportFile(bezName, fileSuffix); - } - - result = AutoColorString(bezdata, fontinfo, output, (int *)&outputsize, allowEdit, allowHintSub, roundCoords, debug); - if (result == AC_DestBuffOfloError) { - if (reportFile != NULL) { - closeReportFile(); - if (!argumentIsBezData && (doAligns || doStems)) { - openReportFile(bezName, fileSuffix); - } - } - free(output); - output = malloc(outputsize); - /* printf("NOTE: trying again. Input size %d output size %d.\n", strlen(bezdata), outputsize); */ - AC_SetReportCB(reportCB, FALSE); - result = AutoColorString(bezdata, fontinfo, output, (int *)&outputsize, allowEdit, allowHintSub, roundCoords, debug); - AC_SetReportCB(reportCB, verbose); - } - - if (reportFile != NULL) { - closeReportFile(); - } else { - if ((outputsize != 0) && (result == AC_Success)) { - if (!argumentIsBezData) { - writeFileData(bezName, output, fileSuffix); - } else { - printf("%s", output); - } - } - } - - free(output); - main_cleanup((result == AC_Success) ? OK : FATALERROR); - } - - return 0; -} -/* end of main */ - -#if ALLOWCSOUTPUT - -typedef struct _wid { - int wid; - char nam[60]; -} WidthElt; - -static WidthElt *widthsarray = NULL; -static int numwidths = 0; -static int maxnumwidths = 0; -#define WIDTHINCR 50 -#define STREQ(a, b) (((a)[0] == (b)[0]) && (strcmp((a), (b)) == 0)) - -static void init_widthsarray(void) { - if (widthsarray != NULL) { -#if DOMEMCHECK - memck_free(widthsarray); -#else - ACFREEMEM(widthsarray); -#endif - widthsarray = NULL; - } - widthsarray = (WidthElt *)calloc(WIDTHINCR + 1, sizeof(WidthElt)); - if (widthsarray == NULL) { - LogMsg("Could not allocate widths.\n", LOGERROR, OK, FALSE); - } - numwidths = 0; - maxnumwidths = WIDTHINCR; -} - -static void set_char_width(char *cname, int width) { - if (numwidths == maxnumwidths) { - widthsarray = (WidthElt *)realloc(widthsarray, (maxnumwidths + WIDTHINCR + 1) * sizeof(WidthElt)); - if (widthsarray == NULL) { - LogMsg("Could not re-allocate widths.\n", LOGERROR, OK, FALSE); - } - maxnumwidths += WIDTHINCR; - } - - widthsarray[numwidths].wid = width; - strcpy(widthsarray[numwidths].nam, cname); - numwidths++; -} - -int get_char_width(char *cname) { - int i; - for (i = 0; i < numwidths; i++) { - if (STREQ(widthsarray[i].nam, cname)) { - return (widthsarray[i].wid); - } - } - sprintf(globmsg, "Could not find width for '%s'. Assuming 1000.\n", cname); - LogMsg(globmsg, INFO, OK, FALSE); - return (1000); -} - -/* Adds width info to char_table. */ -static void read_char_widths(void) { - FILE *fwidth; -#define WIDTHMAXLINE 80 - char cname[50]; - char line[WIDTHMAXLINE + 1]; - int width; - indx ix; - - init_widthsarray(); - fwidth = ACOpenFile("widths.ps", "r", OPENERROR); - while (fgets(line, WIDTHMAXLINE, fwidth) != NULL) { - if (((line[0] == '%') || (ix = strindex(line, "/")) == -1)) { - continue; - } - if (sscanf(&line[ix + 1], " %s %d", cname, &width) != 2) { - sprintf(globmsg, - "%s file line: %s can't be parsed.\n It should have the format: " - "/ WDef\n", - "widths.ps", line); - fclose(fwidth); - LogMsg(globmsg, LOGERROR, NONFATALERROR, TRUE); - } - set_char_width(cname, width); - } - fclose(fwidth); -} -#endif /* ALLOWCSOUTPUT */ diff --git a/c/buildall.cmd b/c/buildall.cmd index a6f60ee43..6dde8b6a9 100755 --- a/c/buildall.cmd +++ b/c/buildall.cmd @@ -9,10 +9,6 @@ if %do_target%==0 ( exit /B ) -echo " " -echo "Building autohint..." -call %~dp0autohint\build\win\visualstudio\BuildAll.cmd %1 || EXIT /B 1 - echo " " echo "Building detype1..." call %~dp0detype1\build\win\visualstudio\BuildAll.cmd %1 || EXIT /B 1 diff --git a/setup.py b/setup.py index 410eae6cf..42a4b7ec4 100644 --- a/setup.py +++ b/setup.py @@ -144,7 +144,7 @@ def copy_scripts(self): def _get_scripts(): script_names = [ - 'autohintexe', 'detype1', 'makeotfexe', 'mergefonts', 'rotatefont', + 'detype1', 'makeotfexe', 'mergefonts', 'rotatefont', 'sfntdiff', 'sfntedit', 'spot', 'tx', 'type1' ] if platform.system() == 'Windows':