Fontconfig Errors on Edge Function

Hi, I’m seeing an error similar to this unresolved thread: Fontconfig error: Cannot load default config file - #3 by bertramye The Vercel staff member claims that Fontconfig should work on the runtime so I’d like to get confirmation if this is true or not.

I have a SVG → PDF conversion on an API route that works locally but fails in production. The code looks something like this:

const svgBuffer = extractedFiles.get(pageFile);
        if (!svgBuffer) {
          console.warn(`⚠️ Page file not found: ${pageFile}, skipping...`);
          continue;
        }
        
        const svgContent = svgBuffer.toString('utf-8');
        
        // Embed images in SVG
        const svgWithEmbeddedImages = await this.embedImagesInSvg(svgContent, extractedFiles);
        
        // Get SVG dimensions
        const dimensions = this.extractSvgDimensions(svgWithEmbeddedImages);
        
        // Convert SVG to PNG
        const pngBuffer = await this.convertSvgToPng(svgWithEmbeddedImages);
        
        // Add page to PDF
        const pngImage = await pdfDoc.embedPng(pngBuffer);
        const page = pdfDoc.addPage([dimensions.width, dimensions.height]);
        
        page.drawImage(pngImage, {
          x: 0,
          y: 0,
          width: page.getWidth(),
          height: page.getHeight(),
        });

I don’t have any non standard packages or setup, and I’m under the impression things are failing due to the Vercel Edge Function runtime not having pathing set up for Fontconfig whereas local just uses my system or something similar? If there are custom configuration instructions, please let me know.

Fontconfig warning: using without calling FcInit()

Fontconfig error: Cannot load default config file: No such file: (null)

nextconfig.mjs

/** @type {import('next').NextConfig} */
const nextConfig = {
  eslint: {
    ignoreDuringBuilds: true,
  },
  typescript: {
    ignoreBuildErrors: true,
  },
  images: {
    unoptimized: true,
  },
}

export default nextConfig

package.json

{
  "name": "notebook-converter",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "build": "next build",
    "dev": "next dev",
    "lint": "next lint",
    "typecheck": "tsc --noEmit",
    "start": "next start",
    "test": "jest",
    "test:watch": "jest --watch",
    "test:coverage": "jest --coverage"
  },
  "dependencies": {
    "@radix-ui/react-checkbox": "^1.3.3",
    "@radix-ui/react-dialog": "^1.1.15",
    "@radix-ui/react-progress": "^1.1.7",
    "@radix-ui/react-slot": "^1.2.3",
    "@stripe/stripe-js": "^7.8.0",
    "@supabase/ssr": "^0.6.1",
    "@supabase/supabase-js": "^2.55.0",
    "@types/jszip": "^3.4.1",
    "class-variance-authority": "^0.7.1",
    "clsx": "^2.1.1",
    "google-auth-library": "^10.2.1",
    "googleapis": "^156.0.0",
    "jszip": "^3.10.1",
    "lucide-react": "^0.454.0",
    "next": "15.4.6",
    "next-themes": "^0.4.6",
    "pdf-lib": "^1.17.1",
    "react": "^19.1.1",
    "react-dom": "^19.1.1",
    "react-dropzone": "latest",
    "sharp": "^0.34.3",
    "stripe": "^18.4.0",
    "tailwind-merge": "^2.5.5",
    "tailwindcss-animate": "^1.0.7",
    "xml-js": "^1.6.11"
  },
  "devDependencies": {
    "@types/jest": "^30.0.0",
    "@types/node": "^22",
    "@types/react": "^19.1.10",
    "@types/react-dom": "^19.1.7",
    "@typescript-eslint/eslint-plugin": "^8.39.1",
    "@typescript-eslint/parser": "^8.39.1",
    "autoprefixer": "^10.4.21",
    "eslint": "^8.57.1",
    "eslint-config-next": "14.0.0",
    "eslint-plugin-react": "^7.37.5",
    "eslint-plugin-react-hooks": "^5.2.0",
    "jest": "^30.0.5",
    "postcss": "^8.5",
    "tailwindcss": "^3.4.17",
    "ts-jest": "^29.4.1",
    "typescript": "^5"
  }
}

For posterity: a modified (modulo exact paths) version of this worked

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.