Re: New .dxf to .elmt Conversion Program

Hallo plc-user,

plc-user wrote:

I noticed something similar with the imperial DXF from your American compatriot.!

I can double check, but I believe this extra scaling factor for the imperial unit drawing was fixed in the last commit.

plc-user wrote:

If we focus on the 20 mm font:
In LibreCAD (black background) it is good to see that both texts are the same size - I expect the same for the element.
In the element (white background), the polygon 20 mm are 40px high, but the 20 mm text has a font size of 57.
So there is still a factor of about 1.4 somewhere in there that doesn't belong.

The scaling for the font is handled separately from the rest of the drawing. This is because dxf stores text height in whatever unit the drawing is in (ie mm, inches, etc) and QET uses your stand font points. A font point is defined as 1pt = 1/72 inches, which comes out to 1pt = 0.3528mm.

Based on this conversion the values that are being generated are "correct", because text height in mm would be multiplied by a factor of roughly 2.83. instead of the 2 used to convert mm to pixels.

I checked a couple of online unit conversion calculators to verify my math and 20mm comes out to 56.692913386pt font, rounded to 57 in the element.

You are right though that this clearly isn't correct in the element file. Doing a quick hacky test of modifying the text element font size to try and match the polygon size, it looks like the factor in your sample file should be 2.1. (for the 20mm text, a font size of 42pts).  It's not clear to me where this 2.1 comes from...but it is close to the 2px per mm we use in the conversion of this drawing. Perhaps multiplying the text height in real world units by the same as the rest of the drawing instead of "properly" converting between font points and real world units would be better? I'll need to try and do more testing and see what I can come up with, and test it against some other drawings.

Re: New .dxf to .elmt Conversion Program

scorpio810 wrote:

My health is deteriorating and I find it hard to think and organise myself.


Laurent,

I'm sorry to hear about your health, and I hope you get better.

I wish I had more time to contribute and help out with QET, but I have young children which for the moment take a lot of time and energy.

Re: New .dxf to .elmt Conversion Program

Hello vadoola,

vadoola wrote:

(...) A font point is defined as 1pt = 1/72 inches, which comes out to 1pt = 0.3528mm.

Based on this conversion the values that are being generated are "correct", because text height in mm would be multiplied by a factor of roughly 2.83. instead of the 2 used to convert mm to pixels.

Just to understand you correctly:
You think the calculation of the text size is correct if a text that fits well into a rectangle in the DXF is much bigger and no longer fits into the same rectangle in the converted element? And that's because it says somewhere that a px is not as big as a pt? Seriously?

Attached is another example to clarify what I mean:
A DXF file in which I have inserted an 11 mm high text into a field of about 12 mm. Next to it is the converted element file, where you can see that the text “11 mm” definitely does not fit into the same field. In addition, the element file in which I changed the text “11 mm” to the appropriate size “22” and moved it.
I am explicitly not talking about the text position here, as we both know that this does not yet fit: I'm talking about the text size!

Note:
I used dxf2elmt - sources from last weeks commit c3a5b2a.

Post's attachments

Bildschirmfoto_20250129_001_LibreCAD.png, 6.68 kb, 970 x 504
Bildschirmfoto_20250129_001_LibreCAD.png 6.68 kb, 1 downloads since 2025-01-29 

Bildschirmfoto_20250129_002_converted_by_dxf2elmt.png, 9.24 kb, 711 x 377
Bildschirmfoto_20250129_002_converted_by_dxf2elmt.png 9.24 kb, 1 downloads since 2025-01-29 

Bildschirmfoto_20250129_003_Textsize_and_Posittion_corrected.png, 11.03 kb, 944 x 501
Bildschirmfoto_20250129_003_Textsize_and_Posittion_corrected.png 11.03 kb, 1 downloads since 2025-01-29 

Attachment icon Fontsize-Sample.zip 535.55 kb, 2 downloads since 2025-01-29 

Fragen zu QET gehören in dieses Forum und werden nicht per PM beantwortet! – Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: New .dxf to .elmt Conversion Program

Hallo plc-user

I think I worded things in a way that did not translate properly for someone who is not a native English speaker. Sorry about that, I will try and word things better to make it more clear.

The current code is my first attempt and properly handling the text sizing, and text scaling over what Antonio had with just a fixed 12pt font. I based the conversion of the text size from real world units (which the text height is stored as in dxf) to font points using the defined definition of 1pt = 1/72 inch. In the couple of drawings I tested this scaling looked OK, but I knew it needed more testing and verification. I checked it in because it was already better than what was there. Perhaps I need to do a better job and work at some of these features in branches instead of on master so people don't think the checked in code is fully functional, however you testing against it and provided these files is very useful feedback for me to fix problems.

When you brought this up and provided the Schriftgroessen file I checked against some online calculators converting mm to pt to verify that I had done the math correctly in my code. Based on the conversion of 1pt = 1/72 inch, I did do the match correctly in my code, but this conversion factor clearly does not provide good results, after testing against some more files.

