Closed bennyboer closed 4 years ago
Hi @bennyboer , Can I work on this issue?
Thanks.
Hi there,
sure you can! Basically all cached stuff is under the user folder ~/.thaw
that can be fetched from the CacheUtil
class via a static method: getCacheRootDir()
.
For the CLI we use https://picocli.info/ which to my knowledge should have something like subcommands, but I am not that familar with it, so you can live it up as you wish! :smile:
Let me know here or via e-mail if you need any help!
Hi, Thanks for the instruction. :smile:
I tried to run the application with the following command in Ubuntu
./gradlew :cli:run --args="--root-folder='../example/demo' --output='../example/demo/demo.pdf'"
But I am getting the following erro-
########################
### Thaw Project CLI ###
########################
### Configuration ###
Charset: 'UTF-8'
### Processing ###
Searching for Thaw files within folder at '/home/badal/Documents/codeProject/thaw/cli/../example/demo'...
Processing Thaw info file 'demo.tdi'...
Processing Thaw text file 'demo.tdt'...
Processing Thaw style file 'demo.tds'...
Oct. 14, 2020 10:57:52 P.M. org.apache.fontbox.ttf.CmapSubtable processSubtype14
WARNING: Format 14 cmap table is not supported and will be ignored
An exception occurred while trying to export the resulting document.
The exception message is: 'de.be.thaw.typeset.exception.TypeSettingException: Could not convert the document into the Knuth-Plass algorithm format'
de.be.thaw.export.exception.ExportException: de.be.thaw.typeset.exception.TypeSettingException: Could not convert the document into the Knuth-Plass algorithm format
at de.be.thaw.export.pdf.PdfExporter.export(PdfExporter.java:109)
at de.be.thaw.cli.CLI.call(CLI.java:236)
at de.be.thaw.cli.CLI.call(CLI.java:36)
at picocli.CommandLine.executeUserObject(CommandLine.java:1853)
at picocli.CommandLine.access$1100(CommandLine.java:145)
at picocli.CommandLine$RunLast.executeUserObjectOfLastSubcommandWithSameParent(CommandLine.java:2255)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2249)
at picocli.CommandLine$RunLast.handle(CommandLine.java:2213)
at picocli.CommandLine$AbstractParseResultHandler.execute(CommandLine.java:2080)
at picocli.CommandLine.execute(CommandLine.java:1978)
at de.be.thaw.cli.CLI.main(CLI.java:69)
Caused by: de.be.thaw.typeset.exception.TypeSettingException: Could not convert the document into the Knuth-Plass algorithm format
at de.be.thaw.typeset.knuthplass.KnuthPlassTypeSetter.convertToParagraphs(KnuthPlassTypeSetter.java:177)
at de.be.thaw.typeset.knuthplass.KnuthPlassTypeSetter.typesetWithConfig(KnuthPlassTypeSetter.java:89)
at de.be.thaw.typeset.knuthplass.KnuthPlassTypeSetter.typeset(KnuthPlassTypeSetter.java:77)
at de.be.thaw.export.pdf.PdfExporter.typeset(PdfExporter.java:219)
at de.be.thaw.export.pdf.PdfExporter.export(PdfExporter.java:107)
... 10 more
Caused by: de.be.thaw.core.document.convert.exception.DocumentConversionException: de.be.thaw.export.exception.ExportException: Could not find font family 'Arial' in OS installed fonts. If on Windows make sure that the fonts were installed for all users for Thaw to be able to pick it up.
at de.be.thaw.typeset.knuthplass.converter.context.ConversionContext.appendTextToParagraph(ConversionContext.java:198)
at de.be.thaw.typeset.knuthplass.converter.KnuthPlassConverter.initializeTextualNode(KnuthPlassConverter.java:153)
at de.be.thaw.typeset.knuthplass.converter.KnuthPlassConverter.initializeForNode(KnuthPlassConverter.java:118)
at de.be.thaw.typeset.knuthplass.converter.KnuthPlassConverter.initializeForNode(KnuthPlassConverter.java:126)
at de.be.thaw.typeset.knuthplass.converter.KnuthPlassConverter.initializeForNode(KnuthPlassConverter.java:126)
at de.be.thaw.typeset.knuthplass.converter.KnuthPlassConverter.convert(KnuthPlassConverter.java:100)
at de.be.thaw.typeset.knuthplass.KnuthPlassTypeSetter.convertToParagraphs(KnuthPlassTypeSetter.java:175)
... 14 more
Caused by: de.be.thaw.export.exception.ExportException: Could not find font family 'Arial' in OS installed fonts. If on Windows make sure that the fonts were installed for all users for Thaw to be able to pick it up.
at de.be.thaw.export.pdf.util.ExportContext.lambda$getFontVariantLocatorForStyleValue$0(ExportContext.java:322)
at java.base/java.util.Optional.orElseThrow(Optional.java:401)
at de.be.thaw.export.pdf.util.ExportContext.getFontVariantLocatorForStyleValue(ExportContext.java:322)
at de.be.thaw.export.pdf.util.ExportContext.getFontForNode(ExportContext.java:363)
at de.be.thaw.export.pdf.PdfExporter$3.getSpaceWidth(PdfExporter.java:270)
at de.be.thaw.typeset.knuthplass.converter.context.ConversionContext.appendTextToParagraph(ConversionContext.java:193)
... 20 more
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':cli:run'.
> Process 'command '/home/badal/.jabba/jdk/openjdk@1.14.0/bin/java'' finished with non-zero exit value 4
Not sure if I need to do any additional set up.
Nothing wrong except for the font :smile: I have to admit that I have never run it on Linux so I hope it will work without problems.
It says:
Could not find font family 'Arial' in OS installed fonts. If on Windows make sure that the fonts were installed for all users for Thaw to be able to pick it up.
Since I was running the demo on Windows, I have set the font to Arial, so you have to find a font that is installed on your system or use another font (ending with .ttf, since .oft fonts are currently not supported). If you want to use an .oft font you may just convert it to .ttf since the only difference is how the glyphs are stored (Google "OTF to TTF online" for example).
However for Linux-Distributions Thaw will look into the following folders to find fonts:
/usr/share/fonts
/usr/local/share/fonts
~/.fonts
You can then update the file example/demo/demo.tds
where you need to change all font-family
properties to fonts that are known to your system (font-family
, inline-code-font-family
, line-number-font-family
).
Alternatively you could just point those properties to a folder of font files using something like font-family: Roboto:url(/usr/share/fonts/roboto);
(For example from Google fonts). You need to specify the name of the font family in front of url(...) since it will look for all fonts with name "Roboto Regular" (for normal style), "Roboto Bold" (for bold style), "Roboto Italic" (for italic style) and "Roboto Bold Italic" (for both bold and italic).
Hope it helps!
I changed the demo.tds
file with Ubuntu
font like below -
font-family: Ubuntu:url(/usr/share/fonts/truetype/ubuntu/);
inline-code-font-family: Ubuntu:url(usr/share/fonts/truetype/ubuntu/);
But I am getting the following error-
### Processing ###
Searching for Thaw files within folder at '/home/badal/Documents/codeProject/thaw/cli/../example/demo'...
Processing Thaw info file 'demo.tdi'...
Processing Thaw text file 'demo.tdt'...
Processing Thaw style file 'demo.tds'...
An exception occurred while trying to parse the provided style file at '/home/badal/Documents/codeProject/thaw/cli/../example/demo/demo.tds'.
The exception message is: 'de.be.thaw.style.parser.value.exception.StyleValueParseException: Could not resolve font file at 'usr/share/fonts/truetype/ubuntu/''
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':cli:run'.
> Process 'command '/home/badal/.jabba/jdk/openjdk@1.14.0/bin/java'' finished with non-zero exit value 8
My directory has the following contents-
It says, it can't resolve the font file. But the files are in the folder. Any idea what can be wrong?
I will also switch to Windows in the meantime and finish #62.
Hi there,
I tested now on Ubuntu as well and had to fix some Font-related stuff.
My current working demo.tds
is:
document {
font-family: DejaVu Serif;
inline-code-font-family: Ubuntu Mono;
font-size: 13pt;
color: #222222;
// Set the document page dimensions
width: 210mm;
height: 297mm;
margin: 2cm 3cm;
}
page {
footer: footer; // We want the sub-folder "footer" to be included as footer to all pages
}
title {
font-family: Ubuntu;
font-size: 48pt;
text-align: center;
}
code {
font-family: Ubuntu Mono;
line-number-font-family: Ubuntu Mono;
}
h {
font-family: Ubuntu;
margin: 4mm 0 0 0;
padding: 0;
}
table-cell.footer-table {
border-width: 0.25mm 0 0 0; // Hide borders of the tables cells, except on the top
// Font settings
font-family: Ubuntu;
font-size: 11pt;
}
table-cell.footer-table:column(1) {
text-align: left;
}
table-cell.footer-table:column(*) {
text-align: right;
}
table-cell.person-table {
border-width: 0;
font-size: 13pt;
}
table-cell.person-table:even-rows {
background-color: rgb(0.98, 0.98, 0.98);
}
table-cell.person-table:row(1) {
font-variant: bold;
border-width: 0;
}
table-cell.person-table:cell(2, 1) {
border-radius-top: 2mm;
}
table-cell.person-table:cell(2, *) {
border-radius-right: 2mm;
}
table-cell.person-table:cell(*, 1) {
border-radius-left: 2mm;
}
table-cell.person-table:cell(*, *) {
border-radius-bottom: 2mm;
}
table-cell.person-table:column(1) {
text-align: right;
font-variant: italic;
}
I had to use DejaVu Serif for the document font-family because there is an unordered enumeration in the document that wants to use the asterisk operator character as item symbol, which Ubuntu does not have. Unfortunately there are some display problems with DejaVu Serif with uppercase letters. Probably should investigate that at some point 😄 .
You will have to install python and pygments as well (sudo apt-get install python3 python3-pygments) because the demo document uses syntax highlighting for code blocks.
Other than that it is working!
Would be useful to be able to clear the Thaw cache under
~/.thaw
with a CLI command:thaw clean