DynaPDF.SetFont
---------------

The function loads a font that can be used for text output and interactive form fields.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [DynaPDF](component_DynaPDF.md) | [3.1](newinversion31.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |

MBS( "DynaPDF.SetFont"; PDF; Name { ; Style; Size; Embed; CodePage } ) 

**MBS**( **"DynaPDF.SetFont";** /\* The function loads a font that can be used for text output and interactive form fields. \*/  
**$PDF**; /\* The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). \*/   
**$Name**; /\* Font name for new font to set or empty text to deactivate current font.e.g. "Arial" \*/   
**$Style**; /\* Optional; Font style value.   
Can be a combination of values 1 for italic, 2 for bold, 4 for underlined and 8 for striked.  
  
With version 12.0 or newer, this can be passed as text:  
UltraCondensed, ExtraCondensed, SemiCondensed, Condensed, SemiExpanded, ExtraExpanded, UltraExpanded, Expanded, ExtraBold, DemiBold, Bold, UltraBlack, Black, Normal, Italic, Underlined, Striked, VerticalMode, Thin, ExtraLight, Light, Regular, Medium, DoubleUnderlined.e.g. 3 \*/   
**$Size**; /\* Optional; Font size in points.e.g. 12 \*/   
**$Embed**; /\* Optional; Whether to embed font in PDF.   
Can be 1 to embed or 0 to not embed.  
  
Default is 1.e.g. 1 \*/   
**$CodePage**) /\* Optional; The code page to use.   
Code page can be 1250, 1251, 1252, 1253, 1254, 1255, 1256, 1257, 1258, 8859-2, 8859-3, 8859-4, 8859-5, 8859-6, 8859-7, 8859-8, 8859-9, 8859-10, 8859-13, 8859-14, 8859-15, 8859-16, Symbol, 437, 737, 775, 850, 852, 855, 857, 860, 861, 862, 863, 864, 865, 866, 869, 874, Unicode.  
Default is unicode since v12.3, but was 1252 for Windows ANSI before.e.g. "Unicode" \*/ 

### Parameters

| Parameter | Description | Example | Flags |
|---|---|---|---|
| PDF | The PDF reference returned from [DynaPDF.New](DynaPDFNew.md). | $pdf |  |
| Name | Font name for new font to set or empty text to deactivate current font. | "Arial" |  |
| Style | Font style value.    Can be a combination of values 1 for italic, 2 for bold, 4 for underlined and 8 for striked.      With version 12.0 or newer, this can be passed as text:   UltraCondensed, ExtraCondensed, SemiCondensed, Condensed, SemiExpanded, ExtraExpanded, UltraExpanded, Expanded, ExtraBold, DemiBold, Bold, UltraBlack, Black, Normal, Italic, Underlined, Striked, VerticalMode, Thin, ExtraLight, Light, Regular, Medium, DoubleUnderlined. | 3 | Optional |
| Size | Font size in points. | 12 | Optional |
| Embed | Whether to embed font in PDF.    Can be 1 to embed or 0 to not embed.      Default is 1. | 1 | Optional |
| CodePage | The code page to use.    Code page can be 1250, 1251, 1252, 1253, 1254, 1255, 1256, 1257, 1258, 8859-2, 8859-3, 8859-4, 8859-5, 8859-6, 8859-7, 8859-8, 8859-9, 8859-10, 8859-13, 8859-14, 8859-15, 8859-16, Symbol, 437, 737, 775, 850, 852, 855, 857, 860, 861, 862, 863, 864, 865, 866, 869, 874, Unicode.   Default is unicode since v12.3, but was 1252 for Windows ANSI before. | "Unicode" | Optional |

### Result

Returns font handle or error message.

### Description

