Nutrient Web SDK
    Preparing search index...

    Type Alias FontMatcher

    FontMatcher: (
        match: string,
        fontInfo: FontInfo,
        availableFonts: AvailableFontFace[],
    ) => FontMatchResult | undefined

    Callback to evaluate or override a font match during content editing.

    This callback is invoked when the system has determined a best-match font for text during content editing operations. It allows developers to provide custom font matching logic or override the system's choice.

    The callback receives the system's proposed font match, metadata about the original font from the PDF, the current font size, and a list of all available fonts that can be used. It can return a different font reference to override the match, or undefined to accept the system's choice.

    Type Declaration

      • (
            match: string,
            fontInfo: FontInfo,
            availableFonts: AvailableFontFace[],
        ): FontMatchResult | undefined
      • Parameters

        • match: string

          The font name selected by the system as the best match.

        • fontInfo: FontInfo

          Font metadata from the PDF including current size.

        • availableFonts: AvailableFontFace[]

          Array of all fonts available for use in content editing.

        Returns FontMatchResult | undefined

        A font and size to override the match, or undefined to accept the system match.

    Simple font matching using available fonts.

    NutrientViewer.load({
    contentEditingFontMatcher: (match, fontInfo, availableFonts) => {
    // For Helvetica, try to find Arial or use the first available font
    if (fontInfo.name?.includes("Helvetica")) {
    const arialFont = availableFonts.find(font => font.family === "Arial" && !font.bold && !font.italic);
    if (arialFont) {
    return { font: arialFont, size: fontInfo.fontSize };
    }
    // Fallback to first available font
    if (availableFonts.length > 0) {
    return { font: availableFonts[0], size: fontInfo.fontSize };
    }
    }
    return undefined; // Accept system match
    }
    });