KiCad Schematics Font is a Deal-Breaker => Feature Sponsorship?

Sweet looking schematic

FYI, the plan is in fact to potentially drop cairo in V7 depending on how things go. I’m eyeballing vulkan/directx options on Windows now that we are MSVC based instead of msys2.
There’s been thoughts about replacing the current GAL backend with a far more flexible one off the shelf really. But all thoughts for the future.

2 Likes

hello, would it be the right decision to replace the GAL backend?
Thank you

In the future, maybe or we may opt to improve it instead. It is still too early to decide and we are focused on v6. It won’t come up until next year.

As I never saw a PR, I took your commit and pushed it slightly modified to master. Thanks.

Thank you :slight_smile: And sorry, I got distracted by the project that I’m using KiCAD on. CYUSB3014 were sold out everywhere so I had to modify my design. I guess, the chip shortage has now also reached us hobbyists.

BTW I just noticed another issue with Eeschema and its font handling, which is the PDF export.

  1. When I go Plot -> PDF I’ll sometimes have slightly different text placement and colors than in the graphical editor window.

  2. It appears that the ghost text which Eeschema puts into the PDF to make it searchable does not work for unicode codepoints > 255, for example the ± or Ω characters. I’m also seeing issues with German special characters like äöüß.

  3. When special characters are involved, the generated PDFs don’t pass the PDF 1.5 verifier that one of my collaborators uses.

#2 and #3 are now blocking my project, so I’ll try to build a band-aid solution for myself. Afterwards we can then take a look if it makes sense to merge my PDF export changes into the main KiCAD.

In general, the PDF file format is a huge mess w.r.t. fonts. Apparently, the /Encoding option that KiCAD uses is deprecated by now and instead one should emit two /Font dictionaries to embed a TTF font into the PDF and then populate the ToUnicode stream to enable PDF readers to convert the positioned glyphs into matching unicode characters. For some reason, doing that also deprecates the old (text) way of outputting pure ASCII7 characters, because now everything is assumed to be glyph indices and not code points anymore. The spec is 750 pages …

My first idea is that maybe one could use a dummy PDF template generated with Illustrator which contains a SIL TTF font. Then KiCAD could copy over all that PDF text setup mess from that template so that we don’t need to add TTF and unicode glyph mapping into the PDF_PLOTTER class.

@fxtentacle, isn’t this https://gitlab.com/fxtentacle/kicad/-/commit/aa87d9fcb148f0036d99dd5a64fe2e9a3e8b702c about https://gitlab.com/kicad/code/kicad/-/issues/6562 ? In case it is, could this be merged to kicad official master?

Not quite.

As you can see here: https://gitlab.com/fxtentacle/kicad/-/commit/444f1364368e1fb9bab13db879beea0627b22f96
I completely replaced the 7 bit text encoding and instead I’m now using a unicode font everywhere. That is necessary to make things like the ± or Ω characters work, because as soon as one specifies any kind of encoding, PDF will limit the unicode codepoints to 8 bit.

As a result of that patch, the PDF reader will now parse text differently, so it would actually show the FEFF as þÿ and thereby shift all text by 2 characters.

But the patch that I linked to greatly improves https://gitlab.com/kicad/code/kicad/-/issues/6562 for me, because now I am embedding my TTF font into the PDF and (due to earlier patches) my Eeschema is also using a TTF font for rendering the GUI and for the PDF plot, so then the font spacings match pretty perfectly. It’s just that this improvement is sadly not transferable to the KiCAD main branch, because it relies on my hack to force the PDF printouts to be just high-resolution screenshots of the GUI. (https://gitlab.com/fxtentacle/kicad/-/commit/3791c124b573b9d3decd949a413ac052b440a14b will replace the PDF with just one image downloaded from the GPU anti-aliasing buffer)

That said, as soon as KiCAD supports custom fonts, the embedding logic that I used here can then be used for KiCADs PDF export. That would (sometime in the future) enable the printouts to actually render the text with the PDF TTF engine, which means the text for searching and display will become identical, thereby fixing the current misalignment. But I guess that’s more v7+ stuff.

4 Likes

Thank you very much for such a thorough explanation :slight_smile:

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.