The function loads a font that can be used for text output and interactive form fields.   
See also [DynaPDF.GetFontSelMode](DynaPDFGetFontSelMode.md) and [DynaPDF.SetFontSelMode](DynaPDFSetFontSelMode.md) function for the current selection mode.  
See also [SetFont](https://www.monkeybreadsoftware.com/DynaPDF-Manual/SetFont.shtml) function in DynaPDF manual.

### Examples

Sets a font:

 MBS ("DynaPDF.SetFont"; $pdf ; "Zapf Dingbats"; 0; 12)  
Sets italic font:

 MBS ("DynaPDF.SetFont"; $pdf ; "Times"; 1; 40; 1; "unicode")  
Set font variants with style as text:

 Set Variable \[ $r ; Value: MBS ("[DynaPDF.AppendPage](DynaPDFAppendPage.md)"; $pdf ) \]   
Set Variable \[ $fontName ; Value: "Avenir Next Condensed" \]   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.SetFillColor](DynaPDFSetFillColor.md)"; $pdf ; 0; 0; 0) \]   
Set Variable \[ $r ; Value: MBS ("DynaPDF.SetFont"; $pdf ; $fontName ; ""; 12) \]   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.WriteText](DynaPDFWriteText.md)"; $pdf ; 100; 500; "Normal text") \]   
Set Variable \[ $r ; Value: MBS ("DynaPDF.SetFont"; $pdf ; $fontName ; "bold"; 12) \]   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.WriteText](DynaPDFWriteText.md)"; $pdf ; 100; 450; "Bold text") \]   
Set Variable \[ $r ; Value: MBS ("DynaPDF.SetFont"; $pdf ; $fontName ; "italic"; 12) \]   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.WriteText](DynaPDFWriteText.md)"; $pdf ; 100; 400; "Italic text") \]   
Set Variable \[ $r ; Value: MBS ("DynaPDF.SetFont"; $pdf ; $fontName ; "condensed"; 12) \]   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.WriteText](DynaPDFWriteText.md)"; $pdf ; 100; 350; "Condensed text") \]   
Set Variable \[ $r ; Value: MBS ("DynaPDF.SetFont"; $pdf ; $fontName ; "condensed bold"; 12) \]   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.WriteText](DynaPDFWriteText.md)"; $pdf ; 100; 300; "Condensed bold text") \]   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.EndPage](DynaPDFEndPage.md)"; $pdf ) \]  
Set font variants with style as numbers:

 Set Variable \[ $r ; Value: MBS ("[DynaPDF.AppendPage](DynaPDFAppendPage.md)"; $pdf ) \]   
Set Variable \[ $fontName ; Value: "Avenir Next Condensed" \]   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.SetFillColor](DynaPDFSetFillColor.md)"; $pdf ; 0; 0; 0) \]   
Set Variable \[ $r ; Value: MBS ("DynaPDF.SetFont"; $pdf ; $fontName ; 0; 12) \]   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.WriteText](DynaPDFWriteText.md)"; $pdf ; 100; 500; "Normal text") \]   
Set Variable \[ $r ; Value: MBS ("DynaPDF.SetFont"; $pdf ; $fontName ; 2; 12) \]   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.WriteText](DynaPDFWriteText.md)"; $pdf ; 100; 450; "Bold text") \]   
Set Variable \[ $r ; Value: MBS ("DynaPDF.SetFont"; $pdf ; $fontName ; 1; 12) \]   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.WriteText](DynaPDFWriteText.md)"; $pdf ; 100; 400; "Italic text") \]   
Set Variable \[ $r ; Value: MBS ("DynaPDF.SetFont"; $pdf ; $fontName ; 1792; 12) \]   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.WriteText](DynaPDFWriteText.md)"; $pdf ; 100; 350; "Condensed text") \]   
Set Variable \[ $r ; Value: MBS ("DynaPDF.SetFont"; $pdf ; $fontName ; 1792 + 2; 12) \]   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.WriteText](DynaPDFWriteText.md)"; $pdf ; 100; 300; "Condensed bold text") \]   
Set Variable \[ $r ; Value: MBS ("[DynaPDF.EndPage](DynaPDFEndPage.md)"; $pdf ) \]  
### See also

- [DynaPDF.SetAltFonts](DynaPDFSetAltFonts.md)
- [DynaPDF.SetBBox](DynaPDFSetBBox.md)
- [DynaPDF.SetFontEx](DynaPDFSetFontEx.md)
- [DynaPDF.SetUseStdFonts](DynaPDFSetUseStdFonts.md)
- [DynaPDF.SetUseSystemFonts](DynaPDFSetUseSystemFonts.md)
- [DynaPDF.TestGlyphs](DynaPDFTestGlyphs.md)
- [DynaPDF.WriteFTextEx](DynaPDFWriteFTextEx.md)
- [DynaPDF.WriteStyledText](DynaPDFWriteStyledText.md)
- [DynaPDF.WriteStyledTextEx](DynaPDFWriteStyledTextEx.md)
- [DynaPDF.WriteText](DynaPDFWriteText.md)

### Release notes

