Font.GetHeight Methode

Definitie

Retourneert de regelafstand van dit lettertype.

Overloads

Name Description
GetHeight()

Retourneert de regelafstand in pixels van dit lettertype.

GetHeight(Graphics)

Retourneert de regelafstand, in de huidige eenheid van een opgegeven Graphics, van dit lettertype.

GetHeight(Single)

Retourneert de hoogte, in pixels, van dit Font wanneer deze wordt getekend op een apparaat met de opgegeven verticale resolutie.

GetHeight()

Bron:
Font.cs
Bron:
Font.cs
Bron:
Font.cs
Bron:
Font.cs
Bron:
Font.cs
Bron:
Font.cs
Bron:
Font.cs
Bron:
Font.cs

Retourneert de regelafstand in pixels van dit lettertype.

public:
 float GetHeight();
public float GetHeight();
member this.GetHeight : unit -> single
Public Function GetHeight () As Single

Retouren

De regelafstand, in pixels, van dit lettertype.

Opmerkingen

De regelafstand van een Font is de verticale afstand tussen de basisregels van twee opeenvolgende tekstregels. De regelafstand bevat dus de spatie tussen regels, samen met de hoogte van het teken zelf.

Als de Unit eigenschap van het lettertype is ingesteld op iets anders dan GraphicsUnit.Pixel, wordt de hoogte (in pixels) berekend met behulp van de verticale resolutie van het schermscherm. Stel dat de tekeneenheid inches is en dat de tekengrootte 0,3 is. Stel ook dat voor de bijbehorende lettertypefamilie de em-hoogte 2048 is en dat de regelafstand 2355 is. Voor een schermweergave met een verticale resolutie van 96 punten per inch kunt u de hoogte als volgt berekenen:

2355*(0,3/2048)*96 = 33,11719

Van toepassing op

GetHeight(Graphics)

Bron:
Font.cs
Bron:
Font.cs
Bron:
Font.cs
Bron:
Font.cs
Bron:
Font.cs
Bron:
Font.cs
Bron:
Font.cs
Bron:
Font.cs

Retourneert de regelafstand, in de huidige eenheid van een opgegeven Graphics, van dit lettertype.

public:
 float GetHeight(System::Drawing::Graphics ^ graphics);
public float GetHeight(System.Drawing.Graphics graphics);
member this.GetHeight : System.Drawing.Graphics -> single
Public Function GetHeight (graphics As Graphics) As Single

Parameters

graphics
Graphics

Een Graphics met de verticale resolutie, in puntjes per inch, van het weergaveapparaat, evenals instellingen voor pagina-eenheid en paginaschaal.

Retouren

De regelafstand, in pixels, van dit lettertype.

Uitzonderingen

graphics is null.

Voorbeelden

Het volgende codevoorbeeld is ontworpen voor gebruik met Windows Forms en vereist PaintEventArgse, een parameter van de Paint gebeurtenis-handler. De code voert de volgende acties uit:

  • Hiermee maak je een Font.

  • Hiermee tekent u een tekstregel naar het scherm met behulp van het nieuwe Font.

  • Hiermee haalt u de hoogte van het lettertype op.

  • Hiermee tekent u een tweede tekstregel direct onder de eerste regel.

public:
   void GetHeight_Example( PaintEventArgs^ e )
   {
      // Create a Font object.
      System::Drawing::Font^ myFont = gcnew System::Drawing::Font( "Arial",16 );

      //Draw text to the screen with myFont.
      e->Graphics->DrawString( "This is the first line", myFont, Brushes::Black, PointF(0,0) );

      //Get the height of myFont.
      float height = myFont->GetHeight( e->Graphics );

      //Draw text immediately below the first line of text.
      e->Graphics->DrawString( "This is the second line", myFont, Brushes::Black, PointF(0,height) );
   }
public void GetHeight_Example(PaintEventArgs e)
{
             
    // Create a Font object.
    Font myFont = new Font("Arial", 16);
             
    //Draw text to the screen with myFont.
    e.Graphics.DrawString("This is the first line",myFont,
        Brushes.Black, new PointF(0, 0));
             
    //Get the height of myFont.
    float height = myFont.GetHeight(e.Graphics);
             
    //Draw text immediately below the first line of text.
    e.Graphics.DrawString(
        "This is the second line",
        myFont,
        Brushes.Black,
        new PointF(0, height));
}
Public Sub GetHeight_Example(ByVal e As PaintEventArgs)

    ' Create a Font object.
    Dim myFont As New Font("Arial", 16)

    'Draw text to the screen with myFont.
    e.Graphics.DrawString("This is the first line", myFont, _
    Brushes.Black, New PointF(0, 0))

    'Get the height of myFont.
    Dim height As Single = myFont.GetHeight(e.Graphics)

    'Draw text immediately below the first line of text.
    e.Graphics.DrawString("This is the second line", myFont, _
    Brushes.Black, New PointF(0, height))
End Sub

Opmerkingen

De regelafstand van een Font is de verticale afstand tussen de basisregels van twee opeenvolgende tekstregels. De regelafstand bevat dus de spatie tussen regels, samen met de hoogte van het teken zelf.

Als de Unit eigenschap van het lettertype is ingesteld op iets anders dan GraphicsUnit.Pixel, wordt de hoogte, in pixels, berekend met behulp van de verticale resolutie van het opgegeven Graphics object. Stel dat de tekeneenheid inches is en dat de tekengrootte 0,3 is. Stel ook dat voor de bijbehorende lettertypefamilie de em-hoogte 2048 is en dat de regelafstand 2355 is. Als het Graphics object een Unit eigenschapswaarde van GraphicsUnit.Pixel en een DpiY eigenschapswaarde van 96 punten per inch heeft, wordt de hoogte als volgt berekend:

2355*(0,3/2048)*96 = 33,1171875

Stel dat de Unit eigenschap van het Graphics object is ingesteld GraphicsUnit.Millimeter op in plaats GraphicsUnit.Pixelvan op hetzelfde voorbeeld. Vervolgens (met 1 inch = 25,4 millimeter) wordt de hoogte, in millimeters, als volgt berekend:

2355*(0,3/2048)25,4 = 8,762256

Zie ook

Van toepassing op

GetHeight(Single)

Bron:
Font.cs
Bron:
Font.cs
Bron:
Font.cs
Bron:
Font.cs
Bron:
Font.cs
Bron:
Font.cs
Bron:
Font.cs
Bron:
Font.cs

Retourneert de hoogte, in pixels, van dit Font wanneer deze wordt getekend op een apparaat met de opgegeven verticale resolutie.

public:
 float GetHeight(float dpi);
public float GetHeight(float dpi);
member this.GetHeight : single -> single
Public Function GetHeight (dpi As Single) As Single

Parameters

dpi
Single

De verticale resolutie, in puntjes per inch, die wordt gebruikt om de hoogte van het lettertype te berekenen.

Retouren

De hoogte, in pixels, van deze Font.

Opmerkingen

Als de Unit eigenschap van het lettertype is ingesteld op iets anders dan GraphicsUnit.Pixel, wordt de hoogte (in pixels) berekend met behulp van de verticale resolutie van het schermscherm. Stel dat de tekeneenheid inches is en dat de tekengrootte 0,3 is. Stel ook dat voor de bijbehorende lettertypefamilie de em-hoogte 2048 is en dat de regelafstand 2355 is. Als de opgegeven verticale resolutie 96 punten per inch is, wordt de hoogte als volgt berekend:

2355*(0,3/2048)*96 = 33,1171875

Zie ook

Van toepassing op