Skip to content

Commit

Permalink
Update fonts to use Makefile, be configurable and automated. Add opti…
Browse files Browse the repository at this point in the history
…on for the YUI compressor too.
  • Loading branch information
fred-wang committed Mar 12, 2013
1 parent 257a3d2 commit 14fbf2a
Show file tree
Hide file tree
Showing 32 changed files with 13,539 additions and 1,166 deletions.
16 changes: 14 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,38 @@ CUSTOM=custom.cfg
-include $(CUSTOM)

help:
@echo "Usage:"
@echo ""
@echo "make config"
@echo " Generate the Perl configuration"
@echo ""
@echo "make fonts"
@echo " Generate and install MathJax fonts and related data."
@echo ""
@echo "make clean"
@echo " Remove temporary directories and files."
@echo ""

$(CUSTOM):
@cp default.cfg $(CUSTOM);
@echo "Configuration file '$(CUSTOM)' created.";
@echo "Edit this file and run 'make config'.";
@exit 1

config: $(CUSTOM)
$(CUSTOM).pl: $(CUSTOM)
@echo "Creating Perl config file..."
@cp $(CUSTOM) $(CUSTOM).pl
@echo >> $(CUSTOM).pl # ensure that the config file ends by a new line
@echo "MFTRACE_PATH=`$(WHICH) $(MFTRACE)`" >> $(CUSTOM).pl
@$(SED) -i "s|^\([A-Z_0-9]*\)=\(.*\)|$$\1='\2';|" $(CUSTOM).pl

fonts:
config: $(CUSTOM).pl

fonts: $(CUSTOM).pl
$(MAKE) -C fonts all

clean:
rm -f $(CUSTOM).pl
$(MAKE) -C fonts clean

.PHONY: fonts
3 changes: 3 additions & 0 deletions default.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,6 @@ SFNT2WOFF=sfnt2woff
TTF2EOT=ttf2eot
TTF2SVG=/usr/share/java/batik-ttf2svg.jar
TTX=ttx

##### packer #####
YUICOMPRESSOR=/usr/share/yui-compressor/yui-compressor.jar
26 changes: 0 additions & 26 deletions fonts/AFM/STIX-1.1/makeAll

This file was deleted.

3 changes: 3 additions & 0 deletions fonts/AMS/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
AMS.pl
data.js
optable.js
37 changes: 37 additions & 0 deletions fonts/AMS/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!gmake
#
# Version: Apache License 2.0
#
# Copyright (c) 2013 MathJax Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

include ../../custom.cfg

all: data optable translation

data.js:
$(PERL) makeData
data: data.js

optable.js:
$(PERL) makeOpTable
optable: optable.js

AMS.pl:
$(PERL) makeTranslation > AMS.pl
translation: AMS.pl

clean:
rm -rf data.js optable.js AMS.pl
1 change: 1 addition & 0 deletions fonts/IMG/TeX/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
TeX
97 changes: 97 additions & 0 deletions fonts/IMG/TeX/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#!gmake
#
# Version: Apache License 2.0
#
# Copyright (c) 2013 MathJax Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

include ../../../custom.cfg

all: png range data

TeX:
# Makes the .png files for ALL the fonts
rm -rf TeX
$(PERL) makePNG otf/MathJax_AMS-Regular.otf
$(PERL) makePNG otf/MathJax_Caligraphic-Bold.otf
$(PERL) makePNG otf/MathJax_Caligraphic-Regular.otf
$(PERL) makePNG otf/MathJax_Main-Bold.otf
$(PERL) makePNG otf/MathJax_Main-Italic.otf
$(PERL) makePNG otf/MathJax_Main-Regular.otf
$(PERL) makePNG otf/MathJax_Math-BoldItalic.otf
$(PERL) makePNG otf/MathJax_Math-Italic.otf
$(PERL) makePNG otf/MathJax_Size1-Regular.otf
$(PERL) makePNG otf/MathJax_Size2-Regular.otf
$(PERL) makePNG otf/MathJax_Size3-Regular.otf
$(PERL) makePNG otf/MathJax_Size4-Regular.otf
$(PERL) makePNG otf/MathJax_Fraktur-Regular.otf
$(PERL) makePNG otf/MathJax_Fraktur-Bold.otf
$(PERL) makePNG otf/MathJax_SansSerif-Regular.otf
$(PERL) makePNG otf/MathJax_SansSerif-Bold.otf
$(PERL) makePNG otf/MathJax_SansSerif-Italic.otf
$(PERL) makePNG otf/MathJax_Script-Regular.otf
$(PERL) makePNG otf/MathJax_Typewriter-Regular.otf

# $(PERL) makePNG ttf/MathJax_Greek-Bold.ttf
# $(PERL) makePNG ttf/MathJax_Greek-BoldItalic.ttf
# $(PERL) makePNG ttf/MathJax_Greek-Italic.ttf
# $(PERL) makePNG ttf/MathJax_Greek-Regular.ttf

