Magento – how to remove Open Sans font in magento 2

custom-themefontsmagento2

I need to remove Open Sans font in our Magento2 site. I have inherited the luma theme, so how to override the blank theme _typography.less file?

Best Answer

In addition to Sourav's answer, from what I can tell under Magento 2.3.3 you also need to override the vendor/magento/theme-frontend-luma/Magento_Theme/layout/default_head_blocks.xml file in your theme as the default_head_blocks.xml includes these lines:

<font src="fonts/opensans/light/opensans-300.woff2"/>
<font src="fonts/opensans/regular/opensans-400.woff2"/>
<font src="fonts/opensans/semibold/opensans-600.woff2"/>
<font src="fonts/opensans/bold/opensans-700.woff2"/>
<font src="fonts/Luma-Icons.woff2"/>

In your theme file (eg. app/design/frontend/{vendor}/{theme-name}/Magento_Theme/layout/default_head_blocks.xml) you can remove the references to the files using:

<remove src="fonts/opensans/light/opensans-300.woff2"/>
<remove src="fonts/opensans/regular/opensans-400.woff2"/>
<remove src="fonts/opensans/semibold/opensans-600.woff2"/>
<remove src="fonts/opensans/bold/opensans-700.woff2"/>
<remove src="fonts/Luma-Icons.woff2"/>
Related Topic