pdfApplyFont function

void pdfApplyFont(
  1. PdfEditingController controller,
  2. PdfTextFont font
)

Applies font to controller: it becomes the font new free text is written in (an embedded font sets PdfEditingController.activeFont; a standard family sets PdfEditingController.fontFamily) and, when a single free-text box is selected, restyles it in place too.

Implementation

void pdfApplyFont(PdfEditingController controller, PdfTextFont font) {
  if (font is PdfStandardFont) {
    controller.fontFamily = font;
  } else if (font is PdfEmbeddedFont) {
    controller.activeFont = font;
  }
  if (controller.restyleEditingTextSelection(font: font)) return;
  if (controller.canRestyleSelectedText) {
    controller.restyleSelectedFont(font);
  } else if (controller.selectedFormFieldName case final name?) {
    controller.setFormFieldStyle(name, font: font);
  } else if (font is PdfStandardFont &&
      controller.canRestyleMeasurementCaption) {
    // a measurement caption is drawn in a base-14 face (/DA resource name),
    // so only a standard family applies - embedded fonts don't
    controller.setSelectedMeasurementCaption(font: font);
  }
}