diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 11:31:33 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 11:31:33 +0000 |
commit | e863fd965dd6253243c3342bd6f0adc4fc8aec4d (patch) | |
tree | a4c1b6491a82593950043c3f8b2530e80664d768 /tests/roots/test-latex-includegraphics | |
parent | Initial commit. (diff) | |
download | sphinx-upstream.tar.xz sphinx-upstream.zip |
Adding upstream version 5.3.0.upstream/5.3.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/roots/test-latex-includegraphics')
-rw-r--r-- | tests/roots/test-latex-includegraphics/conf.py | 47 | ||||
-rw-r--r-- | tests/roots/test-latex-includegraphics/img.png | bin | 0 -> 66247 bytes | |||
-rw-r--r-- | tests/roots/test-latex-includegraphics/index.rst | 37 | ||||
-rw-r--r-- | tests/roots/test-latex-includegraphics/sphinx.png | bin | 0 -> 34213 bytes | |||
-rw-r--r-- | tests/roots/test-latex-includegraphics/tall.png | bin | 0 -> 38192 bytes |
5 files changed, 84 insertions, 0 deletions
diff --git a/tests/roots/test-latex-includegraphics/conf.py b/tests/roots/test-latex-includegraphics/conf.py new file mode 100644 index 0000000..65c19ab --- /dev/null +++ b/tests/roots/test-latex-includegraphics/conf.py @@ -0,0 +1,47 @@ +exclude_patterns = ['_build'] + +latex_elements = { + 'preamble': r''' +\makeatletter +\def\dividetwolengths#1#2{\the\dimexpr + \numexpr65536*\dimexpr#1\relax/\dimexpr#2\relax sp}% +\newwrite\out +\immediate\openout\out=\jobname-dimensions.txt +\def\toout{\immediate\write\out} +\def\getWfromoptions #1width=#2,#3\relax{\def\WidthFromOption{#2}}% +\def\getHfromoptions #1height=#2,#3\relax{\def\HeightFromOption{#2}}% +\def\tempincludegraphics[#1]#2{% + \sphinxsafeincludegraphics[#1]{#2}% + \edef\obtainedratio + {\dividetwolengths\spx@image@requiredheight\spx@image@requiredwidth}% + \getWfromoptions#1,width=,\relax + \getHfromoptions#1,height=,\relax + \def\ratiocheck{}% + \ifx\WidthFromOption\empty\else + \ifx\HeightFromOption\empty\else + \edef\askedforratio{\dividetwolengths\HeightFromOption\WidthFromOption}% + \edef\ratiocheck{\dividetwolengths\obtainedratio\askedforratio}% + \fi\fi + \toout{original options = #1^^J% + width = \the\dimexpr\spx@image@requiredwidth, + linewidth = \the\linewidth^^J% + height = \the\dimexpr\spx@image@requiredheight, + maxheight = \the\spx@image@maxheight^^J% + obtained H/W = \obtainedratio^^J% + \ifx\ratiocheck\empty + \else + asked for H/W = \askedforratio^^J% + ratio of ratios = \ratiocheck^^J% + \fi + }% + \ifx\ratiocheck\empty + \else + \ifpdfabsdim\dimexpr\ratiocheck-1pt\relax > 0.01pt + \ASPECTRATIOERROR + \fi + \fi +} +\def\sphinxincludegraphics#1#{\tempincludegraphics#1} +\makeatother +''', +} diff --git a/tests/roots/test-latex-includegraphics/img.png b/tests/roots/test-latex-includegraphics/img.png Binary files differnew file mode 100644 index 0000000..a97e86d --- /dev/null +++ b/tests/roots/test-latex-includegraphics/img.png diff --git a/tests/roots/test-latex-includegraphics/index.rst b/tests/roots/test-latex-includegraphics/index.rst new file mode 100644 index 0000000..920c749 --- /dev/null +++ b/tests/roots/test-latex-includegraphics/index.rst @@ -0,0 +1,37 @@ +==================== +Test image inclusion +==================== + +Tests with both width and height +-------------------------------- + +.. an image with big dimensions, ratio H/W = 1/5 +.. image:: img.png + :height: 200 + :width: 1000 + +.. topic:: Oversized images + + .. an image with big dimensions, ratio H/W = 5/1 + .. image:: img.png + :height: 1000 + :width: 200 + + .. height too big even if width reduced to linewidth, ratio H/W = 3/1 + .. image:: img.png + :width: 1000 + :height: 3000 + +Tests with only width or height +------------------------------- + +.. topic:: Oversized images + + .. tall image which does not fit in textheight even if width rescaled + .. image:: tall.png + :width: 1000 + +.. wide image which does not fit in linewidth even after height diminished +.. image:: sphinx.png + :height: 1000 + diff --git a/tests/roots/test-latex-includegraphics/sphinx.png b/tests/roots/test-latex-includegraphics/sphinx.png Binary files differnew file mode 100644 index 0000000..0a103cd --- /dev/null +++ b/tests/roots/test-latex-includegraphics/sphinx.png diff --git a/tests/roots/test-latex-includegraphics/tall.png b/tests/roots/test-latex-includegraphics/tall.png Binary files differnew file mode 100644 index 0000000..c98c058 --- /dev/null +++ b/tests/roots/test-latex-includegraphics/tall.png |