range: TeX
# Makes the data files needed by the HTML-CSS output jax
# for ALL the MathJax image fonts
$(PERL) makeRanges MathJax_AMS-Regular
$(PERL) makeRanges MathJax_Caligraphic-Bold
$(PERL) makeRanges MathJax_Caligraphic-Regular
$(PERL) makeRanges MathJax_Main-Bold
$(PERL) makeRanges MathJax_Main-Italic
$(PERL) makeRanges MathJax_Main-Regular
$(PERL) makeRanges MathJax_Math-BoldItalic
$(PERL) makeRanges MathJax_Math-Italic
$(PERL) makeRanges MathJax_Size1-Regular
$(PERL) makeRanges MathJax_Size2-Regular
$(PERL) makeRanges MathJax_Size3-Regular
$(PERL) makeRanges MathJax_Size4-Regular
$(PERL) makeRanges MathJax_Fraktur-Regular
$(PERL) makeRanges MathJax_Fraktur-Bold
$(PERL) makeRanges MathJax_SansSerif-Regular
$(PERL) makeRanges MathJax_SansSerif-Bold
$(PERL) makeRanges MathJax_SansSerif-Italic
$(PERL) makeRanges MathJax_Script-Regular
$(PERL) makeRanges MathJax_Typewriter-Regular

# $(PERL) makeRanges MathJax_Greek-Bold
# $(PERL) makeRanges MathJax_Greek-BoldItalic
# $(PERL) makeRanges MathJax_Greek-Italic
# $(PERL) makeRanges MathJax_Greek-Regular

png: TeX

TeX/png/unpacked/imagedata.js:
$(PERL) makeData

data: TeX/png/unpacked/imagedata.js

install:
# Moves the image files to the proper location and
# removes the depth data files
@echo "Copying image data..."
@dir=$(MATHJAXDIR)/fonts/HTML-CSS/TeX; \
rm -rf $$dir/png; \
cp -r TeX/png $$dir; \
rm -f $$dir/png/*/*/depths.pl

clean:
rm -rf TeX
18 changes: 0 additions & 18 deletions fonts/IMG/TeX/makeAll

This file was deleted.

9 changes: 0 additions & 9 deletions fonts/IMG/TeX/makeInstall

This file was deleted.

12 changes: 7 additions & 5 deletions fonts/IMG/TeX/makePNG
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#
# Usage: ./makePNG font [sizes]

require "../../../custom.cfg.pl";

$font = shift;

if (!$font) {
Expand All @@ -22,7 +24,7 @@ sub MakeFontFiles {
Generate("MathJax.pfb","",0x10001);
EOF;
close(FF);
`fontforge -lang=ff -script MathJax.ff 2>/dev/null`;
`$FONTFORGE -lang=ff -script MathJax.ff 2>/dev/null`;
}

sub RemoveFontBlock {
Expand All @@ -36,7 +38,7 @@ sub RemoveFontBlock {
Generate("MathJax.pfb","",0x10001);
EOF;
close(FF);
`fontforge -lang=ff -script MathJax.ff 2>/dev/null`;
`$FONTFORGE -lang=ff -script MathJax.ff 2>/dev/null`;
}

sub GetUnicodePoints {
Expand All @@ -55,7 +57,7 @@ sub GetUnicodePoints {
open(FF,">MathJax.ff");
print FF join("\n",@name,"");
close(FF);
my $unicode = `fontforge -lang=ff -script MathJax.ff 2>/dev/null`;
my $unicode = `$FONTFORGE -lang=ff -script MathJax.ff 2>/dev/null`;
chomp($unicode);
return split(/\n/,$unicode);
}
Expand All @@ -79,12 +81,12 @@ sub MakeTeXfile {
\\end{document}
EOF;
close(TEX);
`latex MathJax`;
`$LATEX MathJax`;
}

sub MakePNGfiles {
my $size = shift;
$depths = `dvipng --gamma 1.5 -q -bgTransparent -D$size --depth -o PNG/%03d.png MathJax`;
$depths = `$DVIPNG --gamma 1.5 -q -bgTransparent -D$size --depth -o PNG/%03d.png MathJax`;
$depths =~ s/^[^\n]*\n//; $depths =~ s/\s//g; $depths =~ s/^depth=//;
my @depths = split(/depth=/,$depths);
while (my $unicode = shift) {$depth{$unicode}{$size} = shift(@depths)}
Expand Down
31 changes: 0 additions & 31 deletions fonts/IMG/TeX/makePNGsuite

This file was deleted.

30 changes: 0 additions & 30 deletions fonts/IMG/TeX/makeRangeSuite

This file was deleted.

4 changes: 3 additions & 1 deletion fonts/IMG/TeX/makeRanges
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
#
# Usage: ./makeRanges fontname

require "../../../custom.cfg.pl";

require "../../AFM/TeX/config.pl";
require "../../Tables/TeX/unicode.pl";

Expand Down Expand Up @@ -46,7 +48,7 @@ foreach $n (sort {$a <=> $b} (keys %depth)) {
}

print " WxH";
$lines = `file $dir/*/*.png`;
$lines = `$FILE $dir/*/*.png`;
foreach $file (split(/\n/,$lines)) {
if ($file =~ m!/(\d+)/([^/]*)\.png:.*, (\d+) x (\d+),!) {
$c = $HDW{"0x$2"}[$index{$1}];
Expand Down
Loading

0 comments on commit 14fbf2a

Please sign in to comment.