netDxf icon indicating copy to clipboard operation
netDxf copied to clipboard

Ask Help For Text/Mtext total length.

Open airsxue opened this issue 1 year ago • 6 comments

Hello, Thanks for your hard work for netDxf,I just want to know how can I get the total Length of a text or Mtext(as below pic. )? Thanks! image

airsxue avatar Aug 14 '22 11:08 airsxue

Hello, Thanks for your hard work for netDxf,I just want to know how can I get the total Length of a text or Mtext(as below pic. )? Thanks! image

BTW, I used tried to get the total Length by the "total Char count"* "width factor", but the result sstill has deviation with actual length.

airsxue avatar Aug 14 '22 11:08 airsxue

Hello, Thanks for your hard work for netDxf,I just want to know how can I get the total Length of a text or Mtext(as below pic. )? Thanks! image

sorry, correct the method i used tried, it should be "total Char count" "width factor" * textHeight*

airsxue avatar Aug 14 '22 11:08 airsxue

As far as I know, the length of the text is depends on the system's graphic render. So there's no method to get the text length before render. In windows, you can do this by gdi or gidplus. see https://stackoverflow.com/questions/263614/calculate-the-display-width-of-a-string-in-c

Snailya avatar Aug 24 '22 09:08 Snailya

As far as I know, the length of the text is depends on the system's graphic render. So there's no method to get the text length before render. In windows, you can do this by gdi or gidplus. see https://stackoverflow.com/questions/263614/calculate-the-display-width-of-a-string-in-c

Got it with many thanks

airsxue avatar Aug 27 '22 08:08 airsxue

Both SHX and TTF fonts stores vector data information from which you can, from every single character (glyph), build words, sentences, paragraphs,... and get its measurements; but you will need to use other libraries for that. So, it is not true that the length of the text depends on the system graphic render, although it is common in them to find some kind getLength method.

haplokuon avatar Aug 27 '22 11:08 haplokuon

Both SHX and TTF fonts stores vector data information from which you can, from every single character (glyph), build words, sentences, paragraphs,... and get its measurements; but you will need to use other libraries for that. So, it is not true that the length of the text depends on the system graphic render, although it is common in them to find some kind getLength method.

so may i have your suggestion on which libraires can i use to measure the length of text? thanks

airsxue avatar Sep 15 '22 04:09 airsxue