Puppeteer screenshot of a Bengali website: install fonts on Ubuntu
Install Bengali fonts in the Ubuntu runtime that launches Chromium, then capture a Puppeteer screenshot and troubleshoot missing glyphs.
Install Bengali-capable fonts in the same Ubuntu machine, VM, or container where Puppeteer launches Chromium. A practical starting point is Ubuntu’s fonts-beng package. It is a metapackage for Bengali and Assamese fonts and includes the Bengali Lohit font package. Then launch Puppeteer and capture the page with page.screenshot(). Installing fonts on your laptop will not help a separate container or remote browser unless those fonts are installed there too.
1. Install Bengali fonts in the Ubuntu browser runtime
Run these commands in the environment that actually runs Chromium:
sudo apt-get update
sudo apt-get install -y fonts-beng
Ubuntu’s Jammy package listing describes fonts-beng as a metapackage for Bengali and Assamese fonts and lists fonts-lohit-beng-bengali among its dependencies. Package contents and versions can vary by Ubuntu release. See the Ubuntu package listing for fonts-beng.
If the base package does not meet the page’s font needs, or the image should include the broader Bengali font collection, install the additional package:
sudo apt-get install -y fonts-beng-extra
Ubuntu describes fonts-beng-extra as TrueType fonts for Bengali. Its availability and version depend on the Ubuntu release; the Ubuntu Noble package listing also recommends the Lohit Bengali package.
Docker image
Install the fonts during the image build so they are present before Puppeteer starts. For example, add this to an Ubuntu-based Dockerfile:
RUN apt-get update \
&& apt-get install -y --no-install-recommends fonts-beng \
&& rm -rf /var/lib/apt/lists/*
For the additional collection, add fonts-beng-extra to the install command. Rebuild the image and restart the browser process after changing installed fonts, then capture a fresh screenshot.
2. Capture the page with Puppeteer
Once the font files are present in the browser runtime, use Puppeteer’s normal navigation and screenshot flow. Save the following as screenshot.js in a project where Puppeteer is installed:
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({ headless: true });
try {
const page = await browser.newPage();
await page.setViewport({ width: 1440, height: 1000, deviceScaleFactor: 1 });
await page.goto('https://example.com', { waitUntil: 'networkidle2', timeout: 60000 });
await page.screenshot({ path: 'bengali-page.png', fullPage: true });
} finally {
await browser.close();
}
})();
Replace https://example.com with the Bengali website URL. The page may need a different readiness condition if it renders content after navigation. Puppeteer documents Page.screenshot() and a general screenshot flow; the screenshot call captures the rendered page but does not install missing system fonts.
3. Choose the package that fits
| Package | When to use it | What the sources establish |
|---|---|---|
fonts-beng |
Start here for Bengali rendering on Ubuntu. | Metapackage for Bengali and Assamese fonts; its listed dependencies include fonts-lohit-beng-bengali. |
fonts-beng-extra |
Add it if the base collection does not meet the page’s needs or you want the additional collection in the image. | Ubuntu describes it as TrueType fonts for Bengali. Availability and version depend on the Ubuntu release. |
These package descriptions do not establish which font family a particular site requests, how Chromium will resolve every fallback, or whether a site’s own webfont will load. Check the site’s CSS and actual screenshot before adding packages based on appearance alone.
4. Verify the rendered result
- Confirm that the package installation ran inside the same VM, container, or host where Puppeteer starts Chromium.
- Rebuild or restart that runtime after installing fonts.
- Capture a new screenshot of the target page.
- Inspect the Bengali text for missing glyphs, fallback differences, or layout changes.
- If characters are still missing, inspect the page’s requested CSS font family and whether its webfont requests succeeded.
Puppeteer’s Linux troubleshooting guidance lists libfontconfig1 among common Debian and Ubuntu browser dependencies and notes that some scripts need additional font files. The examples there include CJK scripts, not Bengali; use the guidance for the general point that the runtime may need script-specific fonts, not as a Bengali-specific install command. See Puppeteer troubleshooting.
5. Troubleshoot missing or incorrect Bengali text
| Symptom | Likely cause | What to check or fix |
|---|---|---|
| Boxes or tofu instead of Bengali glyphs | No suitable Bengali font is visible to Chromium. | Install fonts-beng in the actual browser runtime, restart it, and capture again. If needed, consider fonts-beng-extra. |
| Fonts are installed on the host, but the container screenshot is still wrong | The browser runs in an isolated container that cannot see the host’s installed fonts. | Add the package installation to the container image and rebuild it. |
| Some text renders while other characters do not | The requested typeface may not cover every glyph, or the site’s webfont may not have loaded. | Inspect the CSS font-family declaration and check font network requests and browser errors. Package availability alone does not prove a given family covers the page’s characters. |
| The screenshot is blank or the page is incomplete | Capture happened before the page’s content was ready, or navigation failed. | Check navigation errors and use a readiness condition appropriate to the site. networkidle2 is a documented example, not a guarantee that all application content is ready. |
| Fonts appear unchanged after installation | The browser process or container is still using the previous runtime state. | Rebuild/restart the runtime and launch a fresh browser before capturing. |
| Puppeteer fails to launch on Ubuntu | A required browser library may be missing. | Review Puppeteer’s Linux troubleshooting guidance for Debian/Ubuntu dependencies, including libfontconfig1, and install the dependencies appropriate to the runtime. |
6. Performance, reliability, and cost notes
- Install at image-build time: Baking fonts into a container image makes the runtime setup repeatable and avoids relying on manual changes to a running instance.
- Keep browser and font setup together: A screenshot can only use fonts visible to the Chromium process that renders it.
- Wait for the page’s actual content: Navigation completion and application readiness can differ. Choose a wait condition based on how the target site loads.
- Keep package selection focused: Start with
fonts-beng; add the extra collection only if the page or image requirements call for it. The package listings do not quantify image quality or performance differences. - Expect environment-specific results: The Ubuntu package descriptions establish package scope, not exact rendering for every site, CSS font request, or Chromium build.
7. Or skip the browser setup
ScreenshotNeo is a website screenshot API and MCP server from ScreenshotNeo. Its one-call API returns an image or PDF from a URL. The required call is:
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://example.com -o shot.webp
See the ScreenshotNeo API documentation for request options. ScreenshotNeo accepts cookie and consent banners before capture and removes more than 60 known consent platforms, newsletter popups, and chat widgets; each step can be turned off. Bot checks, blank pages, timeouts, failed loads, and cache hits are not billed, and response headers identify the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents. The free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.
Sign up for ScreenshotNeo’s free plan: 1,000 screenshots a month, no card required.
FAQ
Will installing fonts on my development laptop fix a screenshot made in CI?
Only if CI runs Chromium in that same environment. Install the packages in the CI image, VM, or container that launches the browser.
Does fonts-beng guarantee the site’s preferred typeface?
No. It provides Bengali-capable fonts, but a website may request a particular family or load its own webfont. Check the CSS and font requests if rendering remains unexpected.
Should I always install fonts-beng-extra?
No. Begin with fonts-beng. Add the extra collection when the base setup does not meet the page’s needs or you deliberately want it included.
Does page.screenshot() wait for Bengali fonts to install?
No. Fonts must already be available in the browser runtime. The screenshot method captures the page as rendered; it does not install system packages.


