I'm trying to create a page using different sizes of text.
If I use "font Lines bold 6", it works as expected.
If I use ...
set $text_size 6
font Lines bold $text_size
...any "text" commands after this use a truetype font with a default size. Doesn't matter if I set $text_size to 6 or 16 or 60.
I also tried using ...
set $text_size 6
font Lines bold
font $text_size
Same result - the text uses the default truetype font and doesn't change the size at all.
I'm not familiar with the code base, and I haven't done any java programming since (1997 maybe?) so I don't even know where to start looking in the code to figure this out for myself.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
That was a typo when creating the post, I should have copy/pasted it. The set lines in the actual code do not have $ in them.
In order to avoid confusion, https://jms1.pub/sf/ has an actual .hcl file which exhibits the problem. I added a variable $fsvar so I only need to change one place to control whether all of the font lines use a literal or a variable as the size. The same location also has PDFs showing the output with this variable set to 0 (specifying sizes as integers, which produces correct output) or set to 1 (specifying sizes with a variable, which makes the text use a truetype font and doesn't set the size at all).
To me this smells like a bug in the code, but again, my java-fu is weak so I fully expect to be wrong about this. It's entirely possible I mis-understood the documentation in the PDF that came with the download, but if so I mis-understood it about seven times so far.
FWIW I'm using version 1.32 ... and I also noticed that the download's filename was Drawj2d-1.3.2.zip, which seems like it should be the same version, but the numbering is inconsistent (i.e. 1.3.2 vs 1.32).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The arguments to the font command are evaluated in FontCmd.java (sourceforge.net). Maybe the font command does not recognize the size variable as a number. I eventually will have to debug using the NetBeans IDE.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Other than in a list of keywords at the end of the PDF, is the [float ___] function documented anywhere? If there's documentation out there, separate from the PDF, I'd like to read through that as well.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
2024-03-05
The drawj2d vector graphics language uses and extends the Hecl scripting language. Its core commands are listed here.
In the case of the drawj2d font command ideally it would not be necessary to call [float $size]. Let's see if I can fix it without an incompatible change.
A few other drawj2d commands might require float if you want to allow integer input. For non-programmers this might be surprising.
set L 2.0
puts [format "Length: %.2f m" $L ]
or
set L 2
puts [format "Length: %.2f m" [float $L] ]
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm trying to create a page using different sizes of text.
If I use "font Lines bold 6", it works as expected.
If I use ...
...any "text" commands after this use a truetype font with a default size. Doesn't matter if I set $text_size to 6 or 16 or 60.
I also tried using ...
Same result - the text uses the default truetype font and doesn't change the size at all.
I'm not familiar with the code base, and I haven't done any java programming since (1997 maybe?) so I don't even know where to start looking in the code to figure this out for myself.
Both examples should actually work. Just try to omit the dollar sign in the "set" command.
I thought I had already logged in - this was my question.
That was a typo when creating the post, I should have copy/pasted it. The
setlines in the actual code do not have$in them.In order to avoid confusion, https://jms1.pub/sf/ has an actual
.hclfile which exhibits the problem. I added a variable$fsvarso I only need to change one place to control whether all of thefontlines use a literal or a variable as the size. The same location also has PDFs showing the output with this variable set to 0 (specifying sizes as integers, which produces correct output) or set to 1 (specifying sizes with a variable, which makes the text use a truetype font and doesn't set the size at all).To me this smells like a bug in the code, but again, my java-fu is weak so I fully expect to be wrong about this. It's entirely possible I mis-understood the documentation in the PDF that came with the download, but if so I mis-understood it about seven times so far.
FWIW I'm using version
1.32... and I also noticed that the download's filename wasDrawj2d-1.3.2.zip, which seems like it should be the same version, but the numbering is inconsistent (i.e.1.3.2vs1.32).You are right, there is an issue. Thanks for reporting it.
The work-around is to replace
$text_sizeby[float $text_size].In your linked example replace the following way (output of "diff -y --suppress-common-lines orginal.hcl modified.hcl")
The arguments to the font command are evaluated in FontCmd.java (sourceforge.net). Maybe the font command does not recognize the size variable as a number. I eventually will have to debug using the NetBeans IDE.
The issue will be fixed in the next version. Thanks for reporting.
Drawj2d version 1.3.3 released. The issue "font command doesn't work with variables" should be fixed.
That work-around did indeed work, thank you.
Other than in a list of keywords at the end of the PDF, is the
[float ___]function documented anywhere? If there's documentation out there, separate from the PDF, I'd like to read through that as well.The drawj2d vector graphics language uses and extends the Hecl scripting language. Its core commands are listed here.
In the case of the drawj2d font command ideally it would not be necessary to call
[float $size]. Let's see if I can fix it without an incompatible change.A few other drawj2d commands might require float if you want to allow integer input. For non-programmers this might be surprising.
or