Text drawing issue

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Sébastien Bicaïs

    #1

    Text drawing issue

    Hi,

    I made a VB class to generate images on the fly.
    The idea is to generate an image with a text, a font, a font size, a
    maximum width and height given as parameters, and the text to fit in the
    image.
    I'm experiencing 2 problems:
    firstable, I can't set the text exactly at the top left corner.
    I use the Graphics.DrawSt ring method as following:

    g.DrawString(my String, New Font(myFont, myFontSize), myFBrush, 0, 0)

    Depending on the font and the font size, the text will be positionned
    differently on the image (like 2 or 3 pixels from the top left corner of
    the image, not at 0,0).

    Secondable, I'm using the Graphics.Measur eString function to determine
    what will be my image size (as I want the text to fit "perfectly" in the
    image). Once again, the function doesn't return the proper size of the
    text, and I have to adjust the width and height to get finer results.

    Does anybody had to work on a similar problem ? What options do you
    suggest ?

    thx,
    seb



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
Working...