Last Updated: February 25, 2016
·
598
· asbigger

Override User Selected Font in iBooks

Sometimes users change the font when reading ePubs in iBooks, and although I am all for that freedom, sometimes when a font is used for icons or another very specific reason, it becomes necessary to force it to render that way.

This can be achieved by placing the character in a samp as opposed to a span:

<samp class="some-icon">A</span>

Then in the stylesheet defining the font as normal:

@font-face {
  font-family: 'SomeFont';
  font-weight: normal;
  font-style: normal;
  src: url('SomeFont.ttf');
  }

samp.some-icon { font-family:SomeFont; }

Be sure to have the font defined in the ePub manifest otherwise you'll have a bad time: