Summary
We'd like contributors to use the same linter and lint rules that we use
internally. This diff swaps out eslint for jshint and fixes all lint failures
except for the max-len failures in the test suites.
Test Plan:
- ka-lint src
- make lint
- make test
Reviewers: emily
Summary:
The ability to use pre-determined character widths will benefit alternative
layout engines such as gagern's canvas layout engine. I would also like to
experiment would using CSS transforms to absolutely position each glyph. This
diff adds a new make rule, make extended_metrics, which generates metrics that
also containing glyph widths.
Test Plan:
- run `make extended_metrics`
- verify that fontMetricsData.js contains entries with 5 numbers instead of 4
Reviewers: emily alpert
The dependencies of fonttools are much lighter than fontforge, and since all
we need are some metrics, fonttools is very much up to that task.
This addresses issue #288.
We had some duplicate mappings in mappings to start with. Now we have some
code to complain loudly about these, and all currently existing duplicates
have been dealt with.
We also had a problem where in some Python dict, existing stuff was using
strings as keys while new data would use numeric indices, thus not
overwriting the previous value. Now we always use strings as keys.
Along the road, the italic dotless i and j symbols were changed
so that they now are taken from cmmi10 instead of cmti10.
This will make reviewing modifications easier, since the affected glyphs
will be more readily visible in the diff.
The formatting tool was applied to the existing data, instead of
regenerating the data, so the semantic content should be unmodified.
This separates auto-generated code from manually created code.
We need a more recent version of browserify to directly require JSON.
Note that the data was copied, not recreated, so it has not been changed.
This addresses issue #301.
Summary:
- Some of the symbols were of the wrong type (I wrote some scripts to
search the TeX source for the correct types for the symbols; I should
put these somewhere for future reference)
- Some of the symbols had the incorrect unicode replacement value. I
copied what MathJax used for the ones that were wrong. In one case,
something had the wrong font, so I used the one MathJax used.
- Some symbols were duplicates of existing symbols, those were removed.
- Some symbols are text symbols that aren't usable in math mode (maybe
they should be text symbols?) (`\aa`, `\AA`, etc.)
- Some symbols didn't seem to work/I couldn't figure out how to make
them work. For example, `\imath` and `\jmath` require an italic font
in KaTeX_Main, but we don't have the ability to do that yet. `\dots`
was removed because it's not an ordinary symbol. `\*vert` were
removed because I don't understand what they're for, nor what they
should look like.
- Some symbols weren't actually in the KaTeX fonts; to make sure they
don't fall back to something weird, I removed them. (`\S`, `\pounds`,
etc.)
Test plan:
- `make test`
- See that all of the symbols in: `\equiv \prec \succ \sim \perp
\preceq \succeq \simeq \mid \ll \gg \asymp \parallel \bowtie \smile
\sqsubseteq \sqsupseteq \doteq \frown \ni \propto \vdash \dashv \owns
\ldotp \cdotp \aleph \forall \hbar \exists \nabla \flat \ell \natural
\clubsuit \wp \sharp \diamondsuit \Re \heartsuit \Im \spadesuit
\rmoustache \lmoustache \rgroup \lgroup \mp \ominus \uplus \sqcap
\ast \sqcup \bigcirc \bullet \ddagger \wr \amalg \longleftarrow
\Leftarrow \Longleftarrow \longrightarrow \Rightarrow \Longrightarrow
\leftrightarrow \longleftrightarrow \Leftrightarrow
\Longleftrightarrow \mapsto \longmapsto \nearrow \hookleftarrow
\hookrightarrow \searrow \leftharpoonup \rightharpoonup \swarrow
\leftharpoondown \rightharpoondown \nwarrow \rightleftharpoons \nless
\nleqslant \nleqq \lneq \lneqq \lvertneqq \lnsim \lnapprox \nprec
\npreceq \precnsim \precnapprox \nsim \nshortmid \nmid \nvdash
\nvDash \ntriangleleft \ntrianglelefteq \subsetneq \varsubsetneq
\subsetneqq \varsubsetneqq \ngtr \ngeqslant \ngeqq \gneq \gneqq
\gvertneqq \gnsim \gnapprox \nsucc \nsucceq \succnsim \succnapprox
\ncong \nshortparallel \nparallel \nVDash \ntriangleright
\ntrianglerighteq \nsupseteqq \supsetneq \varsupsetneq \supsetneqq
\varsupsetneqq \nVdash \precneqq \succneqq \nsubseteqq \unlhd \unrhd
\nleftarrow \nrightarrow \nLeftarrow \nRightarrow \nleftrightarrow
\nLeftrightarrow \vartriangle \hslash \triangledown \lozenge
\circledS \measuredangle \nexists \mho \Finv \Game \Bbbk \backprime
\blacktriangle \blacktriangledown \blacksquare \blacklozenge \bigstar
\sphericalangle \complement \eth \diagup \diagdown \square \Box
\Diamond \beth \daleth \gimel \digamma \varkappa \ulcorner \urcorner
\llcorner \lrcorner \leqq \leqslant \eqslantless \lesssim \lessapprox
\approxeq \lessdot \lll \lessgtr \lesseqgtr \lesseqqgtr \doteqdot
\risingdotseq \fallingdotseq \backsim \backsimeq \subseteqq \Subset
\sqsubset \preccurlyeq \curlyeqprec \precsim \precapprox
\vartriangleleft \trianglelefteq \vDash \Vvdash \smallsmile
\smallfrown \bumpeq \Bumpeq \geqq \geqslant \eqslantgtr \gtrsim
\gtrapprox \gtrdot \ggg \gtrless \gtreqless \gtreqqless \eqcirc
\circeq \triangleq \thicksim \thickapprox \supseteqq \Supset
\sqsupset \succcurlyeq \curlyeqsucc \succsim \succapprox
\vartriangleright \trianglerighteq \Vdash \shortmid \shortparallel
\between \pitchfork \varpropto \blacktriangleleft \therefore
\backepsilon \blacktriangleright \because \llless \gggtr \lhd \rhd
\eqsim \Join \Doteq \dotplus \smallsetminus \Cap \Cup \doublebarwedge
\boxminus \boxplus \divideontimes \ltimes \rtimes \leftthreetimes
\rightthreetimes \curlywedge \curlyvee \circleddash \circledast
\centerdot \intercal \doublecap \doublecup \boxtimes \dashrightarrow
\dashleftarrow \leftleftarrows \leftrightarrows \Lleftarrow
\twoheadleftarrow \leftarrowtail \looparrowleft \leftrightharpoons
\curvearrowleft \circlearrowleft \Lsh \upuparrows \upharpoonleft
\downharpoonleft \multimap \leftrightsquigarrow \rightrightarrows
\rightleftarrows \twoheadrightarrow \rightarrowtail \looparrowright
\curvearrowright \circlearrowright \Rsh \downdownarrows
\upharpoonright \downharpoonright \rightsquigarrow \leadsto
\Rrightarrow \restriction \yen \dag \ddag` look the same as they do
in LaTeX and don't print any warnings about unknown font metrics.
Auditors: alpert
Summary:
Add the ability to base the metrics for a TTF character on the metrics
from one of the TFM characters.
Test Plan:
- Make sure the tests still work
- Make sure huxley tests didn't change
Reviewers: alpert
Reviewed By: alpert
Differential Revision: http://phabricator.khanacademy.org/D13217
Summary:
Add support for math-mode accents. This involves a couple changes.
First, in order to correctly position the accents, we must know the kern between
every character and the "skewchar" in that font. To do this, we improve our tfm
parser to run the mini-kern-language and calculate kerns. We then export these
into fontMetrics.js.
Then, we add normal support for accents. In particular, we do some special
handling for supsubs around accents. This involves building the supsub
separately without the accent, and then replacing its base with the built
accent.
Finally, the character in the fonts for the \vec command is a combining unicode
character, so it is shifted to the left, but none of the other characters do
this. We add some special handling for \vec to account for this.
Fixes#7
Test Plan:
- Make sure tests pass
- Make sure no huxley screenshots changed, and the new one looks good
Reviewers: alpert
Reviewed By: alpert
Differential Revision: http://phabricator.khanacademy.org/D13157
Summary:
The `\dots` and `\dots{c,o,b,i,m}` commands do more than just show characters,
they add extra space and `\dots` also looks ahead to determine what kind of
environment it is in (see [this math.sx post]
(http://tex.stackexchange.com/questions/122491/difference-of-the-dots)). We
can't support that yet, so remove them.
Also, add comments to the extract_ttf script to show what caracters we are
extracting metrics for.
Test Plan: - Make sure tests work
Reviewers: alpert
Reviewed By: alpert
Differential Revision: http://phabricator.khanacademy.org/D13151
Summary:
Upon switching over from ttf metrics to TeX metrics, we lost metrics for a
couple of the characters that are dynamically generated by TeX. Thus TeX doesn't
have metrics for them, but our fonts do have the characters because the MathJax
scripts also dynamically build them. This adds the ability to extract metrics
from the generated font files so that we can use the generated characters
correctly. A better solution would be to dynamically generate the characters
ourselves, but that is much harder, and will be left to a future time.
Test Plan:
- Make sure typing "\neq \cong \text{ }" produces no warnings in the console.
- Make sure huxley screenshots look the same
Reviewers: alpert
Reviewed By: alpert
Differential Revision: http://phabricator.khanacademy.org/D13107
Summary:
Added stacked delimiter support for more delimiters. Split out delimiter
functions into its own file, and split out some tree building functions into a
common file. Supports the empty `.` delimiter with \left and \right, and doesn't
try to produce huge /, \backslash, <, or > delimiters. Depends on D7844
Test input:
\left( \left) \left[ \left\lbrack \left] \left\rbrack \left\{ \left\lbrace
\left\} \left\rbrace \left\lfloor \left\rfloor \left\lceil \left\rceil
\left\langle \left\rangle \left/ \left\backslash \left| \left\vert \left\|
\left\Vert \left\uparrow \left\Uparrow \left\downarrow \left\Downarrow
\left\updownarrow \left\Updownarrow {x^{x^{x^{x^{x^{x^{x^{x^{x^{x^x}}}}}}}}}}
\right.\right.\right.\right.\right.\right.\right.\right.\right.\right.
\right.\right.\right.\right.\right.\right.\right.\right.\right.\right.
\right.\right.\right.\right.\right.\right.\right.\right.
Test Plan:
- Run the test input, see that it works
- Run the tests, see that they work
- Look at huxley screenshots (not here yet :( ) and make sure they look good
Reviewers: alpert
Reviewed By: alpert
Differential Revision: http://phabricator.khanacademy.org/D11602
Summary:
Instead of using the metrics from our generated TTF files, use the fonts that
TeX ships with. Pull the mapping out of the MathJax-dev repo from makeFF to get
the correct mapping of metrics to font characters, and use our own tfm reader to
extract metrics out of the tfm files into a useable format. Add a README and
Makefile rule to make this process easier in the future.
Also remove the silly 0.05em we put on supsubs because our italic correction
works now.
Test Plan:
- Run huxley tests, see that changes are because of font metric changes.
- See that the extension piece of `\bigl |` now extends above the top, as it is
supposed to.
Reviewers: alpert
Reviewed By: alpert
Differential Revision: http://phabricator.khanacademy.org/D12867
Summary:
Fixes T1325.
This has the advantage of not having to do the mapping manually. Also it means that characters like \neq are included in the mapping, so this resolves T1323 as well.
I opted to group the metrics by character instead of by metric type because I think it'll gzip better and it makes getCharacterMetrics simpler anyway.
Test Plan: The test page looks identical to the pixel to my eye.
Reviewers: emily
Reviewed By: emily
Maniphest Tasks: T1323, T1325
Differential Revision: http://phabricator.khanacademy.org/D3535
Summary: Add margin to the right of characters that have italic correction.
Test Plan:
Look at `f'` and `C'` before and after. Note that they both now look
good at small font sizes (like 17pt).
Reviewers: alpert
Reviewed By: alpert
Differential Revision: http://phabricator.khanacademy.org/D3534
Summary:
This diff does a couple different things:
- There is now a metrics/ folder, which contains the property files describing
the metrics if the fonts, as well as a script for reading and printing the
metrics in javascript.
- Fractions and superscripts/subscripts are now rendered in slightly different
ways now (notably, no use of inline-table). This allows for much more precise
positioning of the superscripts, subscripts, numerators, and denominators,
while still having an appropriate baseline. Also, there is no longer a
sup/sub/supsub distinction, there are only supsubs with null sup/sub.
- Using the new font metrics and by implementing the formulas found in The TeX
Book, Appendix G, the heights and depths of all of the sub-expressions in a
formula are now calculated. These are currently used to:
- Correctly position superscripts, subscripts, numerators, and denominators
- Adjust the height and depth of the overall expression so it takes up the
appropriate space
- Because we have to add attributes (height and depth) to every attribute, I
have changed the way DOM nodes are assembled. Now, instead of assembling the
DOM elements inline (which is a problem because we need to track
height/depth, and we shouldn't (and can't in IE 8) attach raw attributes to DOM
nodes), we assemble a pseudo-DOM structure with the extra information, and
then actually assemble it at the very end.
The main page also now has an updated expression to show off and test the new
and improved parsing.
Test Plan:
View the main page, make sure that the expression renders. Make sure
that the tests pass. Make sure that expressions have the correct calculated
height (this is most easily tested by viewing them on the main page and making
sure that the top of the expression lines up with the bottom of the input box).
Reviewers: alpert
Reviewed By: alpert
Differential Revision: http://phabricator.khanacademy.org/D3442