So the question is what conversion factor do I need to use? In the Schriftgoessen file you provided, if I had assumed that 1mm  = 1pt and then scaled it with the mm->px conversion of 2x, that actually would have been more accurate. It looks like it actually should be converted by a factor of 2.1, but 2 would have been closer than 2.8 used based on the mm->pt conversion I used. What I need to figure out is that roughly 2x height to pt conversion in the Schriftgroessen file something that could be valid or just coincidence in the factors similar?

Perhaps a better method here is assume that 1 unit (based on the file, mm, inches etc) is equal to 1pt and then scale based on the 1mm = 2px, perhaps I should always assume 1mm = 1pt, and then scale. I'm not really sure, I'll need to do more testing to try and narrow down what the right scaling factor might be, and need to make sure I'm testing against multiple units.

I think the next step for me to do is create a handful of files along the lines of Schriftgroessen but in several units like inches, ft, cm, etc and do some testing to try and narrow down a more accurate scaling factor.

Hopefully that makes things a bit more clear.

Re: New .dxf to .elmt Conversion Program

Hello vadoola,

let's put it this way:
I created a QET-Element just with the use of element-editor.
In the attachment you see, that the texts are the same size as the height of the rectangles.

So in my opinion we do not have to use another factor than 2.0 for the "real world" size in the DXF!
When DXF says circle has a diameter of 10mm then in element it is 20.
If it says 1 inch in the DXF it will be 50.8 in the element whether it is a graphical part or a text!
It does not matter if text or anything else: There is always a "scale" of 1mm = 2px

I checked in all DXFs I have: Fits everywhere! 
If you have a DXF where the factor of 2.0 does not fit: Let me see.

Post's attachments

Bildschirmfoto_2025-01-29_textsizes_in_QET.png, 54.08 kb, 820 x 534
Bildschirmfoto_2025-01-29_textsizes_in_QET.png 54.08 kb, 1 downloads since 2025-01-29 

Attachment icon textsizes_in_QET.elmt 2.94 kb, 4 downloads since 2025-01-29 

Fragen zu QET gehören in dieses Forum und werden nicht per PM beantwortet! – Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: New .dxf to .elmt Conversion Program

If you look at the “imperial” DXF from last week:
Which one matches the original sizes better?

I know that we won't be perfect with text-size, because for elements we have to round to integer numbers, but I think we should be as close to the original as possible!

Post's attachments

Bildschirmfoto_2025-01-29_001_LibreCAD.png, 4.92 kb, 1086 x 219
Bildschirmfoto_2025-01-29_001_LibreCAD.png 4.92 kb, 1 downloads since 2025-01-29 

Bildschirmfoto_2025-01-29_002_converted_with_original_dxf2elmt.png, 51.77 kb, 1221 x 283
Bildschirmfoto_2025-01-29_002_converted_with_original_dxf2elmt.png 51.77 kb, 1 downloads since 2025-01-29 

Bildschirmfoto_2025-01-29_003_converted_with_modified_dxf2elmt.png, 49.06 kb, 1404 x 303
Bildschirmfoto_2025-01-29_003_converted_with_modified_dxf2elmt.png 49.06 kb, 2 downloads since 2025-01-29 

Fragen zu QET gehören in dieses Forum und werden nicht per PM beantwortet! – Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !

Re: New .dxf to .elmt Conversion Program

I think I see the confusion.

QET says it's measuring the font size in pts...but pts and pixels are not the same. Based on the file you just provided  (textsizes_in_QET.elmt) QET is actually storing the text size in pixels not points, despite it being labeled as in points. (I don't know if this is the case in all languages, or perhaps a mistranslation in the English text for QET). If that is the case, then you are correct that using the exact same scaling factor as the rest of the drawing should be accurate, since the text sizing is not stored how I though it was based on how QET labels it.

Re: New .dxf to .elmt Conversion Program

I'm taking a closer look now that I'm on my lunch break, and it looks like I'm completely wrong about QET saying the font is in pt's. Nowhere does it say that, it simply refers to it as size. It's just so common for font to be stored as pt's instead of pixels I must have just assumed size meant font points instead of pixels. I clearly made a mistake here, downside of squeezing in time when I can even if that means I'm a bit distracted or tired. I'll try and find some time to get the code updated to scale the text correctly.

Re: New .dxf to .elmt Conversion Program

Hello vadoola,

It's good that we agreed on the scaling after all! I knew there was a misunderstanding somewhere... but didn't see
Sometimes I have to read the documentation and comments in the source code several times, too: the language barrier (French, English, German, ...) is sometimes quite high and with sharp edges! nomicons/wink

Take your time for the realization!
As we say in German: "Gut Ding braucht Weile!"
‘Good things take time!’

Fragen zu QET gehören in dieses Forum und werden nicht per PM beantwortet! – Questions regarding QET belong in this forum and will NOT be answered via PM! – Les questions concernant QET doivent être posées sur ce forum et ne seront pas traitées par MP !