printing a minus sign in RC3

classic Classic list List threaded Threaded
9 messages Options
Reply | Threaded
Open this post in threaded view
|

printing a minus sign in RC3

adrianv
I'm trying to print columnar output of numbers in RC3.  I'm having a problem
with minus signs because they aren't the same width as anything else, it
seems.   I'm wondering if this is the same result everyone gets, or if it
depends on my environment (like my font is misbehaving).   I'm using Ubuntu.  

function str_join(list,sep="",_i=0, _result="") =
    _i >= len(list)-1 ? (_i==len(list) ? _result : str(_result,list[_i])) :
    str_join(list,sep,_i+1,str(_result,list[_i],sep));

function repeat(x,n) = [for(i=[1:1:n]) x];

minus = chr(8722);
space_figure = chr(8199);

echo(str_join(["X", each repeat("-",10), "X"]));    // Hyphen character, too
short
echo(str_join(["X", each repeat(minus,10), "X"]));  // unicode minus
character
echo(str_join(["X", each repeat("0",10), "X"]));    // zero digit
echo(str_join(["X", each repeat("1",10), "X"]));    // one digit
echo(str_join(["X", each repeat(space_figure,10), "X"]));  // Figure space
echo(str_join(["X", each repeat(" ",10), "X"]));    // Regular space (wrong)


The output in my console:

<http://forum.openscad.org/file/t2477/screen.png>

I was expecting to see the line of minus signs the same with as the three
lines below with numbers and figure spaces.  









--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: printing a minus sign in RC3

nophead
I get the same on Windows but I never expect it to work because the console isn't a monospace font.?

image.png

On Thu, 31 Dec 2020 at 17:25, adrianv <[hidden email]> wrote:
I'm trying to print columnar output of numbers in RC3.  I'm having a problem
with minus signs because they aren't the same width as anything else, it
seems.   I'm wondering if this is the same result everyone gets, or if it
depends on my environment (like my font is misbehaving).   I'm using Ubuntu. 

function str_join(list,sep="",_i=0, _result="") =
    _i >= len(list)-1 ? (_i==len(list) ? _result : str(_result,list[_i])) :
    str_join(list,sep,_i+1,str(_result,list[_i],sep));

function repeat(x,n) = [for(i=[1:1:n]) x];

minus = chr(8722);
space_figure = chr(8199);

echo(str_join(["X", each repeat("-",10), "X"]));    // Hyphen character, too
short
echo(str_join(["X", each repeat(minus,10), "X"]));  // unicode minus
character
echo(str_join(["X", each repeat("0",10), "X"]));    // zero digit
echo(str_join(["X", each repeat("1",10), "X"]));    // one digit
echo(str_join(["X", each repeat(space_figure,10), "X"]));  // Figure space
echo(str_join(["X", each repeat(" ",10), "X"]));    // Regular space (wrong)


The output in my console:

<http://forum.openscad.org/file/t2477/screen.png>

I was expecting to see the line of minus signs the same with as the three
lines below with numbers and figure spaces. 









--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: printing a minus sign in RC3

adrianv
I thought the minus character was supposed to be the same width as the
figures.   I'm not sure why I thought this.  I can't find it stated
anywhere.  Note that all the digits are the same width and they are the
width of the figure space.  In an actual proportional font, the 1 will be
narrower.   It looks like "+" is the same width as the minus (U+2122).    

So is there a space character or combination of them that are supposed to
match the width of a minus sign?

Note see:

http://jkorpela.fi/chars/spaces.html


nophead wrote
> I get the same on Windows but I never expect it to work because the
> console
> isn't a monospace font.?
>
> [image: image.png]
>
> On Thu, 31 Dec 2020 at 17:25, adrianv &lt;

> avm4@

> &gt; wrote:
>
>> I'm trying to print columnar output of numbers in RC3.  I'm having a
>> problem
>> with minus signs because they aren't the same width as anything else, it
>> seems.   I'm wondering if this is the same result everyone gets, or if it
>> depends on my environment (like my font is misbehaving).   I'm using
>> Ubuntu.
>>
>> function str_join(list,sep="",_i=0, _result="") =
>>     _i >= len(list)-1 ? (_i==len(list) ? _result : str(_result,list[_i]))
>> :
>>     str_join(list,sep,_i+1,str(_result,list[_i],sep));
>>
>> function repeat(x,n) = [for(i=[1:1:n]) x];
>>
>> minus = chr(8722);
>> space_figure = chr(8199);
>>
>> echo(str_join(["X", each repeat("-",10), "X"]));    // Hyphen character,
>> too
>> short
>> echo(str_join(["X", each repeat(minus,10), "X"]));  // unicode minus
>> character
>> echo(str_join(["X", each repeat("0",10), "X"]));    // zero digit
>> echo(str_join(["X", each repeat("1",10), "X"]));    // one digit
>> echo(str_join(["X", each repeat(space_figure,10), "X"]));  // Figure
>> space
>> echo(str_join(["X", each repeat(" ",10), "X"]));    // Regular space
>> (wrong)
>>
>>
>> The output in my console:
>>
>> &lt;http://forum.openscad.org/file/t2477/screen.png&gt;
>>
>> I was expecting to see the line of minus signs the same with as the three
>> lines below with numbers and figure spaces.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> --
>> Sent from: http://forum.openscad.org/
>>
>> _______________________________________________
>> OpenSCAD mailing list
>>

