css - How to standardise font-sizes across different font-family -
i using oswald (http://www.google.com/fonts/specimen/oswald) , bebas neue (http://dharmatype.com/dharma-type/bebas-neue.html) on website.
i loading both via font-face
(oswald via google web fonts, it's same process).
however, fonts appear dramatically different heights when using same font-size definition (e.g. font-size:14px
renders 2 different sizes).
i need them render same size page work.
two questions: i) causing difference, , ii) can done fix it? preferably ie8 compliance.
thanks
answer 1: glyphs in font positioned on canvas. need whitespace around positioned each other. amount of white differs. 1 of reasons ratio between x-height size of ascenders (bdfhklt) , descenders (gjqpy). if font has relative small x-height (large (as/de)cenders), there more white around glyph font has relative big x-height. there more variables influence amount of white. capital/lowercase ratio , font weight.
answer 2: nothing broken. can use css , set font-size relatively , correct size of text.
you can scroll image edge of browser window check glyphs align.
top: no adjustment
middle: same x-height. looks good!
bottom: same capital height. need since 1 of fonts capitals.
the html:
<!doctype html> <html> <head> <meta charset="utf-8" /> <style> p { border: 1px solid red; line-height: 1em; font-size: 600%; margin: 0 0 0.1em 0; } .arial { font-family: 'arial'; } .times { font-family: 'times new roman'; } .times_same_x_height { font-size:116%; } .times_same_capital_height { font-size:108%; } .font_stack { font-family: "does not exist", serif; } </style> </head> <body> <p> <span class="arial">xh</span> <span class="times">xh</span> </p> <p> <span class="arial">xh</span> <span class="times times_same_x_height">xh</span> </p> <p> <span class="arial">xh</span> <span class="times times_same_capital_height">xh</span> </p> </body> </html>
note 0: if looks right, right. don't use x-height , done it. clear difference in size make font combination more harmonious. use eyes (and brain).
note 1: placed text in same paragraph. did because aligns baseline. it's more text elements separated form each other. define right line-height
, margin
position. use relative values. , little baseline shift: .shift { top: -.01em; position:relative; }
note 2: if font not exist. font_stack use next best font. realize fine typography applies fonts in stack!
tip: if want change weight of font slightly. can make color little lighter. eg. black dark gray. make less bold.
bonus: ie comply.
feedback appreciated.
Comments
Post a Comment