How can I change monospace elements to sans-serif
Post here questions and problems related to editing and publishing DITA content.
-
- Posts: 30
- Joined: Sat Feb 16, 2019 8:43 pm
How can I change monospace elements to sans-serif
Hi,
I am using the Ditamap PDF html5/css transformation in editor 21.1.
I set my font-family to the following:
Everything works fine except for elements that are monospace. Content in these elements is monospaced, but with a serif font.
How can I make this content sans-serif, too? For example, codeph, codeblock, filepath, userinput....
Thanks a lot.
Adam
I am using the Ditamap PDF html5/css transformation in editor 21.1.
I set my font-family to the following:
Code: Select all
* {font-family: Arial, Verdana, Tahoma, Helvetica, sans-serif}
How can I make this content sans-serif, too? For example, codeph, codeblock, filepath, userinput....
Thanks a lot.
Adam
Adam Myers
Technical Publications Manager
MATRIXX Software
Technical Publications Manager
MATRIXX Software
-
- Posts: 501
- Joined: Mon Feb 03, 2003 10:56 am
Re: How can I change monospace elements to sans-serif
In case you want to replace all fonts in your publication with a single Sans Serif font, you can increase the importance of your CSS rule:
In case you want to change the font for all code sections, you should create rules that match those elements.
For example:
In general, to debug your CSS and test selectors, see:
https://www.oxygenxml.com/doc/versions/ ... ng_the_css
Many regards,
Dan
Code: Select all
* {
font-family: Arial, Verdana, Tahoma, Helvetica, sans-serif !important;
}
For example:
Code: Select all
pre,
.codeblock {
font-family: monospace;
}
.codeph {
font-family: monospace;
}
.filepath {
font-family: monospace;
}
https://www.oxygenxml.com/doc/versions/ ... ng_the_css
Many regards,
Dan
-
- Posts: 30
- Joined: Sat Feb 16, 2019 8:43 pm
Re: How can I change monospace elements to sans-serif
Thanks for your reply, Dan.
The problem I am having is that when I set the font family as this:
* {
font-family: Arial, Verdana, Tahoma, Helvetica, sans-serif !important;
}
These styles are correctly ignored:
pre,
.codeblock {
font-family: monospace;
}
.codeph {
font-family: monospace;
}
.filepath {
font-family: monospace;
}
If I remove !important, monospace works, but the font changes to serif in the pdf. In the merged html, the font appears correctly (monspace +sans-serif).
The problem I am having is that when I set the font family as this:
* {
font-family: Arial, Verdana, Tahoma, Helvetica, sans-serif !important;
}
These styles are correctly ignored:
pre,
.codeblock {
font-family: monospace;
}
.codeph {
font-family: monospace;
}
.filepath {
font-family: monospace;
}
If I remove !important, monospace works, but the font changes to serif in the pdf. In the merged html, the font appears correctly (monspace +sans-serif).
Adam Myers
Technical Publications Manager
MATRIXX Software
Technical Publications Manager
MATRIXX Software
-
- Posts: 663
- Joined: Wed Oct 16, 2019 3:47 pm
Re: How can I change monospace elements to sans-serif
Post by julien_lacour »
Hello Adam,
What I will recommend for you is NOT using the * selector inside you customization.
Instead you should prefer:
Regards,
Julien
What I will recommend for you is NOT using the * selector inside you customization.
Instead you should prefer:
Code: Select all
/* This will customize the main title */
*[class ~= "front-page/front-page-title"] {
font-family: Arial, Verdana, Tahoma, Helvetica, sans-serif;
}
/* This will customize the content */
body {
font-family: Arial, Verdana, Tahoma, Helvetica, sans-serif;
}
Julien
-
- Posts: 30
- Joined: Sat Feb 16, 2019 8:43 pm
Re: How can I change monospace elements to sans-serif
Thanks Julien,
I tried this and it didn't work, either. Codeph, codeblock, filepath are still what looks like courier.
I went back to the oob pdf based on html5 transformation and the only change I made was to the oxygen-print.css file:
body {
font-size: 10pt;
font-family: Roboto;
I get the same result. The filepath is courier while everything else is Roboto - as you can see in the attachment.
I tried this and it didn't work, either. Codeph, codeblock, filepath are still what looks like courier.
I went back to the oob pdf based on html5 transformation and the only change I made was to the oxygen-print.css file:
body {
font-size: 10pt;
font-family: Roboto;
I get the same result. The filepath is courier while everything else is Roboto - as you can see in the attachment.
2019-11-08_13-46-00.gif
You do not have the required permissions to view the files attached to this post.
Adam Myers
Technical Publications Manager
MATRIXX Software
Technical Publications Manager
MATRIXX Software
-
- Posts: 663
- Joined: Wed Oct 16, 2019 3:47 pm
Re: How can I change monospace elements to sans-serif
Post by julien_lacour »
If what you want is simply replacing the default font for monospace contents you should do the following in your custom CSS file:
Feel free to modify this sample, add some classes, etc... if I omit something.
Regards,
Julien
Code: Select all
.pre,
.filepath,
.codeph,
.codeblock {
font-size: 10pt;
font-family: Roboto;
}
Regards,
Julien
-
- Posts: 922
- Joined: Thu May 02, 2019 2:32 pm
Re: How can I change monospace elements to sans-serif
Post by chrispitude »
I second what Dan said - use the CSS Style Inspector! It will show you any CSS properties that are overriding your setting.
-
- Posts: 30
- Joined: Sat Feb 16, 2019 8:43 pm
Re: How can I change monospace elements to sans-serif
I appreciate everybody's input, and yes, I use the css inspector. I don't know if anybody has actually tried this, but no matter what I do, codeblock is not sans serif in the pdf. In the merged html file, the codeblock font is sans serif and the inspector identifies the style in the css. But in the PDF, codeblock only appears as serif. I'm giving up.
Adam Myers
Technical Publications Manager
MATRIXX Software
Technical Publications Manager
MATRIXX Software
-
- Posts: 30
- Joined: Sat Feb 16, 2019 8:43 pm
Re: How can I change monospace elements to sans-serif
Ok - I decided to try one more time. I was able to get the codeblock to be sans serif by not using the class and by using the code element. Thanks for everybody's input.
Adam Myers
Technical Publications Manager
MATRIXX Software
Technical Publications Manager
MATRIXX Software
-
- Posts: 663
- Joined: Wed Oct 16, 2019 3:47 pm
Re: How can I change monospace elements to sans-serif
Post by julien_lacour »
Hello Adam,
I can provide you a snapshot of the current version of the oxygen-publishing-engine, can you contact us at support@oxygenxml.com.
If the problem still reproduces in this version feel free to send us an email with a sample of your customization, like this we will try to reproduce your problem and correct it.
Regards,
Julien
I can provide you a snapshot of the current version of the oxygen-publishing-engine, can you contact us at support@oxygenxml.com.
If the problem still reproduces in this version feel free to send us an email with a sample of your customization, like this we will try to reproduce your problem and correct it.
Regards,
Julien
Return to “DITA (Editing and Publishing DITA Content)”
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service