Short answer: You cannot access environment variables directly.
There are a few ways to pass parameters to drawj2d in order to access them from the hcl script:
1. source someinput.hcl
2. read data from file: open
3. system.getproperty user.dir gives access to some system properties, e.g. the user working directory. Get the complete list in jshell:
System.getProperties().forEach((key, value) -> System.out.println(key + ": " + value));`
4. $argv gives access to the list of command line arguments, passed to the drawing script
Long answer : drawj2d accessEnv.hcl "$(env)"
It is valid for Linux (and probably Mac) and uses way number 4.
accessEnv.hcl
if{<$argc1}{puts{USAGE:}puts{drawj2daccessEnv.hcl"$(env)"}exit1}setenvList[split[lindex$argv0]\n]puts"Number of variables: [llength $envList]"# foreach entry [sort $envList] {# puts $entry # }setitemLANG
setvalue{}foreachentry$envList{setindex[strfind${item}=$entry]if{=$index0}{setvalue[strtriml$entry${item}=]break}}puts"environment variable $item is: $value"
may return:
Number of variables: 99
environment variable LANG is: de_CH.UTF-8
The complete list of the available commands is printed in the drawj2d function reference. The hecl commands are documented on the hecl website.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
A Monospaced Lines font would have to be added. I will have to look at it to see, if it can be implemented with a reasonable effort.
The stroke with of the letters is hard coded. It is related to the font size (but not linearly).
The width of the text block can be changed, see program documentation.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
have added to font LinesMono. It currently is just the single line font Lines monospaced.
There is no new release yet. If you want to test it, you'll need to download the source code and run ant to compile the program (requires JDK and Apache Ant).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
2023-11-04
Hello, newbie here. I must miss something obvious, so please excuse my ignorance:
using command prompt (or PowerShell), I can cd to the directory where I unzipped Drawj2d files. I launch by typing "drawj2d" (without the quotes of course).
I get the welcome prompt (with wopyright and version 1.32). Mode says: Freehep
Problem: when typing the example prompt: ''drawj2d -T svg -W 100 -H 60 drawing.hcl'' nothing happens...
drawing.hcl contains the prompted input: (# variables set dx 50 etc. etc.)
What am I doing wrong?
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Not sure which issue you are referring to. To run drawj2d cd into the directory where you have unzipped drawj2d files and then run
drawj2d -Tscreen doc/example.hcl
On the command line you should see a few lines ...
Welcome to Drawj2d
Copyright (c) A. Vontobel, 2014-2024
Version 1.3.4
Mode: JRE
Preview: doc/example.hcl
... and a windows should open showing the same content as in doc/out-example.pdf. Hitting the Esc key closes the preview window.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Anonymous
Anonymous
-
2024-01-25
A. Vontobel,
Would you customise this library for generating some enclosure drawings? We will pay you. If you are interested please contact yashodhan.joshi@gmail.com
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Personally I am not interested, but thanks for asking.
Drawj2d is is free software, subject to the GPL. The license allows the modification of the software, you just have to grant the users the same rights when redistributing the modified version (e.g. give them the source code). Thus you may ask any programmer to customize the software.
By the way, chances are that you can create customized drawings without modifying the drawj2d program. The hcl input files are "scriptable". Have a look at the manual, chapter "Programming commands". Again, you may ask any programmer (hcl is similar to the widely known TCL Tool Command Language).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Would it be possible to add a new function similar to here, that instead of returning the current position, returns the lower right bounary position of the last text line?
Perhaps call it textpos.
Last edit: Stefan Blixten Karlsson 2025-09-19
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Currently drawj2d does not remember where the last writing operation ended. That could be implemented (in net/sf/drawj2d/cmd/API.java ) for the commands label, texlabel and text. A new command textpos could return that position.
May I ask what the intention is? Do you want to change the font properties (e.g. bold)?
Then we might need to remember the x position "here before text" as well, for the carriage return ...
For a short text without line breaks you can use the BLC (base line continue) parameter to the label command (you probably know).
set part1Regular {Lorem ipsum}
set part2Bold { dolor }
set part3Regular {sit amety}
m 10 15
label $part1Regular BLC
font bold
label $part2Bold BLC
font plain
label $part3Regular BLC
You are right, I want to change font and/or properties of some words in the middle of text block even if it is split up into multiple lines.
A short time after I published my quetstion, I realized that it might not solve what I wanted to do anyway. Since I like to use the "Lines" and "LinesMono" fonts, and as I understand, the line thickness of these cannot be changed to make them bold.
I did not know about BLC, I have only been using the compass directions since they where the only one I could guess what they did, since non of the abbreviations are described in the manual.
My main goal is to make a tool that will convert a markdown file to hcl, so that it can be sent to the reMarkable. I have most of it working now, but some features are still missing. For example, bold/italic and inline code, but also the column width in a table are currently hardcoded. It needs manual adjutments to make nice tables. Since I have not beeen able to create a table function that will auto detect the column width. Currently using the table procedure in utils.hcl.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
font Lines bold and font LinesMono bold should work:
I'll have to explain the parameters for label in the manual. BL (base line) and BLC (base line continue) are indeed hard to guess...
It would be really nice to have a tool to interpret markdown or at least a subset of it.
The implementation for text is quite rudimentary. A few ideas:
- Maybe we would need a command "append text (write)" that just continues writing (knowing xLeft, text coloumn width and the current position) but does line breaks. Would not work for justified text though.
- Or the text command could be extended to understand some markdown formatting. I am just not sure it will be straight forward to implement.
- Or a command "info label width" could return the width of a text fragment without writing it. This would allow to reimplement "text" in a hcl script (an adapt it as mdtext).
- If you only use the Lines or (easier) the LinesMono font, you could calculate (or at least estimate) the width of the rendered words. Thus the text algorithm could be reproduced using label BLC in a hcl script.
When it come to the fonts Lines and LinesMono, I know about the plain vs bold style. The thing is that they have, in my opinion, too thin lines compared the there size when using the plain style, especially when displayed on the reMarkable. So I usually always use them bold.
What I would like to implement in the markdown conversion tool, is the different levels of bold that some Markdown viewer shows .
So if there was a way to control the thickness of the lines in those fonts, maybe as a scale factor. That would be great.
Great ideas you have!
My first vote goes to the "append text" for good flexibility when changing style/font within a text block.
The second vote goes to the "info label width" to get the width before writing. That would be useful for detecting column width in tables.
The next release of drawj2d will introduce a command textcontinue (or just textc). It will append text to the previous paragraph written by the text command (or an earlier textcontinue command, but not to labels).
I have pushed a commit with the implementation of that functionality. It is not complete, e.g. for justified text the line break in the example above has to be adapted. (Probably justified text will lead to strange spacing issues anyway).
There is no release yet. To test it now you will need a java compiler (Java SDK) and "Apache Ant". Download the source, compile it (type ant).
So if there was a way to control the thickness of the lines in those fonts, maybe as a scale factor. That would be great.
The next release of drawj2d will introduce a new font style pen for Lines / LinesMono fonts. It is equivalent to the plain (upright) style, but the thickness of the lines is taken from the pen stroke width (at the moment the font is changed to Lines).
Example:
pen 0.55
font Lines pen
text {really bold text}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have not been successful attempting to use those colors. I'm not trying to change your code, I'm simply doing a (simple-minded) edit of an .rm file (i.e., changing black '0000' to shader red '0018'. I'm aware that I'm out of my depth here, so I'm sure this is too simplistic an experiment.
In any case, I hope you are able to use these numbers to allow us to draw lines, etc. using the shader colors.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
For testing purposes it should be enough to adapt, compile and run the single file net/sf/jtikz/ReMarkablePage.java. It has no dependencies other than the java runtime. The main() method can be used for low level testing.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Please use this forum topic for comments about these releases.
Is there a way to access environment variables from HCL ?
Short answer: You cannot access environment variables directly.
There are a few ways to pass parameters to drawj2d in order to access them from the hcl script:
1. source someinput.hcl
2. read data from file: open
3.
system.getproperty user.dirgives access to some system properties, e.g. the user working directory. Get the complete list in jshell:System.getProperties().forEach((key, value) -> System.out.println(key + ": " + value));`
4. $argv gives access to the list of command line arguments, passed to the drawing script
Long answer :
drawj2d accessEnv.hcl "$(env)"It is valid for Linux (and probably Mac) and uses way number 4.
accessEnv.hcl
may return:
Number of variables: 99
environment variable LANG is: de_CH.UTF-8
The complete list of the available commands is printed in the drawj2d function reference. The hecl commands are documented on the hecl website.
Thanks for you quick answer and list of options. I now think I know how to proceed.
I have two questions regarding the font "Lines".
A Monospaced Lines font would have to be added. I will have to look at it to see, if it can be implemented with a reasonable effort.
The stroke with of the letters is hard coded. It is related to the font size (but not linearly).
The width of the text block can be changed, see program documentation.
have added to font LinesMono. It currently is just the single line font Lines monospaced.
There is no new release yet. If you want to test it, you'll need to download the source code and run ant to compile the program (requires JDK and Apache Ant).
Released in 1.3.2
Hello, newbie here. I must miss something obvious, so please excuse my ignorance:
using command prompt (or PowerShell), I can cd to the directory where I unzipped Drawj2d files. I launch by typing "drawj2d" (without the quotes of course).
I get the welcome prompt (with wopyright and version 1.32). Mode says: Freehep
Problem: when typing the example prompt: ''drawj2d -T svg -W 100 -H 60 drawing.hcl'' nothing happens...
drawing.hcl contains the prompted input: (# variables set dx 50 etc. etc.)
What am I doing wrong?
Thanks
Have you tried to type
drawj2d -T svg -W 100 -H 60 drawing.hclimmediately (not testing "drawj2d" before)?Long shot, but did you manage to find a solution to this? Having exactly the same issue.
Not sure which issue you are referring to. To run drawj2d cd into the directory where you have unzipped drawj2d files and then run
drawj2d -Tscreen doc/example.hclOn the command line you should see a few lines ...
... and a windows should open showing the same content as in doc/out-example.pdf. Hitting the
Esckey closes the preview window.A. Vontobel,
Would you customise this library for generating some enclosure drawings? We will pay you. If you are interested please contact yashodhan.joshi@gmail.com
Personally I am not interested, but thanks for asking.
Drawj2d is is free software, subject to the GPL. The license allows the modification of the software, you just have to grant the users the same rights when redistributing the modified version (e.g. give them the source code). Thus you may ask any programmer to customize the software.
By the way, chances are that you can create customized drawings without modifying the drawj2d program. The hcl input files are "scriptable". Have a look at the manual, chapter "Programming commands". Again, you may ask any programmer (hcl is similar to the widely known TCL Tool Command Language).
Would it be possible to add a new function similar to

here, that instead of returning the current position, returns the lower right bounary position of the last text line?Perhaps call it
textpos.Last edit: Stefan Blixten Karlsson 2025-09-19
Currently drawj2d does not remember where the last writing operation ended. That could be implemented (in net/sf/drawj2d/cmd/API.java ) for the commands label, texlabel and text. A new command textpos could return that position.
May I ask what the intention is? Do you want to change the font properties (e.g. bold)?
Then we might need to remember the x position "here before text" as well, for the carriage return ...
For a short text without line breaks you can use the

BLC(base line continue) parameter to the label command (you probably know).Last edit: A. Vontobel 2025-09-21
You are right, I want to change font and/or properties of some words in the middle of text block even if it is split up into multiple lines.
A short time after I published my quetstion, I realized that it might not solve what I wanted to do anyway. Since I like to use the "Lines" and "LinesMono" fonts, and as I understand, the line thickness of these cannot be changed to make them bold.
I did not know about BLC, I have only been using the compass directions since they where the only one I could guess what they did, since non of the abbreviations are described in the manual.
My main goal is to make a tool that will convert a markdown file to hcl, so that it can be sent to the reMarkable. I have most of it working now, but some features are still missing. For example, bold/italic and inline code, but also the column width in a table are currently hardcoded. It needs manual adjutments to make nice tables. Since I have not beeen able to create a table function that will auto detect the column width. Currently using the table procedure in utils.hcl.
font Lines boldandfont LinesMono boldshould work:I'll have to explain the parameters for label in the manual. BL (base line) and BLC (base line continue) are indeed hard to guess...
It would be really nice to have a tool to interpret markdown or at least a subset of it.
The implementation for text is quite rudimentary. A few ideas:
- Maybe we would need a command "append text (write)" that just continues writing (knowing xLeft, text coloumn width and the current position) but does line breaks. Would not work for justified text though.
- Or the text command could be extended to understand some markdown formatting. I am just not sure it will be straight forward to implement.
- Or a command "info label width" could return the width of a text fragment without writing it. This would allow to reimplement "text" in a hcl script (an adapt it as mdtext).
- If you only use the Lines or (easier) the LinesMono font, you could calculate (or at least estimate) the width of the rendered words. Thus the text algorithm could be reproduced using label BLC in a hcl script.
Last edit: A. Vontobel 2025-09-22
When it come to the fonts Lines and LinesMono, I know about the plain vs bold style. The thing is that they have, in my opinion, too thin lines compared the there size when using the plain style, especially when displayed on the reMarkable. So I usually always use them bold.
What I would like to implement in the markdown conversion tool, is the different levels of bold that some Markdown viewer shows .
So if there was a way to control the thickness of the lines in those fonts, maybe as a scale factor. That would be great.
Great ideas you have!
My first vote goes to the "append text" for good flexibility when changing style/font within a text block.
The second vote goes to the "info label width" to get the width before writing. That would be useful for detecting column width in tables.
Last edit: Stefan Blixten Karlsson 2025-09-23
The next release of drawj2d will introduce a command
textcontinue(or justtextc). It will append text to the previous paragraph written by the text command (or an earlier textcontinue command, but not to labels).Example input
I have pushed a commit with the implementation of that functionality. It is not complete, e.g. for justified text the line break in the example above has to be adapted. (Probably justified text will lead to strange spacing issues anyway).
There is no release yet. To test it now you will need a java compiler (Java SDK) and "Apache Ant". Download the source, compile it (type
ant).Last edit: A. Vontobel 2025-10-06
The command will be called
textappend(not textcontinue).The next release of drawj2d will introduce a new font style
penfor Lines / LinesMono fonts. It is equivalent to the plain (upright) style, but the thickness of the lines is taken from the pen stroke width (at the moment the font is changed to Lines).Example:
The next release of drawj2d will introduce the command
info:Last edit: A. Vontobel 2025-10-11
I think the shader colors have been identified, e.g.,
https://github.com/ricklupton/rmscene/blob/997f0b4769dbce0c5f49c53feb439123c294a1f5/src/rmscene/scene_items.py#L96
https://github.com/ricklupton/rmscene/pull/44/files
I have not been successful attempting to use those colors. I'm not trying to change your code, I'm simply doing a (simple-minded) edit of an .rm file (i.e., changing black '0000' to shader red '0018'. I'm aware that I'm out of my depth here, so I'm sure this is too simplistic an experiment.
In any case, I hope you are able to use these numbers to allow us to draw lines, etc. using the shader colors.
Thanks for the information.
Drawj2d still uses "reMarkable .lines file, version=5" . This might (or might not) be an issue for the shader colours.
For the record: The relevant drawj2d code is in these two files
- net/sf/jtikz/ReMarkablePage.java: rmColour and rmPen
- net/sf/jtikz/RemarkableGraphics2D.java: linecolour()
For testing purposes it should be enough to adapt, compile and run the single file net/sf/jtikz/ReMarkablePage.java. It has no dependencies other than the java runtime. The main() method can be used for low level testing.