It is very easy to define font name when converting from plain text files.
LibreOffice help includes an example for conversion from plain text file:
--infilter="Text (encoded):UTF8,LF,,"
The help didn’t specify what were those missing parameters after LF
(now I added that, and it will go to the next help version), but here they are:
-
UTF8
is encoding used to decode the file.
-
LF
is line ending format (CR
and CRLF
are the other allowed options; if missing, CRLF
is used on Windows, and LF
on all other platforms).
-
Font name.
-
BCP 47 Language tag.
So, the command line could be like this:
soffice --infilter="Text (encoded):UTF8,,Courier New,en-US" --convert-to docx path/to/file.txt
to convert a UTF8-encoded plain-text file with default line endings, using Courier New font, and English (USA) language for the imported text.
A side note
LibreOffice is quite smart when it comes to default fonts it uses, which are possibly not available on other systems. For instance, for Liberation Mono
, it defines a substitute font in the generated docx (see word/fontTable.xml), which is Courier New
; as well as the font properties (fixed-pitch “modern” font), which allows to find proper substitutions on any system.