img formatter renders text at wrong position (on Windows?)

Issue #1509 new
Hiroaki Itoh created an issue

Note that I have reproduced this problem only on Windows (Japanese edition).

In the case where the lexer is other than "text", the drawing position of tokens other than the first one appearing on the line is wrong.

If you change the passing text to getsize in the "get_char_size" method of class FontManager from "M" to "a", it will draw in the correct position, but I can't explain what's happened. Apart from this mysterious fix method, I think that in the first place the approach adopted does not work when it contains kanji characters.

Maybe I think this is the conclusion:

  • Don't multiply the font size by the character position.
  • Use the size of all text before the drawing target token in the line.

used versions:

  • python 2.7, 3.5
  • pygments 2.3.1
  • pillow 4.2.1
  • Windows 7

Comments (5)

  1. Hiroaki Itoh reporter

    Sorry to attach the modified source code directly. I got lost about how to do PR with BitBucket + Mercurial.

  2. Log in to comment