Skip to content

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

@Anteru

Description

@Anteru

(Original issue 1509 created by hhsprings on 2019-04-26T01:11:55.667733+00:00)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-formattingarea: changes to formattersS-minorseverity: minorT-bugtype: a bugX-importedimported from Bitbucket

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions