source-code-pro icon indicating copy to clipboard operation
source-code-pro copied to clipboard

Mathematical operators and symbols support

Open k0001 opened this issue 12 years ago • 26 comments

Modern markup languages such as MathML, or programming languages such as Agda, Haskell and Scala can make extensive use of the Greek alphabet and mathematical symbols. Users of these languages could benefit from Source Code Pro if these characters were supported. In particular Agda and MathML make the most extensive use of Unicode, by design.

Issue #48 already requests Greek alphabet support.

Here are some quite comprehensive list of mathematical symbols:

  • MathML 2.0: Characters, Entities and Fonts (W3C): http://www.w3.org/TR/MathML2/chapter6.html
  • Unicode Entity Codes for Math (PSU): http://archive.tlt.psu.edu/suggestions/international/bylanguage/mathchart.html
  • Mathematical operators and symbols in Unicode (Wikipedia): http://en.wikipedia.org/wiki/Mathematical_operators_and_symbols_in_Unicode

Here are some code snippets and blog posts making use of this feature:

  • http://www.w3.org/TR/MathML2/chapter6.html
  • http://code.haskell.org/Agda/examples/SimpleTypes.agda
  • http://code.haskell.org/Agda/examples/Introduction/Unicode.agda
  • http://scalaz.github.com/scalaz/scalaz-2.9.0-1-6.0.1/doc.sxr/scalaz/MA.scala.html
  • http://conal.net/blog/posts/a-third-view-on-trees

k0001 avatar Feb 04 '13 22:02 k0001

I'd like to add that fonts such as DejaVu Sans Mono or FreeMono already support a wide variety of such mathematical symbols, operators, and letters.

k0001 avatar Feb 04 '13 22:02 k0001

I am planning on adding Greek at some point, but I had no plans to add these. I would definitely need some help creating all of these.

pauldhunt avatar Feb 04 '13 22:02 pauldhunt

Greek support will be excellent.

Certainly, this is hard work. In any case, maybe it can be helpful to start by prioritizing some of these symbols according to how often they are used, so I'll try that:

In this list http://archive.tlt.psu.edu/suggestions/international/bylanguage/mathchart.html#set I've often came across symbols in these categories:

  • Letter Symbols
  • Logic & Set Theory
  • Common Statistics
  • Common Symbols
  • Calculus
  • Geometric Symbols (Tacks)
  • Logical Proofs
  • Common Equivalence Operators
  • Other mathematical symbols (∓ ∗ ∘ ∙ ∶ ∷ ≔ ≟ ≺ ≻ ⊓ ⊔ ⊕ ⊖ ⊗ ⊙ ⊛ ⊝ ⋅)

k0001 avatar Feb 05 '13 01:02 k0001

Can you give Unicode ranges/code points for these?

pauldhunt avatar Feb 05 '13 02:02 pauldhunt

Yes. Thanks for asking that.

It seems that the most common mathematical symbols are, unsurprisingly, in the Mathematical Operators block: U+2200–U+22FF.

There are some letter-like symbols, however, that fall outside that block:

  • ℵ → U+2135
  • ℘ → U+2118
  • ℑ → U+2111
  • ℜ → U+211C
  • ℝ → U+211D
  • ℂ → U+2102
  • ℕ → U+2115
  • ℙ → U+2119
  • ℚ → U+211A
  • ℤ → U+2124

k0001 avatar Feb 05 '13 03:02 k0001

Specifically for the Scala programming language, the rightwards double arrow (U+21D2 ⇒) is part of the language specification, so it would be awesome to have it. The leftwards single arrow (U+2190 ←) is already in the font and looks great!

jfim avatar Jan 02 '14 21:01 jfim

@jfim that’s easy, i’ll sneak that in there.

pauldhunt avatar Jan 06 '14 22:01 pauldhunt

Sweet, can't wait to get rid of the horrid fallback font arrows! :)

jfim avatar Jan 06 '14 23:01 jfim

@pauldhunt Hooray! Mono fonts always seem to have ←/→ but never ⇐/⇒. (Haskell uses ⇒ with the UnicodeSyntax option as well, fwiw.) So a font that actually has them would be a nice change. :)

andy-morris avatar Jan 16 '14 15:01 andy-morris

The Hasklig font has some arrows that could be checked-in upstream.

adrientetar avatar Aug 14 '14 13:08 adrientetar

The Powerline glyphs may be a good addition since there's an open request (#43). The other glyphs not so much because the set of arrows is very incomplete.

miguelsousa avatar Aug 14 '14 17:08 miguelsousa

Any progress on this? (Especially ∷ ⇒ →)

valpackett avatar Feb 19 '15 17:02 valpackett

I am actively working on the next revision of the SCP fonts and plan to add these characters. the single arrow is already in the font, so you’re jus looking for the double stroked arrow and the proportion symbol (u+2237)? is that correct?

pauldhunt avatar Feb 20 '15 01:02 pauldhunt

If you wouldn't mind adding ∀ and ∃ too, that'd be even better. But at least a mono font with a non-ugly ⇒ would be great.

