Giter Club home page Giter Club logo

katex-fonts's Introduction

How to generate KaTeX fonts and metrics

Originally based on MathJax font generation

Fonts

The buildFonts.sh script should do everything automatically, as long as Docker is installed.

If you want to try out a change to the katex-fonts repository, create a local clone (or download and unpack the ZIP file) and specify the path to this directory as an argument to buildFonts.sh. You can also specify a local or remote tarball, e.g. a GitHub download of your own personal feature branch.

The script buildFonts.sh automatically creates Docker images from the supplied Dockerfile. It uses the hash of the file to tag the image, so a change to the file will result in the creation of a new image. If you want to see all created images, run docker images katex/fonts. To remove all generated images, you can run docker rmi $(docker images --format '{{.Repository}}:{{.Tag}}' katex/fonts).

Metrics

The script buildMetrics.sh generates metrics (dimensions of each character) for the generated fonts. See detailed requirements for running this script.

If there is a problem, file a bug report.

katex-fonts's People

Contributors

blaiprat avatar edemaine avatar gagern avatar iamdanfox avatar kevinbarabash avatar mathiasbynens avatar sophiebits avatar sven-frotscher avatar xymostech avatar ylemkimon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

katex-fonts's Issues

Merging katex-fonts into the main KaTeX repo

Having the font generation code in the same repo would simplify the process for making font changes. One of the concerns in the past was that having the font files in the repo would bloat the repo. While this has been addressed in part by #54, I think we could take things even further by using Git LFS (Large File Support) for the binary font files.

https://git-lfs.github.com/

\notin missing metrics, \notin & \neq wrong glyph

As mentioned here, the \notin symbol (U+2209, 8713 in decimal) is missing font metrics. This seems to be an isolated instance, but maybe worth checking for other missing characters.

Once this is fixed, we should change the corresponding KaTeX test to check toBuild instead of toParse.

Generation of redundant bold glyphs?

During clean-up of font generation scripts, it was discovered that extra glyphs like \cdots and \longleftarrow for Main-Bold font were generated.

However, it seems that it's not used in the KaTeX, nor is it possible to access them.

Is it used anywhere? Or, will it be used in the future?

