0

I am scared of 1 pixel gaps, cause they can occur everywhere and take different approaches to solve:

From (Int32)((Decimal)(Decimal))

To Math.Floor and Math.Round

To (2 % X)

I'm getting better at solving those, but I have a string drawing as a title and I do not know how to debug math errors and pixel gaps as the font is not touching the borders of the string and there are no borders to begin with, is there efficient way to debug DRAW STRING and pixel gaps in draw string and mis calculation in draw string

Fildor
  • 14,510
  • 4
  • 35
  • 67
yaolema
  • 1
  • 1
  • _"I am scared of 1 pixel gaps"_ - why is that? Really: Almost nobody will even notice, less so bother. And: Rendering depends on so many factors, that you probably never will catch _every_ glitch 100% of the time, when it comes to strings. So my honest but inconvenient suggestion would be: get over it. :) It's "best effort". – Fildor Dec 07 '22 at 12:02
  • You might want to "define pixel gaps to what". If you have problems defining the correct positioning in the first place what are you expecting to find when debugging? – Ralf Dec 07 '22 at 12:05
  • 4
    When you draw text, either using `Graphics.DrawString()` or `TextRenderer.DrawText()`, some specific padding is added to the rendering (the latter has flags that allow to remove the default padding). It's quite standard when custom-drawing the content of Controls. It's not clear what problem you're trying to solve, but see the notes and the question here: [Remove top and bottom padding from Text drawn on an Image](https://stackoverflow.com/a/54383828/7444103) – Jimi Dec 07 '22 at 13:52
  • 3
    Or [How to compute the correct width of a digit in pixels?](https://stackoverflow.com/a/54772134/7444103) – Jimi Dec 07 '22 at 13:59

0 Answers0