Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix all AMS mathord symbols #618

Merged
merged 11 commits into from
Jan 16, 2017
Merged

Fix all AMS mathord symbols #618

merged 11 commits into from
Jan 16, 2017

Conversation

edemaine
Copy link
Member

@edemaine edemaine commented Jan 10, 2017

Here is a fix for #600 (and #609 and #512 and #374). In fact, all AMS textord symbols were similarly broken. Here is a complete list of symbols fixed by this PR:

\hslash, \triangledown, \lozenge, \circledS, \circledR, \measuredangle, \nexists, \mho, \Finv, \Game, \Bbbk, \backprime, \blacktriangle, \blacktriangledown, \blacksquare, \blacklozenge, \bigstar, \sphericalangle, \complement, \eth, \diagup, \diagdown, \square, \Box, \Diamond, \yen, \checkmark, \beth, \daleth, \gimel, \digamma, \varkappa, \varnothing, \maltese

Basically, in buildCommon.js, mathsym had logic for choosing between font families Main-Regular and AMS-Regular, but this applies to types rel, bin, open, close, inner, punct only. makeOrd is used specifically for mathord and textord, and needed similar logic. To complicate things, makeOrd was also losing track of the original macro name and thus AMS vs. Main, replacing it with the unicode symbol. So I had to refactor code a bit so that mathDefault could figure it out.

@kevinbarabash
Copy link
Member

@edemaine thanks for the PR. How did you determine the list of broken chars? Is it just all mathords?

@edemaine
Copy link
Member Author

It is all symbols in symbols.js of font "ams" and type "textord".

@edemaine edemaine mentioned this pull request Jan 12, 2017
utils.contains(mainitLetters, value)) {
// For greek capitals, we have a choice, but Math-Italic
// seems closer to LaTeX.
//|| utils.contains(greekCapitals, value)) {
Copy link
Member

@kevinbarabash kevinbarabash Jan 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this code supposed to be commented out?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I meant to ask you about this. Yes, it seems so:

Greek capital letters are in both fonts, Main-Italic and Math-Italic. So which should we use? The master code claims to use Main-Italic for Greek capital letters. But if you try the demo with \mathit{\Omega\imath}, and inspect, you'll see that the \Omega gets class mathit while \imath gets mainit:

<span class="mord mathit" style="margin-right: 0.05017em;">Ω</span>
<span class="mord mainit">ı</span>

In fact, the master code ends up calling mathit() with a single-unicode-character string (Ω), while greekCapitals is defined in terms of the macro name ("\Omega"). When my code fixed this, I ended up changing Greek capital letters to use Main-Italic font, which caused some tests to fail. I confirmed with texcmp that Math-Italic seems slightly closer, so kept it there.

Let me know if you'd like this code changed at all...

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, can you remove the commented out code? TBH, I'm not sure why we have the same glyphs duplicated in different fonts. It would be nice if we could avoid this and save a few bytes. I'm curious to find out why the rendering looks different even though the glyphs are the same. Maybe the advance or skew metrics for the Greek capitals are differ between fonts. I think it's safe to investigate this separate from this pull request.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I remove the list of greekCapitals as well? It's currently commented out (to prevent lint from complaining).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes please.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

return {
fontName: "Math-Italic",
fontClass: "mathit"
};
}
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you update the doc string for mathit now that it no longer creates a symbol?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed, thanks!

@kevinbarabash
Copy link
Member

@edemaine a few minor nits and this'll be ready to merge. Thanks for fixing all of these symbols.

@edemaine
Copy link
Member Author

Cool! I just merged with master and moved to ES2016 style.

@kevinbarabash
Copy link
Member

@edemaine thanks for cleaning up the commented out code. ^_^

@edemaine
Copy link
Member Author

No problem! Now you should be able to close #600, #609, #512, and #374!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants