Skip to content

Commit fb31055

Browse files
970148: ImportCustomFonts
1 parent ea8538e commit fb31055

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

blazor/pdfviewer-2/annotation/free-text-annotation.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,30 @@ The following example demonstrates how to load, edit, and save custom fonts in F
324324

325325
[View sample in GitHub](https://github.com/SyncfusionExamples/blazor-pdf-viewer-examples/tree/master/Annotations/FreeText/Custom%20Font%20Support%20For%20FreeText%20Annotation).
326326

327+
To ensure proper and seamless execution when using Google API fonts in the PDF Viewer component, it's essential to load these fonts into the sample application as well. This is particularly important because FreeText annotations are rendered directly onto the canvas, making it mandatory to have the fonts available in the sample for accurate rendering.
328+
329+
The following example illustrates how to load custom fonts in FreeText annotations using fonts from Google Fonts or other external sources.
330+
331+
```cshtml
332+
<script>
333+
window.addEventListener('DOMContentLoaded', () => {
334+
var fontFamily = ["Allura, Tangerine, Sacramento, Inspiration"];
335+
for (var fontIndex=0; fontIndex<fontFamily.length; fontIndex++)
336+
{
337+
document.fonts.load(`16px ${fontFamily[fontIndex]}`).then(() => {
338+
console.log(`Font "${fontFamily[fontIndex]}" loaded successfully.`);
339+
}).catch(err => {
340+
console.error(`Failed to load font "${font}":`, err);
341+
});
342+
}
343+
});
344+
</script>
345+
```
346+
347+
>**Note:** If external fonts are not properly loaded in the environment, it may lead to slight inconsistencies when importing and rendering free text annotations using those custom fonts. This issue typically occurs only with fonts that are referenced externally, such as those loaded from web-based sources.
348+
349+
[View sample in GitHub](https://github.com/SyncfusionExamples/blazor-pdf-viewer-examples/tree/master/Annotations/FreeText/Load%20Custom%20Font%20From%20External%20Links).
350+
327351
## See also
328352

329353
* [How to delete the annotation programmatically](./text-markup-annotation#delete-annotation-programmatically)

0 commit comments

Comments
 (0)