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

Independent font setting for notebook output #123149

Closed
DonJayamanne opened this issue May 6, 2021 · 14 comments · Fixed by #147321
Closed

Independent font setting for notebook output #123149

DonJayamanne opened this issue May 6, 2021 · 14 comments · Fixed by #147321
Assignees
Labels
feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders notebook-output verification-needed Verification of issue is requested verified Verification succeeded
Milestone

Comments

@DonJayamanne
Copy link
Contributor

@chungmoklee commented on Wed May 05 2021

As far as know, there is no separate setting for notebook output font setting now.
(Correct me if I am mistaken about this)
I often want to reduce the font size and line space in the notebook output so that condensed information can be displayed.

Thanks in advance!


@DonJayamanne commented on Thu May 06 2021

Thanks for filing this issue, I don't think we have plans on supporting this at our end.
With the new Native Notebooks VS Code owns the output and the font settings.
Transferring issue to VS Code.

@IanMatthewHuff
Copy link
Member

Something to mention related here. Non-monospaced fonts can look really bad in dataframe output in particular. microsoft/vscode-jupyter#6546

@Dr-Irv
Copy link

Dr-Irv commented Jul 10, 2021

Another issue is that the line spacing is inconsistent in code and the notebook output and the terminal. See this example:
image

@bicycle1885
Copy link

bicycle1885 commented Aug 6, 2021

Also, the font of Notebook output seems to be inconsistent on my platform: the font of the output (middle) is different from that of editor (top) and terminal (bottom):
image

I took this screenshot on VS Code 1.59 for Linux. No font settings are applied.

@stevenlis
Copy link

stevenlis commented Oct 20, 2021

Another issue is that the current font used in HTML (from Jupyter) does not display the same-length strings to have the same length in a dataframe.
image

@rebornix rebornix removed the notebook label Oct 21, 2021
@rebornix rebornix removed their assignment Oct 22, 2021
@aldanor
Copy link

aldanor commented Mar 5, 2022

Starting from today, for whatever reason, in all of my vscode notebooks, the output is no longer rendered as monospace; rather, it's the default browser font (some sans):

image

I've triple-checked all of my user/workspace settings, and there's nothing related to this. What could have cause this and how does one change it back to monospace?..

(It makes it extremely hard to work with any notebooks)

@aldanor
Copy link

aldanor commented Mar 5, 2022

For anyone else affected, you can temporarily set styles in your notebooks sort of like so:

from IPython.core.display import HTML
HTML(r"""
<style>
    .output-plaintext, .output-stream, .output {
        font-family: Monaco, Menlo, monospace !important;
        line-height: 1.2 !important;
        font-size: 12px !important;
    }
</style>
""")

But this is an ugly hack, works for one notebook only, and I hope someone can answer what's the current story with notebook output fonts?

@JohnnyFoulds
Copy link

PLEASE change the font behaviour back to what it was in the previous version. And may I please ask the team to see if they can improve their QA procedures before releasing a new version as I instantly picked up this issue the second I had to re-open VS Code, so in my view, this is not acceptable. It might seem like a minor nuisance to some, but when you have been working for weeks on a series of notebooks and suddenly your work looks messed up for no logical reason at all, it becomes a major annoyance.

@aldanor
Copy link

aldanor commented Mar 8, 2022

PLEASE change the font behaviour back to what it was in the previous version.

Since it would need to be fixed anyway, the best way to go would be to move 2 steps forward and finally allow users to set notebook.output.fontSize and notebook.output.fontFamily (and for extra kicks, notebook.output.lineHeight).

IIUC, if it can be done via a triivial CSS hack, it should also be trivial to add it to the settings? (and keep the default font-family the same as the terminal font / editor font / whichever - most importantly, monospace)

@JohnnyFoulds
Copy link

Since it would need to be fixed anyway, the best way to go would be to move 2 steps forward and finally allow users to set notebook.output.fontSize and notebook.output.fontFamily (and for extra kicks, notebook.output.lineHeight).

IIUC, if it can be done via a triivial CSS hack, it should also be trivial to add it to the settings? (and keep the default font-family the same as the terminal font / editor font / whichever - most importantly, monospace)

You might be right, and I might just be confused, but I am not sure it is quite the same as the trivial hack. For example, compare the .show() output of a PySpark vs a Pandas DataFrame .head() in 1.64.2. The one needs monospace, the other doesn't use (or need) it. And then more subtle things, like if you show your spark session with simply spark there is a mix in the output of monospace for the warnings and then the specific formatting for the actual SparkContext display.

The trivial CSS hack just forces everything to monospace and equally makes it "ugly" but at least everything is aligned. Things were perfect (in my opinion) before, so for now I just went back to the old version, and if this font issue stays I guess I will be stuck on this version until some fancy new feature arrives I just have to have.

@aldanor
Copy link

aldanor commented Mar 8, 2022

You might be right, and I might just be confused, but I am not sure it is quite the same as the trivial hack. For example, compare the .show() output of a PySpark vs a Pandas DataFrame .head() in 1.64.2. The one needs monospace, the other doesn't use (or need) it. And then more subtle things, like if you show your spark session with simply spark there is a mix in the output of monospace for the warnings and then the specific formatting for the actual SparkContext display.

The trivial CSS hack just forces everything to monospace and equally makes it "ugly" but at least everything is aligned. Things were perfect (in my opinion) before, so for now I just went back to the old version, and if this font issue stays I guess I will be stuck on this version until some fancy new feature arrives I just have to have.

There's separate CSS classes, e.g. .output-stream or .output-plaintext, for when you print() stuff or for output results if it's not a rich-repr object - it's this part that should be configurable. Please let us configure fonts (and most importantly, font size! and maybe line-height) of output-stream and output-plaintext. It's not a cosmetic thing for stdout-heavy notebooks.

DataFrames and the like are more like overrides (their custom reprs output HTML, for dataframes it's .dataframe inside .output_container > .output) and should be formatted as they previously were - i.e. as long as .output is untouched, it should be all fine. You can try experimenting by removing .output in the css hack above and see what it does.

@stevenlis
Copy link

@aldanor Thanks for the hack. Is there any way to make the monospaced font sans-serif? I tried a couple of different fonts, but they are all serif.

@amunger
Copy link
Contributor

amunger commented Apr 13, 2022

verification steps:
create some output for a notebook or an interactive window
change the settings notebook: output line height, notebook: output font size, notebook: output font family and the corresponding fallback editor options and verify the output uses them

@rzhao271 rzhao271 modified the milestones: Backlog, April 2022 Apr 26, 2022
@rzhao271 rzhao271 added verification-needed Verification of issue is requested verified Verification succeeded labels Apr 26, 2022
@github-actions github-actions bot locked and limited conversation to collaborators May 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders notebook-output verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

Successfully merging a pull request may close this issue.

12 participants