Skip to content

Commit

Permalink
Merge branch 'package_override'
Browse files Browse the repository at this point in the history
Provides --package option for make_gdl and make_fea in order to override
methods in GDL.pm and Fea.pm, respectively.
  • Loading branch information
bobh0303 committed Jun 7, 2016
2 parents 2b2ea09 + b64ce57 commit f348553
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 42 deletions.
45 changes: 34 additions & 11 deletions scripts/make_fea
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,31 @@ use Font::TTF::Scripts::Fea;
use IO::File;
use Getopt::Long;
use Pod::Usage;
use File::Basename;

our(%opts);
GetOptions(\%opts,
'ap|a=s',
# 'b', # used in make_volt
'classfile|c=s',
'classfile|c=s',
'classprops',
# 'autodefines|d', # used in make_gdl
# 'define|D=s%', # used in make_gdl
'empty|e=s',
'empty|e=s',
# 'forceadd|f=i', # used in make_volt
'help|h',
'include|i=s@',
'ligatures|l=s',
'mark|m=s',
'help|h',
'include|i=s@',
'ligatures|l=s',
'mark|m=s',
'markattach=s%',
# 'normalize|n=i', # used in make_gdl, make_volt
'omitaps|o=s',
'preinclude=s',
'omitaps|o=s',
'package=s',
# 'positions|p=i', # used in make_gdl
'preinclude=s',
'renameaps|r',
# 'substitutions|s=i', # used in make_gdl
# 'outVOLT|t', # used in make_volt
'renameaps|r',
'z=i');

unless ($ARGV[1] || $opts{'help'})
Expand Down Expand Up @@ -59,10 +61,25 @@ if ($opts{'empty'})
$options{'-knownemptyglyphs'} = \@glist if scalar(@glist);
}

# Process -o if supplied
$options{'-omittedAPs'} = $opts{'omitaps'} if $opts{'omitaps'};

my $f = Font::TTF::Scripts::Fea->read_font($ARGV[0], $opts{'ap'}, %options) || die "Can't read font information";

# Open font, using custom module if --package suppplied
my $f;
if ($opts{'package'})
{
my $pkg = $opts{'package'};
require $pkg;
# Assume the package name is the basename of the filename:
($pkg, undef, undef) = fileparse($opts{'package'}, qr/\.[^.]*/);
$f = $pkg->read_font($ARGV[0], $opts{'ap'}, %options);
}
else
{
$f = Font::TTF::Scripts::Fea->read_font($ARGV[0], $opts{'ap'}, %options);
}
die "Can't read font information" unless $f;

if (exists $f->{'WARNINGS'})
{
warn $f->{'WARNINGS'};
Expand Down Expand Up @@ -145,6 +162,12 @@ Creates font specific AFDKO fea source file from a font and optional attachment
lastcomp - treat extensions as part of elements, as last
-m "list" List of APs to ignore when deciding whether a glyph is a mark
-o "list" List of AP names to omit
--package file
Use the named file instead of Font::TTF::Scripts::GDL.pm to
open the font. Assumes the internal package name is the
same as the basename of file (sans any extension).
--preinclude file
add #include statement at begining of file
-r Rename point names such that final M gets initial _ and final S
is removed. Typically for Fontographer fonts.
-z bitfield Bitfield of various controls:
Expand Down
85 changes: 54 additions & 31 deletions scripts/make_gdl
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,32 @@ use Font::TTF::Scripts::GDL;
use IO::File;
use Getopt::Long;
use Pod::Usage;
use File::Basename;

our(%opts);
GetOptions(\%opts,
'ap|a=s',
# 'b', # used in make_volt
'classfile|c=s',
'classprops',
'autodefines|d',
'define|D=s%',
'empty|e=s',
# 'forceadd|f=i', # used in make_volt
'help|h',
'include|i=s@',
'ligatures|l=s',
'mark|m=s',
'normalize|n=i',
'omitaps|o=s',
'positions|p=i',
'renameaps|r',
'substitutions|s=i',
# 'outVOLT|t', # used in make_volt
'z=i');
'ap|a=s',
# 'b', # used in make_volt
'classfile|c=s',
'classprops',
'autodefines|d',
'define|D=s%',
'empty|e=s',
# 'forceadd|f=i', # used in make_volt
'help|h',
'include|i=s@',
'ligatures|l=s',
'mark|m=s',
# 'markattach=s%', # used in make_fea
'normalize|n=i',
'omitaps|o=s',
'package=s',
'positions|p=i',
# 'preinclude=s', # used in make_fea
'renameaps|r',
'substitutions|s=i',
# 'outVOLT|t', # used in make_volt
'z=i');

unless ($ARGV[1] || $opts{'help'})
{
Expand All @@ -45,25 +49,40 @@ my %options;
if ($opts{'empty'})
{
my @glist;
open (IN, "<$opts{'empty'}") or die "Couldn't open '$opts{'empty'}' for reading.";
while (<IN>)
{
s/[\r\n]*$//o; # platform-safe chomp
s/;.*$//o; # Strip comments
s/ //go; # Strip whitespace
push (@glist, $_) unless $_ eq '';
}
open (IN, "<$opts{'empty'}") or die "Couldn't open '$opts{'empty'}' for reading.";
while (<IN>)
{
s/[\r\n]*$//o; # platform-safe chomp
s/;.*$//o; # Strip comments
s/ //go; # Strip whitespace
push (@glist, $_) unless $_ eq '';
}
close IN;
$options{'-knownemptyglyphs'} = \@glist if scalar(@glist);
$options{'-knownemptyglyphs'} = \@glist if scalar(@glist);
}

# Process -o if supplied
$options{'-omittedAPs'} = $opts{'omitaps'} if $opts{'omitaps'};

my $f = Font::TTF::Scripts::GDL->read_font($ARGV[0], $opts{'ap'}, %options) || die "Can't read font information";

# Open font, using custom module if --package suppplied
my $f;
if ($opts{'package'})
{
my $pkg = $opts{'package'};
require $pkg;
# Assume the package name is the basename of the filename:
($pkg, undef, undef) = fileparse($opts{'package'}, qr/\.[^.]*/);
$f = $pkg->read_font($ARGV[0], $opts{'ap'}, %options);
}
else
{
$f = Font::TTF::Scripts::GDL->read_font($ARGV[0], $opts{'ap'}, %options);
}
die "Can't read font information" unless $f;

if (exists $f->{'WARNINGS'})
{
warn $f->{'WARNINGS'};
warn $f->{'WARNINGS'};
}


Expand Down Expand Up @@ -138,6 +157,10 @@ Creates font specific GDL from a font and optional attachment point database
-m "list" List of APs to ignore when deciding whether a glyph is a mark
-n num Add a normalization substitution with the given pass number
-o "list" List of AP names to omit
--package file
Use the named file instead of Font::TTF::Scripts::GDL.pm to
open the font. Assumes the internal package name is the
same as the basename of file (sans any extension).
-p num Add auto positioning attachment rules with the given pass number
-r Rename point names such that final M gets initial _ and final S
is removed. Typically for Fontographer fonts.
Expand Down

0 comments on commit f348553

Please sign in to comment.