# PdfFont class

> A font for drawing text. Font size is given when drawing, so one instance serves every size. Vertical metrics are fractions of the font size: multiply...

Namespace: [PdfNetStack.Fonts](https://www.jadev-corp.com/api/pdfnetstack-fonts/)  
Assembly: PdfNetStack.dll  
Package: `PdfNetStack`

A font for drawing text. Font size is given when drawing, so one instance serves every size.
Vertical metrics are fractions of the font size: multiply by the size in points to get points.

```csharp
public abstract class PdfFont
```

**Inheritance**

[object](https://learn.microsoft.com/dotnet/api/system.object) ← 
[PdfFont](https://www.jadev-corp.com/api/pdfnetstack-fonts/pdffont/)

**Derived**

[PdfOpenTypeFont](https://www.jadev-corp.com/api/pdfnetstack-fonts/pdfopentypefont/), 
[PdfStandardFont](https://www.jadev-corp.com/api/pdfnetstack-fonts/pdfstandardfont/)

## Remarks

Use [PdfStandardFont](https://www.jadev-corp.com/api/pdfnetstack-fonts/pdfstandardfont/) for the 14 fonts every PDF viewer has. A font is written into a
document the first time text is drawn with it, once per document, and is safe to share between
documents and threads.

## Properties

### <a id="PdfNetStack_Fonts_PdfFont_Ascent"></a> Ascent

Height above the baseline used for line spacing.

```csharp
public double Ascent { get; }
```

#### Property Value

 [double](https://learn.microsoft.com/dotnet/api/system.double)

### <a id="PdfNetStack_Fonts_PdfFont_CapHeight"></a> CapHeight

Height of flat capital letters such as H.

```csharp
public double CapHeight { get; }
```

#### Property Value

 [double](https://learn.microsoft.com/dotnet/api/system.double)

### <a id="PdfNetStack_Fonts_PdfFont_Descent"></a> Descent

Depth below the baseline used for line spacing, as a positive number.

```csharp
public double Descent { get; }
```

#### Property Value

 [double](https://learn.microsoft.com/dotnet/api/system.double)

### <a id="PdfNetStack_Fonts_PdfFont_FamilyName"></a> FamilyName

Family name, such as "Helvetica".

```csharp
public abstract string FamilyName { get; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

### <a id="PdfNetStack_Fonts_PdfFont_IsBold"></a> IsBold

True for bold and heavier weights.

```csharp
public abstract bool IsBold { get; }
```

#### Property Value

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### <a id="PdfNetStack_Fonts_PdfFont_IsItalic"></a> IsItalic

True for italic and oblique styles.

```csharp
public abstract bool IsItalic { get; }
```

#### Property Value

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### <a id="PdfNetStack_Fonts_PdfFont_ItalicAngle"></a> ItalicAngle

Slant in degrees, counterclockwise from vertical; negative for fonts leaning right.

```csharp
public double ItalicAngle { get; }
```

#### Property Value

 [double](https://learn.microsoft.com/dotnet/api/system.double)

### <a id="PdfNetStack_Fonts_PdfFont_LineGap"></a> LineGap

Extra space the font designer recommends between lines.

```csharp
public double LineGap { get; }
```

#### Property Value

 [double](https://learn.microsoft.com/dotnet/api/system.double)

### <a id="PdfNetStack_Fonts_PdfFont_Name"></a> Name

PostScript name, as written to /BaseFont.

```csharp
public abstract string Name { get; }
```

#### Property Value

 [string](https://learn.microsoft.com/dotnet/api/system.string)

### <a id="PdfNetStack_Fonts_PdfFont_StrikeoutPosition"></a> StrikeoutPosition

Height of the middle of a strikethrough line above the baseline.

```csharp
public double StrikeoutPosition { get; }
```

#### Property Value

 [double](https://learn.microsoft.com/dotnet/api/system.double)

### <a id="PdfNetStack_Fonts_PdfFont_StrikeoutThickness"></a> StrikeoutThickness

Strikethrough stroke thickness.

```csharp
public double StrikeoutThickness { get; }
```

#### Property Value

 [double](https://learn.microsoft.com/dotnet/api/system.double)

### <a id="PdfNetStack_Fonts_PdfFont_UnderlinePosition"></a> UnderlinePosition

Distance from the baseline down to the middle of an underline.

```csharp
public double UnderlinePosition { get; }
```

#### Property Value

 [double](https://learn.microsoft.com/dotnet/api/system.double)

### <a id="PdfNetStack_Fonts_PdfFont_UnderlineThickness"></a> UnderlineThickness

Underline stroke thickness.

```csharp
public double UnderlineThickness { get; }
```

#### Property Value

 [double](https://learn.microsoft.com/dotnet/api/system.double)

### <a id="PdfNetStack_Fonts_PdfFont_XHeight"></a> XHeight

Height of flat lowercase letters such as x.

```csharp
public double XHeight { get; }
```

#### Property Value

 [double](https://learn.microsoft.com/dotnet/api/system.double)

## Methods

### <a id="PdfNetStack_Fonts_PdfFont_CanRender_System_String_"></a> CanRender\(string\)

True when every character of <code class="paramref">text</code> can be drawn: the font has a glyph for
it (directly, or for OpenType fonts after Unicode normalization: decomposed, composed with
the marks before it, or a space drawn with the font's space), or it is an invisible control
or format character, which drawing skips.

```csharp
public bool CanRender(string text)
```

#### Parameters

`text` [string](https://learn.microsoft.com/dotnet/api/system.string)

#### Returns

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### <a id="PdfNetStack_Fonts_PdfFont_GetLineHeight_System_Double_"></a> GetLineHeight\(double\)

Default line height for <code class="paramref">size</code>: ascent, descent and line gap, in points.

```csharp
public double GetLineHeight(double size)
```

#### Parameters

`size` [double](https://learn.microsoft.com/dotnet/api/system.double)

#### Returns

 [double](https://learn.microsoft.com/dotnet/api/system.double)

### <a id="PdfNetStack_Fonts_PdfFont_HasGlyph_System_Int32_"></a> HasGlyph\(int\)

True when the font has a glyph for the Unicode code point.

```csharp
public bool HasGlyph(int codePoint)
```

#### Parameters

`codePoint` [int](https://learn.microsoft.com/dotnet/api/system.int32)

#### Returns

 [bool](https://learn.microsoft.com/dotnet/api/system.boolean)

### <a id="PdfNetStack_Fonts_PdfFont_MeasureString_System_String_System_Double_"></a> MeasureString\(string, double\)

Width of <code class="paramref">text</code> drawn on one line at <code class="paramref">size</code>, in points.

```csharp
public double MeasureString(string text, double size)
```

#### Parameters

`text` [string](https://learn.microsoft.com/dotnet/api/system.string)

`size` [double](https://learn.microsoft.com/dotnet/api/system.double)

#### Returns

 [double](https://learn.microsoft.com/dotnet/api/system.double)

#### Exceptions

 [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception)

The font has no glyph for a character of the text.

### <a id="PdfNetStack_Fonts_PdfFont_ToString"></a> ToString\(\)

Returns a string that represents the current object.

```csharp
public override string ToString()
```

#### Returns

 [string](https://learn.microsoft.com/dotnet/api/system.string)

A string that represents the current object.

## Used in

- [Fonts and text in PDF with C# and .NET](https://www.jadev-corp.com/guides/fonts-and-text/)
- [Fill and create PDF forms in C# and .NET](https://www.jadev-corp.com/guides/forms/)
- [Add images to PDF in C# and .NET](https://www.jadev-corp.com/guides/images/)
- [Create PDF/A files in C# and .NET](https://www.jadev-corp.com/guides/pdf-a/)
- [Add page numbers to a PDF in C#](https://www.jadev-corp.com/recipes/add-page-numbers/)
- [Add a watermark to a PDF in C#](https://www.jadev-corp.com/recipes/add-watermark/)
- [Write Arabic text in a PDF in C#](https://www.jadev-corp.com/recipes/arabic-text-pdf/)
- [Create a Factur-X invoice PDF in C#](https://www.jadev-corp.com/recipes/pdf-a-3-xml-attachment/)

Source: https://www.jadev-corp.com/pdfnetstack/api/pdfnetstack-fonts/pdffont/
