jamesshore / quixote

CSS unit and integration testing
Other
848 stars 45 forks source link

Font metrics #44

Open jamesshore opened 7 years ago

jamesshore commented 7 years ago

Even when using web fonts, font metrics vary across browsers. We need the ability to easily do relative comparisons to the current browser's font metrics.

For example, if we want to test that buttons have 10px of padding, this doesn't work cross browser:

button.assert({
  height: 38
});

Instead, we need to do this:

button.assert({
  height: font.height.plus(10)
});

It's possible to emulate this now by creating an element with the font in it, but I would like this to be foolproof and easy. A dedicated 'font' descriptor would also open up opportunities for useful comparisons such as x-height, m-width, and so forth.

jamesshore commented 7 years ago

See https://github.com/jamesshore/quixote/issues/41#issuecomment-293987088

jamesshore commented 6 years ago

v0.13 adds QElement.calculatePixelValues(), which might be enough to satisfy this need.