Obtenir la taille d'un caractère.

Résolu
The Meteorologist Messages postés 232 Date d'inscription jeudi 18 janvier 2007 Statut Membre Dernière intervention 3 novembre 2011 - 4 févr. 2008 à 22:48
Kevin.Ory Messages postés 840 Date d'inscription mercredi 22 octobre 2003 Statut Membre Dernière intervention 7 janvier 2009 - 5 févr. 2008 à 04:03
Bonjour,
Alors voilà, je souhaiterais simplement obtenir la taille en pixel d'un carractère suivant sa police et sa taille en Vb.net.

Petit exemple :
    'Je souhaiterais faire l'équivalent de ceci :
    Dim x AsInteger = 0
    Dim y AsInteger = 0

    Ecrire_Sur_Form("Salut",x,y)

    'Mais de cette manière :
    Dim x As Integer = 0

    Dim y As Integer = 0

    Ecrire_Sur_Form("S",x,y)
    Ecrire_Sur_Form("a",x + ?,y) 'Quel est la position du prochain caractère ?
    Ecrire_Sur_Form("l",x + ?,y) 'Quel est la position du prochain caractère ?
    Ecrire_Sur_Form("u",x + ?,y) 'Quel est la position du prochain caractère ?
    Ecrire_Sur_Form("t",x + ?,y) 'Quel est la position du prochain caractère ?

J'espere avoir été clair
Merci pour votre aide ,

Simon

1 réponse

Kevin.Ory Messages postés 840 Date d'inscription mercredi 22 octobre 2003 Statut Membre Dernière intervention 7 janvier 2009 11
5 févr. 2008 à 04:03
Salut,

Graphics.MeasureCharacterRanges(String, Font, RectangleF, StringFormat) as Region devrait faire l'affaire.
http://msdn2.microsoft.com/fr-fr/library/system.drawing.graphics.measurecharacterranges(en-us,VS.80).aspx

Voir aussi Graphics.MeasureString(String, Font) as SizeF:
http://msdn2.microsoft.com/fr-fr/library/system.drawing.graphics.measurestring(en-us,VS.80).aspx
3
Rejoignez-nous