quantumlib / Cirq

A python framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits.
Apache License 2.0
4.2k stars 996 forks source link

ASCII art of circuit print shifted on my Japanese based WIN10 #3998

Open freezemusic opened 3 years ago

freezemusic commented 3 years ago

Description of the issue ASCII art of circuit print shifted on my Japanese based WIN10

Circuit:

a: ───H───────────

b: ───H───@───H───
          │
c: ───────X───────

How to reproduce the issue My OS is WIN10, using Japanese based system would cause the ASCII art shifted due to the "─" is not using "-"


put code in code blocks *like this*
put long logs in details blocks *like this*

Cirq version You can get the cirq version by printing cirq.__version__. From the command line: "0.11.0.dev"

python -c 'import cirq; print(cirq.__version__)'
balopat commented 3 years ago

Thanks for opening @freezemusic - this was within Colab right?

freezemusic commented 3 years ago

you're right, that was within Colab

balopat commented 3 years ago

From the diagram that you inserted it is hard to tell what's happening (I added the code block around it and it seems fine). This might be a font issue in your browser / colab - not sure - but it would be great if we could repro it.

  1. Can you paste a screenshot by any chance?
  2. Also - what browser are you using?
freezemusic commented 3 years ago
  1. Sure, let me provide screenshots here

image image image

  1. My browser is Google Chrome 89.0.4389.114 (64-bit)
95-martin-orion commented 3 years ago

It sounds like your fixed-width font is not actually fixed-width for these characters.

In the Colab FAQ, it notes that you can go to chrome://settings/fonts to check which fixed-width font you're currently using and/or change it to a different one. Note that this will change your default fixed-width font throughout Chrome, not just Colab; I'm not 100% certain what else it would affect.

What fixed-width font does it list for you? Mine is "Cousine".

freezemusic commented 3 years ago

Thanks for replying, mine is "Consolas"

95-martin-orion commented 3 years ago

Thanks for replying, mine is "Consolas"

Tried to reproduce the issue on US-based WIN10 with Consolas, but didn't see a shift. It seems like this issue is specific to the Japanese WIN10 - maybe a half-width vs. full width font issue?

One other note: in US-based WIN10, Consolas has a distinctive "hook" at the tip of the letter r that is missing in the images above. There may be something else we're missing here.

balopat commented 3 years ago

I managed to repro this on an English Win10 but by setting the primary language of chrome itself to Japanese!

image

Workaround This means that a possible (though unfortunate) workaround @freezemusic is to switch in chrome://settings to English - add language and move to top and/or enable "display Google chrome in this language": image

Towards a solution I wonder if we could detect this in colab, we could then tie it into the diagram drawer? We'll have to experiment a little bit with it. Other options is trying to force a different font somehow...this seems like Colab specific but I'm also curious whether this happens in Jupyter notebooks.