Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jcwinkler committed Feb 3, 2022
2 parents 10123a6 + 0f63161 commit 6179a9d
Show file tree
Hide file tree
Showing 11 changed files with 138 additions and 15 deletions.
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ went into the development of the project.
- Markus Wallerberger
- Michael Struwig
- Noel Kuntze
- Patrick Kappl
- Robert Szalai
- Rafal Kolanski
- Toru Araki
Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
Version 1.8.0 (2022-02-03)
~~~~~~~~~~~~~~~~~~~~~~~~~~
- New: It is now possible to use the ``\documentclass`` statement in the
preamble file. This makes it easier to adjust the fontsize. Old preamble
files without the ``\documentclass`` statement can still be used.
- Changed: Instructions for installation of TexText for Inkscape in
Windows PortableApps (fixes :issue_num:`288`)

Version 1.7.1 (2022-01-04)
~~~~~~~~~~~~~~~~~~~~~~~~~~
- Fixed: In Inkscape 1.2-dev new nodes are not placed in the center of the view.
Expand Down
18 changes: 14 additions & 4 deletions docs/source/install/advanced.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,11 @@ options to adapt the installation process to your system configuration:

--inkscape-extensions-path INKSCAPE_EXTENSIONS_PATH
Path to inkscape extensions directory. Use this if the user
extensions are installed in an unusual place, e.g. when using |Inkscape|
in PortableApps on Windows.
extensions are installed in an unusual place.

--inkscape-executable INKSCAPE_EXECUTABLE
Full path to inkscape executable. Use this if |Inkscape| is not found
automatically by the setup script (Test- or Beta-installations, Portable
Apps on Windows).
automatically by the setup script (Test- or Beta-installations).

--pdflatex-executable PDFLATEX_EXECUTABLE
Full path to pdflatex executable.
Expand All @@ -37,6 +35,18 @@ options to adapt the installation process to your system configuration:
--xelatex-executable XELATEX_EXECUTABLE
Full path to xelatex executable.

--portable-apps-dir INSTALLATION_DIRECTORY_OF_PORTABLEAPPS
Windows only: If you use Inkscape from PortableApps use this parameter
to specifiy the directory into which PortableApps has been installed, e.g.
``C:\Users\YourUserName\PortableApps``. It ensures that |TexText| is
installed correctly into the PortableApps structure.

.. attention::
If you also have your LaTeX distribution installed in PortableApps
you need to specify the paths to the latex executables by
using the ``--pdflatex-executable`` and/or ``--lualatex-executable``
and/or ``--xelatex-executable`` arguments.

--skip-requirements-check
Bypass minimal requirements check. |TexText| will be installed even if
the requirements for running it are not meat.
Expand Down
33 changes: 32 additions & 1 deletion docs/source/install/windows.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
|TexText| on Windows
====================

If you use Inkscape in PortableApps please go to `these special instructions <portableapps-install_>`_.

.. _windows-install-preparation:

Preparation
Expand Down Expand Up @@ -117,4 +119,33 @@ Problems with the GUI framework

The GUI framework should already be included in the Inkscape installation on Windows.
Hence, if the |TexText| installer complains about missing GTK3 or TkInter bindings
please file a bug report on `github <https://github.com/textext/textext/issues/new/choose>`_
please file a bug report on `github <https://github.com/textext/textext/issues/new/choose>`_

.. _portableapps-install:

Installation for Inkscape in PortableApps
=========================================

If you use Inkscape in PortableApps you have to proceed as follows:

1. Download the most recent package from :textext_current_release_page:`GitHub release page <release>` (direct links: :textext_download_zip:`.zip <Windows>`)
2. Extract the package and change into the created directory.
3. Open a Windows command prompt or Windows power shell window in this directory
(``SHIFT`` + right-click in the Windows explorer, then select `Open powershell window here`)
4. Enter and execute the following command where ``C:\Path\To\Your\PartableApps\Installation``
is the path to your PortableApps installation (usually this is ``C:\User\YourUserName\PortableApps``):

.. code-block:: bash
setup_win.bat --portable-apps-dir "C:\Path\To\Your\PartableApps\Installation"
If you also use your LaTeX system from PortableApps use the following command instead:

.. code-block:: bash
setup_win.bat --portable-apps-dir "C:\Path\To\Your\PartableApps\Installation" --pdflatex-executable "C:\Path\To\pdflatex.exe"
(use ``--lualatex-executable`` and ``--xelatex-executable`` if you also want to have
lualatex and xelatex available as well)

See :ref:`advanced-install` for further options provided by :bash:`setup_win.bat`.
11 changes: 11 additions & 0 deletions docs/source/usage/faq.rst
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,17 @@ The resulting text should be of equal height as if has been typeset directly in
.. figure:: ../images/texttext-fontsize-example.png
:alt: Font size example

If you want to change the default font size you can do that by specifying it in the
:ref:`usage-preamble-file`.

.. code-block:: latex

\documentclass[12pt]{article}
% ***rest of the preamble file***

This is convenient, e.g., if you want to create multiple nodes with the same,
specific font size.

.. _faq-font-custom-font:

Selection of special fonts
Expand Down
8 changes: 5 additions & 3 deletions docs/source/usage/gui.rst
Original file line number Diff line number Diff line change
Expand Up @@ -175,26 +175,28 @@ Preamble file
Be aware of including the required packages in the *preamble file* if you
use special commands in your code that rely on such packages. The
preamble file can be chosen by the selector |usage-label-2|. The default preamble
file shipped with |TexText| includes the following packages:
file shipped with |TexText| includes the following:

.. code-block:: latex

\documentclass{article}