$extra{'Main-Bold'} = {
cdots => [
'Select(0u22C5)','Copy()',
'Select(0u22EF)','Paste()',
'PasteWithOffset(488,0)',
'PasteWithOffset(976,0)',
'SetRBearing(976,1)',
],
ldots => [
'Select(0u2E)','Copy()',
'Select(0u2026)','Paste()',
'PasteWithOffset(488,0)',
'PasteWithOffset(976,0)',
'SetRBearing(976,1)',
],
vdots => [
'Select(0u2E)','Copy()',
'Select(0u22EE)','Clear()',
'PasteWithOffset(0,-30)',
'PasteWithOffset(0,380)',
'PasteWithOffset(0,780)',
'SetRBearing(-681,1)',
],
ddots => [
'Select(0u2E)','Copy()',
'Select(0u22F1)','Clear()',
'PasteWithOffset(55,700)',
'PasteWithOffset(502,400)',
'PasteWithOffset(949,100)',
'SetRBearing(323,1)',
],
spaceEn => [
'Select(0u2002)',
'SetRBearing(500)',
],
spaceEm => [
'Select(0u2003)',
'SetRBearing(999)',
],
space3 => [
'Select(0u2004)',
'SetRBearing(333)',
],
space4 => [
'Select(0u2005)',
'SetRBearing(250)',
],
space6 => [
'Select(0u2006)',
'SetRBearing(167)',
],
thinspace => [
'Select(0u2009)',
'SetRBearing(167)',
],
hairspace => [
'Select(0u200A)',
'SetRBearing(83)',
],
cong => [
'Select(0u223C)','Copy()',
'Select(0u2245)','Clear()',
'PasteWithOffset(0,247)',
'Select(0u3D)','Copy()',
'Select(0u2245)',
'PasteWithOffset(0,-136)',
],
bowtie => [
'Select(0u25B9)','Copy()',
'Select(0u22C8)','Paste()',
'Select(0u25C3)','Copy()',
'Select(0u22C8)',
'PasteWithOffset(425,0)',
'SetRBearing(425,1)',
'RemoveOverlap()',
],
models => [
'Select(0u2223)','Copy()',
'Select(0u22A8)','Paste()',
'Select(0u3D)','Copy()',
'Select(0u22A8)',
'PasteWithOffset(89,0)',
'SetRBearing(655,1)',
'RemoveOverlap()',
],
doteq => [
'Select(0u3D)','Copy()',
'Select(0u2250)','Paste()',
'Select(0u2E)','Copy()',
'Select(0u2250)',
'PasteWithOffset(288,550)',
],
not => [
'Select(0u338)',
'SetRBearing(894,1)',
],
notin => [
'Select(0u2208)','Copy()',
'Select(0u2209)','Paste()',
'Select(0u338)','Copy()',
'Select(0u2209)',
# 'PasteWithOffset(-63,0)',
'PasteWithOffset(831,0)',
'RemoveOverlap()',
],
noteq => [
'Select(0u3D)','Copy()',
'Select(0u2260)','Paste()',
'Select(0u338)','Copy()',
'Select(0u2260)',
# 'PasteWithOffset(0,0)',
'PasteWithOffset(894,0)',
'RemoveOverlap()',
],
longleftarrow => [
'Select(0u2190)','Copy()',
'Select(0u27F5)','Paste()',
'Select(0u2212)','Copy()',
'Select(0u27F5)',
'PasteWithOffset(944,0)',
'SetRBearing(655,1)',
'RemoveOverlap()','Simplify()',
],
Longleftarrow => [
'Select(0u21D0)','Copy()',
'Select(0u27F8)','Paste()',
'Select(0u3D)','Copy()',
'Select(0u27F8)',
'PasteWithOffset(975,0)',
'SetRBearing(718,1)',
'RemoveOverlap()','Simplify()',
],
longrightarrow => [
'Select(0u2212)','Copy()',
'Select(0u27F6)','Paste()',
'Select(0u2192)','Copy()',
'Select(0u27F6)',
'PasteWithOffset(688,0)',
'SetRBearing(939,1)',
'RemoveOverlap()','Simplify()',
],
Longrightarrow => [
'Select(0u3D)','Copy()',
'Select(0u27F9)','Paste()',
'Select(0u21D2)','Copy()',
'Select(0u27F9)',
'PasteWithOffset(720,0)',
'SetRBearing(976,1)',
'RemoveOverlap()','Simplify()',
],
leftrightarrow => [
'Select(0u2190)','Copy()',
'Select(0u27F7)','Paste()',
'Select(0u2192)','Copy()',
'Select(0u27F7)',
'PasteWithOffset(976,0)',
'SetRBearing(976,1)',
'RemoveOverlap()','Simplify()',
],
Leftrightarrow => [
'Select(0u21D0)','Copy()',
'Select(0u27FA)','Paste()',
'Select(0u21D2)','Copy()',
'Select(0u27FA)',
'PasteWithOffset(976,0)',
'SetRBearing(976,1)',
'RemoveOverlap()','Simplify()',
],
mapsto => [
'Select(0u2192)','Copy()',
'Select(0u21A6)','Paste()',
'Generate("otf/KaTeX_Main-Bold.otf")',
'Open("pfa/cmbsy10.pfa")',
'Select(0x37)','Copy()',
'Open("otf/KaTeX_Main-Bold.otf")',
'Select(0u21A6)',
'PasteWithOffset(0,0)',
'RemoveOverlap()','Simplify()',
],
xlongmapsto => [
'Select(0u27F6)','Copy()',
'Select(0u27FC)','Paste()',
'Generate("otf/KaTeX_Main-Bold.otf")',
'Open("pfa/cmbsy10.pfa")',
'Select(0x37)','Copy()',
'Open("otf/KaTeX_Main-Bold.otf")',
'Select(0u27FC)',
'PasteWithOffset(0,0)',
'RemoveOverlap()','Simplify()',
],
hookleftarrow => [
'Select(0u2190)','Copy()',
'Select(0u21A9)','Paste()',
'Generate("otf/KaTeX_Main-Bold.otf")',
'Open("pfa/cmmib10.pfa")',
'Select(0x2D)','Copy()',
'Open("otf/KaTeX_Main-Bold.otf")',
'Select(0u21A9)',
'PasteWithOffset(965,0)',
'SetRBearing(132,1)',
'RemoveOverlap()','Simplify()',
],
hookrightarrow => [
'Generate("otf/KaTeX_Main-Bold.otf")',
'Open("pfa/cmmib10.pfa")',
'Select(0x2C)','Copy()',
'Open("otf/KaTeX_Main-Bold.otf")',
'Select(0u21AA)','Paste()',
'Select(0u2192)','Copy()',
'Select(0u21AA)',
'PasteWithOffset(132,0)',
'SetRBearing(963,1)',
'RemoveOverlap()','Simplify()',
],
rightleftharpoons => [
'Select(0u21BD)','Copy()',
'Select(0u21CC)','Paste()',
'Select(0u21C0)','Copy()',
'Select(0u21CC)',
'PasteWithOffset(0,200)',
'RemoveOverlap()','Simplify()',
],
hbar => [
'Select(0u2C9)','Copy()',
'Select(0u210F)','PasteWithOffset(0,0)',
'RemoveOverlap()','Simplify()',
],
angle => [
'Select(0u2220)','Copy()',
'PasteWithOffset(0,10)',
'PasteWithOffset(0,20)',
'RemoveOverlap()','Simplify()',
'PasteWithOffset(10,0)',
'RemoveOverlap()','Simplify()',
],
diacriticals => [
'Select(0uB0)', 'SetRBearing(-147,1)', # \degree
'Select(0u20D7)','SetRBearing(154,1)', # \vec
],
};

CC @kevinbarabash @edemaine

Add lowercase script and/or lowercase calligraphic letters

Reason: I need to support all characters from https://www.w3.org/2003/entities which includes lower case script letters. As lower case script letters are seldom used, numerical references to Unicode codepoints would suffice [UPDATE: see my next comment], but: due to issue KaTeX/KaTeX#2226 lower case script letters cannot be used this way. If that issue cannot be resolved, it would be nice to have the KaTeX fonts include lower case script letters.

for which katex functions are these fonts used?

We use Katex in Joplin, but run into rendering issues now and again. Most likely because we haven't added all fonts. Laurent is reluctant to add all fonts without knowing what they are actually used for.

Is there a list or matrix of why these fonts are used and what for?

I checked the contributing doc, but there's no reference to a help forum or something else.
So I hope it's ok to ask a question here.

Add italic capital Greek letters

AMS defines these macros for italic capital Greek letters:

\varGamma
\varDelta
\varTheta
\varLambda
\varXi
\varPi
\varSigma
\varUpsilon
\varPhi
\varPsi
\varOmega

These are the remaining characters (I believe) needed for KaTeX/KaTeX#130

Document the workflow

Prompted by a conversation under KaTeX/KaTeX#2284:

  • Which files should be edited prior to running buildFonts.sh?
  • Where are the TeX files which src/fonts/makeFF supposedly uses?
    • Alternatively: What should they contain and where should they be placed?

README.md and CONTRIBUTING.md don't make that clear.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.