Authoring for Pocketbook

From MobileRead
Jump to: navigation, search

This is a collection of things I've discovered (or rediscovered) about how PocketBook renders EPUB books. As PocketBook uses the Adobe RMSDK, this may possibly be applicable to other RMSDK-based readers.

[edit] Fonts

Generally, the reader program supports lots of font-related settings in the CSS, including custom embedded fonts using @font-face. However there's a gotcha.

If you have set the reader to use the "default" font in the font menu, then you can specify fonts for every element, including custom fonts. There's no problem as far as I can see, however who uses the "default" font in real life?

Otherwise, the reader ignores a lot of your CSS "font-family" specifications and instead uses whatever font you've chosen in the font menu. That's a bit surprising, because it also changes things like HTML "pre" elements.

In fact, what I think it does is just override "font-family" in any element in the HTML that has the CSS display property of "block". Elements with other display types like "inline" are not changed.

In other words, you can do something like this:

<tt>This is some computer code</tt>

and it will be formatted in monospace, regardless of the chosen font.

Generic font-family names like "serif", "sans-serif" and "monospace" work for inline elements.

Here's a working @font-face example:

    @font-face {
       font-family: 'JetBrains Mono';
       font-style: normal;
       font-weight: normal;
       font-stretch: normal;
       src: url('../Fonts/JetBrainsMono-Regular.ttf') format('truetype');
   }
   @font-face {
       font-family: 'Ubuntu Mono';
       font-style: normal;
       font-weight: normal;
       font-stretch: normal;
       src: url('../Fonts/UbuntuMono-Regular.ttf') format('truetype');
   }
   @font-face {
       font-family: 'Ubuntu Mono';
       font-style: normal;
       font-weight: bold;
       font-stretch: normal;
       src: url('../Fonts/UbuntuMono-Bold.ttf') format('truetype');
   }
   
   .mono {
       font-family: "JetBrains Mono";
       font-size: 90%;
   }
   .mono2 {
       font-family: "Ubuntu Mono";
       font-size: 90%;
   }

and in the HTML you can do:

<span class="mono">This is in Jetbrains Mono</span>
<span class="mono2">This is in the <b>Ubuntu Mono</b> font</span>

[edit] Dark mode

You can use CSS media selectors to change the CSS if you're using the reader in dark mode:

   table.values {
       border-collapse: collapse;
       border: 2px solid black;
       font-family: sans-serif;
       font-size: 90%;
       margin: 1em auto 0px;
   }
   table.values tr td {
       border: 1px solid black;
       padding: 0.2em 1em;
   }
   table.values tr th {
       background-color: black;
       color: white;
       padding: 0.2em 1em;
   }
   
   /* Handle dark mode */
   @media (prefers-color-scheme: dark) {
       table.values {
           border: 2px solid white;
       }
       table.values tr td {
           border: 1px solid white;
       }
       table.values tr th {
           background-color: white;
           color: black;
       }
   }
Personal tools
Namespaces

Variants
Actions
Navigation
MobileRead Networks
Toolbox