(btw: Hasklig doesn't play nice with GUI vims because it lays out the characters on a grid.)

andy-morris avatar Feb 20 '15 01:02 andy-morris

I’ve gone and added u+21D2, u+2200, u+2203, u+2237 to the design masters and these will make it into the next version of the released upright fonts.

pauldhunt avatar Feb 20 '15 02:02 pauldhunt

Is there is any way to add Greek symbols like λ (lambda), θ (theta), σ (Sigma) and ι(iota). This would be of great help.

deepankarpathak avatar Jun 05 '15 12:06 deepankarpathak

@deepankarpathak You might want to watch #94.

yurikhan avatar Jun 05 '15 12:06 yurikhan

All the Greek letters (except for polytonic) will be in the upright fonts of the upcoming release.

pauldhunt avatar Jun 05 '15 14:06 pauldhunt

+1 I use the julia repl and I cannot see certain symbols since they are not available to source code pro. Would love to use source code pro but certain math symbols are simply not there. E.g. compare (right, dejavu sans mono, left source code pro)

symbols compare

musm avatar Aug 24 '15 21:08 musm

@mmoh please list the Unicode values or enumerate the characters here for the missing characters so that I can get this into an upcoming release.

pauldhunt avatar Aug 24 '15 21:08 pauldhunt

The missing characters in the screenshot are:

  • ∈ (U+2208)
  • ∉ (U+2209)
  • ∋ (U+220B)
  • ∌ (U+220C)
  • ∛ (U+221B)
  • ≢ (U+2262)
  • ⊆ (U+2286)
  • ⊈ (U+2288)
  • ⊊ (U+228A)

If you do add these, may I request also ⊂ (U+2282) and the superset signs (U+2283,5,7,9)?

andy-morris avatar Aug 24 '15 21:08 andy-morris

Thanks @andy-morris here is also a larger list that would be useful to include: http://julia.readthedocs.org/en/latest/manual/unicode-input/

musm avatar Aug 24 '15 21:08 musm

Are there any plans to add some more math symbols? The number of the most used ones is not that big:

  • ∈/∉ (U+2208 and U+2209)
  • ∘ (U+2218)
  • ∧/∨ (U+2227 and U+2228)
  • ∩/∪ (U+2229 and U+222A) — for some reason the former is already supported while the latter is not
  • ⊢/⊨ (U+22A2 and U+22A8)
  • ⊤/⊥(U+22A4 and U+22A5)
  • ↵ (U+21B5) is used by some editors to point the end of line

Most of these symbols also seem to be pretty easy to draw.

loskutov avatar Apr 21 '16 13:04 loskutov

I am open to adding more mathematical symbols, but this is low on my priority list unless given some compelling reason to include them particular symbols. Because of the sheer number of symbols that are used in mathematics, it would be instructive to understand how useful particular definite sets would be. For example, the addition of u+2229 came about when I wanted to add support for a historical standard font scheme, the Windows Glyph List 4. Having clearly delimited sets like this with a clear intended purpose makes it easier to prioritize the addition of more mathematical symbols that otherwise seem very arbitrary.

pauldhunt avatar Apr 21 '16 14:04 pauldhunt

These symbols are used in base-unicode-symbols Haskell package as well as in ScalaZ, a popular library for the Scala programming language, so their addition would make it much less painful to view and edit the code written in these languages. (As was previously stated, Agda makes even more extensive use of Unicode, so these symbols are used in it as well)

The following symbols provided by the UnicodeSyntax Haskell extension are lacking:

Character Code point Unicode name
U+2605 BLACK STAR
U+2919 LEFTWARDS ARROW-TAIL
U+291A RIGHTWARDS ARROW-TAIL
U+291B LEFTWARDS DOUBLE ARROW-TAIL
U+291C RIGHTWARDS DOUBLE ARROW-TAIL

The following symbols used in Prelude.Unicode Haskell module are lacking:

Character Code point Unicode name
U+2124 DOUBLE-STRUCK CAPITAL Z
U+211A DOUBLE-STRUCK CAPITAL Q
U+2208 ELEMENT OF
U+2209 NOT AN ELEMENT OF
U+2218 RING OPERATOR
U+2227 LOGICAL AND
U+2228 LOGICAL OR
U+2260 NOT EQUAL TO
U+2261 IDENTICAL TO
U+2262 NOT IDENTICAL TO
U+226E NOT LESS-THAN
U+226F NOT GREATER-THAN
U+22A5 UP TACK
U+22C5 DOT OPERATOR
U+29FA DOUBLE PLUS

The following symbols used in other modules of the same package are lacking:

Character Code point Unicode name
U+2042 ASTERISM
U+2205 EMPTY SET
U+2206 INCREMENT
U+220B CONTAINS AS MEMBER
U+220C DOES NOT CONTAIN AS MEMBER
U+2216 SET MINUS
U+222A UNION
U+226A MUCH LESS-THAN
U+226B MUCH GREATER-THAN
U+2295 CIRCLED PLUS
U+229B CIRCLED ASTERISK OPERATOR
U+22D8 VERY MUCH LESS-THAN
U+22D9 VERY MUCH GREATER-THAN
U+29FB TRIPLE PLUS
U+2AF4 TRIPLE VERTICAL BAR BINARY RELATION

Also, many of these characters are required for APL (issue #114).

  • https://hackage.haskell.org/package/base-unicode-symbols/ contains a Haskell package for Unicode support, Prelude.Unicode is probably the most important module inside it.
  • https://gist.github.com/folone/6089236 — Table of unicode operators in scalaz 6.0.x

loskutov avatar Apr 21 '16 15:04 loskutov

The ≡ (U+2261) character from one of @loskutov's lists is needed by posh-git. Although this is in the 2.030R-ro/1.050R-it release.

marckassay avatar Sep 21 '18 13:09 marckassay