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?
2 Answers
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"/>
-
this doesn't really remove it as you end up having it included in styles-m.css for some reason. I'm still looking at why it's not being removed. Commented Aug 10, 2021 at 20:01
Step1: Copy the _typography.less from location
vendor\magento\theme-frontend-blank\web\css\source
paste to location
app\design\frontend\vendor\theme-name\web\css\source.
Remove the lines that refer to the opensans fonts.
Step2: Run the following commands from root of magento directory
rm -rf pub/static/*
php bin/magento setup:static-content:deploy -f