Cirq icon indicating copy to clipboard operation
Cirq copied to clipboard

ASCII art of circuit print shifted on my Japanese based WIN10

Open freezemusic opened this issue 3 years ago • 8 comments

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__)'

freezemusic avatar Apr 06 '21 18:04 freezemusic

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

balopat avatar Apr 06 '21 22:04 balopat

you're right, that was within Colab

freezemusic avatar Apr 07 '21 08:04 freezemusic

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?

balopat avatar Apr 07 '21 22:04 balopat

  1. Sure, let me provide screenshots here

image image image

  1. My browser is Google Chrome 89.0.4389.114 (64-bit)

freezemusic avatar Apr 08 '21 07:04 freezemusic

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".

95-martin-orion avatar Apr 08 '21 21:04 95-martin-orion

Thanks for replying, mine is "Consolas"

freezemusic avatar Apr 08 '21 21:04 freezemusic

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.

95-martin-orion avatar Apr 12 '21 19:04 95-martin-orion

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.

balopat avatar Apr 28 '21 21:04 balopat