- **Version 12.3**
    - Changed [DynaPDF.SetFont](https://www.mbsplugins.eu/DynaPDFSetFont.shtml), [DynaPDF.SetFieldFont](https://www.mbsplugins.eu/DynaPDFSetFieldFont.shtml), [DynaPDF.SetFontEx](https://www.mbsplugins.eu/DynaPDFSetFontEx.shtml) and [DynaPDF.Table.SetFont](https://www.mbsplugins.eu/DynaPDFTableSetFont.shtml) to use unicode as default code page.
- **Version 12.0**
    - Changed [DynaPDF.SetFont](https://www.mbsplugins.eu/DynaPDFSetFont.shtml), [DynaPDF.Table.SetFont](https://www.mbsplugins.eu/DynaPDFTableSetFont.shtml), [DynaPDF.SetFontEx](https://www.mbsplugins.eu/DynaPDFSetFontEx.shtml), [DynaPDF.ChangeFontEx](https://www.mbsplugins.eu/DynaPDFChangeFontEx.shtml), [DynaPDF.SetFieldFont](https://www.mbsplugins.eu/DynaPDFSetFieldFont.shtml) and [DynaPDF.SetBookmarkStyle](https://www.mbsplugins.eu/DynaPDFSetBookmarkStyle.shtml) functions to accept styles as text.

### Example Databases

- [Barcode/QRCode PDF](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Barcode/QRCode%20PDF.shtml#2ScriptAnchor_)
- [DynaPDF/Add Page Numbers](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Add%20Page%20Numbers.shtml#2ScriptAnchor_)
- [DynaPDF/Book Creation](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Book%20Creation.shtml#3ScriptAnchor_)
- [DynaPDF/Bookmarks](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Bookmarks.shtml#2ScriptAnchor_)
- [DynaPDF/Create DeviceN ColorSpace](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Create%20DeviceN%20ColorSpace.shtml#2ScriptAnchor_)
- [DynaPDF/Create PDF with Bezier Curves](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Create%20PDF%20with%20Bezier%20Curves.shtml#1ScriptAnchor_)
- [DynaPDF/Create Text as PDFA](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Create%20Text%20as%20PDFA.shtml#3ScriptAnchor_)
- [DynaPDF/Styled Text](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/Styled%20Text.shtml#2ScriptAnchor_)
- [DynaPDF/WriteFText](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/WriteFText.shtml#2ScriptAnchor_)
- [DynaPDF/ZUGFeRD and Facture-X/ZUGFeRD Invoice](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/ZUGFeRD%20and%20Facture-X/ZUGFeRD%20Invoice.shtml#3ScriptAnchor_)

### Blog Entries

- [Create PDF/UA with DynaPDF in FileMaker](https://www.mbsplugins.de/archive/2026-05-27/Create_PDFUA_with_DynaPDF_in_F/monkeybreadsoftware_blog_filemaker)
- [Using DynaPDF with Data API for PDF generation](https://www.mbsplugins.de/archive/2026-05-25/Using_DynaPDF_with_Data_API_fo/monkeybreadsoftware_blog_filemaker)
- [Make PDF certificates in calculation with DynaPDF](https://www.mbsplugins.de/archive/2026-05-18/Make_PDF_certificates_in_calcu/monkeybreadsoftware_blog_filemaker)
- [Draw images with text using DynaPDF](https://www.mbsplugins.de/archive/2026-01-03/Draw_images_with_text_using_Dy/monkeybreadsoftware_blog_filemaker)
- [PDF Draw Modes](https://www.mbsplugins.de/archive/2025-09-25/PDF_Draw_Modes/monkeybreadsoftware_blog_filemaker)
- [Use complex text rendering with DynaPDF in FileMaker](https://www.mbsplugins.de/archive/2025-06-25/Use_complex_text_rendering_wit/monkeybreadsoftware_blog_filemaker)
- [Page Layouting in DynaPDF](https://www.mbsplugins.de/archive/2024-04-05/Page_Layouting_in_DynaPDF/monkeybreadsoftware_blog_filemaker)
- [MBS Plugin Advent calendar: 15 - DynaPDF](https://www.mbsplugins.de/archive/2023-12-15/MBS_Plugin_Advent_calendar_15_/monkeybreadsoftware_blog_filemaker)
- [Merge documents with DynaPDF](https://www.mbsplugins.de/archive/2023-07-06/Merge_documents_with_DynaPDF/monkeybreadsoftware_blog_filemaker)
- [Add page links for FileMaker](https://www.mbsplugins.de/archive/2022-06-18/Add_page_links_for_FileMaker/monkeybreadsoftware_blog_filemaker)

### FileMaker Magazin

- [Ausgabe 3/2019, Seite 38](https://filemaker-magazin.de/neuigkeit/4046-Appetithappen-FMM_201903)
- [Ausgabe 2/2019, Seite 27](https://filemaker-magazin.de/neuigkeit/4043-Appetithappen-FMM_201902)

This function checks for a license.

Created 18th August 2014 , last changed 8th April 2025

  
[DynaPDF.SetFloatPrecision](DynaPDFSetFloatPrecision.md) - [DynaPDF.SetFontEx](DynaPDFSetFontEx.md)

[HTML Version](DynaPDFSetFont.shtml)