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

unicode exponents for display #297

Merged
merged 3 commits into from
Feb 8, 2020
Merged

Conversation

briochemc
Copy link
Contributor

Suggestion for #18 to use for displaying fractional dimensions.

FYI, I used SIUnits' superscript combined with unicode character (Canadian Syllabics Final Acute '\u141F'), which looks like a superscript / for fractions.

It looks like

julia> 3u"m^4/s^(1//2)"
3 m⁴ s⁻¹ᐟ²

and I think/hope this is good enough?

@ajkeller34
Copy link
Collaborator

Great find, it looks perfect on my Mac. Unfortunately on Windows, the default console does not seem to display the character. If I launch Julia from the console that Git Bash runs in, the character displays and the fraction is readable, but it doesn't look as nice as one would hope.

This is so slick I'm tempted to merge it anyway, but my better judgment says that it is worth thinking about this a bit. I wonder if the best thing to do for now is display the old way on Windows?

@briochemc
Copy link
Contributor Author

Ah yes I'm sorry I tested only on my mac (and by "tested" I mean just tried it out, as you can see the failed CI tests 😅).

I found the character in this SO question, which suggests two other characters. First is Right Raised Omission Bracket '\u2E0D', which does not look as nice on my mac. But maybe it looks good on Windows and that would work? The other character suggested, Musical Symbol Repeated Figure-1, does not display on my mac at all.

@ajkeller34
Copy link
Collaborator

It's a similar situation for the other suggested character on Windows. Anyone able to chime in regarding appearance on Linux systems?

@briochemc
Copy link
Contributor Author

What about having an environment variable or some other flag mechanism to toggle either of the display options?

My guess is that the actual display of unicode characters is not exactly an OS issue but rather a question of which fonts are installed on that OS, right? Having a toggle/flag for swithcing would be good enough IMHO :) (Even better would be to detect if the characters are displayed somehow)

@ajkeller34
Copy link
Collaborator

I am not sure how much of it is only a font issue. The default Windows console may be part of the problem.

An environment variable would work. Kind of wordy, but maybe UNITFUL_UNICODE_DISPLAY? It should probably default to true for macOS and false for Windows, still not sure about Linux or FreeBSD for that matter.

@briochemc
Copy link
Contributor Author

briochemc commented Jan 23, 2020

I asked on slack (mentioned you but not sure you saw) and Mark Kittisopikul uploaded this screenshot which suggests it should work for Ubuntu users :)

image

@giordano
Copy link
Collaborator

This is how it looks like on my system (Arch Linux):
image
Not great

@briochemc
Copy link
Contributor Author

@giordano Could you check the other characters?

@ajkeller34
Copy link
Collaborator

I think it makes sense to default to this on macOS and otherwise have it be opt-in using an environment variable. It's legible on all of the default themes in Terminal (2/10 themes look a little funny but still pretty decent), and seems legible with default iTerm2 settings as well. There's probably a fair bit of variation across other operating systems.

Suggestion for PainterQubits#18 to use ᐟ for displaying fractional dimensions.
I just used SIUnits' `superscript` function for digits 0–9 and minus sign, and a unicode character that looks like a superscript `/` for fractions.
@codecov-io
Copy link

Codecov Report

Merging #297 into master will increase coverage by 0.11%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #297      +/-   ##
==========================================
+ Coverage   81.28%   81.39%   +0.11%     
==========================================
  Files          15       15              
  Lines        1122     1129       +7     
==========================================
+ Hits          912      919       +7     
  Misses        210      210
Impacted Files Coverage Δ
src/display.jl 96.07% <100%> (+0.62%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d147b0b...127f227. Read the comment docs.

@ajkeller34 ajkeller34 merged commit f9c5476 into PainterQubits:master Feb 8, 2020
@ajkeller34
Copy link
Collaborator

I rebased onto master and did some force pushing, sorry for the noise. The environment variable UNITFUL_FANCY_EXPONENTS is annoying to type but presumably people won't be changing it all the time. Since nobody objected to the proposed behavior, I'll go ahead and merge this.

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

Successfully merging this pull request may close these issues.

4 participants