title: iText monospaced fonts in html view with bold, italic from css style
body: <p>I am using html to generate PDF document, since its an EMR record I have to use Monospaced fonts.</p>
  
  <p>PDF is getting generated fine, but css style for bold and italics are getting ignored, as I am using single .otf file for font hence no bold and italics.</p>
  
  <p>I was wondering how to enable the same. Below are the code snippets.</p>
  
  <p><strong>Font Factory:</strong></p>
  
  <pre><code>public static class MyFontFactory implements FontProvider,Serializable {
          public Font getFont(String fontname,
                  String encoding, boolean embedded, float size,
                  int style, BaseColor color) {
                  BaseFont bf3 = null;
              try {
                  bf3 = BaseFont.createFont("Inconsolata.otf",BaseFont.CP1252, BaseFont.EMBEDDED);
              } catch (Exception e) {
                  e.printStackTrace();
              } 
  
              return new Font(bf3, 6);
          }
  
          public boolean isRegistered(String fontname) {
              return false;
          }
      }
  </code></pre>
  
  <p><strong>PDF Generation Code:</strong></p>
  
  <pre><code>public void createPdf(Object object) throws Exception, DocumentException{
          // step 1
          Document document = new Document();
          // step 2
          PdfWriter.getInstance(document, new FileOutputStream(new File("test.pdf")));
          // step 3
          document.open();
         // create extra properties
          HashMap&lt;String,Object&gt; map = new HashMap&lt;String, Object&gt;();
          map.put(HTMLWorker.FONT_PROVIDER, new MyFontFactory());
          // step 4
          String snippet;
          // create the snippet
          snippet = createHtmlSnippet(object);
          Map&lt;Object,Object&gt; model = new HashMap&lt;Object,Object&gt;();
          model.put("object", object);
  
          StyleSheet css = new StyleSheet();
          Map&lt;String, String&gt; stylemap = new HashMap&lt;String, String&gt;();
          stylemap.put("font-style", "italic");
          stylemap.put("font-size", "small");
          stylemap.put("font-weight", "bold");
          css.loadStyle("header",(HashMap&lt;String, String&gt;) stylemap);
          css.loadStyle("strongClass", "text-decoration", "underline");
          List&lt;Element&gt; objects = HTMLWorker.parseToList(new StringReader(snippet), css, map);
  
         for (Element element : objects)
                document.add(element);
          // step 5
          document.close();
      }
  </code></pre>
  
  <blockquote>
    <p>In the above code css supplied does not produce any effect on output
    as I mentioned due to single font defined, if I want to have bold and
    italics how can that be achieved?</p>
  </blockquote>
  
  <p>Really appreciate if anyone provides pointers or help regarding same.</p>
  
  <p>Thanks.</p>
  
  <p><em><strong>Note: If I remove Monospaced fonts css gets applied.</em></strong></p>