> Discuss@.openscad

>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>>
>
> _______________________________________________
> OpenSCAD mailing list

> Discuss@.openscad

> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
>
> image.png (8K)
> &lt;http://forum.openscad.org/attachment/31398/0/image.png&gt;





--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: printing a minus sign in RC3

JordanBrown
In reply to this post by adrianv
http://jkorpela.fi/chars/spaces.html

If you pop up a level and look, you'll find

http://jkorpela.fi/dashes.html

and that will in turn lead you to FIGURE DASH U+2012 / chr(8210).

That seems to do what you need.

(But mostly I across with nop head; trying to do tabular data in a proportional font without table layout support is doomed.)

(But but ... it's really an HTML renderer, so if we (re)added HTML support...)


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: printing a minus sign in RC3

JordanBrown
On 12/31/2020 1:29 PM, Jordan Brown wrote:
http://jkorpela.fi/chars/spaces.html

If you pop up a level and look, you'll find

http://jkorpela.fi/dashes.html

and that will in turn lead you to FIGURE DASH U+2012 / chr(8210).

That seems to do what you need.

(But mostly I across with nop head; trying to do tabular data in a proportional font without table layout support is doomed.)

mostly I *agree*... jeez, don't know where that came from.


(But but ... it's really an HTML renderer, so if we (re)added HTML support...)


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: printing a minus sign in RC3

thehans
In reply to this post by JordanBrown
I think the solution should be to have the Console font configurable via Preferences, in the same way that the Editor font is.
It would be nice to be able to choose a different / monospaced console font according to preference.

Seems like a good candidate for a feature request... I thought there may have been an issue already discussing this, but couldn't find one on github.

Hans

On Thu, Dec 31, 2020 at 3:30 PM Jordan Brown <[hidden email]> wrote:
http://jkorpela.fi/chars/spaces.html

If you pop up a level and look, you'll find

http://jkorpela.fi/dashes.html

and that will in turn lead you to FIGURE DASH U+2012 / chr(8210).

That seems to do what you need.

(But mostly I across with nop head; trying to do tabular data in a proportional font without table layout support is doomed.)

(But but ... it's really an HTML renderer, so if we (re)added HTML support...)

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: printing a minus sign in RC3

adrianv
In reply to this post by JordanBrown
Hmmm.  Not sure how I missed that.  I was just exploring using en-dash
instead of minus (along with the en space) and that was working for me, but
the figure dash will make things simpler.  

I've been waiting for the dev version because doing table layout seemed to
be hopeless with the HTML support.  The HTML support ate spaces, but as far
as I could tell, didn't actually support table layout, so I gave up on
getting anything working there.  

I'm not trying to do some massive complex formatting operation.  I just want
to print numerical matrices in columns, mainly so I can debug my code more
easily.  So it's a very limited task.  All numbers have the same width, and
I have the figure space.  The decimal point has a matching space.  And then
sometimes there's an "e" which is slightly off, but it's a very slight
error, so readability is preserved.  

It would be nice if the console font was a fixed width font.  Having it be
configurable isn't so helpful if you don't know if it's fixed width or
proportional, because then it's hard to write code that will work for
everyone.  


JordanBrown wrote

>> http://jkorpela.fi/chars/spaces.html
>
> If you pop up a level and look, you'll find
>
> http://jkorpela.fi/dashes.html
>
> and that will in turn lead you to FIGURE DASH U+2012 / chr(8210).
>
> That seems to do what you need.
>
> (But mostly I across with nop head; trying to do tabular data in a
> proportional font without table layout support is doomed.)
>
> (But but ... it's really an HTML renderer, so if we (re)added HTML
> support...)
>
>
> _______________________________________________
> OpenSCAD mailing list

> Discuss@.openscad

> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org





--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
Reply | Threaded
Open this post in threaded view
|

Re: printing a minus sign in RC3

MichaelAtOz
Administrator
In reply to this post by adrianv
Experiment with tabs
echo("1\t2");

> -----Original Message-----
> From: Discuss [mailto:[hidden email]] On Behalf Of adrianv
> Sent: Fri, 1 Jan 2021 04:25
> To: [hidden email]
> Subject: [OpenSCAD] printing a minus sign in RC3
>
> I'm trying to print columnar output of numbers in RC3.  I'm having a problem
> with minus signs because they aren't the same width as anything else, it
> seems.   I'm wondering if this is the same result everyone gets, or if it
> depends on my environment (like my font is misbehaving).   I'm using Ubuntu.
>
> function str_join(list,sep="",_i=0, _result="") =
>     _i >= len(list)-1 ? (_i==len(list) ? _result : str(_result,list[_i])) :
>     str_join(list,sep,_i+1,str(_result,list[_i],sep));
>
> function repeat(x,n) = [for(i=[1:1:n]) x];
>
> minus = chr(8722);
> space_figure = chr(8199);
>
> echo(str_join(["X", each repeat("-",10), "X"]));    // Hyphen character, too
> short
> echo(str_join(["X", each repeat(minus,10), "X"]));  // unicode minus
> character
> echo(str_join(["X", each repeat("0",10), "X"]));    // zero digit
> echo(str_join(["X", each repeat("1",10), "X"]));    // one digit
> echo(str_join(["X", each repeat(space_figure,10), "X"]));  // Figure space
> echo(str_join(["X", each repeat(" ",10), "X"]));    // Regular space (wrong)
>
>
> The output in my console:
>
> <http://forum.openscad.org/file/t2477/screen.png>
>
> I was expecting to see the line of minus signs the same with as the three
> lines below with numbers and figure spaces.
>
>
>
>
>
>
>
>
>
> --
> Sent from: http://forum.openscad.org/
>
> _______________________________________________
> OpenSCAD mailing list
> [hidden email]
> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org


--
This email has been checked for viruses by AVG.
https://www.avg.com


_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
OpenSCAD Admin - email* me if you need anything, or if I've done something stupid...
* on the Forum, click on my MichaelAtOz label, there is a link to email me.

Unless specifically shown otherwise above, my contribution is in the Public Domain;
to the extent possible under law, I have waived all copyright and related or neighbouring rights to this work.
Obviously inclusion of works of previous authors is not included in the above.
Reply | Threaded
Open this post in threaded view
|

Re: printing a minus sign in RC3

adrianv
I tried using tabs.  They are too weak of a tool.  They are only at every 8th
position, so I have to be very careful about the lengths of texts and I can
only align at every 8th...or likely every 16th in practice if anything
exceeds length 8 anywhere.  But worse, I can only align on the left.  So "1"
and "1000" will be left aligned instead of right aligned.  So to get
properly right aligned columns I still need to adjust spacing for every
character in the output.  It doesn't actually solve the problem at all.  It
just introduces extra complexity.  

The tab key was handy on a mechanical typewriter.....but in the modern world
they are pointless and in my opinion, mainly an annoying nuisance.  


MichaelAtOz wrote
> Experiment with tabs
> echo("1\t2");
>
>> -----Original Message-----
>> From: Discuss [mailto:

> discuss-bounces@.openscad

> ] On Behalf Of adrianv
>> Sent: Fri, 1 Jan 2021 04:25
>> To:

> discuss@.openscad

>> Subject: [OpenSCAD] printing a minus sign in RC3
>>
>> I'm trying to print columnar output of numbers in RC3.  I'm having a
>> problem
>> with minus signs because they aren't the same width as anything else, it
>> seems.   I'm wondering if this is the same result everyone gets, or if it
>> depends on my environment (like my font is misbehaving).   I'm using
>> Ubuntu.
>>
>> function str_join(list,sep="",_i=0, _result="") =
>>     _i >= len(list)-1 ? (_i==len(list) ? _result : str(_result,list[_i]))
>> :
>>     str_join(list,sep,_i+1,str(_result,list[_i],sep));
>>
>> function repeat(x,n) = [for(i=[1:1:n]) x];
>>
>> minus = chr(8722);
>> space_figure = chr(8199);
>>
>> echo(str_join(["X", each repeat("-",10), "X"]));    // Hyphen character,
>> too
>> short
>> echo(str_join(["X", each repeat(minus,10), "X"]));  // unicode minus
>> character
>> echo(str_join(["X", each repeat("0",10), "X"]));    // zero digit
>> echo(str_join(["X", each repeat("1",10), "X"]));    // one digit
>> echo(str_join(["X", each repeat(space_figure,10), "X"]));  // Figure
>> space
>> echo(str_join(["X", each repeat(" ",10), "X"]));    // Regular space
>> (wrong)
>>
>>
>> The output in my console:
>>
>> &lt;http://forum.openscad.org/file/t2477/screen.png&gt;
>>
>> I was expecting to see the line of minus signs the same with as the three
>> lines below with numbers and figure spaces.
>>
>>
>>
>>
>>
>>
>>
>>
>>
>> --
>> Sent from: http://forum.openscad.org/
>>
>> _______________________________________________
>> OpenSCAD mailing list
>>

> Discuss@.openscad

>> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org
>
>
> --
> This email has been checked for viruses by AVG.
> https://www.avg.com
>
>
> _______________________________________________
> OpenSCAD mailing list

> Discuss@.openscad

> http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org





--
Sent from: http://forum.openscad.org/

_______________________________________________
OpenSCAD mailing list
[hidden email]
http://lists.openscad.org/mailman/listinfo/discuss_lists.openscad.org