\usepackage{amsmath,amsthm,amssymb,amsfonts}
\usepackage{color}

Basically, your LaTeX code will be inserted into this environment:

.. code-block:: latex

\documentclass{article}
% ***preamble file content***
\pagestyle{empty}
\begin{document}
% ***Your code***
\end{document}

This will be typeset, converted to SVG and inserted into your Inkscape
document.
document. If no :latex:`\documentclass` or :latex:`\documentstyle` is specified
in the preamble file, :latex:`\documentclass{article}` is used by default.

.. _usage-scaling:

Expand Down
23 changes: 22 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,13 @@ def remove_previous_installation(extension_dir):
help="Full path to xelatex executable"
)

parser.add_argument(
"--portable-apps-dir",
default=None,
type=str,
help="PortableApps installation directory (Windows only)"
)

parser.add_argument(
"--skip-requirements-check",
default=False,
Expand Down Expand Up @@ -327,7 +334,21 @@ def remove_previous_installation(extension_dir):
fh.setFormatter(formatter)
logger.addHandler(fh)

settings = Settings(directory=defaults.textext_config_path)
# Address special Portable Apps directory structure
if args.portable_apps_dir:
if not os.path.isdir(args.portable_apps_dir):
logger.error("Path specified for PortableApps is not a valid directory!")
exit(EXIT_REQUIREMENT_CHECK_FAILED)
if os.name != "nt":
logger.error("The --portable-apps-dir argument can only be used under MS Windows!")
exit(EXIT_REQUIREMENT_CHECK_FAILED)
args.inkscape_executable = os.path.join(args.portable_apps_dir,
"InkscapePortable\\App\\Inkscape\\bin\\inkscape.exe")
args.inkscape_extensions_path = os.path.join(args.portable_apps_dir,
"InkscapePortable\\Data\\settings\\extensions")
settings = Settings(directory=os.path.join(args.portable_apps_dir, "InkscapePortable\\Data\\settings\\textext"))
else:
settings = Settings(directory=defaults.textext_config_path)

checker = TexTextRequirementsChecker(logger, settings)

Expand Down
25 changes: 21 additions & 4 deletions setup_win.bat
Original file line number Diff line number Diff line change
Expand Up @@ -50,16 +50,33 @@ if defined args (
rem Check for explicitely given inkscape executable
if /I "%%C"=="inkscape-executable" if not "%%D"=="" (
if not exist "%%D" (
echo %%D not found!
echo Specified directory %%D for Inkscape executable not found!
goto FINAL
) else (
echo %%D found!
rem Just take the path from %%D
set INKSCAPE_DIR=%%~dpD
)
) else (
echo No value specified for key --%%C
goto PRINT_USAGE
)
rem Check for given --portable-apps-dir argument
if /I "%%C"=="portable-apps-dir" if not "%%D"=="" (
if not exist "%%D" (
echo Specified PortableApps directory %%D not found!
goto FINAL
) else (
set arg=%%D
rem Remove quotes
set arg=!arg:"=%!
rem Remove possible trailing whitespaces
if "!arg:~-1!"==" " set arg=!arg:~0,-1!
set INKSCAPE_DIR=!arg!\InkscapePortable\App\Inkscape\bin
)
) else (
echo No value specified for key --%%C
goto PRINT_USAGE
)
set PYTHON_ARGS=!PYTHON_ARGS!--%%A
)
rem Repeat operation with remaining argument list
Expand Down Expand Up @@ -220,9 +237,9 @@ set PYTHON_EXE="%INKSCAPE_DIR%\python.exe"
if exist "%PYTHON_EXE%" (
echo %PYTHON_EXE% found
echo.

goto RUN_SETUP_PY
goto RUN_SETUP_PY
) else (
echo %PYTHON_EXE% not found!
goto PYTHON_NOT_FOUND
)

Expand Down
2 changes: 1 addition & 1 deletion textext/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.7.1
1.8.0
22 changes: 21 additions & 1 deletion textext/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -505,8 +505,8 @@ class TexToPdfConverter:
"""
Base class for Latex -> SVG converters
"""
DEFAULT_DOCUMENT_CLASS=r"\documentclass{article}"
DOCUMENT_TEMPLATE = r"""
\documentclass{article}
%s
\pagestyle{empty}
\begin{document}
Expand Down Expand Up @@ -543,6 +543,10 @@ def tex_to_pdf(self, tex_command, latex_text, preamble_file):
with open(preamble_file, 'r') as f:
preamble += f.read()

# Add default document class to preamble if necessary
if not _contains_document_class(preamble):
preamble = self.DEFAULT_DOCUMENT_CLASS + preamble

# Options pass to LaTeX-related commands

texwrapper = self.DOCUMENT_TEMPLATE % (preamble, latex_text)
Expand Down Expand Up @@ -636,6 +640,22 @@ def parse_pdf_log(self):
return "TeX compilation failed. See stdout output for more details"


def _contains_document_class(preamble):
"""Return True if `preamble` contains a documentclass-like command.
Also, checks and considers if the command is commented out or not.
"""
lines = preamble.split("\n")
document_commands = ["\documentclass{", "\documentclass[",
"\documentstyle{", "\documentstyle["]
for line in lines:
for document_command in document_commands:
if (document_command in line
and "%" not in line.split(document_command)[0]):
return True
return False


class TexTextElement(inkex.Group):
tag_name = "g"

Expand Down
2 changes: 2 additions & 0 deletions textext/default_packages.tex
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
\documentclass{article}

\usepackage{amsmath,amsthm,amssymb,amsfonts}
\usepackage{color}

0 comments on commit 6179a9d

Please sign in to comment.