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.
- python 2.7, 3.5
- pygments 2.3.1
- pillow 4.2.1
- Windows 7