Cannot use custom fonts with -autostart script

If you are having problems with QCAD, post here. Please report bugs through our Bug Tracker instead.

Always attach your original DXF or DWG file and mentions your QCAD version and the platform you are on.

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files and screenshots.

Post one question per topic.

Post Reply
Ewald Moitzi
Newbie Member
Posts: 5
Joined: Tue Jul 10, 2018 10:09 am

Cannot use custom fonts with -autostart script

Post by Ewald Moitzi » Tue Jul 10, 2018 11:12 am

Hello forum,

I'm using QCAD Professional 3.18.1, both on Ubuntu 18.04 and Debian Jessie inside a Docker container. The problem that I have occurs in both environments.
I'm trying to add a text entity to a .dxf with a script called from the command line. I use additional true-type fonts, but they are always replaced with the standard font. According to the QCAD gui the fonts are available, but when I list the fonts with

Code: Select all

RFontList.init();
print (RFontList.getNames());
(Is this the right way to check installed fonts?)

they do not show up. The code used to create the Entity:

Code: Select all

function addText(doc, text, size, font, offsetx, offsety, bold, italic, hAlign) {
    if (isNull(font)) font = "Standard";
    if (isNull(hAlign)) hAlign = CONSTANTS[align];
    if (isNull(bold)) bold = false;
    if (isNull(italic)) italic = false;

    var height = parseInt(size);
    var angle = 0.0;
    var vAlign = RS.VAlignTop;
    var position = new RVector(offsetx, offsety);

    var entity = new RTextEntity(
        doc,
        new RTextData(
            position,
            position,
            height,
            100.0,
            vAlign,
            hAlign,
            RS.LeftToRight,
            RS.Exact,
            1.0,
            '\\H' + size + ';' + text,
            'Sansation',
            bold,
            italic,
            deg2rad(angle),
            false
        )
    );
    var di = new RDocumentInterface(doc);
    di.applyOperation(new RAddObjectOperation(entity, false));
}
The fonts are installed in /usr/share/fonts, and are listed when calling 'fc-list'.

Thanks,
Ewald

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: Cannot use custom fonts with -autostart script

Post by andrew » Tue Jul 10, 2018 11:22 am

You might have to set the environment variable

QT_QPA_FONTDIR=/usr/share/fonts

If you cannot fix the problem, please provide more information:
- What are the exact arguments passed to QCAD to run the script?
- Which QCAD package are you using (file name of installer)?

Ewald Moitzi
Newbie Member
Posts: 5
Joined: Tue Jul 10, 2018 10:09 am

Re: Cannot use custom fonts with -autostart script

Post by Ewald Moitzi » Tue Jul 10, 2018 12:42 pm

Hi Andrew,

thanks for the quick answer. Setting the environment variable did not help unfortunately.
qcad package: qcad-3.18.1-pro-linux-x86_64.run

The script is called with:
qcad -platform offscreen -allow-multiple-instances -no-gui -autostart qcad.js test.dxf
(I created a simplified script file removing all the custom parameters with hardcoded params for the text)

One more thing: When opening the file the font set for the text is 'standard'.

Regards,
Ewald

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: Cannot use custom fonts with -autostart script

Post by andrew » Tue Jul 10, 2018 1:58 pm

Can you attach the generated test.dxf output file?

Ewald Moitzi
Newbie Member
Posts: 5
Joined: Tue Jul 10, 2018 10:09 am

Re: Cannot use custom fonts with -autostart script

Post by Ewald Moitzi » Tue Jul 10, 2018 2:04 pm

Sure. I have also attached the script itself.
Attachments
test_merged.dxf
(7.45 MiB) Downloaded 320 times
qcad.js
(2.11 KiB) Downloaded 338 times

User avatar
andrew
Site Admin
Posts: 9037
Joined: Fri Mar 30, 2007 6:07 am

Re: Cannot use custom fonts with -autostart script

Post by andrew » Tue Jul 10, 2018 2:12 pm

The script is exporting to DXF R12 which does not support TrueType fonts. Try using a newer DXF version such as R27.

Ewald Moitzi
Newbie Member
Posts: 5
Joined: Tue Jul 10, 2018 10:09 am

Re: Cannot use custom fonts with -autostart script

Post by Ewald Moitzi » Tue Jul 10, 2018 2:32 pm

Ah, I see.

I will try that, thanks!

Kind Regards,
Ewald

Post Reply

Return to “QCAD Troubleshooting and Problems”