FBXL5 wrote: ↑Sat Aug 06, 2022 4:33 pm
I still don't get it.
I am a bit unsure what you mean and what you don't get? I am assuming, that you don't have some background information about the issue - let me know if I am wrong.
The template/background of a Page is currently made by loading an SVG file onto the TechDraw Page, example:
https://github.com/FreeCAD/FreeCAD/blob ... 00_Pep.svg. This contains information about the drawing such as page number, author, description and also make up the borders of the page.
It is Qt (3rd party library) that handles the template SVG together with all the other TechDraw objects such as View, Dimensions and Annotations.
Then, when the users are finished with the drawing, they most probably want to export this TechDraw Page (containing the template from SVG, views, dimensions and annotations). The exporting of a PDF is made by a build-in function of Qt (3rd party library) - but it has a fatal flaw: what is text in the SVG gets converted to path in the PDF.
So what does this mean? Well in the PDF, the text from the SVG isn't anymore made by "real letters" as we know them, but is instead drawn as a figure having the same shape as the letters. (This might be known to some people as text to path as I call it. In InkScape, you can use the Object to Path function if you want to play around and see the difference between real text and path text.) And because this text in the SVG isn't real text anymore, but just path text, it means that it isn't markable and it isn't searchable.
This is nuisance to the user and makes up the issue that is talked about in this thread. But then - how does this make up the background of the thread about converting to FreeCAD objects?
Earlier, I only wrote that the template of SVG gets its text convert to path. This is because the fatal flaw only applies to objects loaded in as SVG (ref. QGraphicsSvgItem). That is also why the text that is not a part of the template (made from SVG) - such as annotations, dimensions and etc. does not get converted to path text but still is real text. This is because annotations, dimensions and etc. is drawn as FreeCAD object (QGraphicsItems made from bottom not involving importing any SVG).
And here we get to the proposal made in the initial post in the thread: convert the template to FreeCAD objects. If the template is made as FreeCAD objects and not as imported SVG, then the text in the template won't get converted to path but will still remain real text. Now, there aren't any issue with unmarkable or unsearchable text anymore.
That is why you would want the template to be made as text objects and not as an imported SVG object. It doesn't have anything to do with fonts or similar, but that the PDF rendering from the Qt (3rd party library) as a fatal flaw, nuisance to the user. Rendering to PDF is not to avoid any problem: rendering to PDF is the issue itself as it contains the fatal flaw: unmarkable and unsearchable text. There is no such thing as font incompatibility related to the issue.
For everyone who wants to dive more into this issue as developers:
- Text gets converted to path if SVG imported as a QGraphicsSvgItem is rendered with a QPainter.
- Text doesn't get converted to path if made as QGraphicsItems made from scratch.
- The rendering is done by QGraphicsScene::render (
https://doc.qt.io/qt-6/qgraphicsscene.html#render) or QGraphicsView::render (
https://doc.qt.io/qt-6/qgraphicsview.html#render) (I don't remember which).
- In source code, the rendering for PDF is done here
https://github.com/FreeCAD/FreeCAD/blob ... #L674-L835
- In source code, the rendering for SVG is done here
https://github.com/FreeCAD/FreeCAD/blob ... #L692-L768
- In source code, the workaround for SVG is implemented here
https://github.com/FreeCAD/FreeCAD/blob ... #L731-L739 and here
https://github.com/FreeCAD/FreeCAD/blob ... e.cpp#L767
- The rendered SVG doesn't convert text to path because the above workaround has been implemented. The workaround works by hiding the template (made from SVG) from rendering and then adding it manually again (since we already got the SVG source)
- If the code inside FreeCAD is too complicated to wrap your head around, then a short simplified demo of the issue is made here
https://stackoverflow.com/questions/732 ... d-not-text. I also made a repository on
https://github.com/benj5378/QGraphicsSv ... nder-issue with build instructions if you want to play with the code
I hope this clears things up a bit.