Headless Chrome on Ubuntu 22.04 with Selenium fails to render emojis and custom fonts, unlike Ubuntu 20.04. Example configuration:
config = webdriver.ChromeOptions()
config.add_argument('--headless')
config.add_argument('--no-gpu')
config.add_argument('--disable-sandbox')
config.add_argument('--resolution=1920,1080')
In my experience, I’ve noticed that headless mode in Chrome on newer Ubuntu releases doesn’t always replicate the desktop environment device settings, particularly when it comes to fonts and emojis. While experimenting with the configuration, I found that, unlike Ubuntu 20.04, Ubuntu 22.04 may require additional tweaks. One method that helped was using a virtual framebuffer to simulate a graphical environment, which allowed the proper loading of font libraries. Ensuring that the system font cache is updated before running tests also made a noticeable difference in rendering quality.
i had a similar issue. try removing the --no-gpu flag, or add --use-gl=desktop to see if that forces the right rendering enviroment. sometimes new ubuntu versions need a bit more tweaking for fonts/emojis to show correctly.
Using headless Chrome on Ubuntu 22.04 exposed issues that I didn’t encounter on earlier versions. In my testing, the problem was that the headless mode doesn’t load some font rendering resources by default. I eventually solved this by ensuring that all necessary emoji and custom font packages were installed and then forcing an updated font cache run via fc-cache. Moreover, I discovered that simulating a display with xvfb allowed headless Chrome to access the system fonts, which in turn improved the rendering of emojis and custom fonts. Adjusting the environment variables also contributed to a more desktop-like behavior.
In my experience, headless Chrome behaves differently due to environmental factors and the underlying libraries. It appears that Ubuntu 22.04 might not load all the font resources and associated libraries by default in headless mode. I found that ensuring custom fonts and reusable emoji fonts are correctly installed at the system level make a difference. Additionally, some extra flags such as ‘–use-gl=desktop’ seemed to improve rendering reliability. Reviewing system font paths or verifying that the fonts are available to headless processes has helped in similar scenarios.
I encountered a similar challenge while upgrading to Ubuntu 22.04. In headless mode, certain system resources, like custom fonts and emoji libraries, may not be loaded unless explicitly configured. My workaround involved verifying that all font packages are installed and that the system font cache is updated before launching tests. Additionally, simulating a display environment using tools such as xvfb helped ensure that headless Chrome accesses the required libraries. This approach, while not perfect, provided a more stable rendering output for both emojis and custom fonts in headless mode.