#! /usr/bin/perl

#  Creates the fontdata.js file from the individual font data files
#  
#  Usage:  ./makeData

@files = (
  "STIXGeneral-Regular",
  "STIXGeneral-Bold",
  "STIXGeneral-Italic",
  "STIXIntegralsD-Regular",
  "STIXNonUnicode-Regular",
  "STIXNonUnicode-Bold",
  "STIXNonUnicode-Italic",
  "STIXSizeOneSym-Regular",
  "STIXSizeTwoSym-Regular",
  "STIXSizeThreeSym-Regular",
  "STIXSizeFourSym-Regular",
  "STIXSizeFiveSym-Regular",
  "STIXVariants-Regular",
);

open(DATA,">fontdata.js");
foreach $file (@files) {
  $file =~ s/STIX//;
  $file .= "-Regular" unless $file =~ m/-/;
  $file = "fonts/STIX/$file"; $file =~ s!-!/!g;
  $file .= (-e "$file/Main.js" ? "/Main.js" : "/All.js");
  open(FONT,$file) || print "Can't open $file\n";
  $lines = "  ".join("  ",<FONT>);
  close(FONT);
  $lines =~ s/.*FONTDATA/  HTMLCSS.FONTDATA/s;
  $lines =~ s/};.*/};\n/s;
  print DATA $lines,"\n";
}
close(DATA);

