mb21 / panwriter

Markdown editor with pandoc integration and paginated preview.
https://PanWriter.com
GNU General Public License v3.0
1.04k stars 51 forks source link

Fonts are ignored in PDF #131

Closed Skeeve closed 1 year ago

Skeeve commented 1 year ago

I put into my document:

---
mainfont: Avenir Next
---

and. in split mode I can see the font change.

But when exporting to PDF, the font is ignored.

Are there any troubleshooting tips?

I'm using

mb21 commented 1 year ago

PDF export is using pandoc, which is using LaTeX under the hood. There, not all normally installed fonts are supported. See https://pandoc.org/MANUAL.html#fonts

Skeeve commented 1 year ago

Okay. But I have a font which works with pandoc on another machine, but I do not use panwriter there. So what would be the correct syntax to tell pandoc from panwriter where the fontfile resides?

I already tried the full path to the font file but I did not succeed.

Skeeve commented 1 year ago

I checked as described here: https://fedidat.com/160-installing-fonts-for-pandoc/

and I can see: My font is installed.

Skeeve commented 1 year ago

Update:

pandoc -f markdown --pdf-engine=xelatex --to pdf -o Untitled.pdf Untitled.md

This works with my intended font "Avenir Next"

but when I define in the document or defaults.yaml

papersize: A4
mainfont: Avenir Next
output:
  latex:
    toc: true
    pdf-engine: xelatex

panWriter fails

Called: pandoc --metadata-file '/Users/skeeve/Library/Application Support/PanWriterUserData/default.yaml' --toc --pdf-engine xelatex --metadata 'mainfont=-apple-system, BlinkMacSystemFont, Segoe UI, sans-serif' --metadata monobackgroundcolor=#f0f0f0 --output /Users/skeeve/Desktop/Untitled.pdf --to latex --standalone

Error producing PDF.
! Package fontspec Error: The font "-apple-system, BlinkMacSystemFont, Segoe
(fontspec)                UI, sans-serif" cannot be found.

For immediate help type H <return>.
...                                              

l.24 \fi
Skeeve commented 1 year ago

Update: mainfont works if a) You put it into the document, not in the defaults.yaml b) You use xelatex as the pdf-engine

Skeeve commented 1 year ago

Would, maybe, this solve the issue?

  if (docMeta.mainfont === undefined) {
    out.metadata.mainfont = extMeta.mainfont || '-apple-system, BlinkMacSystemFont, Segoe UI, sans-serif';
  }

Yes, it does. Please see PR #134

Skeeve commented 1 year ago

Will be fixed when PR #134 is merged.