Changing fonts within a chapter- PrinceXML Export

I’m working on a Programming book, and there is a convention in Programming where code is presented as a different font than the rest of the book.

The faculty member wants code in Courier New.

I tried to format the HTML like this:

span style=“font-family: courier new;”

That worked in the webbook view, but not across export types. What would be a way to do what this faculty member wants and change fonts within a chapter. Anyone have any ideas?

Hi @beckej, we need to add a good monospace font for this to our exports. Thanks for flagging it. Right now in the default styles we have this rule for <code>: https://github.com/pressbooks/buckram/blob/master/assets/styles/variables/_elements.scss#L918

Obviously that doesn’t work everywhere.

We probably need to find an open source (SIL) font that is suitable. Open to suggestions from forum members.

Thanks @ned ,

I didn’t realize that there were such a thing as code tags. That will make this a lot easier to manage. There’s even a keyboard shortcode to go through rapidly.

Ed

1 Like

Ned,

I don’t have strong preferences about Open Source Fonts or Monospace fonts, but I found this article that highlights 5 open source monospace fonts.

The one supported by Google seems to have a lot of languages, Fira Code was commissioned by Mozilla, Deja Vu Sans is meant to look like the font used in GNOME…

1 Like

I’m a big fan of Inconsolata. Anyone else have opinions? @dac.chartrand?

I actually don’t have an opinion on this. I use the defaults in PhpStorm?

Usually DejaVu Sans Mono, or Liberation Mono.

I’ll create an issue and we can add a font for this. Thanks for flagging it, @beckej.