- This topic has 9 replies, 2 voices, and was last updated 6 years, 9 months ago by Tom.
-
AuthorPosts
-
July 12, 2017 at 11:52 am #348315Sharif
Hello there;
Is it possible to add @font-face for custom fonts without using child theme? I have uploaded custom fonts to wp-content folder. How Can I add @font-face?
I saw in another topic that following code is for child theme.@font-face { font-family: 'Your Font Name'; src: url('font-file-name.eot'); /* IE9 Compat Modes */ src: url('font-file-name.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */ url('font-file-name.woff2') format('woff2'), /* Super Modern Browsers */ url('font-file-name.woff') format('woff'), /* Pretty Modern Browsers */ url('font-file-name.ttf') format('truetype'), /* Safari, Android, iOS */ url('font-file-name.svg#svgFontName') format('svg'); /* Legacy iOS */ }
What should I write in url if custom fonts are in wp-content?
Regards,July 12, 2017 at 12:28 pm #348337TomLead DeveloperLead DeveloperJust replace the file name with the full URL:
http://yoursite.com/wp-content/font-file-name.eot
July 12, 2017 at 12:46 pm #348349SharifHi Tom,
Is something like this OK?font-face { font-family: 'hanis'; src: url('http://www.anis.af/wp-content/fonts/hanis.eot'); src: url('http://www.anis.af/wp-content/fonts/hanis.eot?#iefix') format('embedded-opentype'), url('http://www.anis.af/wp-content/fonts/hanis.woff2') format('woff2'), url('http://www.anis.af/wp-content/fonts/hanis.woff') format('woff'), url('http://www.anis.af/wp-content/fonts/hanis.ttf') format('truetype'), url('http://www.anis.af/wp-content/fonts/hanis.svg#hanis') format('svg'); }
BTW I thinks it is worth-mentioning that Simple CSS plugin is not compatible with RTL language. In RTL language Simple CSS is also converted to RTL which is not what should be. It does not matter whether language is RTL or LTR, Simple CSS should be always LRT because we write css from left to right.
Hope I had been able to write what I mean.July 12, 2017 at 7:22 pm #348526TomLead DeveloperLead DeveloperThat should work as long as those URLs are correct.
Thanks for letting me know about Simple CSS – I’ll take a look 🙂
July 12, 2017 at 8:15 pm #348551SharifHi Tom,
I addedfont-face { font-family: 'hanis'; src: url('http://www.anis.af/wp-content/fonts/hanis.eot'); src: url('http://www.anis.af/wp-content/fonts/hanis.eot?#iefix') format('embedded-opentype'), url('http://www.anis.af/wp-content/fonts/hanis.woff2') format('woff2'), url('http://www.anis.af/wp-content/fonts/hanis.woff') format('woff'), url('http://www.anis.af/wp-content/fonts/hanis.ttf') format('truetype'), url('http://www.anis.af/wp-content/fonts/hanis.svg#hanis') format('svg'); }
to Simple CSS and then added
`
p{
font-family:”hanis”;
}
but paragraph font did not change. It means that ulrs are incorrect but I was not able to find what is wrong with those ulrs. can you guide me please to find the correct urls? also can you tell me should I use http or https for urls?
Regards,July 12, 2017 at 8:27 pm #348554SharifI also added
html{ font-family:"hanis" } body{ font-family:"hanis" } a{ font-family:"hanis" }
But nothing changed.
July 13, 2017 at 12:12 am #348613TomLead DeveloperLead Developerfont-face
should be@font-face
July 13, 2017 at 12:30 am #348621SharifThanks Tom,
I changed font-face to @font-face but still nothing happened.July 13, 2017 at 6:34 am #348776SharifHi Tom,
Finally I found correct urls but how to use this function to integrate two fonts:add_filter( 'generate_typography_default_fonts','tu_add_system_fonts' ); function tu_add_system_fonts( $fonts ) { $fonts[] = 'font-name'; return $fonts; }
Regards,
July 13, 2017 at 9:28 am #348888TomLead DeveloperLead DeveloperLike this:
add_filter( 'generate_typography_default_fonts','tu_add_system_fonts' ); function tu_add_system_fonts( $fonts ) { $fonts[] = 'font-name'; $fonts[] = 'second-font-name'; return $fonts; }
This will add those two fonts to the Customizer dropdown lists of fonts.
-
AuthorPosts
- You must be logged in to reply to this topic.