<html>
    <head>
      <base href="https://bugs.freedesktop.org/">
    </head>
    <body>
      <p>
        <div>
            <b><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - FreeText annotation ignores font"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=81748#c16">Comment # 16</a>
              on <a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - FreeText annotation ignores font"
   href="https://bugs.freedesktop.org/show_bug.cgi?id=81748">bug 81748</a>
              from <span class="vcard"><a class="email" href="mailto:haxtibal@posteo.de" title="Tobias Deiminger <haxtibal@posteo.de>"> <span class="fn">Tobias Deiminger</span></a>
</span></b>
        <pre>(In reply to Dileep Sankhla from <a href="show_bug.cgi?id=81748#c14">comment #14</a>)
<span class="quote">> This patch is generated as per my experiment in Poppler and is a workaround
> for the Base 14/standard fonts.</span >

Thanks Dileep. The patch has several problems, but it's good you sent it, it
helps narrowing down a solution.

<span class="quote">> It gets rid of the "Invalid_font" tags and
> generates meaningful font tags.</span >

Tags have to be unique in the AcroForm->DR->Font dictionary. Your patch can't
ensure this, because you did no lookup to DR. There might already be a "/DejSe"
tag existing, coming from another PDF tool for another font. We must not
overwrite that tag.

Your patch may even collide with its own tags, because for example
QFont("Liberation Mono,12,-1,5,50,0,0,0,0,0,Regular") and QFont("Liberation
Mono,12,-1,5,75,1,0,0,0,0,Bold Italic") both become "LiberMo", but they're
different fonts.

We often see PDF docs where font tags are counted like this, F1, F2, F3,... or
R1, R2, R3... I believe that's a reasonable scheme. No need to make the tag
sound like the name, but just use the next free number to make it unique.

<span class="quote">> Secondly, the font name as per the Base 14
> font names is exactly generated from the QFont and the font name is set in
> the font dictionary inside createAnnotDrawFont.</span >

No, your generated names are neither Base14 nor PostScript names, but quite
arbitrary. Your new method createFontTagandName() generates font names and tags
from QFonts with results like this:
QFont("DejaVu Serif,12,-1,5,50,0,0,0,0,0,Book") => Tag="DejSe",
Name="DejaVu-Book"
QFont("FreeSans,12,-1,5,63,0,0,0,0,0,Bold") => Tag="Free", Name="FreeSans-Bold"
QFont("Liberation Mono,12,-1,5,50,0,0,0,0,0,Regular") => Tag="LiberMo",
Name="Liberation"
QFont("Liberation Mono,12,-1,5,75,1,0,0,0,0,Bold Italic") => Tag="LiberMo",
Name="Liberation-BoldItalic"

That generated names really don't refer to Base14 fonts. In the standard,
there's a list of exactly 14 Type1 base fonts:
[Times-Roman, Helvetica, Courier, Symbol, Times-Bold, Helvetica-Bold,
Courier-Bold, ZapfDingbats, Times-Italic, Helvetica-Oblique, Courier-Oblique,
Times-BoldItalic, Helvetica-BoldOblique, Courier-BoldOblique]
That's it. None of DejaVu-Book, FreeSans-Bold, Liberation,
Liberation-BoldItalic is listed here, so they're not Base14 fonts.

The names are also not PostScript names. You can check for PostScript name like

$ fc-scan --format "%{postscriptname}\n"
/usr/share/fonts/truetype/dejavu/DejaVuSerif.ttf 
DejaVuSerif

So the PostScript name for QFont("DejaVu Serif,12,-1,5,50,0,0,0,0,0,Book")
would have been "DejaVuSerif", not "DejaVu-Book".

We can use non-Base14 fonts, it's just harder to set them up. It's important to
use the real PostScript name then, and to provide encoding and a font
descriptor. And, for platform independence, non-Base14 font programs should be
embedded into the PDF. Embedding is optional: If font is not embedded, a reader
will do font substitution with available system fonts by available metrics.

I think we should start by querying fontconfig in poppler to get font type and
PostScript name, and then write it to SubType and BaseName. In a second step,
we should try to get the encoding right and to setup a font descriptor. I guess
most readers have heuristics to cope without a font descriptor, but standard
says it's required. If we managed that too, we can finally research for font
embedding.

<span class="quote">> The default is set to
> "Helvetica". What this patch can do is when the Okular program is in the
> memory, you can try different base-14 fonts for the typewriter annotation
> but if you save the PDF doc and then quit it, the fonts will be set to
> "Helvetica".</span >

I've not looked into that yet. Eventually we should generate a DA that's the
same in memory and on disk.

<span class="quote">> Imho this experimental patch can be extended and modified to write the font
> dictionary for the base 14 fonts in the document and to generate freetext
> appearance based on the DA and DR entries and the font dict. The second
> follows the embedded fonts.</span >

Yes, both needs to be done.</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>