khadem1386 Posted December 14, 2009 Share Posted December 14, 2009 hello all:font-family: Mitra, Tahoma; font-size: 14pt, 12ptI want If my client hasn't Mitra in his browser ,it use Tahoma instead.but best size for Mitra is 14 and for Tahoma is 12.What can I do?Thanks a lot Link to comment Share on other sites More sharing options...
roundcorners Posted December 14, 2009 Share Posted December 14, 2009 You could use JavaScript to check which font the text has been rendered in and switch the font size accordingly e.g.(Set the font family on the body element)var x = document.getElementsByTagName('body');if (x.style.fontFamily = 'Mitra') { x.style.fontSize = '14px'} else { x.fontSize = '12px'}However, it is quite unlikely that a user will have Mitra installed on their system.Another alternative is to use the @font-face css rule.Font squirrel has a bunch of free fonts you can pick from and also provides a kit that contains the different font formats you will need to serve each user agent correctly. It even includes the CSS. It's not yet a perfect solution and you might not find Mitra for free, but it is worth a look.There is most likely a way of changing the font sizes using a server side script language such as PHP which is more robust than JAvaScrip that could be disabled. Link to comment Share on other sites More sharing options...
Ingolme Posted December 14, 2009 Share Posted December 14, 2009 Actually, Javascript cannot know which font is being used on the text.The style.fontFamily property would be empty unless something was put into the style attribute of the element. Besides, it would only show exactly what had been put in the element. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.