0

i tried fully embedding a font using directives from How can I verify that the fonts are all embedded in my LuaLatex document? [1], using font BlackChancery from https://www.1001fonts.com/blackchancery-font.html [2]. The embedding seems to work (Adobe Reader says the font is embedded not (subsetted as usual), but i can't seem to make it work inside eforms. [1] also said that i needed to reload my fonts, i tried even uninstalling the font and it dind't work (I'm on Windows if it helps). Can someone help me?

Here's my MWE:

\usepackage{fontspec}
\usepackage{luacode}
\begin{luacode}
local function embedfull(tfmdata)
    tfmdata.embedding = "full"
end

luatexbase.add_to_callback("luaotfload.patch_font", embedfull, "embedfull") \end{luacode} \setmainfont{Black Chancery} \usepackage{eforms} \begin{document} \centering \textField[\Q{1}\textFont{Black Chancery}\textSize{15}\V{This text wants to be in chosen font}]{MyText}{100mm}{15mm}

\end{document}

Khalni
  • 1

1 Answers1

1

There shouldn't be a space in the font name. This here works for me. It doesn't require to embed the font but it requires that the font is installed as system font, and it also depends on the pdf viewer -- I tested with adobe reader on windows.

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Black Chancery}
\usepackage{eforms}
\begin{document}
\centering
\textField[\Q{1}\textFont{BlackChancery}\textSize{15}\V{This text wants to be in chosen font}]{MyText}{100mm}{15mm}
\end{document}

If the font is not available as system font you must embed it as you did in your code, but then you must also add it to the /DR dictionary and also you must use the internal name.

I don't know if you can add a font with eforms. With the new pdfmanagement and l3pdffield it works like this:

\RequirePackage{pdfmanagement-testphase}
\DeclareDocumentMetadata{uncompress} 
\RequirePackage{expl3}
\ExplSyntaxOn
\pdf_uncompress:
\ExplSyntaxOff

\documentclass[12pt]{article} \usepackage{fontspec} \usepackage{luacode} \begin{luacode} local function embedfull(tfmdata) tfmdata.embedding = "full" end

luatexbase.add_to_callback("luaotfload.patch_font", embedfull, "embedfull") \end{luacode} \setmainfont{Black Chancery} \usepackage{l3pdffield-testphase} \begin{document} \ExplSyntaxOn % deprecated but forces the text to appear when the pdf is open: \pdfmanagement_add:nnn{Catalog/AcroForm}{NeedAppearances}{true}

% add the font to the /DR/Font dictionary: \pdfmanagement_add:nxx{Catalog/AcroForm/DR/Font} {F\pdffeedback~fontname\font} {\pdffeedback~fontobjnum\font \c_space_tl 0 \c_space_tl R}

textfield:~\pdffield_textfield:n {name=text,font=F\pdffeedback~fontname\font,fontsize=15pt,value={some~text}}

\ExplSyntaxOff \end{document}

enter image description here

Ulrike Fischer
  • 327,261
  • Thanks a lot, it's always the small things :) I think i'll use the first solution tho, the customization that eforms offer is needed :) – Khalni Oct 11 '21 at 19:10
  • Marked the answer, but if anyone has another add-font solution that works with eforms that would be really welcome. – Khalni Oct 11 '21 at 19:20
  • well I'm quite confident that all eforms options can be done with l3pdffield too. Actually I think that l3pdffield has more options as it also supports pdf 2.0. And if something is missing I can always add it. – Ulrike Fischer Oct 11 '21 at 19:51
  • I will try it then, thank you :) I din't know it was your package, sorry – Khalni Oct 11 '21 at 20:26